初始化串口为9600,n,8,1 并发送数据0xaa,电脑端接收到的数据为0x80 或0xf8,以下代码
CLK_PeripheralClockConfig (CLK_Peripheral_USART1,ENABLE);//开启USART时钟
USART_Init(USART1,9600,USART_WordLength_8b,USART_StopBits_1,USART_Parity_No,(USART_Mode_TypeDef)(USART_Mode_Tx| USART_Mode_Rx));//设置USART参数9600,8N1,接收/发送
USART_ITConfig (USART1,USART_IT_RXNE,ENABLE);//使能接收中断
USART_Cmd (USART1,ENABLE);//使能USART
CLK_PeripheralClockConfig (CLK_Peripheral_USART1,ENABLE);//开启USART时钟
USART_Init(USART1,9600,USART_WordLength_8b,USART_StopBits_1,USART_Parity_No,(USART_Mode_TypeDef)(USART_Mode_Tx| USART_Mode_Rx));//设置USART参数9600,8N1,接收/发送
USART_ITConfig (USART1,USART_IT_RXNE,ENABLE);//使能接收中断
USART_Cmd (USART1,ENABLE);//使能USART
USART1_SendChar(0XAA);
Delay(1000);
|