13 UART相关¶
13.1 UART1不进入RX中断回调函数问题¶
根本原因:
1,UART FIFO has only one byte. If the system is busy, a byte length is about 10 bits, and at 115200 baud rate, it takes about 1us. If the FIFO is not cleared within 1us after receiving the interrupt, it will overflow;;
2,The USART1_IRQHandler interrupt can come in, but due to an error, there is no upper layer callback. The upper layer callback occurs only when data is received normally;。Since Uart1 is used to control audio Bluetooth and changed to Segger printing and system polling, it may cause RX interrupt not to be cleared in time;。
解决方案:
改成DMA RX中断。
rt_device_open(g_bt_uart, RT_DEVICE_FLAG_INT_RX);
改成
rt_device_open(g_bt_uart, RT_DEVICE_FLAG_DMA_RX);