cancel
Showing results for 
Search instead for 
Did you mean: 

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

durna
Associate III

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!

4 REPLIES 4
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.

 

 

If you FIFO doesn't work, then it's called GIGO.
TimerCallback tutorial! | UART and DMA Idle with multiple UART instances tutorial!

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

Thank you for your feedback, I tried the methods you mentioned but did not get any positive results.

Hello @durna 

Did you try to look at the example below ?

STM32CubeH7/Projects/STM32H743I-EVAL/Examples/ADC/ADC_DMA_Transfer at master · STMicroelectronics/STM32CubeH7 · GitHub

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

Hello

I will try it and let you know the result. Thank you