cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 ADC DMA Read Problem: Value Not Updating, Callback Not Triggered

durna
Associate II

Hello,

I am using an STM32H755. I want to read a potentiometer via ADC and transfer the value to a variable using DMA. I have configured everything with CubeMX (ADC1, DMA, channel, sampling time, etc.) and I start the conversion with HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&adc_dma_val, 1).

When I use polling mode, ADC works perfectly and I get correct values.
However, when I try to read with DMA:

The adc_dma_val variable remains 0 and is never updated.

The HAL_ADC_ConvCpltCallback function is never triggered.

All init functions (MX_DMA_Init, MX_ADC1_Init) are called in the correct order, DMA interrupt handler is active.

ADC and DMA clocks are enabled.

There seems to be no issue in the code, and the hardware wiring is correct.

I have been struggling with this issue for a while. If anyone has experienced a similar problem or has an idea, I would appreciate your help.
I am attaching my source code.

Thank you!

1 REPLY 1
Karl Yamashita
Principal

You didn't enable the NVIC for the ADCx

 

KarlYamashita_1-1752268980518.png

I would disable Continuous Conversion Mode. 

KarlYamashita_2-1752269096402.png

You can either call the HAL_ADC_Start_DMA in the HAL_ADC_ConvCpltCallback

Or better yet, use a timer to trigger the ADC conversion in a timely fashion.

 

 

I was told that if a devices starts to smoke, put the smoke back in. I guess I never got all the smoke because the device never worked afterwards.
Don't worry, I won't byte.
TimerCallback tutorial! | UART and DMA Idle tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.