voidUSART1_IRQHandler(void)//串口1中断服务程序{
u8 Res;if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)//接收中断(接收到的数据必须是0x0d 0x0a结尾){
Res=USART_ReceiveData(USART1);//读取接收到的数据}if(USART_GetITStatus(USART1, USART_IT_TXE) !=RESET)//发送中断
{if(BuffCnt--)
{
USART_SendData(USART1,*dat);//发送数据
dat++;
}else{//发送字节结束USART_ClearITPendingBit(USART1,USART_IT_TXE);
USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
USART_ITConfig(USART1, USART_IT_TC, ENABLE);
}
}//发送完成if(USART_GetITStatus(USART1, USART_IT_TC) !=RESET)
{
USART_ClearITPendingBit(USART1,USART_IT_TC);
USART_ITConfig(USART1, USART_IT_TC, DISABLE);
}
}
|