UART Overrun Error | Cypress Semiconductor
Support & Community
UART Overrun Error
What is meant by Overrun error in UART and what considerations should be taken to overcome it?
Overrun error occurs when another byte of data arrives even before the previous byte has not been read from the UART's receive buffer. This is mainly due to time taken by CPU to service the UART interrupt in order to remove characters from receive buffer. If the CPU does not service the UART interrupt quick enough and does not read the received byte before the next arrives, then the buffer becomes full and an Overrun error occurs. Below are some tips to avoid overrun errors.
1. Run the CPU at the maximum possible speed. This will speed up the execution of the UART interrupt (and any other interrupt too).
2. Keep the UART ISR efficient and as short as possible. For example the ISR could just read from the UART's RX buffer and transfer it to a RAM buffer and set a flag. The processing of the received data could be done in the foreground. The time taken to execute the ISR should be less than the time taken to receive the next data byte.
3. Writing a C ISR pushes and pops all the virutual registers, paging registers and A and X registers. This increases the time taken to execute an ISR. Write the UART ISR in assembly to make it more efficient.
4. Other interrupts in the program can also create interrupt latencies which could result in overrun errors. Under such circumstances, reducing the baud rate of the UART will also prevent the overrun error.