我正在尝试使用
STM32L011F4 读取 2 通道 ADC。
我在cubemx中的ADC和DMA设置如下
我的问题是 DMA 只返回最后一个通道的低 8 位。
- uint16_t ADC_Reads[2] = {0};
- while (1)
- {
- HAL_ADC_Start_DMA(&hadc,(uint32_t *)ADC_Reads,2);
- HAL_Delay(1000);
- }
当我在 DMA IRQ 处理程序中编写以下代码时,我可以读取这些值。
- uint16_t ADCReads[2];
- char i=0;
- void DMA1_Channel1_IRQHandler(void)
- {
- /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
- ADCReads = hadc.Instance->DR;
- i = 1-i;
- /* USER CODE END DMA1_Channel1_IRQn 0 */
- HAL_DMA_IRQHandler(&hdma_adc);
- /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
- /* USER CODE END DMA1_Channel1_IRQn 1 */
- }
EWARM 实时观看屏幕如下所示