USART 1 配置
如果需要使用奇数校验或者偶数校验,需要把数据长度定位9bit
*/
USART_InitStructure.USART_BaudRate = COM1BAUD;
USART_InitStructure.USART_WordLength =USART_WordLength_9b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_Even;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
STM_EVAL_COMInit(COM1, &USART_InitStructure);
/*使能USART1的接收中断*/
USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);
看了数据手册,还是不太明白为啥要把数据长度定位9,
难道 奇偶校验位也是数据的一部分,无就是 0 +8 = 8,
而有校验就是1+8 = 9
或许只能这样理解了。