2014-01-11 08:28 AM
Hello
I am trying to implement indirect voltage measurement in a battery operated application.Our MCU supports VREF+ and VREF+ is derived from the battery voltage. Therefore - VREFINT must be used to extract VREF+.The trouble is I keep getting a wrong digital value when measuring VREFINT via ADC (I get a digitized value of around 600 for the first measurement and from the second measure and forth I receive a value around 1400).Thus the VREFINT I get is ~1.12V (when neglecting the first measurement).VREF+ is stable at 3.3V during the measurements. The ADC is configured to a sampling time of 384 cycles The code for indirect VREF+ measurement is based on AN3964 (see below).Please be so kind to share your thoughts as to why the ADC measurement deviates.Thank you very much/Gilvoid Indirect_Input_BatterySampling( void ){ static U16 val_vrefint; //for vref int (1.2 volt via channel17 static U16 val_bat_mon; // bat volt in units via adc static U32 v_bat; // bat in volt static U32 vref_plus;// For Indirect VREF+ calculation while((PWR->CSR & PWR_CSR_VREFINTRDYF) == RESET) { } ADC_TempSensorVrefintCmd(ENABLE); // ENABLE VREFINT val_vrefint = Adc_GetAdcValue ( ADC_Channel_17 ); // Measured value of VREFINT via ADC. val_bat_mon = Adc_GetAdcValue (ADC_BATTERY ); vref_plus = (vrefcal*3*10000) / val_vrefint; v_bat = ((val_bat_mon * vref_plus) / 4096) * 2;} #stm32l #vrefint2014-01-12 12:18 PM