cancel
Showing results for 
Search instead for 
Did you mean: 

Do ADC_GetConversionValue read the current ADC value?

vicki19880929
Associate III
Posted on November 23, 2013 at 01:22

Hi all,

I'm recently building an application which asks for the current analog input at each poll.  It only reads the ADC value when it receives the request, which means that my STM32L will not read the ADC value all the time.  

And here's my question,  I found out that the ADC value I read at the current request is always the value read in the previous request.

So I did a simple test like this: I wrote a for loop that will read the ADC value for ten times.  In the meanwhile, I tuned my power supply which gives the analog input. (e.x. 0V-3V-0V-3V-0V-3V...)  And then I found out the same thing that it only prints out the previous ADC value instead of the current one. (e.x. 0-0-4096-0-4096-0...)  

 

for (i = 0; i < 10; i++) {

    /* Read ADC conversion result */

    ADCdata = ADC_GetConversionValue(ADC1);

    printf(''%4u\n'', ADCdata);

    printf(''change value now\n'');

    Delay(0xfffff);

    Delay(0xfffff);

    Delay(0xfffff);

    Delay(0xfffff);

    Delay(0xfffff);

    Delay(0xfffff);

  }

Does anyone know how I could read the current ADC value?

Thanks a lot!

#use-your-head!
10 REPLIES 10
Posted on October 28, 2016 at 15:04

Look, you've off-topic'd a 3 year old thread on the STM32L1 for some issue reading battery voltages on an STM32F0, I ask you what the analogue reference *voltage* is on your design, which I know nothing about, and you give me a pair of numbers in the thousands that make no sense.

Open a new thread, describe your design so I have some context about what voltages you are presenting where.

Can the F0 accept a VBAT that is higher than +VREF?

Does it half or quarter the VBAT internally to keep it from going off-scale?

You have to take the 0..4095 value returned by the ADC an scale that against the external minimum/maximal references.

You should also be able to benchmark the reading against the internal reference.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..