2015-03-05 11:10 AM
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-adc2015-03-05 02:05 PM
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 EOC2015-03-06 08:05 AM
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.2015-03-06 08:24 AM
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.2015-03-06 09:05 AM
> 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 JW2015-03-06 09:42 AM
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.