Skip to main content
Explorer
June 19, 2025
Solved

Struggling with STM32L432 CAN Bus communication using MCP2551

  • June 19, 2025
  • 2 replies
  • 585 views

Hi all,

I am Struggling with STM32L432 CAN Bus communication from one STM32L432 to another STM32L432 using MCP2551.

* I have checked loopback works.

*I am using HSE Clock (After soldering SB17) - 

Dave001_0-1750297415512.png

Dave001_1-1750297436889.png

 

* I have also tried putting Oscilloscope at TX pins between STM32 Transmitter and MCP2551 but signal just stays high.

* Plus, i can see that this never triggers but putting it in debug mode and putting a breakpoint in there

Dave001_2-1750297571288.png

 

I also tried following this guy: 115. STM32CubeIDE MCP2551 CAN BUS with STM32 F103C8T6 

but to no avail. 

* I also tried doing the same setup i.e. ADC on transmitter sending information to other side via CANBUS.

* I have quadrupled checked Hardware circuitry, and all seems to be right.

* CANBUS Distance is also less than a meter now with termination at both ends.

TX Code - 

Dave001_5-1750297828603.pngDave001_6-1750297837587.png

 

 

RX Code - 

Dave001_3-1750297798394.png

Dave001_4-1750297807967.png

 

 

Any help would be much appreciated.

 

Thanks

 

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

    Hello @Dave001  and welcome to the ST community,

    First in next time please use </> button to share your code instead of sharing screen shots. Please review how to post a code.

    Second, these are a very bad bit timing parameters:

    mALLEm_0-1750327556925.png

    You need to decrease as much as possible the Prescaler and increase as much as possible BS1 and BS2 while having a simple point at around 87%;

    Refer to this article: CAN (bxCAN) bit time configuration on STM32 MCUs

    This link can help you to calculate the timings parameters. You need to select:

    mALLEm_0-1750328006080.png

    Hope that helps.

     

    2 replies

    mƎALLEmAnswer
    Technical Moderator
    June 19, 2025

    Hello @Dave001  and welcome to the ST community,

    First in next time please use </> button to share your code instead of sharing screen shots. Please review how to post a code.

    Second, these are a very bad bit timing parameters:

    mALLEm_0-1750327556925.png

    You need to decrease as much as possible the Prescaler and increase as much as possible BS1 and BS2 while having a simple point at around 87%;

    Refer to this article: CAN (bxCAN) bit time configuration on STM32 MCUs

    This link can help you to calculate the timings parameters. You need to select:

    mALLEm_0-1750328006080.png

    Hope that helps.

     

    Dave001Author
    Explorer
    June 19, 2025

    YOU ARE A LEGEND!!!

     

    Thank you.... i was stuck on this for so long.

    Graduate II
    June 19, 2025

    You should try playing with the parameters , increase the sample points , use internal/ external loop back mode and see if the RxCallback Triggers, you can refer to https://kvaser.com/support/calculators/bit-timing-calculator/ this website for the CAN bus timing parameters , works well with the ST Boards and is easy to use, You will most likely get the Communication started.

    Dave001Author
    Explorer
    June 19, 2025

    Thank you for commenting, Much appreciated.

     

    Problem is resolved by mƎALLEm.