SLAAET4 April 2025 MSPM0G3506 , MSPM0G3507 , MSPM0G3518 , MSPM0G3519
The RX is configured as FIFO mode in the current demo projects in SDK. The section below describes how to use RX in buffer mode.
static const DL_MCAN_StdMsgIDFilterElement gMCAN0StdFiltelem = {
.sfec = 0x7,
.sft = 0x0,
.sfid1 = 3,
.sfid2 = 0x0,
};
/* Configure Standard ID filter element */
DL_MCAN_addStdMsgIDFilter(MCAN0_INST, 0U, (DL_MCAN_StdMsgIDFilterElement *) &gMCAN0StdFiltelem);
The RX buffer mode is enabled when the filter element is configured as Store into Rx buffer or as debug message. First, add a filter with .sfec as 0x7. The .sft does not care when .sfec is set as 0x7. The .sfid1 is the filter ID, the receive message ID must match this ID to receive. The .sfid2 configures which Rx buffer is used to store receive messages.
/* New message received by Rx Buffer (Filter matched) */
if(gInterruptLineStatus & DL_MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG){
gInterruptLine1Status |= DL_MCAN_INTR_SRC_DEDICATED_RX_BUFF_MSG;
DL_MCAN_getNewDataStatus(MCAN0_INST, &newDataStatus);
if(newDataStatus.statusLow) {
/* Check Rx Buffer0 status */
if(newDataStatus.statusLow & 0x1){
DL_MCAN_readMsgRam(MCAN0_INST, DL_MCAN_MEM_TYPE_BUF, MCAN_RX_MSG_BUFFER_INDEX, 0U, &rxMsg);
ProcessCanRxMsg(&rxMsg);
}
/* Check remaining Rx Buffer */
}
if(newDataStatus.statusHigh) {
; /* 32-63, not applicable in demo */
}
/* Clear all new data status */
DL_MCAN_clearNewDataStatus(MCAN0_INST, &newDataStatus);
}
When receiving a message which matches the filter configuration, the RX message is stored into the RX buffer from 0 to 63. First, get a new data status. If there are new messages received in RX buffer 0 to RX buffer 31, then the corresponding bit of the newDataStatus.statusLow is set to 1. If there are new messages received in RX buffer 32 to RX buffer 63, then the corresponding bit of the newDataStatus.statusHigh is set to 1. Then, check if there is new message received in RX buffer 0. If so, then read the RX message out by calling DL_MCAN_readMsgRam() with MCAN_RX_MSG_BUFFER_INDEX value. In this case, the index value of RX buffer 0 is 0. Finally, after processing the message, clear the new data status by calling DL_MCAN_clearNewDataStatus().