Skip to main content
Graduate II
June 11, 2024
Solved

Stm32H7 Can bus communication issue

  • June 11, 2024
  • 7 replies
  • 8835 views

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?

    This topic has been closed for replies.
    Best answer by mƎALLEm

    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.

     

    7 replies

    Graduate II
    June 12, 2024

    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?

     

    AmoghAuthor
    Graduate II
    June 12, 2024

    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.

    Technical Moderator
    June 12, 2024

    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

     

     

    AmoghAuthor
    Graduate II
    June 12, 2024

    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!

     

    Technical Moderator
    June 12, 2024

    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?

    Graduate II
    June 13, 2024

    draw a block diagram of how you're connecting the H7/CAN transceiver to the Canable. Include the terminating resistors, ground reference. Is the terminating resistor on the Canable enabled? 

     

    Canable are made from all kinds of 3rd party vendors. Some have isolation circuits. Do you have V1, V1 Pro or V2 of the Canable? A link to the Canable would help. 

    Graduate II
    June 15, 2024

    More than likely the level shifter is causing an issue. An oscilloscope will help determine what is going on.

    Also, I assume that you didn't connect the 3.3V to ground as shown in the schematic?

    AmoghAuthor
    Graduate II
    June 15, 2024

    Hi Karl,

    Yea, in first image stm32 to stm32 where can bus works there was an error with wiring. please see attached revised.

     

    In my opinion level shifter is not the culprit because stm32->stm32 can bus works. Would you not agree?

    So to conclude, I will report how does HSE/MCO on PA8 mirror looks like tomorrow once the scope arrives. 

     

    Thank you!

     

     

    AmoghAuthor
    Graduate II
    June 15, 2024

    Thanks @Karl Yamashita @mƎALLEm 

    My Can BUS works. I think it was a combination of clock, Bit timing parameters, and (maybe) RCC Prescaler disabled.

     

    Thank you soo very much!!

     

    Graduate
    December 22, 2025

    hi i am trying something similar like this .do you have some example code for this ..

    Technical Moderator
    December 23, 2025