# USB: HCD timeout waiting for transfer completion on pipe 3

- **ID:** `embedded/usb-host-hcd-timeout`
- **Domain:** embedded
- **Category:** protocol_error
- **Verification:** ai_generated
- **Fix Rate:** 77%

## Root Cause

USB host controller driver (HCD) timeout due to device not responding, incorrect endpoint configuration, or electrical noise on D+/D- lines.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 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 | — | — |

## Workarounds

1. **Increase USB host channel timeout value in HAL_HCD_Init(): hhcd.Init.TransferTimeout = 5000; (from default 1000 ms) and regenerate code.** (80% success)
   ```
   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.** (85% success)
   ```
   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.** (75% success)
   ```
   Reinitialize the USB host port after timeout: call HAL_HCD_Stop(&hhcd); HAL_HCD_Start(&hhcd); then retry the transfer up to 3 times.
   ```

## Dead Ends

- **Increasing USB host polling interval in HAL_HCD_IRQHandler()** — Longer polling intervals may cause missed transfers and do not solve underlying timeout. (85% fail)
- **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% fail)
- **Adding a 100 ms delay before each USB transfer** — Degrades throughput and may violate USB timing specifications. (80% fail)
