0
\$\begingroup\$

I am struggling with a bit timing of CAN bus. Perhaps, someone will be able to explain me, how it actually works.

There are two configurations of the CAN controller inside STM32 (bxCAN). The desired configuration is 250 kbps and sample point at 80%. SJW is configured as 1 time quanta.

First configuration (failing):
CLK = 1.25 MHz
5 time quanta in total
SYNC_SEG 800 ns
TS1 2400 ns
TS2 800 ns
Baud rate = 1/(TS1 + TS2 + SYNC_SEG) = 250 000
NominalBitTime = tq + tBS1 + tBS2 = 800 + 2400 + 800 = 4 000 ns

Second configuration (working):
CLK = 2.5 MHz
10 time quanta in total
SYNC_SEG 400 ns
TS1 2800 ns
TS2 800 ns
Baud rate = 1/(TS1 + TS2 + SYNC_SEG) = 250 000
NominalBitTime = tq + tBS1 + tBS2 = 800 + 2400 + 800 = 4 000 ns

The first configuration with 5 time quanta generate a lot of error frames, once STM32F7 is connected to the CAN network, whereas the second one with 10 time quanta seems to eliminate these error frames.

Is there a minimal number of time quanta, that must be kept? There is no such number defined in the documentation of the bxCAN IP. Probably re-synchronization is causing the frame errors. Could someone explain in detail, what is happening and why these errors appear, when the configured baud rate and sample points are identical for both scenarios? I really would like to understand.

Thanks.

\$\endgroup\$
  • \$\begingroup\$ The CAN spec says the total number of time quanta in a bit time has to be programmable at least from 8 to 25. Maybe the STM32 needs a minimum of 8, so your 5 quanta version doesn't work. I found this page which has a link to The Configuration of the CAN Bit Timing. \$\endgroup\$ – Martin Apr 29 at 15:36
  • \$\begingroup\$ Hello Martin, I also ran across this sentence from spec before:"The total number of TIME QUANTA in a bit time has to be programmable at least from 8 to 25." I do not know, how to understand it. For me it does not explicitly says that the minimal number of time quanta is 8. There isn't stated anywhere in ST documentation that the controller needs at least 8 time quanta. Furthermore, in peripheral registers it is possible to configure the total number from 5. \$\endgroup\$ – Jaroslav Bečka Apr 30 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.