ID filter table of FlexCAN

cancel
Showing results for 
Search instead for 
Did you mean: 

ID filter table of FlexCAN

603 Views
1668834026
Contributor I

Hello, 

While I use Rx FIFO of rt1052's FlexCAN , I don't understand how to set ID filter table. There is a table which describe the relationship between ID filter table and global mask or individual mask in the last row, and I don't understand that rx fifo ID table is affected by mask.

pastedImage_1.png

Here are global mask register.

pastedImage_2.png

Finally,  how do  ID filter table select CAN ID? What is the process ?

Labels (1)
Tags (1)
0 Kudos
3 Replies

440 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi 植渲 周,

  建议你看看RT1050 RM的, 这些章节:

44.7.5 Matching Process

44.6 Rx FIFO Structure

你的问题应该还是上次的问题,怎么接受去滤波为你设定的接受ID的,是这个问题吗?

其实如果官方的代码,你现在用的是MB的mask。

比如你设定了接受rxIdentifier = 0x123;

你如果debug去看你的CAN2寄存器:

pastedImage_1.png

pastedImage_2.png

pastedImage_3.png

而SDK 的CAN例程用的是0X123 RX ID,标准帧,对比这个MB的结构,你会发现32位,如果每位都去做filter,正好是0X048C0000,所以这个就决定了你RX ID设定了什么,你就只能接收什么。

当然,如果你想接收其他的,也可以把filter做宽,比如某些位0,不检查,或者多加些滤波的ID。

希望能帮到你。

Wish it helps you!

If you still have questions about it, please kindly let me know.

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

441 Views
1668834026
Contributor I

Hello Kerry,

我想问的并不是过滤器怎么过滤MB,也就是不是同一个问题。我想用FIFO模式接收报文信息,但是SDK中并没有这个例程。现在我看FIFO的结构感觉很疑惑,其中有下面这个表,最后两列说掩码寄存器会影响到FIFO中ID过滤表的元素。

pastedImage_1.png

ID过滤表元素有A/B/C三种格式,下图是全局掩码寄存器对ID过滤表元素的匹配位。

pastedImage_2.png

我不是很明白全局掩码寄存器或者私有掩码寄存器是怎么匹配ID过滤表中的元素的,这个过程是怎样子?

还有就是ID过滤表中的元素是怎么筛选报文,这个过程又是什么,能否举个示例,我对文档中的匹配过程看的不是很懂?

我是不是可以可以只用ID过滤表来筛选报文,而不需要用掩码寄存器对ID过滤表中的元素进行筛选?

这才是我实际想问的。

我现在的理解是这样的:

假设我设置RFFN = 1, FIFO使能,标准帧。0x123(0b0001_0010_0011),0x321(0b0011_0010_0001)

我想接收的ID是0x123,设置的过滤表中元素的格式为A格式,全局掩码寄存器为0x123(0b0001_0010_0011),A格式(这个是不是可以不需要?如果不用掩码寄存器会有什么影响);

现在就往ID筛选表里面填写元素{0x123,0x321},A格式;

然后全局掩码寄存器将会匹配ID过滤表的元素,查看寄存器说明是0不检测相应位,1检测;所以是不是这样,全局掩码寄存器只会检测ID过滤表中元素的第0,1,5,8位,只要接收到的报文这几位和ID过滤表的元素对应,就认为是可接收报文)

如果上面没有理解错误,有一个ID为0x323(0b0011_0010_0011)的报文过来,报文也会被接收;

当ID为0x320(0b0011_0010_0000)的报文过来,报文会被丢弃,因为第0位不是1。

不知道我的理解有没错,望解答。谢谢。

0 Kudos

441 Views
kerryzhou
NXP TechSupport
NXP TechSupport

楼主你好!

你的理解是正确的,这里要注意的是,如果你ID全局掩码你配置的不是每位检测,那么要注意那些为0的对应ID的位,其实是0,1都被检测,所以,如果你要只接收你设定ID, 可以全部位检测。

我建议你直接用代码去跑下,这样会更加直观。

如果跑代码遇到任何和理解有出入的地方,欢迎继续讨论。

If you still have questions about it, please kindly let me know.

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos