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;
}
}
2026-02-06 2:24 AM
Hello,
"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. "
I didn't understand the relation between the statement above and the FIFO callback.
Please be concise in the description. Does the issue is on Rx or on Tx?
Check the TxHeader. Is it set to DLC 12 or DLC 8?:
TxHeader.DataLength = FDCAN_DLC_BYTES_12;
2026-02-06 2:26 AM
Sorry.
The issue is on my Tx
I have configured my Tx as follows
TxHeader2.Identifier = 0x321;
TxHeader2.BitRateSwitch = FDCAN_BRS_ON;
TxHeader2.FDFormat = FDCAN_FRAME_FD_BRS;
TxHeader2.IdType = FDCAN_EXTENDED_ID;
TxHeader2.TxFrameType = FDCAN_DATA_FRAME;
TxHeader2.DataLength = FDCAN_DLC_BYTES_12;
TxHeader2.ErrorStateIndicator = FDCAN_ESI_PASSIVE;
TxHeader2.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
TxHeader2.MessageMarker = 0;
2026-02-06 2:29 AM
Please clarify this point:
How did you check the Tx buffer was truncated?
2026-02-06 2:34 AM - edited 2026-02-06 2:34 AM
I will reword my issue
I am defining a 12-byte payload and setting TxHeader.DataLength = FDCAN_DLC_BYTES_12. In debug mode, I can verify that the header value is correctly set to 0x00090000 (DLC 9). However, my IXXAT analyzer shows the message arriving with DLC 8 and only the first 8 bytes of data.
Even when sending internally from FDCAN2 to FDCAN1, the RxData array only updates the first 8 bytes, while the remaining 4 bytes remain zeroed, despite the RxHeader reporting a DLC of 12.
Also another issue I am facing is when I add this. It say FifoFreeLevel is == 0
if (HAL_FDCAN_GetTxFifoFreeLevel(&hfdcan2) > 0)
{
// TxHeader2.DataLength = msg.Length;
//TODO: remove TxData1 -> msg.Data
memcpy(&TxData2, msg.Data, sizeof(msg.Data));
if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan2, &TxHeader2, TxData2) == HAL_OK) {
FDCAN1_LED_State = LED_Tx_SUCCESS;
printf("Bridge: Forwarded ID 0x%lx to FDCAN2\n\r", msg.Identifier);
} else {
FDCAN1_LED_State = LED_TRANSMISSION_ERROR;
printf("Transmission Error!\n\r");
}
}
else
{
FDCAN1_LED_State = LED_FIFO0_ERROR;
printf("FDCAN2: Hardware FIFO Full - stalling bridge\n\r");
}2026-02-06 2:38 AM
Please share your project. What you are sharing doesn't tell anything about the issue.
2026-02-06 2:41 AM - edited 2026-02-06 2:52 AM
I have attached a ZIP file of it below.
2026-02-06 2:49 AM - edited 2026-02-06 2:51 AM
What that printf is showing here for the DLC?: DLC 12?
printf("FDCAN1 RxHeader: DLC=%lu (bytes=%u) FDFormat=%lu last Byte=%u\r\n",
TxHeader2.DataLength,
Can_DlcToBytes(TxHeader2.DataLength),
TxHeader2.FDFormat,
TxData2[11]);
And what Can_BytesToDlc() returns here?
TxHeader2.DataLength = Can_BytesToDlc(currentPacketSize);
Try to force TxHeader2.DataLength with:
FDCAN_DLC_BYTES_12
2026-02-06 2:52 AM
DLC = 9
Bytes = 12
2026-02-06 2:53 AM
Try to force TxHeader2.DataLength with:
FDCAN_DLC_BYTES_12
In your code, it's assigned dynamically.