在C51中是通过工作模式和数据位来进行设置的,在STM32中设置了校验位之后就老是收不到数据后来才知道需要把数据位设置成9位就可以了但是好像不区分odd和even但是和无校验是区分开的代码如下
switch (P)
{
case 0:
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
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;

}

    USART_Init(USART1, &USART_InitStructure); 
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_Cmd(USART1, ENABLE);