cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F042: ADC conversion keeps getting ~.3 - .4V even with 0V input

Vu.Andy
Associate III
Posted on November 13, 2017 at 20:43

I am not sure why I keep getting around .3 - .4 V even when the measured input is at 0V using a hand-held DMM.  It's hard to imagine my ground noise is that high.  Do you think it could be a software issue? 

Here are the codes for reading ADC value.  The reference voltage is 3.3V.

void StartADCConversion(void)

{

        G_ADC_conv_ready = 0;    

        HAL_ADC_Start_IT(&L_hadc);    

}

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)  

{

  double temp_volt = 0;

    if (__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_EOC))

    {

            temp_volt = HAL_ADC_GetValue(hadc);

            G_PackVoltage = (temp_volt/4095.0) * 3.30;

            G_ADC_conv_ready = 1;

    }

}
2 REPLIES 2
Posted on November 13, 2017 at 22:06

Have you tried hard shorting the ADC input to VDDA?

JW

Posted on November 13, 2017 at 22:58

It seems like my conversion time is too short.  I increase to ADC_SAMPLETIME_55CYCLES_5 and now it seems to work.

Thanks.