How to distinguish received CAN frame format(CNA2.0B or CAN FD) for RT1060

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to distinguish received CAN frame format(CNA2.0B or CAN FD) for RT1060

Jump to solution
1,975 Views
HM_UoP
Contributor II

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.

 

 

 

Tags (2)
0 Kudos
Reply
1 Solution
1,957 Views
HM_UoP
Contributor II

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);

...

 

 

 

View solution in original post

0 Kudos
Reply
7 Replies
1,958 Views
HM_UoP
Contributor II

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);

...

 

 

 

0 Kudos
Reply
1,948 Views
guys_fr
Contributor II

Ho yes, there is two table

Table 44-4. Message Buffer Structure

Table 45-26. Message buffer structure — example with 64-byte payload

0 Kudos
Reply
1,945 Views
guys_fr
Contributor II

Is the EDL bit set even if payload is less or equal to 8 ?, would make sens and give FD ind bit.

0 Kudos
Reply
1,930 Views
HM_UoP
Contributor II

@guys_fr Yes, the EDL bit indicates if the CAN frame is a CANFD frame or a CAN2.0B frame. The CAN FD frame can also have less than 8 bytes of payload.

0 Kudos
Reply
1,943 Views
guys_fr
Contributor II

I am confused

S32K 53.4.3 Message buffer structure have a 4 bits fields but 2 bits in the structure. What is the code says ?

0 Kudos
Reply
1,937 Views
guys_fr
Contributor II
misleading, there is 4 bits, 27-24
0 Kudos
Reply
1,971 Views
guys_fr
Contributor II

Yes there is four combination, the Message Buffer Structure doesn't have FD indication bit. Unclear about Rx FIFO with an 8 bytes payload compatibility mode in FD, would be nice!

0 Kudos
Reply