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?
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
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.
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.
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.
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.
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
BR!
Jim,