Page 1 of 1

ADC banks 2 and 3 on STM32

Posted: Tue Feb 01, 2011 2:22 am
by ianmga
I want to read from ADC2 and ADC3 on a STM32 HD device (STM3210E-EVAL). I'll start by duplicating anything specific to the ADC1 and replace for ADC2 and 3 specific things (registers, DMA channels etc). Any other suggestions on how to approach this?

Re: ADC banks 2 and 3 on STM32

Posted: Tue Feb 01, 2011 3:04 am
by ianmga
Darn, ADC2 doesn't have DMA. Luckily between ADC1 and ADC3 they cover all the ADC pins so I'll stick to adding ADC3

Re: ADC banks 2 and 3 on STM32

Posted: Tue Feb 01, 2011 4:13 am
by ianmga
Got ADC3 working. The only non-copy-and-paste detail was that for the F103 the DMA2 channel 5 IRQ is mixed with channel 4 so name combines both.

Now I have 21 analog inputs.

ian

Re: ADC banks 2 and 3 on STM32

Posted: Tue Feb 01, 2011 9:11 am
by Giovanni
You did all by yourself :-)

Your approach and conclusions are correct, ADC3 is not a problem, just follow the patterns. ADC2 cannot be implemented as a standalone ADC unit. ADC2 could be only implemented as a special mode of ADC1, enabling one of those linked modes in the context of the ADC1 driver.

Giovanni

Re: ADC banks 2 and 3 on STM32

Posted: Mon May 28, 2012 9:40 pm
by elims
Hi,

I just tried to duplicate ianmga's efforts with ADC3. So I copied the necessary parts off adc_ll.h, adc_ll.c, mcuconf.h and stm32_rcc.h. Now it compiles well, but doesn't work. I think it is the before mentioned issue with DMA2 Channel 4 and Channel 5 share the same interrupt. Now I totally got lost in stm32_dma.h and stm32_dma.h. From what I understand initiation of ADC3 with STM32_DMA2_STREAM5 should automatically point to the right ISR with the help of _stm32_dma_streams[STM32_DMA_STREAMS]. Maybe I've just overlooked something.

At the end of the day I also want to include the analog watchdog functionality in the ADC-drivers. But that will be the next big challenge.

elims

Re: ADC banks 2 and 3 on STM32

Posted: Tue May 29, 2012 6:06 am
by Giovanni
Hi,

I added watchdog functionality to the F0 ADC driver yesterday, I plan to extend it to the other STM32 if it works well. I cannot do tests because I am in travel for work but you could give it a try.

About DMAs, it should work like you described, there must be some small error somewhere.

Giovanni

Re: ADC banks 2 and 3 on STM32

Posted: Tue May 29, 2012 5:55 pm
by elims
Found the bug. Was a popular one. Forgot the enable the Clock :D Now it works.

I'll have a look at your F0 ADC-Driver with watchdog and try to port it to F1. Hopefully it works.

Re: ADC banks 2 and 3 on STM32

Posted: Tue May 29, 2012 10:44 pm
by elims
So, analog watchdog is implemented and works. :D

Tomorrow I'll have a deeper look at ADC2 and how to include it without a dedicated DMA. I want at least be able to use the watchdog functionality.