embedded protocol_error ai_generated partial

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

ID: embedded/uart-overrun-error-dma-mode

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
1Evidence
2023-11-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
STM32Cube_FW_F4 V1.27.0 active
HAL V1.8.0 active

Root Cause

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

generic

中文

UART 溢出因 DMA 传输速率不足以在下个字节到达前清空接收缓冲区而发生。

Official Documentation

https://www.st.com/resource/en/application_note/dm00110233.pdf

Workarounds

  1. 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.
    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. 90% success Enable UART hardware flow control (RTS/CTS) to throttle sender: set `huart.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;`
    Enable UART hardware flow control (RTS/CTS) to throttle sender: set `huart.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;`
  3. 75% success Reduce interrupt priority of DMA and increase priority of UART global interrupt to handle ORE flag faster.
    Reduce interrupt priority of DMA and increase priority of UART global interrupt to handle ORE flag faster.

中文步骤

  1. 增加 DMA 缓冲区大小并使用循环模式以提供更多处理时间:`HAL_UART_Receive_DMA(&huart, buffer, BUFFER_SIZE);` 其中 BUFFER_SIZE >= 512。
  2. 使能 UART 硬件流控制(RTS/CTS)以限制发送端:设置 `huart.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;`
  3. 降低 DMA 的中断优先级,提高 UART 全局中断优先级以更快处理 ORE 标志。

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Increasing UART baud rate worsens overrun as data arrives faster.

  2. 60% fail

    Disabling DMA and using interrupt mode shifts bottleneck but does not fix root cause.