2009-10-05 07:15 AM
ADC Sequence, who's result is it?
2011-05-17 04:14 AM
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. QuestionWhen 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 ]2011-05-17 04:14 AM
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.2011-05-17 04:14 AM
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.2011-05-17 04:14 AM
Thanks. The DMA do work. But still, it would be nice to know which channel is being converted.
2011-05-17 04:14 AM
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.2011-05-17 04:14 AM
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. thanks2011-05-17 04:14 AM
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.