cancel
Showing results for 
Search instead for 
Did you mean: 

Hello ! I'm working on STM32L4 family and I want to use CAN filter to avoid a lot of message which are not for me. I need to filter only on bits [26:23] in ExtID. I read a lot of topic on this forum but I don't find the answer .... Thanks :)

MDami.3
Associate II
 
7 REPLIES 7

>>I read a lot of topic on this forum but I don't find the answer

So a comprehension problem?

The register represents a bit pattern as seen on the wire, you mask the things of interest, and those flagging a particular state vs others, and after you've masked the bits you compare that to a pattern.

Typically with Extended ID you need to be looking at the IDE flag to know it's this vs something else.

https://community.st.com/s/question/0D50X0000BedK8USQU/how-to-use-the-stm32f205-canbus-id-filter-it-seems-like-it-does-not-works-as-rule

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MDami.3
Associate II

Thanks for your quick answer !

I understand than using IDE flag can filter all EXTID right ? Can I filter all message with EXTID[26:23] set to 0x1 ?

In my confitguration I use :

   sFilterConfig.FilterMaskIdHigh = 0x07C0 ;

   sFilterConfig.FilterMaskIdLow = 0x0000 ;

   sFilterConfig.FilterIdHigh    = 0x0080 ;

   sFilterConfig.FilterIdLow     = 0x0000 ;

I prettry sure I miss something ...

Thanks again for reading me

Try

sFilterConfig.FilterMaskIdHigh = 0x3C00;

sFilterConfig.FilterMaskIdLow = 0x0004;

sFilterConfig.FilterIdHigh    = 0x0400;

sFilterConfig.FilterIdLow     = 0x0004;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MDami.3
Associate II

Hello

Thanks for your answer and sorry for delay I wasn't available. I tried what you proposed and it's almost work but I miss some message ... I don't understand why to be honest .

MDami.3
Associate II

For example, with your configuration I catch header 0x8d0104 but I miss 0x8d0084

In order to debug/understand why you'd need to dump the CAN reception data, and analyze that, and why the patterns fit or not.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Perhaps get a digest of ALL the extended messages, making sure you see the one you're looking for.

sFilterConfig.FilterMaskIdHigh = 0x0000;

sFilterConfig.FilterMaskIdLow = 0x0004;

sFilterConfig.FilterIdHigh    = 0x0000;

sFilterConfig.FilterIdLow     = 0x0004;

If you've got some register data I can look that over, but not going to work/test this independently.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..