Skip to main content
Associate II
April 11, 2024
Question

CAN Bus doesn't work in normal mode between two MCUs

  • April 11, 2024
  • 22 replies
  • 6877 views

Hello,
Hope you all doing well..!!

I am using two microcontrollers i.e., for transmitting data I have to use STM32F407VET6 and for receiving I have to use STM32F407VGT6 also I have to connect MCP2551 CAN Transceiver. I am transmitting data from one board and receiving data from another board through CAN Bus Protocol Communication

However, the data is not transmitted and received. I have properly checked the hardware connections and terminated the bus at both ends with 120-ohm resistors.

IDE: STM32CubeIDE

Which step should I follow for communication between boards?

Thank You in advance!!


This topic has been closed for replies.

22 replies

Tesla DeLorean
Guru
April 11, 2024

>>Which step should I follow for communication between boards?

The F407 hardware side should work.

Guess you'll want to start debugging things.

Check register settings and clocks. Perhaps inspect the error/status flags to better understand what IS happening.

You could test single nodes in Loop-back mode, also check the CAN-TX pin with a scope. Observe data and timing.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
mr_vineetAuthor
Associate II
April 11, 2024

I can already test the loopback mode with both boards separately and it works properly.

I am using breakpoints and status flags for debugging but I can't rectify the problems. and also I have crosschecked many times with the configuration and clock.


mƎALLEm
ST Technical Moderator
April 11, 2024

Also what is the clock source you set for the system clock? HSI or HSE?

Need to select HSE with an external crustal otherwise you risk you have some troubles in the communication.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
ST Technical Moderator
April 11, 2024

What about Rs pin voltage level? How did you connect that tranceiver's pin? this pin is to put the tranceiver in a stanby mode. So you can't send/receive anything on the bus.

So it should be at least tied it to the ground:

SofLit_0-1712863545784.png

Read Rs section in the datasheet.

 

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mr_vineetAuthor
Associate II
April 12, 2024

I have connected transreceiver like this. How can I connect Rs Pin to ground?

If you have any reference for connection video or code?

Andrew Neil
Super User
April 12, 2024

@mr_vineet wrote:

I have connected transceiver like this. How can I connect Rs Pin to ground?

 


So you're using some 3rd-party module?

Then you need to check the schematic of that module.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Karl Yamashita
Principal
April 17, 2024

The RS pin is already grounded through a 4.7k resistor. 

Show a diagram on how you've connected each of the pins on the CAN module to your STM32F407. Is this a custom board? Do the two STM32F407 have a ground reference between them or are they isolated from each other besides just the 2 CAN wires? 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
mƎALLEm
ST Technical Moderator
April 17, 2024

The RS pin is already grounded through a 4.7k resistor. 


According to the schematics? Do you have it?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mr_vineetAuthor
Associate II
April 26, 2024

I had to check with the logic analyser it's showing can_error.

mƎALLEm
ST Technical Moderator
April 26, 2024

can_error? How?

Could you please share the analyser CAN frames screenshots of CAN_TX of the transmitter and CAN_RX of the receiver?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.