CAN Bus doesn't work in normal mode between two MCUs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 11:28 AM - last edited on ‎2024-04-12 1:08 AM by mƎALLEm
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!!
- Labels:
-
CAN
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 11:42 AM
>>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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 11:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 12:25 PM - edited ‎2024-04-11 1:37 PM
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:
Read Rs section in the datasheet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 12:51 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 11:54 PM
I have connected transreceiver like this. How can I connect Rs Pin to ground?
If you have any reference for connection video or code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 11:55 PM
Yes, I am setting clock to HSE with Crystal oscillator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 12:24 AM
Hello,
It seems they are a purchased modules. But anyway you need to:
- Check the Rs pin connection continuity: Pin 8 connected to the ground?
- Are you sure about the correct GPIOs? are the GPIO pins connected to the transceiver are the ones configured in your code (CAN_TX/CAN_RX alternate functions)?
- Are you sure about the correct connections CAN_TX/CAN_RX with the transceivers?
- Check if there are some activity on CAN_TX/CAN_RX pins with an oscilloscope or a logic analyzer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 2:17 AM
It needs to connect Rs to Ground for both the transreceiver??
And All the other point I have checked properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-12 2:40 AM
@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.
