系统时钟和PCLK2皆为72M,调用固件库设置USART1波特率为115.2K,
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); //使能USART1时钟
USART_Init(USART1, &USART_InitStructure);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_ITConfig(USART1, USART_IT_TXE, DISABLE); //禁止USART1的发送缓冲寄存器空中断
USART_Cmd(USART1, ENABLE);
但是,实际测试下来还不到100K,查看USART1->BRR为0x341,对照手册525页在72M情况下115.2K波特率对应USART1->BRR为0x271,如果设置为0x271,那么实际测试结果就是115.2K;这是为什么?设置其他波特率结果页不对。期待指点,谢谢! |