Skip to main content
PKris
Associate
September 28, 2018
Question

Repeat sequence of ADC conversions using DMA

  • September 28, 2018
  • 2 replies
  • 816 views

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

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
September 28, 2018

>>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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
PKris
PKrisAuthor
Associate
September 28, 2018

Thanks for the suggestion. I'll try that.