cancel
Showing results for 
Search instead for 
Did you mean: 

Struggling with STM32L432 CAN Bus communication using MCP2551

Dave001
Associate II

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

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.

 

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

5 REPLIES 5
mƎALLEm
ST Employee

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.

 

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

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.

YOU ARE A LEGEND!!!

 

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

Thank you for commenting, Much appreciated.

 

Problem is resolved by mƎALLEm.

 

@mƎALLEm 

ST should make an online calculator like http://www.bittiming.can-wiki.info/ or kvaser.

The wiki has been my go to site forever since probably 2005, and with the CAN FD peripherals, I've been using Kvaser

I was told that if a devices starts to smoke, put the smoke back in. I guess I never got all the smoke because the device never worked afterwards.
Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.