Skip to main content
Moe
Associate II
Jul 29, 2022 1:07 PM UTC
Question

CAN Bus Error: TX FIFO has no allocated RAM memory? Issue from CubeMX ?

Hi all,

I'm struggling for some time to get the CAN bus of my Evalboard (STM32H745I-DISCO) working. No matter how I configure the CAN bus in CubeMX, I always end up in the following error area and I don't know why:

 /* Check that the Tx FIFO/Queue has an allocated area into the RAM */
 if ((hfdcan->Instance->TXBC & FDCAN_TXBC_TFQS) == 0U)
 {
 /* Update error code */
 hfdcan->ErrorCode |= HAL_FDCAN_ERROR_PARAM;
 
 return HAL_ERROR;
 }

First, my FDCAN initialization looks like this:

static void MX_FDCAN1_Init(void)
{
 hfdcan1.Instance = FDCAN1;
 hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
 hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
 hfdcan1.Init.AutoRetransmission = ENABLE;
 hfdcan1.Init.TransmitPause = DISABLE;
 hfdcan1.Init.ProtocolException = DISABLE;
 hfdcan1.Init.NominalPrescaler = 12;
 hfdcan1.Init.NominalSyncJumpWidth = 1;
 hfdcan1.Init.NominalTimeSeg1 = 5;
 hfdcan1.Init.NominalTimeSeg2 = 2;
 hfdcan1.Init.DataPrescaler = 12;
 hfdcan1.Init.DataSyncJumpWidth = 1;
 hfdcan1.Init.DataTimeSeg1 = 5;
 hfdcan1.Init.DataTimeSeg2 = 2;
 hfdcan1.Init.MessageRAMOffset = 0;
 hfdcan1.Init.StdFiltersNbr = 1;
 hfdcan1.Init.ExtFiltersNbr = 0;
 hfdcan1.Init.RxFifo0ElmtsNbr = 1;
 hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
 hfdcan1.Init.RxFifo1ElmtsNbr = 0;
 hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
 hfdcan1.Init.RxBuffersNbr = 0;
 hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
 hfdcan1.Init.TxEventsNbr = 0;
 hfdcan1.Init.TxBuffersNbr = 16;
 hfdcan1.Init.TxFifoQueueElmtsNbr = 16;
 hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
 hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
 if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
 {
 Error_Handler();
 }

Then I configure the RX filter, start the CAN bus and configure the TX settings:

 /* Configure Rx filter */
 sFilterConfig.IdType = FDCAN_STANDARD_ID;
 sFilterConfig.FilterIndex = 0;
 sFilterConfig.FilterType = FDCAN_FILTER_MASK;
 sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
 sFilterConfig.FilterID1 = 0x321; 
 sFilterConfig.FilterID2 = 0x7FF;
 if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
 {
 Error_Handler();
 }
 
 /* Start FDCAN bus */
 if (HAL_FDCAN_Start(&hfdcan1) != HAL_OK)
 {
 Error_Handler();
 }
 
 /* Configure Tx Settings */
 TxHeader.Identifier = 0x321; 
 TxHeader.IdType = FDCAN_STANDARD_ID; 			
 TxHeader.TxFrameType = FDCAN_DATA_FRAME; 			
 TxHeader.DataLength = FDCAN_DLC_BYTES_2; 			
 TxHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE; 
 TxHeader.BitRateSwitch = FDCAN_BRS_OFF; 			
 TxHeader.FDFormat = FDCAN_CLASSIC_CAN; 	
 TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS; 
 TxHeader.MessageMarker = 0;

Only after these mentioned settings are done I try to send a simple message but that always ends in the above mentioned error area:

FDCAN_HandleTypeDef hfdcan1;
FDCAN_FilterTypeDef sFilterConfig;
FDCAN_TxHeaderTypeDef TxHeader;
uint8_t TxData[8]={0xCC,0xDD};
 
int main(void)
{
 ...
 
 MX_GPIO_Init();
 MX_FDCAN1_Init();
 
 while (1)
 {
	 if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData) != HAL_OK)
	 {
	 Error_Handler();
	 }
	 HAL_Delay(1000);
 }
}

Why do I always end up in this error area? The TXBC register is also constantly zero, but I have set TX Buffer via CubeMX. What am I doing wrong?

I would be pleased about answers.

This topic has been closed for replies.

2 replies

Associate II
Jun 4, 2024 5:52 PM UTC

I'm having this issue.  What's the work around?

Associate II
Jul 18, 2024 9:20 AM UTC

hi! have you solved this problem yet if yes can you please share the solution of it to me as I having the same problem while working with it. 

Thank you