cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L051... How to use ADC as simple as possible to measure VREFINT ?

SPres.19
Associate

My application is in STOP Mode the most of the time and is powered by a CR2430 battery. When woken up, I have to send quickly an alarm through a RF chip (for about 5ms) and at the end of transmission, I would like to calculate the battery level. For that, first, I chose to measure the internal VREFINT (Channel 17).

The battery level will be calculate after this measure. Have generated code with cubeMX (Vrefint set) and tried simply to measure VREFINT with the following code:

         gl_tempValue = 0;

         HAL_ADC_Start(&hadc1);

         HAL_ADC_PollForConversion(&hadc1, 10);

         gl_tempValue = (u16)HAL_ADC_GetValue(&hadc1);

         HAL_ADC_Stop(&hadc1);

But "gl_tempValue" has always the same fixed value of 1999. Even by changing the battery level (simulated with an adjustable power supply).

Have tried several variants, without success...

Any Solutions please? Thx!

0 REPLIES 0