AnsweredAssumed Answered

STM32F072 battery reading

Question asked by GIJOW on Nov 4, 2016
Latest reply on Nov 4, 2016 by GIJOW
Hi All

I have the attached circuit and I need to read the battery level using ADC_IN18. I have the following instructions:

Init:

  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Upward;
  ADC_Init(ADC1, &ADC_InitStructure);
///// other stuffs ///
 ADC_AutoPowerOffCmd(ADC1, ENABLE);//Enables or disables the ADC Power Off.
 ADC_VbatCmd(ENABLE);

/* Start ADC1 Software Conversion */
ADC_StartOfConversion(ADC1);

/* Wait until ADC end of conversion */
while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET) {}

/* Read ADC conversion result */
V_Value = ADC_GetConversionValue(ADC1);

I'm getting the value 2072 +/- 4

This value I'm getting whether the battery is charged or empty. 
Can someone help understand and solve it ? I'm not fw programmer, this just fall over me because our guy is sick and I need to deliver this project.

Any help welcome.

Thanks

Outcomes