Skip to main content
Associate
December 23, 2024
Solved

STM32H7 ADC Timer-triggered Sampling only trigger HAL_ADC_ConvCpltCallback once

  • December 23, 2024
  • 1 reply
  • 891 views

Hi, I am trying to use a timer triggered ADC sampler with DMA and a complete conversion-triggered callback function. I followed this guide (https://www.youtube.com/watch?v=_K3GvQkyarg) while configuring my single pin (channel) input for ADC. Specifically,

ADC Settings:

Power_tile_0-1734939776814.png

ADC Regular Conversion Mode:

Power_tile_1-1734939795353.png

DMA Settings:

Power_tile_2-1734939811013.png

Timer Settings (this enables 10Hz timer with 138 MHz APB):

Power_tile_3-1734939838906.png

Initialization Code:

 HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
 HAL_ADC_Start_DMA(&hadc1, (uint32_t *) adcData, 1);
 HAL_TIM_Base_Start(&htim8);

 

However, HAL_ADC_ConvCpltCallback() was only triggered once, as shown by adding a breakpoint to the callback function. What is the reason that this callback is not triggered at every sample?

I have also seen this post (https://community.st.com/t5/stm32cubeide-mcus/hal-adc-convcpltcallback-only-called-once/td-p/637221) featuring similar problems and solution. This post uses "TIM auto-reload preload: Enable", different than the YouTube guide, but neither solved the problem.

Best answer by Power_tile

This ended up being a very *** bug. My adcData is defined as

volatile uint16_t adcData;

So the DMA setup should be

HAL_ADC_Start_DMA(&hadc1, (uint32_t *) &adcData, 1);

 instead. I missed the reference...

1 reply

Power_tileAuthorBest answer
Associate
December 24, 2024

This ended up being a very *** bug. My adcData is defined as

volatile uint16_t adcData;

So the DMA setup should be

HAL_ADC_Start_DMA(&hadc1, (uint32_t *) &adcData, 1);

 instead. I missed the reference...