本帖最后由 Jerry 于 2019-12-25 09:34 编辑
To calculate the BaudRate, you need to know the CAN controller's clock frequency. Here are the clock frequencies of some devices by STM32 Systemtechnik which allow programming of the BaudRate .
STM32 Manual:
Figure 1
Refer to above Figure 1
NomanalBitTime = ((BRP+1) * (tPCLK) * (1+(TS1+1)+(TS2+1)))
tPCLK = 1/APB_CLOCK = 1/36M
BaudRate = 1/NomanalBitTime
BaudRate = 1/ ((BRP+1) * (tPCLK) * (1+(TS1+1)+(TS2+1)))
BaudRate = 1/((BRP+1) * (1/36M) * (1+(TS1+1)+(TS2+1)))
BaudRate = 36M/ ((BRP+1) * (1+(TS1+1)+(TS2+1)))
Ginkgo Api Manual:
BaudRate is affected by three parameters(CAN_BRP , CAN_BS1 , CAN_BS2 CAN).
BaudRate = 36M/((CAN_BRP) * (1+CAN_BS1+CAN_BS2)).
For example, CAN_BRP = 6, CAN_BS1 = 3,CAN_BS2 = 2
BaudRate = 36M/(6 * (1+3+2)) = 1Mbps.
Refer to STM32 Manual:
Figure 2
Refer to Figure 2:
CAN_SJW = (SJW[1:0] + 1) (SJW[1:0] = 0)
Ginkgo Api Manual:
BaudRate set up table:
Summary:
STM32 : BaudRate = 36M/((BRP+1) * (1+(TS1+1)+(TS2+1)))
Gingko : BaudRate = 36M/((CAN_BRP) * (1+CAN_BS1+CAN_BS2))
Version: 1.0
Date: 12/24/2019
Author: Jerry
|