2010-10-12 06:35 AM
Repeating adc scan with multichannel, single conversion mode
2011-05-17 05:11 AM
I agree, the examples are not very helpful for this standard periodic data capture task. This is what worked for me:
In the sample loop, first enable the DMA channel, then start the ADC conversion. At this point the code can go do something useful while the ADC is converting. Test the DMA current data counter, when it decrements to zero, process the sampled ADC channel buffer. Then disable the DMA channel, set the DMA counter for the next sample, and repoint the DMA address register to the start of the ADC channel buffer. Cheers, Hal2011-05-17 05:11 AM
Thanks Hal,
I implemented it as suggested and it works fine. By the way, it seems not to be necessary to repoint the DMA address register. I reduced the code as much as possible. Here is the code to restart sampling.// restart DMA
DMA1_Channel1->CCR &= 0xFFFFFFFE; // reset dma DMA1_Channel1->CNDTR = 2; // setup size for transfer DMA1_Channel1->CCR |= 0x00000001; // enable dma // restart ADC ADC1->SR = 0; // clear flags ADC1->CR2 |= 0x00500001; // enable and start