cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Filter configuration

Palacios.Bruno
Associate III
Posted on March 05, 2014 at 13:17

Hello guys,

Can anyone explain me how CAN filters work? I cannot understand the reference manual, I don�t know if I am stupid or it is very bad explained (stm32f407).

I read a lot of post on the internet but I have a mess in my head with all the concepts. Filters of 32 bits, 16 bits, 28 filters.. I am so confused, lol. 

So if anyone can help me understanding this I will be really grateful.

Thanks in advance.

Best regards,

Bruno.

#can-stm32-filters #wait-for-you--clive1-!-!-!
3 REPLIES 3
stm322399
Senior
Posted on March 05, 2014 at 15:54

Well, te bxCan has 28 filter banks. Every single bank has two 32-bit registers.

Case 1: you match a range of 29-bit identifiers of CAN2B. One register holds a value and the other is a mask (0 is ''dont'care'', 1is ''must match'').

Case 2: Both registers can be configured as two single matches (as if they were associated to a 0xFFFFFFFF mask).

Case 3 & 4 : cases 1 & 2 are derived by splitting their 32-bit registers into 16-bit registers. When you only use CAN2A identifiers it gives you twice more filters. So you can match 2 independant ranges or 4 single identifiers.

Last, The 28 filter bank area is splitted between bxCan0 and bxCan1 (I am not sure that every device has 2 CAN ports). There is a register to tell the controller where to make the split: before the value matches go to bxCan0, and beyond matches go to bxCan1.

Palacios.Bruno
Associate III
Posted on March 07, 2014 at 15:49

Thank you very much for your answer.

I am a little bit confused about how should be the filters configured. But know I am understanding a little bit more.

I will post when I have the hardware to experiment.

Best regards,

Bruno

Posted on March 07, 2014 at 16:32

It's not just you, the documentation is very awkward, and compounded by examples on the internet and other places, which are not internally consistent, so some of them are clearly wrong.

As Laurent indicates there are 28 filters, nominally split 14/14 to CAN1/CAN2, but configurable.

Defining the filters will depend a lot on what traffic you see on the CAN bus and how you want to handle it. The filters should let you capture specific messages, or ranges, and provide a means to manage/interrupt on that.

The simplest approach would be just to capture everything, in a promiscuous mode, understand what traffic is there, and then experiment with the masking and ranging options until you are comfortable with them.

I haven't done much experimentation myself beyond some point to point, and self generated traffic.

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