The RX is configured as FIFO mode in
the current demo projects in SDK. The section below introduces the structure of
DL_MCAN_RxFIFOStatus, which is commonly used in RX FIFO mode. TI recommends for the
users to check this structure when pulling the message from RX FIFO.
/**
* @brief Structure for MCAN Rx FIFO Status.
*/
typedef struct {
/*! Rx FIFO number
* One of @ref DL_MCAN_RX_FIFO_NUM
*/
uint32_t num;
/*! Rx FIFO Fill Level */
uint32_t fillLvl;
/*! Rx FIFO Get Index */
uint32_t getIdx;
/*! Rx FIFO Put Index */
uint32_t putIdx;
/*! Rx FIFO Full
* 0 = Rx FIFO not full
* 1 = Rx FIFO full
*/
uint32_t fifoFull;
/*! Rx FIFO Message Lost */
uint32_t msgLost;
} DL_MCAN_RxFIFOStatus;
- The num indicates the Rx
FIFO instance number of the current operation. MCAN can support multiple Rx
FIFOs (such as Rx FIFO 0 and Rx FIFO 1), and the specific instance must be
specified. For example, the DL_MCAN_RX_FIFO_NUM enumeration contains
DL_MCAN_RX_FIFO_0 and DL_MCAN_RX_FIFO_1.
- The fillLvl indicates the number
of valid messages currently stored in the Rx FIFO. For example, when fillLvl is
5, this means there are 5 unread messages in the FIFO. When fillLvl reaches the
depth of the Rx FIFO (such as 6 messages), the fifoFull field is set to 1,
indicating that the FIFO is full.
- The getIdx points to the next
message to be read. The CPU reads the messages in the FIFO sequentially by
incrementing getIdx. When the Rx FIFO is full and in overwrite mode, new
messages overwrite the oldest messages. At this time, user starts reading from
getIdx + 1 to avoid reading old data that is being overwritten.
- The putIdx points to the next
writable message location. When a new message is received, the message is
written to the location pointed to by putIdx, and then putIdx is
incremented.
- The fifoFull indicates the Rx
FIFO is full or not. When Rx FIFO is full, try the following options:
- Blocking mode: new
messages are discarded and the msgLost count is triggered.
- Overwrite mode: the new
message overwrites the oldest message, putIdx and getIdx are incremented
at the same time.
- The msgLost counts the number of
messages discarded due to Rx FIFO full. This is triggered in the following
situations:
- Blocking mode: when the
Rx FIFO is full, a new message is received and the message is rejected
and discarded.
- Overwrite mode: when
overwriting old messages, the overwritten messages are counted as
lost.