-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can Filters #34
Comments
Hello. 0x681 << 21 = 0xd0200000 0x68103 << 13 = 0xd0206000 The extended format 29-bit length ID range is 0x0 to 0x1FFFFFFF Filter bank format is: |
Thanks for reply. Yes I understand it's 29bit for extended or 11bit for standard.
Because this works to filter 0x681. Infact, you can even see this in your own code from CANReceive function: out = ((CAN_tx_msg->id & CAN_STD_ID_MASK) << 21U); Edit: To clarify what I'm asking, is it possible to filter the first 2 data bytes of a standard frame using the 32bit filters? |
The Filter bank register has 28 FiR1 and 28 FiR2 respectively. F0R1-F27R1 Standard frame filter: Set the first filter to F0R1
|
That is simply using list mode rather than mask mode to match multiple IDs ? To explain my problem more clearly, Can ID 0x681 sends constant keepalive messages every 500ms, first byte of data ID is 0xF0. I am only interested in messages where first byte of data is 0x04 - because of the frequency of the keepalive messages it makes ISR unsuitable. With MCP2515's filter I am able to filter the ID and first 2 bytes of a standard frame, trying to replicate this functionality using STM32. |
Standard frame filter Identifier List mode:
Standard frame filter Identifier Mask mode:
Extended frame filter Identifier List mode:
Extended frame filter Identifier Mask mode:
|
Thank you for trying to help, but I think maybe I am being unclear about my issue or what I am trying to achieve - or maybe it is not even possible. |
Same issue here, transitioning from MCP2515, it is completely unclear how to configure CANSetFilter to allow particular (or range) of ID`s, also it's unclear how to filter on 0,1,2..n bytes of data, for example filter only particular (or range) where data[0] or data[n] corresponds. For example: I want to allow only packets with ID=0x101 and data[0]=0x6B. How to set the filter? |
From RM0008 Reference manual 24.4.1 Initialization mode The software initialization can be done while the hardware is in Initialization mode. To enter To initialize the registers associated with the CAN filter banks (mode, scale, FIFO Case of STM32F103:
|
I don't understand this either. I want to filter only 7E8 diagnostic response messages from OBDII. No go even when directly editing the code as highlighted in the previous response: CANSetFilter(0, 1, 0, 0, 0x7E8, 0x7E8); |
If you want to filter only ID=0x7E8
Mask bit0 indicates that you don't care. Mask bit1 indicates that you care. |
If anyone still struggles with setting up filters in list mode for 16bit IDs, here is how it should look:
|
Please, could i ask how can i filter a range of std ids? ie 0 to 7?, list mode from v-ivanyshyn works well, but im getting confused by bitshift places. for mask mode. I cant get why bank 2 is 0xFFE00006 In the example above:
|
About STM32 CAN Identifier Filtering |
Thanks for the answer nopnop2002: Answering my own question and for reference to future readers, why include 0x06 in the filter? 0x7ff<<21 is not enough? |
This is because IDE and RTR are used to distinguish between frame types.
There are 4 frames type
If you don't include 0x06 in your filter, these will match ID=0x467 and ID=0x119C000 pass the filter even though only ID=0x467 is needed.
|
Having issues with filter settings, receiving id 0x101 and 0x206, how to setup a filter to just receive these messages. Tried :
|
Case of STM32F103:
Otherwise: Look at the source.
|
Hi,
Firstly - thank you for the project, very nicely documented.
Just wondering if you have some examples for CANSetFilter ?
I'm trying to filter messages from ID 0x681 AND the first byte of the message 0x03
So this works fine for filtering all messages from 0x681
So I expected this would work for what I was trying to achieve:
But I'm still receiving all messages to 0x681 with this which is odd.
The text was updated successfully, but these errors were encountered: