最近调试GD32 串口中断发现一个问题,系统默认打开了USART_FLAG_ORE中断,所以先关掉,不然会一直响应和执行该中断函数,见如下代码:
void USART1_IRQHandler(void)
{
//由于打开USART_INT_RBNE中断后,
//系统默认打开了USART_FLAG_ORE中断,所以先关掉,不然会一直响应和执行该中断函数(USART1_IRQHandler)
if(USART_GetIntBitState(USART1, USART_FLAG_ORE) == RESET)
{
USART_ClearBitState(USART1,USART_FLAG_ORE);
//USART_DataReceive(USART1);
}
if(USART_GetIntBitState( USART1, USART_INT_RBNE) != RESET)
{
USART_ClearBitState(USART1,USART_FLAG_ORE);
/* Read one byte from the receive data register */
RxBuffer[RxCount++] = (USART_DataReceive(USART1));
|