2026-02-06 2:16 AM - last edited on 2026-02-06 2:52 AM by mƎALLEm
I am using STM32G491RE - NUCLEO. connected to the ADM3055e CAN Transceiver
Currently I am trying to send 12 Bytes of Data from IXXAT Terminal over to FDCAN1 which receives the message fine and then Output the Message on FDCAN2 though a buffer. So My logic is when a message pass the filter it gets called by the Fifo0Callback and push it to a buffer below. This works fine the buffer also get the full 12Bytes of data same FD format and everything checked out.
But when I try to add the message to HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan2, &TxHeader2, TxData2). Where TxData is the dequeued message from the buffer and copys the 12Bytes. The message somehow gets truncated to 8Bytes on output.
Heck, when I add "if (HAL_FDCAN_GetTxFifoFreeLevel(&hfdcan2) > 0)", It somehow says it is full even when starting the code.
I have been suspecting because I cant set the HAL_FDCAN_ConfigTxBufferElementSize and HAL_FDCAN_ConfigRxBufferElementSize or even the messageRam offset like i could in the STM32H7 series. which may be causing the issue. Any Ideas on what I should do?
Let me know if you need more information.
@LCE @mƎALLEm
Thanks in advance!
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
if((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) != RESET)
{
if (hfdcan->Instance == FDCAN2)
{
...
}
else if (hfdcan->Instance == FDCAN1)
{
if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader1, RxData1) == HAL_OK)
{
uint8_t len = Can_DlcToBytes(RxHeader1.DataLength);
if (!CanRxBuffer_EnqueueFromISR1(RxHeader1.Identifier, RxData1, len)) {
FDCAN1_LED_State = LED_FIFO0_ERROR;
} else {
FDCAN1_LED_State = LED_STORE_BUFFER;
}
}
else {
FDCAN1_LED_State = LED_FIFO0_ERROR;
}
}
Solved! Go to Solution.
2026-02-06 2:55 AM
I did that and still the same result
2026-02-06 3:05 AM - edited 2026-02-06 3:06 AM
I don't have the device to test and debug. I think at this stage better to create a simple project where you simply send 12 bytes to your analyzer and test.
You can also try the Loopback mode.
2026-02-06 3:09 AM - edited 2026-02-06 3:10 AM
Alright I'll do that and let you know how it goes. Thank you for the help @mƎALLEm
On a side note may I ask how the RAM allocation and Tx / Rx BufferElementSize can be configured on G4 Series. As in cubeMX it doesnt give me the option to like the H7 series. Or is that done automatically by the core?
2026-02-06 3:16 AM
Better to separate questions here. Please create another thread for that question.
2026-02-06 4:29 AM - edited 2026-02-06 4:40 AM
Ok I found the issue....It's ridiculous simple mistake but it solved my issue.
I realised that when configuring TxHeader FDFormat my mistake was:
TxHeader1.FDFormat = FDCAN_FRAME_FD_BRS;
however it should be
TxHeader2.FDFormat = FDCAN_FD_CAN;
But anyways that solved my issue.
2026-02-06 6:11 AM
I just had a look at the G4 FDCAN, and the memory is really heavily limited (basically only 3 TX buffers!) compared to the H723..H735 that I know.
I would have suspected that there is your problem, but nice that you found it.
Better check your CAN memory handling anyway.
And in case of doubt, like FIFO level, always check the registers directly.