程序 void UART0_IRQHandler (void) { #if 1 UART_ITConfig(UART0,UART_IT_TimeOutIdle, ENABLE);
if(UART_FlagStatus(UART0,UART_Flag_RxBufFull)==1) { UART0->SR & 0xfffe; if((Uart0_rev_buff[counter++]=(u8)UART0->RxBUFR)!='%' && i!= 2 ) { i=0; counter = 0; UART_ByteSend(UART0,'a' ); UART_ITConfig(UART0,UART_IT_TimeOutIdle, DISABLE); }
else{ i++; if(i>2) { i=2; } if(Uart0_rev_buff[counter]=='!'&& j!=2) { GPIO_WordWrite(GPIO4, ~(GPIO_WordRead(GPIO4))); j++; } if(j==2) { i=0; j=0; UART_ITConfig(UART0,UART_IT_TimeOutIdle, DISABLE); // UART_ITConfig(UART0,UART_IT_RxBufFull, DISABLE);
//返回接受的字符串***********************************8
for(k=0;k<counter;k++) { while ((UART0->SR & UART_Flag_TxEmpty) != UART_Flag_TxEmpty); UART_ByteSend(UART0, Uart0_rev_buff[k] ); } while ((UART0->SR & UART_Flag_TxEmpty) != UART_Flag_TxEmpty); counter=0; // UART_FifoReset (UART0 , UART_RxFIFO); // UART_ITConfig(UART0,UART_IT_RxBufFull, DISABLE); //UART_ITConfig(UART0,UART_IT_RxBufFull, ENABLE); } } } else if(UART_FlagStatus(UART0,UART_IT_TimeOutIdle)==1) { UART_SetTimeOutValue(UART0, 0xff); time++; UART0->SR & 0xff7f; if(time==0xff) { UART_ITConfig(UART0,UART_IT_TimeOutIdle, DISABLE); UART_ByteSend(UART0,'b' ); time=0; } } #endif
} 识别特定的帧 当发送%%sdfdssdfafdsfsfs!!时 能顺利接收 但是返回接受的字符串时 后面总是带个a 就是%%sdfdssdfafdsfsfs!!a 不知道为什么我发送完后 好像是什么又触动了中断 才返回的a |