cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32H7 Can bus communication issue

Amogh
Associate III

Hello

I am having an weird issue and was hoping if someone could provide some guidance.

Hardware :

  1. Two Stm32 H7 with CAN Transciever
  2. Nvidia Orin
  3. Can Adapter/Sniffer (Canable)


What works : 

  1. Stm32H7 to Stm32H7 Nucleo Board Can Bus works.
  2. Nvidia Orin < - > Canable Adapter Can bus works.

Issue :

  1. Can bus communication from stm32 H7 to Canable Adapter are not coming through. neither Tx nor Rx.


What have i done to troubleshoot

  1. Checked wirings for High to High and Low to Low and Tx and Rx as well.
  2. Checked voltages for Rx pins at 3.3v( using level shifters wit h transciever)
  3. Checked termination resistance and have tested the connections in isolation with both ends terminated with 120ohms ie (stm32- > stm32, Stm32-> adapter, Stm32 -> Orin)
  4. I have tested with different baud baud rate like 250, 444, 450, 440, 500k.
  5. Tried different Bit Timing Parameters but to no avail.


Below are my FDCan Parmeters from ioc file.

FDCAN1.AutoRetransmission=ENABLE
FDCAN1.CalculateBaudRateNominal=444444
FDCAN1.CalculateTimeBitNominal=2250
FDCAN1.CalculateTimeQuantumNominal=187.5
FDCAN1.ClockCalibrationCCU=DISABLE
FDCAN1.DataPrescaler=2
FDCAN1.DataSyncJumpWidth=4
FDCAN1.DataTimeSeg1=10
FDCAN1.DataTimeSeg2=3
FDCAN1.FrameFormat=FDCAN_FRAME_CLASSIC
FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,Mode,AutoRetransmission,FrameFormat,NominalSyncJumpWidth,DataSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,StdFiltersNbr,RxBuffersNbr,RxBufferSize,TxEventsNbr,TxBuffersNbr,TxElmtSize,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,DataPrescaler,RxFifo1ElmtsNbr,TxFifoQueueElmtsNbr,RxFifo0ElmtsNbr,ClockCalibrationCCU,ProtocolException
FDCAN1.Mode=FDCAN_MODE_NORMAL
FDCAN1.NominalPrescaler=8
FDCAN1.NominalSyncJumpWidth=1
FDCAN1.NominalTimeSeg1=6
FDCAN1.NominalTimeSeg2=5
FDCAN1.ProtocolException=ENABLE
FDCAN1.RxBufferSize=FDCAN_DATA_BYTES_12
FDCAN1.RxBuffersNbr=10
FDCAN1.RxFifo0ElmtsNbr=10
FDCAN1.RxFifo1ElmtsNbr=10
FDCAN1.StdFiltersNbr=0
FDCAN1.TxBuffersNbr=10
FDCAN1.TxElmtSize=FDCAN_DATA_BYTES_12
FDCAN1.TxEventsNbr=10
FDCAN1.TxFifoQueueElmtsNbr=10


can anyone please advise on what to do to make STM32 communication work with other CAN devices?

1 ACCEPTED SOLUTION

Accepted Solutions

Ah! How the FDCAN is clock sourced if there was no clock source then ;) ?

As per your ioc file FDCAN clock source is HSE and there is no external clock source! 

I suggest to set the clock source in Bypass mode and 

Use STLINK-MCO output as clock source for the system clock and select one of the PLLs output for FDCAN clock source.

For this you need to download ST-LINK firmware upgrade tool from here: https://www.st.com/en/development-tools/stsw-link007.html

connect to ST LINK and select one of the STLINK-MCO HSE clock source (to select 8MHz as external clock) as indicated in the following figure:

SofLit_0-1718211036483.png

I propose you that clock config with a FDCAN timings at 500kb/s (ioc in attachment)

Hope I answered your question.

 

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.

View solution in original post

17 REPLIES 17
Karl Yamashita
Lead III

Have you check with oscilloscope to be sure the H7 is sending messages?

Have you checked the HAL status when you call HAL_FDCAN_AddMessageToTxFifoQ or HAL_FDCAN_AddMessageToTxBuffer?

How about communication between H7 and Nvidia Orin?

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

Yea, so I connected two H7's /Nucleo's together and transferred Random #'s from 1 to other and vice-versa and checked on screen/serial monitor that they are received. So this implies CAN configuration is working but it seems I need to set a specific bit timing a generic baud rate. is there a recommended set of parameters for H7? Any baud rate is okay for now.

 

I dont have a oscilloscope, but so far H7 and Nvidia Orin is also not working. Nvidia Orin to CAN Adapter is working.

Hello,

As you're using a NUCLEO board, what about your clock config? What is the FDCAN clock source: HSI? or HSE in BYPASS mode using STLINK MCO? If STLINK MCO you need also to check the clock source of the ST-LINK. For this you need to specify what is the NUCLEO board you're using.

Could you please attach your ioc file?

I'm suspecting something related to the clock source/ clock config.

PS: as you're in CLASSIC mode no need to configure data phase timing as it is discarded in that mode:

 

FDCAN1.DataPrescaler=2
FDCAN1.DataSyncJumpWidth=4
FDCAN1.DataTimeSeg1=10
FDCAN1.DataTimeSeg2=3

 

 

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.
Amogh
Associate III

Hello, 

Thank you for reading the issue and responding!!

  • Please see attached ioc file.
  • I have 2 identical Nucleo H7A3ZI-Q boards.
  • I have tried a HSE and PLL1Q with a few different Bit Timing Parameters that I found from the web, and from chatGpt for 125k, 250k, 500k, and 1000k, but I cant get any baud rate to work when I try stm32/Nucleo to communicate with a non-Nucleo device.
  • Also, please note I had forgotten to mention even esp32 to esp32 and esp32 to can adapter/sniffer works, but I have to get Orin to STM/Nucleo Can Bus working (@ whatever baud rate even a conservative one will be okay for now )

 

Thank you in advance!

Have a good day!

 

Humm well and thank you for the sharing.

Still one thing to check:

In the schematics HSE crystal is not fitted:

SofLit_0-1718198912798.png

and in your clock config you set HSE to 24MHz as an external clock source. Did you solder that 24MHz crystal with its respective capacitors?

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.

Hi again,

Just noticed that your RCC clock source is set to HSI (64MHz) in your ioc file:

SofLit_0-1718199222167.png

Could you please confirm/check?

 

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.

Sorry: Discard my previous comment about HSI clock source in your ioc file as your FDCAN clock source is HSE:

SofLit_0-1718203294719.png

So please tell if you've already soldered a 24MHz crystal with its respective capacitors!

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.

No I havent soldered anything yet on the Nucleo board. I dint really think HSE would require me solder anything on the nucleo board... My Apologies!!

To resolve the can bus issue now, should I use PLL1Q (42.6667 Mhz)? If yes, can you please recommend some Bit Timing Parameters as well for a few common baud rates.

Ah! How the FDCAN is clock sourced if there was no clock source then ;) ?

As per your ioc file FDCAN clock source is HSE and there is no external clock source! 

I suggest to set the clock source in Bypass mode and 

Use STLINK-MCO output as clock source for the system clock and select one of the PLLs output for FDCAN clock source.

For this you need to download ST-LINK firmware upgrade tool from here: https://www.st.com/en/development-tools/stsw-link007.html

connect to ST LINK and select one of the STLINK-MCO HSE clock source (to select 8MHz as external clock) as indicated in the following figure:

SofLit_0-1718211036483.png

I propose you that clock config with a FDCAN timings at 500kb/s (ioc in attachment)

Hope I answered your question.

 

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.