最新的GD32C103的v1.0.1版本库中的dev_can_baudrate_set()和dev_can_fd_baudrate_set()这两个函数,计算出来的波特率如下:
结果自己看吧,建议不要用这两个函数,避免踩坑。
尤其是常规CAN的波特率,BS1有7位,BS2有5位,这个函数把这些位数全部浪费掉了。
calc CAN baudrate...
baud=1000000, CAN_BT=0x00000013 SJW=1 BS1=1TQ BS2=1TQ PSC=19 66.7%
baud=900000, CAN_BT=0x00000015 SJW=1 BS1=1TQ BS2=1TQ PSC=21 66.7%
baud=800000, CAN_BT=0x00000018 SJW=1 BS1=1TQ BS2=1TQ PSC=24 66.7%
baud=666666, CAN_BT=0x0000001D SJW=1 BS1=1TQ BS2=1TQ PSC=29 66.7%
baud=600000, CAN_BT=0x00010018 SJW=1 BS1=2TQ BS2=1TQ PSC=24 75.0%
baud=500000, CAN_BT=0x00000027 SJW=1 BS1=1TQ BS2=1TQ PSC=39 66.7%
baud=400000, CAN_BT=0x00000031 SJW=1 BS1=1TQ BS2=1TQ PSC=49 66.7%
baud=300000, CAN_BT=0x00010031 SJW=1 BS1=2TQ BS2=1TQ PSC=49 75.0%
baud=250000, CAN_BT=0x0000004F SJW=1 BS1=1TQ BS2=1TQ PSC=79 66.7%
baud=200000, CAN_BT=0x00000063 SJW=1 BS1=1TQ BS2=1TQ PSC=99 66.7%
baud=150000, CAN_BT=0x00010063 SJW=1 BS1=2TQ BS2=1TQ PSC=99 75.0%
baud=125000, CAN_BT=0x0000009F SJW=1 BS1=1TQ BS2=1TQ PSC=159 66.7%
baud=100000, CAN_BT=0x000000C7 SJW=1 BS1=1TQ BS2=1TQ PSC=199 66.7%
baud=90000, CAN_BT=0x000000DD SJW=1 BS1=1TQ BS2=1TQ PSC=221 66.7%
baud=80000, CAN_BT=0x000000F9 SJW=1 BS1=1TQ BS2=1TQ PSC=249 66.7%
baud=60000, CAN_BT=0x000100F9 SJW=1 BS1=2TQ BS2=1TQ PSC=249 75.0%
baud=50000, CAN_BT=0x0000018F SJW=1 BS1=1TQ BS2=1TQ PSC=399 66.7%
baud=40000, CAN_BT=0x000001F3 SJW=1 BS1=1TQ BS2=1TQ PSC=499 66.7%
baud=30000, CAN_BT=0x000101F3 SJW=1 BS1=2TQ BS2=1TQ PSC=499 75.0%
baud=20000, CAN_BT=0x000003E7 SJW=1 BS1=1TQ BS2=1TQ PSC=999 66.7%
baud=10000, CAN_BT=0x000003CF SJW=1 BS1=1TQ BS2=1TQ PSC=975 66.7%
baud=5000, CAN_BT=0x0000039F SJW=1 BS1=1TQ BS2=1TQ PSC=927 66.7%
calc CANFD baudrate...
baud=1000000, CAN_DBT=0x004D0002 SJW=1 BS1=14TQ BS2=5TQ PSC=2 75.0%
baud=2000000, CAN_DBT=0x00390001 SJW=1 BS1=10TQ BS2=4TQ PSC=1 73.3%
baud=3000000, CAN_DBT=0x004D0000 SJW=1 BS1=14TQ BS2=5TQ PSC=0 75.0%
baud=4000000, CAN_DBT=0x00390000 SJW=1 BS1=10TQ BS2=4TQ PSC=0 73.3%
baud=5000000, CAN_DBT=0x00270000 SJW=1 BS1=8TQ BS2=3TQ PSC=0 75.0%
baud=6000000, CAN_DBT=0x00160000 SJW=1 BS1=7TQ BS2=2TQ PSC=0 80.0%
|