cancel
Showing results for 
Search instead for 
Did you mean: 

ADC

brubinstein
Associate II
Posted on March 05, 2015 at 20:10

I need simple stand alone test program which will convert more than one channel when needed. My requirements NOT to use Standard peripheral library, do everything manually, No IRQ nor DMA. The goal is to understand what ADC can do and how.

Please look at the provided code and let me know what did I misunderstand from the datasheet.

Thank you. 

#stm32-adc
5 REPLIES 5
Posted on March 05, 2015 at 23:05

Please look at the provided code and let me know what did I misunderstand from the datasheet

That multi channel read needs to use DMA

That reading the DR clears the EOC

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
brubinstein
Associate II
Posted on March 06, 2015 at 17:05

Thank you for reply.

If I chose to use discontinue mode and will set to discontinue after one channel, to continue reading would it be sufficient to use ADC_CR2_SWSTART or external trigger is the only option?

Do I need to do anything with ADC_SR_STRT?

Could you please provide simple code initializing DMA without STD_Periph_lib as a not ambiguous reference to the RM0090?

Appreciating your help, thank you. 

Posted on March 06, 2015 at 17:24

Maybe Jan can help you? I'm not really up for a register level journey of self discovery, that's really a trip you'll need to own yourself.

The hardware is quite powerful, I'm sure you can use the ADC in a number of modes, and reconfigure it to swap between channels, and start each conversion. I'm not sold on the merits of doing that. You can trigger conversions manually, or with internal/external triggers.

The reference manual and the library provide two perspectives on the hardware implementation. I would recommend to prototype your concepts in the library, and then decompose what it's doing vs how you want to play with the registers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 06, 2015 at 18:05

> Maybe Jan can help you?

Sorry, I did not really dig deep into the ADC to be able to comment on others code or give relevant advice. For my applications, it was always enough to perform single conversion and reconfigure/restart ''manually'' in a polling cycle; that's pretty simple and, as the first experiment, you should be able to perform it from the debugger through direct writes to the registers in the window displaying them, without any code.

> while(!(ADC3->SR & ADC_SR_EOC)); // this line doesn't work in step mode > ADC3->SR &= ~ADC_SR_EOC;

As Clive already said above, SR.EOC gets cleared automatically by reading the DR. That makes the second line superfluous. And, that's also why SR.EOC clears when single-stepping - you surely display the DR and the debugger needs to read it after each step. Don't forget that the ADC won't stop while you are single-stepping.

> The reference manual and the library provide two perspectives on the hardware implementation.

> I would recommend to prototype your concepts in the library, and then decompose what it's doing vs how you want to play with the registers.

+1

JW

brubinstein
Associate II
Posted on March 06, 2015 at 18:42

Read it. Hopefully somebody will answer my question. 

RM0090 is way too far from the best sources of information.

Still didn't understand about ADC_SR_STRT.

Thanks to all.