Home > other >  MCU application into the pit record - AT32 CAN baud rate calculation
MCU application into the pit record - AT32 CAN baud rate calculation

Time:12-02

Recently discovered in research AT32F403A CAN, CAN baud rate formula calculation results is always wrong, again, spend a little bit of time to study summarized concrete results are as follows:
1. The questions
Introduction on the RM algorithm below

After simplifying the baud rate formula is: Boudrate=Fpclk/((BRP [9:0] + 1) (3 + BS1 [3-0] + BS2 [2-0]))
But actually found that when using BSP library CAN_BS1 structure configuration, CAN_BS2 and CAN_Prescaler configuration directly in with calculated the baud rate of the clock never
2. The problem why
Further study of structure configuration and register values after relationship, found
BRP. [9:0] for BSP code CAN_InitStructure CAN_Prescaler value minus 1;
BS1 [3-0] for BSP code CAN_InitStructure. CAN_BS1 value minus 1;
BS2. [2-0] for BSP code CAN_InitStructure CAN_BS2 value minus 1,
So from the perspective of BSP library functions, baud rate formula should be: Boudrate=Fpclk/((CAN_Prescaler) (1 + + CAN_BS2 CAN_BS1))
Before and I also have always been in accordance with the Boudrate=Fpclk/((1 + CAN_Prescaler) + + CAN_BS2 CAN_BS1) (3) the formula to calculate, so inevitable error
3. The actual authentication
When setting
SYSCLK=192 m
APB1CLK=24 m
CAN_InitStructure. CAN_BS1=CAN_BS1_8tq;
CAN_InitStructure. CAN_BS2=CAN_BS2_3tq;
CAN_InitStructure. CAN_Prescaler=2;
According to the calculation method can calculate the Boudrate=24 m/((2) (1 + 3 + 8))=1000 k, and the measured is 1000 k
4. Summarize
A problem is actually quite simple, the Debug to see registers configuration values to know the reason, but because is the new design of the hardware, so the debugging has been key in doubt my hardware circuit, neglect, no flash,,,,
  • Related