{
  "id": "embedded/uart-overrun-error",
  "signature": "UART: overrun error on USART1, data lost",
  "signature_zh": "UART：USART1 上发生溢出错误，数据丢失",
  "regex": "UART: overrun error on USART\\d+, data lost",
  "domain": "embedded",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "UART receive buffer overrun because the CPU failed to read data before the next byte arrived, typically due to high interrupt latency or insufficient DMA buffering.",
  "root_cause_type": "generic",
  "root_cause_zh": "UART 接收缓冲区溢出，因为 CPU 未能在下一个字节到达前读取数据，通常由于高中断延迟或 DMA 缓冲不足。",
  "versions": [
    {
      "version": "STM32Cube_FW_F4 v1.27.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "FreeRTOS v10.4.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "GCC ARM Embedded 12.2.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increase UART baud rate to reduce data arrival rate",
      "why_fails": "Higher baud rate increases data rate, worsening the overrun condition.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable UART interrupts and poll manually",
      "why_fails": "Polling increases CPU load and may miss data entirely, leading to more overruns.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a delay in the UART ISR",
      "why_fails": "Delays in ISR increase interrupt latency, causing more overruns.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Enable UART DMA for reception with a circular buffer: configure DMA with peripheral-to-memory transfer, set buffer size to 256 bytes, and use half-transfer/full-transfer interrupts to process data.",
      "success_rate": 0.85,
      "how": "Enable UART DMA for reception with a circular buffer: configure DMA with peripheral-to-memory transfer, set buffer size to 256 bytes, and use half-transfer/full-transfer interrupts to process data.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase UART FIFO threshold (if hardware supports): set USART_CR3_DMAT to enable DMA, or configure RTO (receive timeout) to flush buffer periodically.",
      "success_rate": 0.75,
      "how": "Increase UART FIFO threshold (if hardware supports): set USART_CR3_DMAT to enable DMA, or configure RTO (receive timeout) to flush buffer periodically.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce interrupt priority of other peripherals to ensure UART ISR executes promptly: use NVIC_SetPriority(USART1_IRQn, 0) for highest priority.",
      "success_rate": 0.7,
      "how": "Reduce interrupt priority of other peripherals to ensure UART ISR executes promptly: use NVIC_SetPriority(USART1_IRQn, 0) for highest priority.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "启用 UART DMA 进行接收并使用环形缓冲区：配置 DMA 为外设到内存传输，设置缓冲区大小为 256 字节，并使用半传输/全传输中断处理数据。",
    "增加 UART FIFO 阈值（如果硬件支持）：设置 USART_CR3_DMAT 启用 DMA，或配置接收超时（RTO）定期刷新缓冲区。",
    "降低其他外设的中断优先级，确保 UART ISR 及时执行：使用 NVIC_SetPriority(USART1_IRQn, 0) 设置最高优先级。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-407-417-427-437-429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf",
  "official_doc_section": null,
  "error_code": "USART_SR_ORE",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}