cancel
Showing results for 
Search instead for 
Did you mean: 

CAN filtering

Alexander Gornik
Associate II
Posted on April 13, 2017 at 16:41

Hello.

Can anyone help me with CAN filters configuration

I need to implement 3 independent cases of the filters(will be used

independently, so not in same time)

Case 1 (for OBDII 11 bits communication)

I need to receive STD ids  0x7E8..0x7EF and filter others

Case 2 (for OBDII 29 bits communication)

I need to receive EXTID with PDU format 0xDA and 0xDB. So the IDs that passed filter are xxDAxxxx and xxDBxxxx

Case 3 (for J1939 29 bits communication)

I need to receive EXTID with PDU format 0xDA..0xFF. So the IDs that passed filter are xxDAxxxx ... xxFFxxxx

Thanks in advance, Alex

2 REPLIES 2

Posted on April 13, 2017 at 17:12

I've explained the filtering several times

https://community.st.com/0D70X000006SuuWSAS

For case 1 (0x7E8 .. 0x7EF)

Mask = 0x7F8, Compare = 0x7E8

HCANFilter_Struct.FilterIdHigh = 0x7E8 << 5; //11-bit ID in top bits ;//MSB of 32b config

HCANFilter_Struct.FilterIdLow = 0;//LSB of 32b config

HCANFilter_Struct.FilterMaskIdHigh = 0x7F8 << 5; //MSB

HCANFilter_Struct.FilterMaskIdLow = 0; //LSB

https://community.st.com/0D70X000006SzPuSAK

 

For the fuller 32-bit case refer to the bit diagram and create a mask so the bits in question can be compared.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 13, 2017 at 17:14

Cites have other post stuck in moderation

For case 1 (0x7E8 .. 0x7EF)

Mask = 0x7F8, Compare = 0x7E8

HCANFilter_Struct.FilterIdHigh = 0x7E8 << 5; //11-bit ID in top bits ;//MSB of 32b config

HCANFilter_Struct.FilterIdLow = 0;//LSB of 32b config

HCANFilter_Struct.FilterMaskIdHigh = 0x7F8 << 5; //MSB

HCANFilter_Struct.FilterMaskIdLow = 0; //LSB
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..