TWAI multiple ID filter configuration help

Scremin34Egl
Posts: 2
Joined: Mon Apr 25, 2022 6:38 pm

TWAI multiple ID filter configuration help

Postby Scremin34Egl » Tue May 10, 2022 9:52 am

Hi everyone, I'm really confused with how to setup my canbus filter to accept this list of ID's.

I have below a list of ID's that I want accepted:
  • ID1 = 11000100000 (0x620)
    ID2 = 11000100001 (0x621)
    ID3 = 11000111000 (0x638)
    ID4 = 00111000100 (0x1C4)
If I follow exactly as the documentation says to get the filter mask will be:

Mask = 11111111101 (0x7FD)
Acceptance code = Any one of the ID's (I chose ID1)

I am convinced that Iv'e set it up wrong as I still get a bunch of ID's that I dont need. The documentation did say single filter but maybe its dual filter ?

Code: Select all

twai_filter_config_t filter = {
    .acceptance_code = (0x620 << 21),
    .acceptance_mask = ~(0x7FD << 21),
    .single_filter = true
};
Thank you for any help

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: TWAI multiple ID filter configuration help

Postby ESP_Dazz » Thu May 19, 2022 3:19 am

I am convinced that Iv'e set it up wrong as I still get a bunch of ID's that I dont need.
That's because its impossible only filter for the exact 4 ID's listed above due to hardware limitations. The mask "11111111101" basically means don't care for all bits except for bit ID[1]. Combined with your acceptance code of "11000100000", it means the any ID will be accept so long as its ID matches "XXXXXXXXX0X" where "X" are don't care bits.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 73 guests