7 years, 4 months ago.

How to get the value of inbuilt vref internal and temperature sensor through adc in stm32l152re?

As stm32l152re has inbuilt voltage refrence of 1.2V, I want to measure this voltage through adc to calibrate the readings of other adc. My supply voltage varies from 2V to 3.6V and I dont want to use any external refrence source or regulator. Any help will be appreciated.

2 Answers

5 years, 7 months ago.

How can I get the implementations of ADC_VREF and ADC_TEMP imported into the nRF51 library?

Error: Identifier "ADC_VREF" is undefined in "shields/main.cpp", Line: 29, Col: 19 Error: Identifier "ADC_TEMP" is undefined in "shields/main.cpp", Line: 30, Col: 19

Steve

7 years, 4 months ago.

Hi rajhans,
you can get the data using following program.
Please try it.
I hope you can use it and make a normalization.

#include "mbed.h"

AnalogIn   vrefint(ADC_VREF);
AnalogIn   tempint(ADC_TEMP);

int main() {
    while(1) {
        printf("Vref(f): %f, Vref : %u, Temperature : %u\r\n",
                 vrefint.read(), vrefint.read_u16(), tempint.read_u16());
        wait(1.0f);
    }
}

What sorts of answers should I except from this code? The "vrefint.read_u16();" is giving an answer of about 26000. I'm assuming that's supposed to be 2.6V, I just want to be sure.

posted by Benjamin Spooner 06 Aug 2018

Hi Ben, answer is not so easy. You can see another sample program as below.

Import programNucleoL152_Volt_meter

Simple digital volt meter using internal reference(VREFINT)


You need to make a normalization.
Please see the comments in main.cpp.
In addition, look a doucument, en.CD00240193.pdf page 286/911 (September 2017 DocID15965 Rev 15).

posted by Kenji Arai 07 Aug 2018