# USB：HCD等待管道3传输完成超时

- **ID:** `embedded/usb-host-hcd-timeout`
- **领域:** embedded
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 77%

## 根因

USB主机控制器驱动超时，原因是设备无响应、端点配置错误或D+/D-线路上的电气噪声。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32Cube_FW_H7_V1.11.0 | active | — | — |
| USB_Host_Lib 2.2.0 | active | — | — |
| IAR EWARM 9.50.1 | active | — | — |
| ARM GCC 12.2.1 | active | — | — |

## 解决方案

1. ```
   Increase USB host channel timeout value in HAL_HCD_Init(): hhcd.Init.TransferTimeout = 5000; (from default 1000 ms) and regenerate code.
   ```
2. ```
   Add USB line debouncing in hardware: place 15 kΩ pull-down resistors on D+ and D- lines, and ensure VBUS is stable with a 10 µF capacitor.
   ```
3. ```
   Reinitialize the USB host port after timeout: call HAL_HCD_Stop(&hhcd); HAL_HCD_Start(&hhcd); then retry the transfer up to 3 times.
   ```

## 无效尝试

- **Increasing USB host polling interval in HAL_HCD_IRQHandler()** — Longer polling intervals may cause missed transfers and do not solve underlying timeout. (85% 失败率)
- **Re-enumerating the device by disconnecting and reconnecting in software** — Does not fix root cause; device may fail again due to same config error. (90% 失败率)
- **Adding a 100 ms delay before each USB transfer** — Degrades throughput and may violate USB timing specifications. (80% 失败率)
