HAL_DMA_ERROR_BUSY
embedded
resource_error
ai_generated
true
DMA:流已使能,无法在忙时重新配置
DMA: stream already enabled, cannot reconfigure while busy
ID: embedded/dma-configuration-busy-flag
88%修复率
87%置信度
1证据数
2023-09-12首次发现
根因分析
在DMA外设仍处于活动状态(EN位已置位)时重新配置DMA流或通道(如更改源/目标地址或传输大小),导致对只读寄存器的写入或总线错误。
English
A DMA stream or channel is being reconfigured (e.g., changing source/destination address or transfer size) while the DMA peripheral is still active (EN bit set), causing a write to read-only registers or a bus error.
官方文档
https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405xx-stm32f407xx-stm32f415xx-stm32f417xx-reference-manual.pdf解决方案
-
Disable the DMA stream before reconfiguration. Example: hdma->Instance->CCR &= ~DMA_CCR_EN; while (hdma->Instance->CCR & DMA_CCR_EN); // Wait for disable confirmation
-
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.
无效尝试
常见但无效的做法:
-
75% 失败
Calling HAL_DMA_Abort() and then immediately reconfiguring without waiting for the abort completion flag results in the same busy state.
-
50% 失败
Resetting the DMA peripheral via RCC reset does clear the busy flag but also loses all configuration, requiring full re-initialization.