Skip to main content
Associate II
December 4, 2024
Solved

Please advise on handling FDCAN Rxfifo.

  • December 4, 2024
  • 3 replies
  • 1526 views

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

 

 

 

.

 

 

 

Best answer by Karl Yamashita

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)

 

 

3 replies

mƎALLEm
Technical Moderator
December 4, 2024

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 "Best answer" on the reply which solved your issue or answered your question.
taeunAuthor
Associate II
December 4, 2024

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

 

 

mƎALLEm
Technical Moderator
December 4, 2024

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 "Best answer" on the reply which solved your issue or answered your question.
Karl Yamashita
Karl YamashitaBest answer
Lead III
December 4, 2024

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)

 

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source