cancel
Showing results for 
Search instead for 
Did you mean: 

Please advise on handling FDCAN Rxfifo.

taeun
Associate II

I am trying to receive CAN FD and save the data to the SD card, but I am having a problem .

Create and deliver an event structure in HAL_FDCAN_RXFifo0Callback, Receive the structure from the application area and call HAL_FDCAN_GetRxmessage. In this case , RxFIFOFULL accur .

IF HAL_FDCAN_GetRxmessage is called from callback, RXFIFOFULL does not occur. 

However i want to keep the callback statement as short as possible , Also idon't understand why tihs is a problem in the first case.

The place where HAL_FDCAN_GetRxMessage is called is cantoQueue(). 

There is no problem if place this function in  callback rather than app()

 

 

 

.

 

 

 

4 REPLIES 4
SofLit
ST Employee

Hello,

Sorry I didn't understand the case. 

Do you mean if you call HAL_FDCAN_GetRxmessage() inside the HAL_FDCAN_RXFifo0Callback() callback the calback doesn't fiire while if you remove HAL_FDCAN_GetRxmessage() call the callback is called?

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
taeun
Associate II

When HAL_FDCAN_GetRxmessage is called in app(), RXfifoFULL occurs and CAN messages can no longer be received or the messages are lost.

 

 

RXfifoFULL when HAL_FDCAN_GetRxmessage() called?? are you sure it's called?

I think better to forget about SD card function for now and try with a simple CAN receiving project. 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Karl Yamashita
Lead III

Skip using memcpy and just have HAL do all the work for you and save the data directly to your queue. When you get return status HAL_OK, then increment your queue pointer so the next CAN message is save in the next queue.

 

if (HAL_FDCAN_GetRxMessage(&hfdcan1, FDCAN_RX_FIFO0, &rxHeader, rxQueue[rxQueueHead]) == HAL_OK)

 

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.