Skip to main content
Visitor 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()

 

 

 

.

 

 

 

    This topic has been closed for replies.
    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

    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?

     

    taeunAuthor
    Visitor 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.

     

     

    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. 

    Graduate II
    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)