Skip to main content
Associate III
February 12, 2024
Solved

CAN bus doesn't work in loopback mode

  • February 12, 2024
  • 3 replies
  • 7018 views

 

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:

Mr4_0-1707733361123.png

Mr4_1-1707733423132.png

Mr4_2-1707733462396.png

Setup:

Mr4_3-1707733661815.png

Mr4_4-1707733718880.png

 

 

 

Best answer by mƎALLEm

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.

 

3 replies

Vidicon
Associate
February 12, 2024

When I had similar problems, I needed a pull-up on the rx signal. You can enable the internal pullup.

Mr4Author
Associate III
February 12, 2024

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.

 

mƎALLEm
Technical Moderator
February 12, 2024

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.

 

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

"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?

 

mƎALLEm
Technical Moderator
February 12, 2024

Hello,

In loopback mode Tx and Rx pins are automatically tied together internally by HW:

SofLit_0-1707743252523.png

Please refer to the reference manual RM0394.

"Can i just connect the rx and tx pint to the osciallator?"

Which oscillator and why??

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
mƎALLEmAnswer
Technical Moderator
February 14, 2024

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.

 

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