Stm32H7 Can bus communication issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-11 9:47 AM - last edited on ‎2024-06-12 2:33 AM by mƎALLEm
Hello
I am having an weird issue and was hoping if someone could provide some guidance.
Hardware :
- Two Stm32 H7 with CAN Transciever
- Nvidia Orin
- Can Adapter/Sniffer (Canable)
What works :
- Stm32H7 to Stm32H7 Nucleo Board Can Bus works.
- Nvidia Orin < - > Canable Adapter Can bus works.
Issue :
- Can bus communication from stm32 H7 to Canable Adapter are not coming through. neither Tx nor Rx.
What have i done to troubleshoot
- Checked wirings for High to High and Low to Low and Tx and Rx as well.
- Checked voltages for Rx pins at 3.3v( using level shifters wit h transciever)
- Checked termination resistance and have tested the connections in isolation with both ends terminated with 120ohms ie (stm32- > stm32, Stm32-> adapter, Stm32 -> Orin)
- I have tested with different baud baud rate like 250, 444, 450, 440, 500k.
- 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?
Solved! Go to Solution.
- Labels:
-
CAN
-
FDCAN
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 9:59 AM - edited ‎2024-06-12 10:12 AM
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:
I propose you that clock config with a FDCAN timings at 500kb/s (ioc in attachment)
Hope I answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-11 6:08 PM
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?
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-11 6:51 PM - edited ‎2024-06-11 6:54 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 1:52 AM - edited ‎2024-06-12 1:58 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 5:53 AM - edited ‎2024-06-12 5:55 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 6:31 AM
Humm well and thank you for the sharing.
Still one thing to check:
In the schematics HSE crystal is not fitted:
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 6:33 AM - edited ‎2024-06-12 7:39 AM
Hi again,
Just noticed that your RCC clock source is set to HSI (64MHz) in your ioc file:
Could you please confirm/check?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 7:43 AM
Sorry: Discard my previous comment about HSI clock source in your ioc file as your FDCAN clock source is HSE:
So please tell if you've already soldered a 24MHz crystal with its respective capacitors!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 9:32 AM - edited ‎2024-06-12 9:43 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-06-12 9:59 AM - edited ‎2024-06-12 10:12 AM
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:
I propose you that clock config with a FDCAN timings at 500kb/s (ioc in attachment)
Hope I answered your question.
