embedded protocol_error ai_generated partial

UART:DMA 模式下检测到溢出错误(ORE),数据丢失

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

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

其他格式: JSON · Markdown 中文 · English
80%修复率
82%置信度
1证据数
2023-11-20首次发现

版本兼容性

版本状态引入弃用备注
STM32Cube_FW_F4 V1.27.0 active — — —
HAL V1.8.0 active — — —

根因分析

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

English

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

generic

官方文档

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

解决方案

  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 标志。

无效尝试

常见但无效的做法:

  1. 85% 失败

    Increasing UART baud rate worsens overrun as data arrives faster.

  2. 60% 失败

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