STM32
直播中

张勇

7年用户 1420经验值
私信 关注
[问答]

STM32串口如何使用偶校验时初始化?

STM32串口如何使用偶校验时初始化?

回帖(1)

陈鹏

2021-12-10 11:10:02
/*   USART 1 配置
使用奇数校验或者偶数校验时,需要把数据长度定位9bit!
*/
   USART_InitStructure.USART_BaudRate =115200;
   
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);
举报

更多回帖

发帖
×
20
完善资料,
赚取积分