CAN bus doesn't work in loopback mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 2:29 AM - last edited on ‎2024-02-14 1:41 AM by mƎALLEm
Hi I followed this yt-guide for CAN-bus https://www.youtube.com/watch?v=JfWlIY0zAIc&t=918s
I'm however using a different type of nucleo board (L433RC-P in my case and F103C8tx in the video) and a different type of CAN-transceiver (MCP2561T-E/SN vs MCP2551 in the video). My board uses a different type of can periphery (can1 vs can). My solution to this difference was to just change all of the code where he writes can to can1. Yet checking with an oscilloscope, I don't seem to be sending any CAN signal.
relevant code:
Setup:
Solved! Go to Solution.
- Labels:
-
CAN
-
STM32L4 series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-14 1:21 AM
Hello,
Attached a project using NUCLEO-L433RC-P on which CAN1 is configured in loopback mode.
Details:
- System clock @80MHz
- System clock: HSI
- CAN1 bitrate @1Mb/s
But be careful, here, HSI has been used as system clock because loopback mode is used. So the timings / jitter are similar on transmit and receive. But when you switch to Normal mode to communicate with another board you need to use HSE with a crystal as source of clock.
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 2:51 AM
When I had similar problems, I needed a pull-up on the rx signal. You can enable the internal pullup.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 3:19 AM
Unfortunately it doesnt seem to be the problem in my case. My problem seems to be deeper as when i resume the code I lose the access to seeing the values of TxHeader and RxHeader.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 3:24 AM - edited ‎2024-02-12 3:25 AM
Hello,
No need for a transceiver for the loopback mode and configure the internal pull-up resistor on Rx pin.
Also I think you have another problem on filters: SlaveStartFilterBank = 0. Please change this value to 14.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 5:03 AM
"No need for a transceiver for the loopback mode and configure the internal pull-up resistor on Rx pin." Are you saying that i shouldn't have the rx-pin or should I have it? Also how do i not need a transceiver for loopback mode? Can i just connect the rx and tx pint to the osciallator?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 5:08 AM - edited ‎2024-02-12 5:11 AM
Hello,
In loopback mode Tx and Rx pins are automatically tied together internally by HW:
Please refer to the reference manual RM0394.
"Can i just connect the rx and tx pint to the osciallator?"
Which oscillator and why??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 5:50 AM
Can i just connect the rx and tx pint to the osciallator?
"osciallator": Do you mean oscilloscope? If yes. Indeed you can. Put the oscilloscope probe on Tx pin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 5:53 AM
Ok yeah I understand now why a transceiver isn't needed. My point of using a oscillator was to check if a CAN-signal is being sent out (since when I click the resume button I lose the possibility of looking at the values in TxHeader and RxHeader. But I guess since I can't look into them it means a signal isn't sent out. How should i do the hardware part then? Just connect the rx-pin to the tx-pin?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 5:58 AM - edited ‎2024-02-12 5:58 AM
Look..
As I said, No need to connect Rx and Tx pins in loopback mode as are already connected together internally in this mode. Look at the figure I shared previously.
If you need to check the CAN frames output using an oscilloscope, the answer is: yes you can. Probe on Tx pin.
Hope it's clear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 6:01 AM
You can look at the TX pin whilst in Loop-Back mode, the Rx pin will be internally disconnected as this is looped-back instead.
The baud rate via the prescaler and segment timings will be non-critical as they will implicitly match in loop-back.
Up vote any posts that you find helpful, it shows what's working..
