Calling HAL_FDCAN_AddMessageToTxBuffer to Tx on FDCAN always end up in the following error condition: See CANFD_Error.png. Main.c has all FDCAN initialization and use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-24 2:26 PM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-24 10:14 PM
Hi,
It looks to me that you are not assigning any space for any kind of tx queue or buffer:
row ~378:
hfdcan1.Init.TxEventsNbr = 0;
hfdcan1.Init.TxBuffersNbr = 0;
hfdcan1.Init.TxFifoQueueElmtsNbr = 0;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
You need to allocate how many elements are reserved for example for the queue. Otherwise there is no reservation in the RAM and no place for the function call to place the data in.
Same thing goes for rx fifo buffers.
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-24 10:14 PM
Hi,
It looks to me that you are not assigning any space for any kind of tx queue or buffer:
row ~378:
hfdcan1.Init.TxEventsNbr = 0;
hfdcan1.Init.TxBuffersNbr = 0;
hfdcan1.Init.TxFifoQueueElmtsNbr = 0;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
You need to allocate how many elements are reserved for example for the queue. Otherwise there is no reservation in the RAM and no place for the function call to place the data in.
Same thing goes for rx fifo buffers.
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-26 10:30 PM
If the above was good enough answer to help you solve the issue, please select it as the answer to help others in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-30 8:29 AM
As suggested by "TOlli" it is a RAM assignment issue. I added "CAN1.Init.TxBuffersNbr = 2;" to my CAN_Init function and worked just fine after that.
Here is the complete CAN Init function function.
void CAN1_Init(void)
{
CAN1.Instance = FDCAN1;
CAN1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
CAN1.Init.Mode = FDCAN_MODE_EXTERNAL_LOOPBACK; // EXTERNAL Means FDCAN treats its own transmitted messages as received messages
CAN1.Init.AutoRetransmission = ENABLE;
CAN1.Init.NominalPrescaler = 3; // Setting values for 500k bps
CAN1.Init.NominalSyncJumpWidth = 1;
CAN1.Init.NominalTimeSeg1 = 2;
CAN1.Init.NominalTimeSeg2 = 2;
CAN1.Init.TxBuffersNbr = 2;
if (HAL_FDCAN_Init(&CAN1) != HAL_OK)
{
Error_Handler();
}
}
