cancel
Showing results for 
Search instead for 
Did you mean: 

Measurement ADC1 Internal reference

dmitrij
Associate
Posted on August 12, 2011 at 12:19

Hello everybody.

 I would like to ask about measurement of Vrefint using ADC1 in STM32F106 64 pin. After conversion I get 0x18E. How to convert this value in voltage?

#adc1-stm32
1 REPLY 1
donald2
Associate II
Posted on August 12, 2011 at 14:55

 Vrefint is a 1.2V bandgap reference.

You can't directly measure its voltage unless you are using an external reference voltage.  The external Vref pins to do that are only available on the 100pin or more packages.

But you can use it to indirectly measure the supply voltage.  With a 3.6V supply the 1.2V reference should read about 33%, or 4095/3 = 1365.  With a 2.4V supply it should read about half, or 2048.  A value outside that range suggests that you are doing something wrong.

My guess is that you either didn't set the sample time, or you failed to enable the internal voltage references by setting the TSVREFE bit.

The internal reference voltages are only available on ADC1.  This is less likely to be a problem as most developers only use that one.

Some of my applications prints out the supply voltage, so ''it works for me''.

int adc_setup(void)

{

    /* Per-channel sample time. */

    ADC1_SMPR1 = 0x00FC0000;    /* Ch16 and Ch17 get a long sample time. */

...

    /* Turn on, then start a calibration cycle. */

    ADC1_CR2 = ADC_TSVREFE | ADC_CAL | ADC_CONT | ADC_ADON;

...

 /* Convert the internal voltage reference (AVR=1.1V, STM:1.2V) and

     * inverting to calculate Vref+ (which is Vcc). */

    count = adc_baseline(16);

    serprintf(PSTR(''System voltages\r\n''));

    serprintf(PSTR(''STM Vcc %dmV (%4d)\r\n''),

              1200*4096 / count, count);