This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

If CAN receive buffer is'nt cleared before a new message arrives,will it over-write the earlier data?

I am writing an application where a number of devices send messages to a common CAN processor in LPC1778 via CAN bus.

FYI-i dont need to use Acceptance Filter because all messages have to be allowed.

My question is that,if Device A sends a message and after Device A finishes sending a frame of data,if Device B sends a data frame,if i have not yet released the receive buffer in CAN in LPC1778,will it over-write the data or will it retry automatically when the receive buffer is released.

  • Hello akshimmu,

    In CAN, the transmitter of any message will only try to retransmit if it loses arbitration on the bus, or potentially if no other CAN node on the bus provides an ACK within the correct window.  Once these two basic criteria are met, the transmitter will broadcast its message without caring about the state of the receiver node's message buffers.

    The reception process of the CAN node has to take care to empty any receive buffers before the next available message cycle.  Since the LPC1700 series CAN peripheral has a double receive buffer, the controller is able to receive a message that is presently coming over the bus, while the CPU is processing a message which was received previously.

    If the receive buffers have not been processed and cleared by the CPU and a new message arrives, the CAN controller flags a data overrun event and discards the new message.  A status flag is set to identify this event, and an optional interrupt can be generated.

    You should ensure that received messages are processed timely.  Also, your CAN message strategy might allow critical messages to be transmitted periodically to help guarantee delivery.

    -arw

  • Thanks allen.

    Suppose i dont release the receive buffer,will the CAN receive buffer accept a new message?? 

  • If a CAN RX buffer has not been read & interrupt status cleared, a new message will not be received from the bus.

    I think you could easily test this behavior using a CAN bus analyzer, by dedicating some messages to send while not servicing the RX buffers and interrupt status registers.  Clear the overrun by setting the CDO bit, and read the RX buffer.  Your code will need to be efficient, not spending lots of time managing the data payload of the message inside of an interrupt service routine, for example.  You may want to create a message queue in the global RAM area where messages are immediately copied once received.  A main loop can manage this queue from outside the low level handler...

    -arw