附上部份代码.
USART_InitTypeDef
USART_InitStructure;
RCC_Configuration();
GPIO_Configuration();
NVIC_Configuration();
LcdShow_Init();
//StepperMotorInit();
// GPIO_Write(GPIOC,GPIO_ReadOutputData(GPIOC)|LED_var);
/* USART2 配置*/
USART_InitStructure.USART_BaudRate
=
9600;
USART_InitStructure.USART_WordLength
=
USART_WordLength_8b;//8位数据位
USART_InitStructure.USART_StopBits
=
USART_StopBits_1;
//1个停止位
USART_InitStructure.USART_Parity
=
USART_Parity_Even;//USART_Parity_No 偶校验
USART_InitStructure.USART_HardwareFlowControl
=
USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode
=
USART_Mode_Rx
|
USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
//使能USART2中断
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
/* Enable the USART2 */
USART_Cmd(USART2, ENABLE); |