Receiving CAN FD frame when FDEN is disabled

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

Receiving CAN FD frame when FDEN is disabled

2,186 Views
nathand
Contributor II

Using an S32K148, what happens when the FlexCAN MCR->FDEN (flexible datarate enable) bit is not set, and the MCU receives a FD frame with DLC > 8? We've installed our device, containing this MCU, in many vehicles, and we're seeing failures with one specific very-recent vehicle model. Using SDK 4.0.1, our code is crashing in flexcan_hw_access.c around line 1616, in FLEXCAN_ReadRxFifo(). One of these two lines

          mbWord = flexcan_mb_data_32[databyte >> 2U];
          FlexcanSwapBytesInWord(mbWord, msgData_32[databyte >> 2U]);

seems to be causing the MCU to crash when a frame arrives with a data length greater than 8, since we're only supplying an 8-byte buffer. When FDEN is disabled, why does the MCU still receive frames with a data length code greater than 8? What's the correct workaround here - do I need to pass a larger buffer when I start the read, or will this still crash because I'm using the Rx FIFO which only has space for 8 bytes of data?

Labels (1)
0 Kudos
Reply
4 Replies

1,274 Views
1069466534
Contributor II

Hello, I have encountered this problem at present. Do you need to change RX FIFO to MB format? Because CAN FD is not supported at present

0 Kudos
Reply

2,166 Views
nathand
Contributor II

Thanks. This does not quite answer my question, though. What is expected to happen when FDEN is 0 (FD not enabled) and the FlexCAN module receives a CAN FD frame? It seems like that causes a CPU exception in the SDK, which is not ideal.

0 Kudos
Reply

2,158 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@nathand

       My thoughts may not be right, but it should also be a possible cause of the exception.

This is Rx FIFO structure.

The region 0x80-0x8C contains the output of the FIFO which must be read by the CPU as
a message buffer. This output contains the oldest message that has been received but not
yet read. The region 0x90-0xDC is reserved for internal use of the FIFO engine.

Senlent_0-1629709462482.png

 

Senlent_2-1629712316172.png

As long as the data length exceeds 8, can_real_payload will also be greater than 8(=12,16,20,24,32,48,64). The following function will access the Reserved space of 0x90~0xDC, causing an exception.

Senlent_1-1629712144888.png

   This is the possible reason I thought of . If you have any questions about this answer, you can ask again in the community forum, and some of my colleagues will help you answer it.

BR!

     Jim.

0 Kudos
Reply

2,172 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@nathand

           yes, you right!

           Rx FIFO does not support CAN FD, because the message data of the mailbox contained in the Rx FIFO structure is 8 bytes ,so you can only use MB when using CAN FD.

S32K-RM

Senlent_0-1629682380970.png

BR!

     Jim,

0 Kudos
Reply