Repeat sequence of ADC conversions using DMA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-09-28 10:48 AM
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
- Labels:
-
ADC
-
DMA
-
STM32Cube MCU Packages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-09-28 11:31 AM
>>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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-09-28 12:37 PM
Thanks for the suggestion. I'll try that.
