今天遇到一问题,在USART中使用库提供的flag清除函数,是清除不了的,搞得中断老跳不出,弄了好久.如下:
void USART1_IRQHandler(void) { if(USART_GetITStatus(USART1, USART_IT_IDLE)!=RESET) { //USART_ClearFlag(USART1, USART_FLAG_IDLE); 清除不了USART_FLAG_IDL Rxtmp=USART1->SR; //先读SR,然后读DR才能清除 Rxtmp=USART1->DR; USART_ClearITPendingBit(USART1, USART_IT_IDLE); ... } }
"This bit is set by hardware when an Idle Line is detected. An interrupt is generated if the IDLEIE=1 in the USART_CR1 register. It is cleared by a software sequence (an read to the USART_SR register followed by a read to the USART_DR register). 0: No Idle Line is detected 1: Idle Line is detected" 在USART中有关的flag几乎都是这样的,USART_GetITStatus()函数毫无用处,反而产生误导. |