According to the processor reference of IMXRT, we can know that FLEXCANFD module supports both CAN2.0B and CAN FD protocol.
This means that after FLEXCANFD is initialized to CANFD mode, it can allow sending/receiving both CAN2.0B format frames and CAN FD format frames as required.
The actual test results are also in line with expectations, although there is a tiny bug in FLEXCAN_WriteFDTxMb function that needs to be fixed (CAN_CS_EDL(1) should be CAN_CS_EDL(pTxFrame->edl)) .
The result of my test is that FLEXCANFD can also receive CAN messages in CAN2.0B and CANFD frame formats at the same time. But I can't use flexcan_fd_frame_t.edl to distinguish which format the received frame is. The flexcan_fd_frame_t.edl is always 0 regardless of whether the received message is a 2.0B frame or an FD frame.
Does anyone have any suggestions? Thank you.
已解决! 转到解答。
I have figured out the issue, which is also due to the bug of fsl_flexcan.c
Adding the following code to the function FLEXCAN_ReadFDRxMb can fix the issue.
....
/* Get the Extended Data Length. */
pRxFrame->edl = (uint8_t)((cs_temp & CAN_CS_EDL_MASK) >> CAN_CS_EDL_SHIFT);
/* Get the Error State Indicator */
pRxFrame->esi = (uint8_t)((cs_temp & CAN_CS_ESI_MASK) >> CAN_CS_ESI_SHIFT);
/* Get the Substitute Remote Request */
pRxFrame->srr = (uint8_t)((cs_temp & CAN_CS_SRR_MASK) >> CAN_CS_SRR_SHIFT);
/* Get the Bit Rate Switch */
pRxFrame->brs = (uint8_t)((cs_temp & CAN_CS_BRS_MASK) >> CAN_CS_BRS_SHIFT);
...
I have figured out the issue, which is also due to the bug of fsl_flexcan.c
Adding the following code to the function FLEXCAN_ReadFDRxMb can fix the issue.
....
/* Get the Extended Data Length. */
pRxFrame->edl = (uint8_t)((cs_temp & CAN_CS_EDL_MASK) >> CAN_CS_EDL_SHIFT);
/* Get the Error State Indicator */
pRxFrame->esi = (uint8_t)((cs_temp & CAN_CS_ESI_MASK) >> CAN_CS_ESI_SHIFT);
/* Get the Substitute Remote Request */
pRxFrame->srr = (uint8_t)((cs_temp & CAN_CS_SRR_MASK) >> CAN_CS_SRR_SHIFT);
/* Get the Bit Rate Switch */
pRxFrame->brs = (uint8_t)((cs_temp & CAN_CS_BRS_MASK) >> CAN_CS_BRS_SHIFT);
...