cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Sequence, who's result is it?

mcp
Associate II
Posted on October 05, 2009 at 16:15

ADC Sequence, who's result is it?

7 REPLIES 7
mcp
Associate II
Posted on May 17, 2011 at 13:14

Scenario

I'm using the STM32F103R8T6 with the RealView compiler and ST peripheral libraries.

I convert 5 ADC channels continuously in an automatic sequence.

I configured ADC1 as follows:

ADC_Mode = ADC_Mode_Independent;

ADC_ScanConvMode = ENABLE;

ADC_ContinuousConvMode = ENABLE;

ADC_DataAlign = ADC_DataAlign_Right;

ADC_NbrOfChannel = 5;

(Off course there are several other things that I initialize, this is only to give you a an idea of how my ADC is configured)

ADC1 EOC (End Of Convert) generates an interruprt.

Question

When the software enters the ADC EOC interrupt, how do I know which channels result is placed in the ADC_DR?

Thank you

[ This message was edited by: mcp on 11-06-2009 22:56 ]

briand.myers9
Associate II
Posted on May 17, 2011 at 13:14

I don't think you can (but I could be wrong!)

From section 10.8 of the fine manual:

''Since converted regular channels value are stored in a unique data register, it is necessary to use DMA for conversion of more than one regular channel. This avoids the loss of data already stored in the ADC_DR register.''

DMA is your friend.

kutnickg
Associate II
Posted on May 17, 2011 at 13:14

You can keep track of the sequence position manually using your own variables/data structures. You just have to guarantee that the interrupt latency is small enough or else another ADC conversion can happen after the IRQ triggered. So this will probably only work with very slow conversion rates.

You can also use injected channels to get 4 unique locations, in addition to 1 regular channel you should get the 5 you want.

DMA is probably the best solution though.

mcp
Associate II
Posted on May 17, 2011 at 13:14

Thanks. The DMA do work. But still, it would be nice to know which channel is being converted.

bejanissim
Associate II
Posted on May 17, 2011 at 13:14

Dear mcp,

I found myself stuck with the same problem (i tried to use interrupt as well).

Can you please tell me how did you use the DMA?

Thanks.

ashutosh
Associate II
Posted on May 17, 2011 at 13:14

dear mcp

i am also using the ADC in my proj. but the problem arises with me is, i am unable to get the adc values in ISR. if it goes to ISR then code is totally hang..

Pls if u know about this reply.

thanks

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

The EOC works at end of the sequence only! If you need to convert more channels, only DMA is of use. Then, in the DMA channel registers, you can read how many transfers were done => which channel was converted as latest one.