如题所示,我知道如果使用默认的100kbps,就发送 ”00 00 00 00“。假设我想使用别的波特率,我应该发送多少。我有看到BootROM当中的相关代码
//
// CAN bit timing settings for running CAN at 100kbps with a 20MHz crystal
//
#define CAN_CALC_BITRATE 100000U
#define CAN_CALC_CANCLK 20000000U
#define CAN_CALC_BITTIME 25U
#define CAN_CALC_TSEG1 ((CAN_CALC_PHSEG1 + CAN_CALC_TPROP) - 1U)
#define CAN_CALC_TSEG2 (CAN_CALC_PHSEG2 - 1U)
#define CAN_CALC_TSJW (((CAN_CALC_PHSEG2 > 4U) ? 4U : CAN_CALC_PHSEG2) - 1U)
#define CAN_CALC_BRPEREG ((CAN_CALC_BRP - 1U) / 64U)
#define CAN_CALC_BRPREG ((CAN_CALC_BRP - 1U) % 64U)
//
//The final result -- a value to write to the bit timing register
//
#define CAN_CALC_BTRREG (((uint32_t)CAN_CALC_BRPEREG<<16U) | ((uint32_t)CAN_CALC_TSEG2<<12U) | ((uint32_t)CAN_CALC_TSEG1<<8U) | (CAN_CALC_TSJW<<6U) | CAN_CALC_BRPREG) // 0<<16 | 0x1110 << 12 | 0x1111 << 8 | 0x100 << 6 | 0x111 = 1110 1111 0100 0111
但是
CAN_CALC_BITTIME是固定的25