Flexcan doesn't apply all filters

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Flexcan doesn't apply all filters

跳至解决方案
1,310 次查看
georgemakarov
Contributor III

I use MK24F12. I adjusted Flexcan module to gather messages from device using Fleet Management Systems Interface.
I turned RxFIFO on and set ID acceptance mode as Format A. Then i filled filter table (it starts at 7th mailbox) with IDs and according RXIMR registers with Mask. The rest filters i filled with 0x40000000 and the rest mask registers with 0x5FFFFFFF.
When i start to listen to device i get some frames, but here's the problem i don't get all messages device sent, despite they match filters.
i know that because if i set any mask register as zero i get all of messages on bus.
i noticed that hit filter (RXFIR register) is (0,1,4,5,...), so in other words i get messages which match filters that stored in registers CSn and IDn of MailBox.

Below is log, here i added 7 filters and i got just 4 types of messages. Then i removed all filters and as you can see i skipped a lot of messages that supposed being caught.

[1.003] Filter added (Type: Ext, ID: 0x00FEE900, Mask: 0x00FFFF00)
[1.004] Filter added (Type: Ext, ID: 0x00FEFC00, Mask: 0x00FFFF00)
[1.005] Filter added (Type: Ext, ID: 0x00FEEE00, Mask: 0x00FFFF00)
[1.006] Filter added (Type: Ext, ID: 0x00FEC100, Mask: 0x00FFFF00)
[1.007] Filter added (Type: Ext, ID: 0x00F00400, Mask: 0x00FFFF00)
[1.008] Filter added (Type: Ext, ID: 0x00FEE500, Mask: 0x00FFFF00)
[1.008] Filter added (Type: Ext, ID: 0x00FEEA00, Mask: 0x00FFFF00)

[1.935] CAN.Got frame (Type: Ext, ID: 0x18F00420, Data: FF FF FF 80 0C FF FF FF, Filter: 4)
[2.436] CAN.Got frame (Type: Ext, ID: 0x18FEE520, Data: 58 1C 00 00 FF FF FF FF, Filter: 5)
[2.938] CAN.Got frame (Type: Ext, ID: 0x18FEE920, Data: FF FF FF FF 59 1C 00 00, Filter: 0)
[3.439] CAN.Got frame (Type: Ext, ID: 0x18FEFC20, Data: FF 48 FF FF FF FF FF FF, Filter: 1)
[4.944] CAN.Got frame (Type: Ext, ID: 0x18F00420, Data: FF FF FF C0 12 FF FF FF, Filter: 4)
[5.445] CAN.Got frame (Type: Ext, ID: 0x18FEE520, Data: 59 1C 00 00 FF FF FF FF, Filter: 5)
[6.950] CAN.Got frame (Type: Ext, ID: 0x18FEE920, Data: FF FF FF FF 5A 1C 00 00, Filter: 0)
[7.452] CAN.Got frame (Type: Ext, ID: 0x18FEFC20, Data: FF 46 FF FF FF FF FF FF, Filter: 1)
[8.957] CAN.Got frame (Type: Ext, ID: 0x18F00420, Data: FF FF FF 00 19 FF FF FF, Filter: 4)
[9.458] CAN.Got frame (Type: Ext, ID: 0x18FEE520, Data: 5A 1C 00 00 FF FF FF FF, Filter: 5)

at this point i removed all filters

[34.186] CAN.Got frame (Type: Ext, ID: 0x18F00420, Data: FF FF FF 00 4B FF FF FF, Filter: 0)
[34.688] CAN.Got frame (Type: Ext, ID: 0x18FEE520, Data: 62 1C 00 00 FF FF FF FF, Filter: 0)
[35.190] CAN.Got frame (Type: Ext, ID: 0x18FEE920, Data: FF FF FF FF 63 1C 00 00, Filter: 0)
[35.691] CAN.Got frame (Type: Ext, ID: 0x18FEFC20, Data: FF 34 FF FF FF FF FF FF, Filter: 0)
[36.193] CAN.Got frame (Type: Ext, ID: 0x18FEEE20, Data: 56 FF FF FF FF FF FF FF, Filter: 0)
[36.694] CAN.Got frame (Type: Ext, ID: 0x18FEC120, Data: AD 05 00 00 FF FF FF FF, Filter: 0)
[37.196] CAN.Got frame (Type: Ext, ID: 0x18F00420, Data: FF FF FF 40 51 FF FF FF, Filter: 0)
[37.698] CAN.Got frame (Type: Ext, ID: 0x18FEE520, Data: 63 1C 00 00 FF FF FF FF, Filter: 0)
[39.203] CAN.Got frame (Type: Ext, ID: 0x18FEE920, Data: FF FF FF FF 64 1C 00 00, Filter: 0)
[39.704] CAN.Got frame (Type: Ext, ID: 0x18FEFC20, Data: FF 32 FF FF FF FF FF FF, Filter: 0)
[40.206] CAN.Got frame (Type: Ext, ID: 0x18FEEE20, Data: 58 FF FF FF FF FF FF FF, Filter: 0)
[40.707] CAN.Got frame (Type: Ext, ID: 0x18FEC120, Data: AD 05 00 00 FF FF FF FF, Filter: 0)

Best regards, George Makarov
标签 (1)
0 项奖励
回复
1 解答
879 次查看
georgemakarov
Contributor III

I have found that I read CODE bits of MB's CS register and it was 1 for filters 2,3,6,7... that means BUSY. But if MB is used by FIFO engine it doesn't contain CODE bits and we shouldn't check Message Buffer Code at all.
They might if don't use some bits keep them clear.

Question is closed.
MB_and_FIFO_structure.png

Best regards, George Makarov

在原帖中查看解决方案

0 项奖励
回复
3 回复数
880 次查看
georgemakarov
Contributor III

I have found that I read CODE bits of MB's CS register and it was 1 for filters 2,3,6,7... that means BUSY. But if MB is used by FIFO engine it doesn't contain CODE bits and we shouldn't check Message Buffer Code at all.
They might if don't use some bits keep them clear.

Question is closed.
MB_and_FIFO_structure.png

Best regards, George Makarov
0 项奖励
回复
879 次查看
Kan_Li
NXP TechSupport
NXP TechSupport

Hi George,

Checking the CANregisters.png, looks like the value setting for RXIMRn has some issue, Did you use the following macro to set the mask value?

#define FLEXCAN_RX_FIFO_EXT_MASK_TYPE_A(id, rtr, ide)                          \
    (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \
     (FLEXCAN_ID_EXT(id) << 1)) /*!< Extend Rx FIFO Mask helper macro Type A helper macro. */

so you will left shift 0x00FFFF00 by 1 bit before feeding it into the RXIMRn, which should be 0x41FFFE00 at last.

Please try with this macro and kindly let me know if the issue is still there.


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
879 次查看
georgemakarov
Contributor III

You are right! I forgot to shift mask left by 1 bit.

I has written code to work with FIFO by myself based on Processor Expert code, but not KSDK

Best regards, George Makarov
0 项奖励
回复