ST应用的问题:串口一直在用。不检测会导致一直中断要规避。
规避范例:
void USART1_IRQHandler(void) //串口1中断服务程序 { u8 Res; u8 DataCount= 0; if(USART_GetITStatus(USART1, USART_IT_PE) != RESET) { USART_ReceiveData(USART1); USART_ClearFlag(USART1,USART_FLAG_RXNE); } if(USART_GetITStatus(USART1, USART_IT_ORE) != RESET) { USART_ReceiveData(USART1); USART_ClearFlag(USART1,USART_IT_ORE); } if(USART_GetITStatus(USART1, USART_IT_FE) != RESET) { USART_ReceiveData(USART1); USART_ClearFlag(USART1,USART_IT_FE); } if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { Res = USART_ReceiveData(USART1); //读取接收到的数据 } }