What is the UART overrun error?
Technical Blog / Author: icDirectory United Kingdom / Date: Jun 24, 2024 02:06
A UART (Universal Asynchronous Receiver/Transmitter) overrun error occurs when the UART's receive buffer is full, and a new data byte arrives before the previous data has been read out by the software or hardware. This means that the UART was not able to transfer the received data to the appropriate location in time, leading to the loss of incoming data.

## How Overrun Error Happens


To understand an overrun error, let’s go through the data reception process in a UART system:

1. Data Reception:
- The UART receiver continuously monitors the serial data input line for data frames.
- When a start bit is detected, it begins receiving the data bits, parity bit (if used), and stop bit(s).

2. Storing Received Data:
- Once a complete data frame is received, the data byte is typically stored in a receive buffer or register.

3. Buffer Management:
- The UART has a finite-sized hardware buffer (often just one or a few bytes deep) to store incoming data.
- The software or a Direct Memory Access (DMA) controller must read the data from this buffer before more data arrives.

## Overrun Error Condition


An overrun error occurs under the following conditions:

- Buffer Full: The receive buffer is already holding data that has not yet been read by the software or hardware.
- New Data Arrives: Another data frame is received and needs to be stored in the already full buffer.
- Data Loss: Since the buffer is full, the new incoming data cannot be stored and is therefore lost. This condition is flagged as an overrun error.

## Causes of Overrun Errors


Several factors can lead to an overrun error:

1. High Data Rate:
- If data is arriving at a very high rate and the software or hardware is not fast enough to read it out of the buffer, an overrun can occur.

2. Slow Processing:
- The microcontroller or processor may be busy performing other tasks and may not service the UART interrupt or poll the UART buffer quickly enough.

3. Interrupt Latency:
- High interrupt latency or disabled interrupts can prevent timely reading of the receive buffer, leading to overrun.

4. Inadequate Buffering:
- Using a UART with a small buffer size can increase the likelihood of overrun errors, especially in high-throughput applications.

## Detecting and Handling Overrun Errors


Most UART hardware provides mechanisms to detect and handle overrun errors:

1. Error Flags:
- The UART hardware sets an overrun error flag in a status register. This flag can be checked by the software to determine if an overrun has occurred.

2. Interrupts:
- An overrun error can trigger an interrupt, alerting the system to the error condition so that corrective action can be taken.

3. Error Handling:
- Upon detecting an overrun error, the software typically needs to:
- Clear the overrun error flag.
- Read the data from the receive buffer to make room for new data.
- Implement strategies to prevent future overruns, such as increasing buffer size, optimizing processing speed, or adjusting the baud rate.

## Preventive Measures


To minimize the occurrence of overrun errors, consider the following strategies:

- Increase Buffer Size:
- If possible, use a UART with a larger receive buffer or implement a software-based circular buffer to temporarily store incoming data.

- Optimize Interrupt Handling:
- Ensure that the UART interrupt service routine (ISR) is efficient and has low latency.

- Use DMA:
- Implement Direct Memory Access (DMA) to offload data transfer tasks from the CPU, allowing continuous data reception without CPU intervention.

- Flow Control:
- Implement hardware (RTS/CTS) or software flow control to manage the data flow and prevent overruns.

## Conclusion


A UART overrun error occurs when the receive buffer is full, and new data arrives before the previous data has been processed, leading to data loss. This can be due to high data rates, slow processing, or inadequate buffering. Detecting overrun errors involves checking status flags or handling interrupts, and preventive measures include optimizing buffer management, improving interrupt handling, using DMA, and implementing flow control. Properly addressing overrun errors is crucial for maintaining reliable UART communication.

icDirectory United Kingdom | https://www.icdirectory.co.uk/a/blog/what-is-the-uart-overrun-error.html
Related Products
XR16C2852CJ-F
XR16C2852CJ-F
MaxLinear
Date: Jun 02, 2026
SC16C2550BIA44,512
SC16C2550BIA44,512
NXP Semiconductors
Date: Jun 01, 2026
XR16C2850CM-F
XR16C2850CM-F
MaxLinear
Date: Jun 01, 2026
XR16C2850IJTR-F
XR16C2850IJTR-F
MaxLinear
Date: Jun 01, 2026
SC16C2550IA44,529
SC16C2550IA44,529
NXP Semiconductors
Date: Jun 01, 2026
SC26C92A1A,529
SC26C92A1A,529
NXP Semiconductors
Date: Jun 01, 2026
XR16C2850CJ-F
XR16C2850CJ-F
MaxLinear
Date: Jun 01, 2026
SC26C92A1B,551
SC26C92A1B,551
NXP Semiconductors
Date: May 31, 2026
CS82C52Z
CS82C52Z
Renesas Electronics
Date: May 31, 2026
XR16C2550IJTR-F
XR16C2550IJTR-F
MaxLinear
Date: May 31, 2026
SC16C2550IA44,518
SC16C2550IA44,518
NXP Semiconductors
Date: May 31, 2026
ST16C1450CJ28TR-F
ST16C1450CJ28TR-F
MaxLinear
Date: May 31, 2026
Technical Blog
  • What is the role of start and stop bits in UART?
  • How do you calculate the UART baud rate?
  • What is the UART communication data parity bit usage?
  • What is the baud rate in UART communication?
  • What is the UART communication reliability?
  • What is the UART communication data buffering strategy?
  • How do you troubleshoot UART communication issues?
  • What is the UART communication handshaking?
  • What is the UART communication master-slave mode?
  • What is the UART communication data stop bit duration?
  • What is the UART communication data integrity check?
  • What is the UART communication multipoint mode?
  • What is the UART data overrun error?
  • What is the UART communication flow control?
  • How do you configure UART communication?
  • What is the UART communication distance?
  • What is the UART idle line condition?
  • What is the UART communication data word length configuration?
  • What is the UART communication data multiplexing technique?
  • What is the UART break condition?
  • What is the UART communication full-duplex mode?
  • What are the disadvantages of UART communication?
  • What is the UART communication data error detection mechanism?
  • What is the UART communication data framing format?
  • What is the UART communication data integrity?
  • What is the UART data idle line condition?
  • What is the maximum cable length for UART communication?
  • What is the UART data format?
  • What is the UART stop bit?
  • What is the UART data framing error?