Skip to main content
Associate III
November 7, 2023
Solved

stm32 canbus loopback working but normal mode Bit timing Error

  • November 7, 2023
  • 7 replies
  • 3684 views

hello I today trying can communication loopback mode working but normal mode bit LEC register showing timing error.

This topic has been closed for replies.
Best answer by mƎALLEm

Indeed.. CAN is not UART nor SPI to test it in standalone. In Normal mode you should have at least two nodes on the bus for acknowledgement mechanism and listening of the bus. Otherwise use loopback mode for standalone config.

 

7 replies

Tesla DeLorean
Guru
November 7, 2023
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
mƎALLEm
ST Technical Moderator
November 7, 2023

Hello,

- What kind of HW you are using?

- Are you using a CAN transceiver in Normal mode? 

- Do you have another CAN node on the bus?

- Are you using HSE or HSI as system clock source?

Also, the values of BS1 and BS2 are not good to me. Please increase BS1 and BS2 as much as possible and decrease the prescaler as much as possible to match your 500kb/s knowing that BS1 must be between 70% and 80% of the bit time.

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
November 7, 2023

@Tesla DeLorean : thank you for pointing this thread out.

@Sergen , please don't duplicate a thread on the community.

Now seeing the previous one. I don't have the visibility of all your environment but I have to add:

- Check RS pin of SN65HVD230 transceiver: connect it to GND.

- In normal mode you have to have at least two nodes on the bus.

- The two STM32 (nodes) have to be clocked with HSE with an external crystal not with HSI. The two nodes have to have the exact bitrate.

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
SergenAuthor
Associate III
November 7, 2023

I checked the RS pin, there was no problem, then I solved the bit timing problem by editing the time segment quanta and prescaler values, but the only thing I'm curious about is that when my device is not connected to any node, something like this picture appears as a frame from my CAN TX output.

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
November 7, 2023

Indeed.. CAN is not UART nor SPI to test it in standalone. In Normal mode you should have at least two nodes on the bus for acknowledgement mechanism and listening of the bus. Otherwise use loopback mode for standalone config.

 

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

Hi @Sergen @mƎALLEm @Tesla DeLorean after using two nodes also i am getting the same waveform.