ADC banks 2 and 3 on STM32

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
ianmga
Posts: 42
Joined: Fri Jan 28, 2011 1:11 am

ADC banks 2 and 3 on STM32

Post 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?
ianmga
Posts: 42
Joined: Fri Jan 28, 2011 1:11 am

Re: ADC banks 2 and 3 on STM32

Post 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
ianmga
Posts: 42
Joined: Fri Jan 28, 2011 1:11 am

Re: ADC banks 2 and 3 on STM32

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ADC banks 2 and 3 on STM32

Post 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
elims
Posts: 5
Joined: Mon May 14, 2012 10:02 pm

Re: ADC banks 2 and 3 on STM32

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ADC banks 2 and 3 on STM32

Post 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
elims
Posts: 5
Joined: Mon May 14, 2012 10:02 pm

Re: ADC banks 2 and 3 on STM32

Post 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.
elims
Posts: 5
Joined: Mon May 14, 2012 10:02 pm

Re: ADC banks 2 and 3 on STM32

Post 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.
Post Reply