cancel
Showing results for 
Search instead for 
Did you mean: 

Repeating adc scan with multichannel, single conversion mode

sros
Associate II
Posted on October 12, 2010 at 15:35

Repeating adc scan with multichannel, single conversion mode

2 REPLIES 2
raptorhal2
Lead
Posted on May 17, 2011 at 14:11

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, Hal

sros
Associate II
Posted on May 17, 2011 at 14:11

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