cancel
Showing results for 
Search instead for 
Did you mean: 

CAN bus doesn't work in loopback mode

Mr4
Associate III

 

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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

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 on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

12 REPLIES 12
Vidicon
Associate II

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

Mr4
Associate III

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.

 

SofLit
ST Employee

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 on "Accept as Solution" on the reply which solved your issue or answered your question.
Mr4
Associate III

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

 

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 on "Accept as Solution" on the reply which solved your issue or answered your question.

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.

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

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?

 

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.

 

 

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.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..