Skip to main content
mhuar.1
Associate II
April 6, 2022
Question

Can't get FDCAN working on STM32H70-DK

  • April 6, 2022
  • 4 replies
  • 3494 views

STM32H70-DK FDCAN

Hello everyone:

I want to use FDCAN in my board but it is not working.

I've been using a few examples I've found as reference but none of them are for my exact board (STM32 H735).

Does anyone have an example I can run?

4 replies

mƎALLEm
Technical Moderator
April 6, 2022

Hello,

You didn't mention which example you did use for this?

What is your HW configuration? are you using FDCAN in loopback or Normal mode?

Please provide more details ..

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
mhuar.1
mhuar.1Author
Associate II
April 6, 2022

Hello, thanks for the help.

I started with the can loopback example for STM32H735 that was in the IDE because that board was similar to mine (changing some parts the code), I have tried both loopback and normal mode after. I have shared parts of the code, but if you prefer the whole main.c I can send it too.

Technical Moderator
April 6, 2022

Hello @mhuar.1​ and welcome to the Community :)

Would you please specify the problem that you faced, and when it occurs ?

Try to debug your project and try to identify where is it sticking.

I advise you to review the pins assignment and clock configuration in your code compared to the datasheet of used product.

Have a look to the STM32H73xx device Errata sheet to check if you have the same conditions as described in the doc.

Imen

"When your question is answered, please close this topic by clicking ""Accept as Solution"".ThanksImen"
mhuar.1
mhuar.1Author
Associate II
April 6, 2022

Hello, thanks a lot for answering

My board is the STM32H750-DK, The progrma doesn't stop anywhere, it's just that I dont' get any signal in the CANH or CANL.

Right now, the program is very simple, it's supposed to send the same data over and over.

It runs fine until the FIFO is full then it stops.

As fot the clock, Ive trieg generating code on the IDE and coping examples, it doesn't fix the problem, but it doesn't cause errors either.

Thanks a lot, here are some parts of the program.

This is the while(1) loop:

 while (1)

 {

// HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData0);

 HAL_Delay(200);

 HAL_GPIO_TogglePin(GPIOJ, GPIO_PIN_2);

   /* Start the Transmission process */

   if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData1) != HAL_OK)

   {

    /* Transmission request Error */

    Error_Handler();

   }

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

 }

This is the can config.

static void MX_FDCAN1_Init(void)

{

 /* USER CODE BEGIN FDCAN1_Init 0 */

 /* USER CODE END FDCAN1_Init 0 */

 /* USER CODE BEGIN FDCAN1_Init 1 */

 /* USER CODE END FDCAN1_Init 1 */

 hfdcan1.Instance = FDCAN1;

 hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_BRS;

 hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;

 hfdcan1.Init.AutoRetransmission = DISABLE;

 hfdcan1.Init.TransmitPause = DISABLE;

 hfdcan1.Init.ProtocolException = DISABLE;

 hfdcan1.Init.NominalPrescaler = 1;

 hfdcan1.Init.NominalSyncJumpWidth = 1;

 hfdcan1.Init.NominalTimeSeg1 = 18;

 hfdcan1.Init.NominalTimeSeg2 = 4;

 hfdcan1.Init.DataPrescaler = 1;

 hfdcan1.Init.DataSyncJumpWidth = 1;

 hfdcan1.Init.DataTimeSeg1 = 18;

 hfdcan1.Init.DataTimeSeg2 = 4;

 hfdcan1.Init.MessageRAMOffset = 0;

 hfdcan1.Init.StdFiltersNbr = 0;

 hfdcan1.Init.ExtFiltersNbr = 0;

 hfdcan1.Init.RxFifo0ElmtsNbr = 0;

 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 = 8;

 hfdcan1.Init.TxFifoQueueElmtsNbr = 15;

 hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;

 hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_64;

 if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)

 {

  Error_Handler();

 }

}

mhuar.1
mhuar.1Author
Associate II
April 6, 2022

There is also this part IN the MX_FDCAN1_init function

 TxHeader.Identifier = 10;

 TxHeader.IdType = FDCAN_STANDARD_ID;

 TxHeader.TxFrameType = FDCAN_DATA_FRAME;

 TxHeader.DataLength = FDCAN_DLC_BYTES_8;

 TxHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE;

 TxHeader.BitRateSwitch = FDCAN_BRS_ON;

 TxHeader.FDFormat = FDCAN_FD_CAN;

 TxHeader.TxEventFifoControl = FDCAN_STORE_TX_EVENTS;

 //TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;

 TxHeader.MessageMarker = 0x52;

 HAL_FDCAN_AddMessageToTxBuffer(&hfdcan1, &TxHeader, TxData0, FDCAN_TX_BUFFER0);

 HAL_FDCAN_Start(&hfdcan1);

 HAL_FDCAN_EnableTxBufferRequest(&hfdcan1, FDCAN_TX_BUFFER0);

 /* USER CODE END FDCAN1_Init 2 */

Associate
February 5, 2025

Hi@mhuar.1

Looking onto Your last message I would say that CAN was initialized as Classic (CAN2.0B), but TxHeader built up as FDCAN. Change this

TxHeader.FDFormat = FDCAN_FD_CAN;

to this

TxHeader.FDFormat = FDCAN_CLASSIC_CAN;

and You don't need BitRateSwitch enabled.

 

> I have tried loopback mode, when I do so, it runs continuously which means the FIFO is working.

I guess MCU just continuously failing to add message to the queue due to the issue above :)

 

Cheers.

Associate
February 5, 2025

BTW, could be a *** question, but @mhuar.1 have You connected CAN transceiver to board CAN_{RX,TX} pins?