# DMA：流已使能，无法在忙时重新配置

- **ID:** `embedded/dma-configuration-busy-flag`
- **领域:** embedded
- **类别:** resource_error
- **错误码:** `HAL_DMA_ERROR_BUSY`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

在DMA外设仍处于活动状态（EN位已置位）时重新配置DMA流或通道（如更改源/目标地址或传输大小），导致对只读寄存器的写入或总线错误。

## 解决方案

1. ```
   Disable the DMA stream before reconfiguration. Example: hdma->Instance->CCR &= ~DMA_CCR_EN; while (hdma->Instance->CCR & DMA_CCR_EN); // Wait for disable confirmation
   ```
2. ```
   Use a state machine to ensure DMA is only reconfigured after transfer completion interrupt. Check the Transfer Complete flag before calling HAL_DMA_Start_IT again.
   ```

## 无效尝试

- **** — Calling HAL_DMA_Abort() and then immediately reconfiguring without waiting for the abort completion flag results in the same busy state. (75% 失败率)
- **** — Resetting the DMA peripheral via RCC reset does clear the busy flag but also loses all configuration, requiring full re-initialization. (50% 失败率)
