STM32 CAN baud rate setting and sample point setting

Source: Internet
Author: User

One, can baud rate

STM32 bit time definition:

Synchronization segment (SYNC_SEG): The change in the expected bit usually occurs within that time period. Its value is fixed to 1
Time unit (1 x tcan).
Time period 1 (BS1): Defines the location of the sample point. It contains the PROP_SEG in the Can standard and
Phase_seg1. The value can be programmed to 1 to 16 time units, but can also be automatically extended
To compensate for the forward drift of the phase caused by the frequency difference of different nodes in the network.
Time period 2 (BS2): Defines the location of the send point. It stands for the can standard.
PHASE_SEG2. The value can be programmed to 1 to 8 time units, but can also be automatically shortened
To compensate for the negative drift of the phase

BRP[9:0]: Baud rate divider

PCLK1 = 36M

bps = 36m/(brp[9:0]* (BS1+BS2+SYNC_SEG))

Where sync_seg is fixed to 1 time units so bps = 36m/(brp[9:0]* (bs1+bs2+1)), it's okay to pay attention to sync jump width sjw, although he has been set to 1.

Second, can sampling point

The sampling point is between time period 1 and time period 2. According to the CIA recommended sampling points, preferably set in 85%~90%.

Check on the Internet a lot, basically is so calculated (bs1+1)/(1+BS1+BS2), the result is BS1 is larger and BS2 relatively small is basically 1.

STM32 CAN baud rate setting and sample point setting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.