Functional Description
794
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
Controller Area Network (CAN) Module
11.3.11 Handling of Received Message Objects
The CPU may read a received message any time through the CAN interface registers, because the data
consistency is ensured by the message handler state machine.
Typically, the CPU first writes 0x007F to the CANIFnCMSK register and then writes the number of the
message object to the CANIFnCRQ register. That combination transfers the whole received message from
the message RAM into the Message Buffer registers (CANIFnMSKn, CANIFnARBn, and CANIFnMCTL).
Additionally, the NEWDAT and INTPND bits are cleared in the message RAM, acknowledging that the
message has been read and clearing the pending interrupt generated by this message object.
If the message object uses masks for acceptance filtering, the CANIFnARBn registers show the full,
unmasked ID for the received message.
The NEWDAT bit in the CANIFnMCTL register shows whether a new message has been received since
the last time this message object was read. The MSGLST bit in the CANIFnMCTL register shows whether
more than one message has been received since the last time this message object was read. MSGLST is
not automatically cleared, and should be cleared by software after reading its status.
Using a remote frame, the CPU may request new data from another CAN node on the CAN bus. Setting
the TXRQST bit of a receive object causes the transmission of a remote frame with the identifier of the
receive object. This remote frame triggers the other CAN node to start the transmission of the matching
data frame. If the matching data frame is received before the remote frame could be transmitted, the
TXRQST bit is automatically reset. This prevents the possible loss of data when the other device on the
CAN bus has already transmitted the data slightly earlier than expected.
11.3.11.1 Configuration of a FIFO Buffer
With the exception of the EOB bit in the CANIFnMCTL register, the configuration of receive message
objects belonging to a FIFO buffer is the same as the configuration of a single receive message object
(see
). To concatenate two or more message objects into a FIFO buffer, the identifiers and
masks (if used) of these message objects must be programmed to matching values. Due to the implicit
priority of the message objects, the message object with the lowest message object number is the first
message object in a FIFO buffer. The EOB bit of all message objects of a FIFO buffer except the last one
must be cleared. The EOB bit of the last message object of a FIFO buffer is set, indicating it is the last
entry in the buffer.
11.3.11.2 Reception of Messages With FIFO Buffers
Received messages with identifiers matching to a FIFO buffer are stored starting with the message object
with the lowest message number. When a message is stored into a message object of a FIFO buffer, the
NEWDAT of the CANIFnMCTL register bit of this message object is set. By setting NEWDAT while EOB is
clear, the message object is locked and cannot be written to by the message handler until the CPU has
cleared the NEWDAT bit. Messages are stored into a FIFO buffer until the last message object of this
FIFO buffer is reached. Until all of the preceding message objects have been released by clearing the
NEWDAT bit, all further messages for this FIFO buffer are written into the last message object of the FIFO
buffer and therefore overwrite previous messages.
11.3.11.3 Reading From a FIFO Buffer
When the CPU transfers the contents of a message object from a FIFO buffer by writing its number to the
CANIFnCRQ register, the TXRQST and CLRINTPND bits in the CANIFnCMSK register should be set
such that the NEWDAT and INTPEND bits in the CANIFnMCTL register are cleared after the read. The
values of these bits in the CANIFnMCTL register always reflect the status of the message object before
the bits are cleared. To assure the correct function of a FIFO buffer, the CPU should read out the
message objects starting with the message object with the lowest message number. When reading from
the FIFO buffer, the user should be aware that a new received message is placed in the message object
with the lowest message number for which the NEWDAT bit of the CANIFnMCTL register is clear. As a
result, the order of the received messages in the FIFO is not ensured.
shows how a set of
message objects which are concatenated to a FIFO Buffer can be handled by the CPU.