初学STM32 CAN,发现同一个波特率(1M)可以有不同的设置办法:
哪一个是最优的设置呢?
const struct {
u8 SJW;
u8 BS1;
u8 BS2;
u8 PreScale;
} CAN_InitTab[6]= { //CLK=36MHz
CAN_SJW_1tq, CAN_BS1_3tq , CAN_BS2_2tq, 6, // 1M 36/6/6 =1M (1+3 )/(1+3+2 )=0.66
CAN_SJW_1tq, CAN_BS1_5tq , CAN_BS2_3tq, 4, // 1M 36/4/9 =1M (1+5 )/(1+5+3 )=0.66
CAN_SJW_1tq, CAN_BS1_6tq , CAN_BS2_2tq, 4, // 1M 36/4/9 =1M (1+6 )/(1+6+2 )=0.77
CAN_SJW_1tq, CAN_BS1_8tq , CAN_BS2_3tq, 3, // 1M 36/3/12=1M (1+ 8)/(1+8+3 )=0.75
CAN_SJW_1tq, CAN_BS1_12tq , CAN_BS2_5tq, 2, // 1M 36/2/18=1M (1+12)/(1+12+5)=0.72
CAN_SJW_1tq, CAN_BS1_13tq , CAN_BS2_4tq, 2, // 1M 36/2/18=1M (1+13)/(1+13+4)=0.77
} |