# UART: overrun error (ORE) detected in DMA mode, data lost

- **ID:** `embedded/uart-overrun-error-dma-mode`
- **Domain:** embedded
- **Category:** protocol_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

UART overrun occurred because DMA transfer rate insufficient to empty receive buffer before next byte arrives.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32Cube_FW_F4 V1.27.0 | active | — | — |
| HAL V1.8.0 | active | — | — |

## Workarounds

1. **Increase DMA buffer size and use circular mode to allow more time for processing: `HAL_UART_Receive_DMA(&huart, buffer, BUFFER_SIZE);` with BUFFER_SIZE >= 512.** (85% success)
   ```
   Increase DMA buffer size and use circular mode to allow more time for processing: `HAL_UART_Receive_DMA(&huart, buffer, BUFFER_SIZE);` with BUFFER_SIZE >= 512.
   ```
2. **Enable UART hardware flow control (RTS/CTS) to throttle sender: set `huart.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;`** (90% success)
   ```
   Enable UART hardware flow control (RTS/CTS) to throttle sender: set `huart.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;`
   ```
3. **Reduce interrupt priority of DMA and increase priority of UART global interrupt to handle ORE flag faster.** (75% success)
   ```
   Reduce interrupt priority of DMA and increase priority of UART global interrupt to handle ORE flag faster.
   ```

## Dead Ends

- **** — Increasing UART baud rate worsens overrun as data arrives faster. (85% fail)
- **** — Disabling DMA and using interrupt mode shifts bottleneck but does not fix root cause. (60% fail)
