cancel
Showing results for 
Search instead for 
Did you mean: 

adc & dma

bernat_f
Associate II
Posted on December 31, 2009 at 11:27

adc & dma

4 REPLIES 4
bernat_f
Associate II
Posted on May 17, 2011 at 13:36

Hi, I've got an usual problem but I don't know which is the best way to solve it.

I am reading from one AD in a interrupt an form seven more in the main program, the problem is how I can avoid the overwriting of the ADC_DR register during the interrupt? because, as it is said in the manual there is just one ADC_DR register.

Looking into it I've seen the DMA but as I am using one low-density micro I just as 7 DMA channels so that I can't save my 8 ADs.

The question is DMA avoids the writing in the AC_DR register? Or it just copies its values in another register?

How I could this problem?

tomas23
Associate II
Posted on May 17, 2011 at 13:36

Hello bernat,

the ADC uses serial conversion of channels, thus needs only one DMA channel (DMA1_Channel1).

Setup the DMA in circular mode, 2*8 items, and instead of ADC interrupt, use HalfTransfer and TransferComplete interrupts from this DMA unit.

The results will be stored in an array of 16 items, each DMA interrupt will tell you that one half of the buffer is converted with new data.

See ADC1_DMA example from firmware library, extend the ADCConvertedValue to an array [16], add more converted channels (8), configure DMA for 16 transfers and enable HT and TC.

bernat_f
Associate II
Posted on May 17, 2011 at 13:36

ok, thanks for the answer. :D

armmcu
Associate II
Posted on May 17, 2011 at 13:36

Hi bernat,

Using an injected channel for (ADC interrupt conversion)is a good condidate solution in your case.

for other ADC conversions you can use regular channels with only one DMA channel transfer as stated by edison.

Happy end of year for all.