Microchip
直播中

马杰

7年用户 162经验值
私信 关注
[问答]

MCP2515读取缓冲区排序?

大家好。我有一个应用程序,其中一个MCP2515连接到一个嵌入式Linux模块的SPI总线。我有一个小麻烦,使CAN数据包的正确顺序。我有过滤器设置,以便任何有效的CAN消息将被接收。我有BUKT设置,如果RXB0是满的,它可以滚动。对于RXB1,问题是我可以每10毫秒左右查询一次设备。有时在两个缓冲区都有消息。我怎么知道先收到哪个消息?我能检查一些标志的组合吗?这可能是显而易见的——RXB0中的第一个出现,其次是RXB1上的一个,对吗?但是有一个条件(我想)可能是不正确的:-假设我对芯片进行投票,只有RXB0IF被设置,这意味着当我正在读取缓冲区时,在RXB0中有一条消息,第二条消息到达程序集缓冲区。它会滚入RXB1。在我再次轮询之前,我等待10毫秒,在此期间,第三条消息到达并放入RXB0。下次轮询时,RXB0IF和RCB1IF都被设置,但我如何知道哪一条消息先到达?

以上来自于百度翻译


      以下为原文

    Hi everyone.
I have an application where an MCP2515 is connected to the SPI bus of an embedded linux module.
I'm having a little trouble getting CAN packets in the correct order.

I have the filters set so that any valid can message will be received.
I have BUKT set so that if RXB0 is full it can roll-over to RXB1

The issue is that I can poll the device every 10ms or so.
Sometimes there are messages in both buffers. How can I tell which message was received first? Is there some combination of flags I can check?

It might seem obvious - the one in RXB0 came first, followed by the one on RXB1 right? But there is a condition (I think) where this might not be true:-

Say I poll the chip and only RXB0IF is set, meaning there is a message in RXB0
While I'm reading the buffer a 2nd message is arriving in the assembly-buffer. It gets rolled into RXB1.
I wait 10 ms before I poll again, during which time a 3rd message arrived and got put into RXB0.

The next time I poll, both RXB0IF and RCB1IF are set, but how can I tell which message arrived first?

回帖(2)

李铭鑫

2019-3-28 12:05:41
嗨,也许,在完成了RXB0和RXB0的处理之后,您应该检查RXB1IF是否再次,RX状态指令,以防在处理RXB0时发生翻滚,然后离开新的10毫秒轮询间隔。问候,Mysil

以上来自于百度翻译


      以下为原文

    Hi,
Maybe, after completed processing of RXB0, and RXB0 have been released, 
you should check RXB1IF again, RX STATUS Instruction, in case a rollover have occurred while processing RXB0, before leaving for a new 10 ms poll interval?
 
Regards,
   Mysil
 
举报

张志诚

2019-3-28 12:14:21
是的,我能做到,谢谢。

以上来自于百度翻译


      以下为原文

    Yes - I could do that, i'll give it a go thanks.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分