cancel
Showing results for 
Search instead for 
Did you mean: 

Repeat sequence of ADC conversions using DMA

PKris
Associate II

Hi All,

I need to do 13 ADC conversions using DMA. And also need to repeat it 10 times so that I can take average for all the 13 values. Here's the code I'm using:

static uint16_t adcDataArrayBeforeAvg[130];

HAL_ADC_Start_DMA(&hadc, (uint32_t *)adcDataArrayBeforeAvg, 130);

ADC Config:

 hadc.Init.EOCSelection = ADC_EOC_SEQ_CONV;

 hadc.Init.LowPowerAutoWait = DISABLE;

 hadc.Init.LowPowerAutoPowerOff = DISABLE;

 hadc.Init.ContinuousConvMode = DISABLE;

 hadc.Init.DiscontinuousConvMode = DISABLE;

 hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;

 hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

 hadc.Init.DMAContinuousRequests = ENABLE;

 hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;

I'm expecting the DMA to repeat the sequence of conversions 10 times and generate an interrupt finally. But HAL_ADC_ConvCpltCallback is not getting called.

NOTE: If I just convert 13 values like below, HAL_ADC_ConvCpltCallback is getting invoked.

HAL_ADC_Start_DMA(&hadc, (uint32_t *)adcDataArrayBeforeAvg, 13);

Is what I'm trying to achieve possible or am I doing something wrong here?

Thanks,

Prakash

2 REPLIES 2

>>Is what I'm trying to achieve possible or am I doing something wrong here?

For it to occur more than once it would need to be in continuous mode.

To scope the number of times, I'd probably use an advanced timer, in single-shot repetition mode, and use that to trigger the ADC.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
PKris
Associate II

Thanks for the suggestion. I'll try that.