cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the STM32F205 Canbus ID filter? it seems like it does not works as rule:

Jxu
Associate II

CAN Bus filter Rules:

  The filter mask is used to determine which bits in the identifier of the received frame are compared with the filter

   If a mask bit is set to a zero, the corresponding ID bit will automatically be accepted, regardless of the value of the filter bit.

   If a mask bit is set to a one, the corresponding ID bit will be compare with the value of the filter bit; if they match it is accepted otherwise the frame is rejected.

 

12 REPLIES 12
Jxu
Associate II

Thanks very much. I tried your code, it seems does not work, looks like it filter out ExtID = 0x0EAEC00 also.

I am going back to check the STM32f2xx_hal_can.c file date, it dated 2017, I am wondering is that the cause of out-dated file version?

Again this assumes the pattern you provided is correct, and why I suggested generating an actual list of whats on the wire to be filtered.

You could just go into a promiscuous mode, and filter the message at the software layer.

I've got no reason to believe the hardware is defective, or there being an unreported errata.

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

I tried get rid of "|8" from extid & mask, it seems works now. still do not know why, anyway thank for your great help !!!

uint32 extid = 0x0EAEC00; // 00=Source ID EXTID[7..0], EC=PDU Specifc EXTID[15..8], EA=PDU Format EXID[23..16]

uint32 mask = 0x0FFFF00; // Ignore EXTID[7..0]/EXID[28..24], Pass EXTID[23..8]

extid = (extid << 3) ; // EXT

mask = (mask << 3) ; // IDE=1

sFilterConfig.FilterIdHigh = (extid >> 16) & 0xFFFF;

sFilterConfig.FilterIdLow = (extid >> 0) & 0xFFFF;

sFilterConfig.FilterMaskIdHigh = (mask >> 16) & 0xFFFF;

sFilterConfig.FilterMaskIdLow = (mask >> 0) & 0xFFFF;