各位好,我用的是stm32f103r8t6,我设成奇校验时,设置如下
switch((unsigned char)(*(DataReg+LINE_SET)>>8))
{
case 0: //无奇偶校验
USART_InitStructure.USART_Parity =USART_Parity_No; //无奇偶校验
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//8位数据位
break;
case 1: //奇校验
USART_InitStructure.USART_Parity =USART_Parity_Odd;//奇校验
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
break;
case 2://偶校验
USART_InitStructure.USART_Parity =USART_Parity_Even; //偶校验
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
break;
default:break;
}
在PC端设为奇校验能通讯,奇怪的是设为偶校验竟然也能通讯,我在CPU设为偶校验时也一样,PC端奇偶校验都能通讯上,这是什么道理呀? |