# USB CDC: ACM数据缓冲区溢出，端点0x81上丢弃64字节

- **ID:** `embedded/usb-cdc-acm-buffer-overflow`
- **领域:** embedded
- **类别:** resource_error
- **错误码:** `CDC_OVF_ERR`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

USB CDC接收缓冲区已满，因为应用程序未能足够快地从虚拟COM端口读取数据，导致溢出。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32Cube_FW_F4 v1.27.0 | active | — | — |
| TinyUSB v0.15.0 | active | — | — |
| USB CDC Class v1.2.0 | active | — | — |

## 解决方案

1. ```
   Implement a circular buffer in the application to store incoming USB data and process it in a lower-priority task, ensuring the CDC receive interrupt never blocks.
   ```
2. ```
   Increase the polling rate of the CDC receive function in the main loop, e.g., call CDC_Receive_FS() every 1ms instead of 10ms.
   ```

## 无效尝试

- **Increase the USB buffer size in the CDC configuration** — Larger buffers only delay the overflow but do not fix the root cause of slow data consumption; eventually overflow still occurs. (85% 失败率)
- **Reduce the baud rate of the virtual COM port to slow transmission** — Baud rate is irrelevant for USB CDC; data is packet-based and the host can still send at full speed. (95% 失败率)
