AnsweredAssumed Answered

CAN FIFO Issues & Questions

Question asked by Jeremiah Gillis on Feb 24, 2017
Latest reply on Apr 6, 2017 by Mikhail Levitskiy

I'm having some troubles filtering CAN messages. Specifically, the RX individual masks don't seem to be doing anything. I am using the global Rx Fifo mask which does work. I have my CAN configured with 16 Mailboxes, 16 RX FIFO Filters, Use Rx FIFO, and the Payload Size of 8. From what I read in the reference manual, Table Elements 0-9 should be affected by RX Individual Masks when enabled. What I don't know is how to enable them. I don't see any registers that enable them. I thought they're enabled when setting them using

FLEXCAN_DRV_SetRxIndividualMask(can_instance, FLEXCAN_MSG_ID_EXT, 0U, 0xff0000);

What exactly am I missing here? Right now the messages are only filtered based on the global mask and my ID table elements.

 

 

I noticed something strange when switching from the normal Rx to FIFO Rx. When a CAN messaged was received with the normal Rx, it would look like

Identifier         DATA:   B0   B1   B2   B3   B4   B5   B6   B7

but when received via the Rx FIFO, it would like like

Identifier         DATA:   B3  B2   B1   B0   B7   B6   B5   B4

I couldn't figure out why my CAN messages weren't functioning correctly until I found out the data needed to be swapped. The identifier was correct, but the data was not. I have not located anything in the reference manual that discusses endianness differences with the CAN FIFO.

 

I sending the messages with CANalyzer as 

Identifier         DATA:   B0   B1   B2   B3   B4   B5   B6   B7

 

 

Lastly, I just want to make sure I'm emptying the FIFO buffer correctly. I'm using ProcessorExpert functions. What I do is read

if(FLEXCAN_DRV_GetReceiveStatus(indexCANPort) == FLEXCAN_STATUS_SUCCESS) ...

Then read my buffer with the received CAN message. Finally I start the next receive by

FLEXCAN_DRV_RxFifo(FSL_CANCOM1, &RxBuffer[indexCANPort]);

I've put

FLEXCAN_DRV_GetReceiveStatus(indexCANPort) == FLEXCAN_STATUS_SUCCESS

in a for loop with a maximum limit of 6 checks in case there is more than one message in the FIFO. This approach seems to work as I've seen times when at least two messages were pulled out of the FIFO. Is this the correct approach? I don't see any other PE functions that can tell me how many messages are in the FIFO.

 

I'm using S32 Design Studio V1.2 with S32_SDK_EAR_0.8.1 and my MCU is the S32K144 64-pin V1.0.

 

I wanted to see if anything changed with the next SDK version, but the only way to access the change log for the SDK is to installed S32 Design Studio V1.3. This requires V2.0 MCUs. I actually installed it awhile back until I realized it doesn't support V1.0 MCUs. It also caused havoc with my V1.2 install as the SDK links changed.

 

Thanks,

Jeremiah

Outcomes