stm32f407中can波特率的设置问题
对于stm32 can的时钟为fpclk = 30m,我所期望的波特率为baud = 500k。那么根据公式 1/baud= (BRP +1)(BS1+BS2+3)*fpclk,算出(BRP +1)(BS1+BS2+3) = 60。那么取BRP = 2,得到BS1+BS2 = 17。然后设置最佳采样点 令 (1+1+BS1)/(1+1+1+BS1+BS2) = 87.5%。最后得出 BRP = 2 , BS1 = 15,BS2 = 2.
设置如下:
CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1=CAN_BS1_16tq;
CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;
CAN_InitStructure.CAN_Prescaler=3;
CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1=CAN_BS1_8tq;
CAN_InitStructure.CAN_BS2=CAN_BS2_6tq;
CAN_InitStructure.CAN_Prescaler=14;