Skip to main content
Wilson
Associate
February 27, 2020
Question

STM32F091RC=please tell me detailed procedure for can bit time calculation,to find value of these hcan.Instance = hcan.Init.Prescaler = hcan.Init.SyncJumpWidth = hcan.Init.TimeSeg1 = hcan.Init.TimeSeg2 =

  • February 27, 2020
  • 6 replies
  • 2124 views

..

This topic has been closed for replies.

6 replies

Tesla DeLorean
Guru
February 27, 2020

CAN BIT RATE = (APBCLOCK / PRESCALER) / (SJW + TS1 + TS2)

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Wilson
WilsonAuthor
Associate
February 27, 2020

can u explain each terms?

Tesla DeLorean
Guru
February 27, 2020

I'm sure the definitions are in the Reference Manual

SJW, TS1 and TS2 are the bit timing quanta, they have ranges as described in the manual. You sum these together to understand how many clock ticks you will need.

The CAN peripheral is clocked by the APB (Peripheral Bus) to which it is attached. Presumably 48 or 24 MHz depending on the dividers you have selected.

48,000,000 / 50,000 = 960

960 / 60 = 16

If you set the Prescaler to 60, the sum of SJW+TS1+TS2 needs to be 16, find a combination that fits.. Say 1, 7 and 8 ?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Wilson
WilsonAuthor
Associate
February 27, 2020

at 48 mhz clock frequency,baudrate=50 kbps

Wilson
WilsonAuthor
Associate
February 28, 2020

ok

Wilson
WilsonAuthor
Associate
February 28, 2020

how did you choose 1,7,8?

sjw=1,ts1=7,ts2=8?

turboscrew
Senior III
February 28, 2020
waclawek.jan
Super User
February 28, 2020

[OT] It's nice how in explanation of a ST's chip you refer to a document to be found at NXP, which refers to "Motorola CAN" in a Freescale chip... ;)

(Sorry for the OT, I couldn't resist. No, no need to explain.)

JW

turboscrew
Senior III
February 29, 2020

BTW, the time quanta settings look different from the standard, because the standard says thet the SYNC_SEG is always 1. It doesn't need to be configured. Alsi in STM32 bxCAN, the TimeSeg1 contains the sum of both PROP_SEG and PHASE_SEG1.

And no, there is no "Motorola CAN", "Intel CAN" or "STMicro CAN". Just CAN.