Skip to main content
martonmiklos
Senior
September 1, 2026
Solved

Ocassionally wrong CAN bit rate with STM32G0B1CBT3

  • September 1, 2026
  • 20 replies
  • 195 views

I am trying to use a STM32G0B1CBT3 for standard (non-FD CAN communication).

The device is running from a 8 MHz HSE oscillator.

This is the clock topology I am using:

 

As you see the CCS is disabled and the CAN clock and the system clock is running on 64 MHz.

In some cases my CAN frames are transmitted with a bitrate faster than expected:

The edges some times falling totally to the sampling points, the calculated bit times are lower than 4 us:
 


Putting the correct and incorrect frames the difference is more visible:

 

I have tried to route the HSE to the MCO to see how stable is it, but I have not detected any deviation which could cause this deviation.

I also tried to run an overnight test to send a CAN frame continuously and capture the waveform and calculate back the bit times are quite identical:

 

Any hints, ideas would be welcome!

Best answer by martonmiklos

Well, we traveled to the customer this week to see the issue and likely managed to solve it. 

Our first suspection was some PLL jitter caused by some ringing on the power rails during arbitration.

Decreased the 2x120 Ohm pulls to reduce the current changes induced by the transceivers, but it had no effect on the issue.

We isolated the 5V supply of the CAN transceivers from the 3V3 feeding the MCU and it did not helped.

Then we monitored the PLL output fed to the CAN module on the MCO output and we did not seen any jitter so we abandoned the idea being clocking related. 

We made some scripting with the Saleae logic to see if the first node transmitting during arbitration ever fails to met the exact 4 us and no, it was always 4 us like this:

My instinct said if the shortened durations would be PLL glitch related then the first sensor waveform would be the most affected. 

So seeing this an idea stuck into my mind: there is an open hardware design featuring the same MCU (in different package):

https://linux-automation.com/en/products/candlelight-fd.html

whi
ch uses the MCU as an USB to CAN converter.-

The firmware is also open source, but it turned out that the CAN bit timing parameters are calculated by the driver (only CAN clock and limitations are being reported upwards). Thankfully the Linux driver is open source and with some code following it turned out that the configuration for the same classic 250 kbaud CAN is slightly different than ours: they use 160 TQ instead of the 8 what we used.

Then guess what: increasing the TQ count to 160 solving the issue.

By reading some more general documentation on the CAN clock syncronisation it is likely that the compensations are limited to equal times of time quantas which was resulted too little resolution on compensation in our case:

https://kvaser.com/lesson/can-bit-timing/

Many thanks for the answers, especially to Jan who’s comment on the arbitration helped us to move to the correct direction.

20 replies

Ozone
Principal
September 1, 2026

While I don’t know the G0 MCU in detail, but I would recommend to configure / enable MCO, and measure this output the same way as the CAN signal.
 

martonmiklos
Senior
September 1, 2026

This was my very first idea as I have written:

I have tried to route the HSE to the MCU to see how stable is it, but I have not detected any deviation which could cause this deviation.

 

 

mƎALLEm
ST Technical Moderator
September 1, 2026

Hello,

Try to capture the bit times in parallel (to the logic analyzer) with an oscilloscope. Do you notice the same bit time difference?

I may suspect an issue with the logic analyzer edge detection.

Is CAN is in Loopback or Normal mode? if in Normal mode, are there any error detected by the CAN nodes?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
waclawek.jan
Super User
September 1, 2026

Due to the resynchronization mechanism of CAN, if several parties start to transmit simultaneously, you can’t determine which of them is deviant and why, purely by observing the bus. You’d need to observe all participant’s Tx, simultaneously, too.

JW

waclawek.jan
Super User
September 11, 2026

> Now it comes the next question: how to debug/fix this arbitration issue. 

And what is the issue, exactly? Apart from what you see at the bus, what is it what made you to investigate this at all, what are the symptoms and how are they different from the expected?

JW

martonmiklos
martonmiklosAuthorBest answer
Senior
September 18, 2026

Well, we traveled to the customer this week to see the issue and likely managed to solve it. 

Our first suspection was some PLL jitter caused by some ringing on the power rails during arbitration.

Decreased the 2x120 Ohm pulls to reduce the current changes induced by the transceivers, but it had no effect on the issue.

We isolated the 5V supply of the CAN transceivers from the 3V3 feeding the MCU and it did not helped.

Then we monitored the PLL output fed to the CAN module on the MCO output and we did not seen any jitter so we abandoned the idea being clocking related. 

We made some scripting with the Saleae logic to see if the first node transmitting during arbitration ever fails to met the exact 4 us and no, it was always 4 us like this:

My instinct said if the shortened durations would be PLL glitch related then the first sensor waveform would be the most affected. 

So seeing this an idea stuck into my mind: there is an open hardware design featuring the same MCU (in different package):

https://linux-automation.com/en/products/candlelight-fd.html

whi
ch uses the MCU as an USB to CAN converter.-

The firmware is also open source, but it turned out that the CAN bit timing parameters are calculated by the driver (only CAN clock and limitations are being reported upwards). Thankfully the Linux driver is open source and with some code following it turned out that the configuration for the same classic 250 kbaud CAN is slightly different than ours: they use 160 TQ instead of the 8 what we used.

Then guess what: increasing the TQ count to 160 solving the issue.

By reading some more general documentation on the CAN clock syncronisation it is likely that the compensations are limited to equal times of time quantas which was resulted too little resolution on compensation in our case:

https://kvaser.com/lesson/can-bit-timing/

Many thanks for the answers, especially to Jan who’s comment on the arbitration helped us to move to the correct direction.