void USART1_Init(void) {
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_InitStructure.USART_Clock = USART_Clock_Disable; USART_InitStructure.USART_CPOL = USART_CPOL_Low; USART_InitStructure.USART_CPHA = USART_CPHA_2Edge; USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
/* Configure the USART1 */ USART_Init(USART1, &USART_InitStructure);
/* Enable the USART Transmoit interrupt: this interrupt is generated when the USART1 transmit data register is empty */ USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
/* Enable the USART Receive interrupt: this interrupt is generated when the USART1 receive data register is not empty */ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //中断方式接收
/* Enable USART1 */ USART_Cmd(USART1, ENABLE); }
中断方式操作串口,为什么要把收中断disable?我尝试把它enable,结果设备初始化不成功,哪位大侠给解释下
|