2024-12-03 07:21 PM - last edited on 2024-12-04 12:50 AM by SofLit
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()
.
2024-12-04 12:27 AM
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?
2024-12-04 01:52 AM
When HAL_FDCAN_GetRxmessage is called in app(), RXfifoFULL occurs and CAN messages can no longer be received or the messages are lost.
2024-12-04 02:13 AM
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.
2024-12-04 02:42 PM
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)