cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 L4 ADC accuracy

dtarrago
Associate II
Posted on March 07, 2017 at 14:32

Hello,

I'm working with the STM32L475 micro. In my application I read several analog values using the ADC1. Values read are quite similar when device is in run mode. But, according to my specs and in order to save power, I need to be most of the time in Stop1 mode. Being in this mode, when device wakes-up (periodically, by RTC) is when I carry out these ADC measurements and I wait until ADC has finished measurements to go again to Stop1 mode. In this situation, measurements from ADC are more different than in run mode: I get of about 300mV of diferences between readings and having the same reference at the analog input. When carrying out these measurements, I measure first Vref in order to base other measurements on this figure. Furthermore, ADC reading depend on cycles that are setup. So...

- Which is the best way to manage ADC in this working mode?

- Is it important to auto-calibrate ADC? (I execute 'HAL_ADCEx_Calibration_Start' at the beginning, once ADC is set-up)

- Any other recommendation?

Best regards.

#adc #stop1 #stm32l4
2 REPLIES 2
Nesrine M_O
Lead II
Posted on March 07, 2017 at 14:57

Hi

TARRAGO.DANIEL

Please try to refer to

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/3f/4c/a4/82/bd/63/4e/92/CD00211314/files/CD00211pdf/jcr:content/translations/en.CD00211pdf

application note abouthow to get the best ADC accuracy in STM32 microcontrollers,it may be helpful.

-Nesrine-

Philippe Cherbonnel
ST Employee
Posted on March 08, 2017 at 18:48

Hi Daniel,

In addition to the application note mentionned by Nesrine above, the best practice to use ADC with MCU low-power stop mode is:

1. Before entring in MCU low-power stop mode, you should put ADC in deep sleep mode to reduce leakage currents.

  • Using HAL driver:

    HAL_ADC_DeInit();

  • Using LL driver:

    LL_ADC_DisableInternalRegulator(ADC1);

    LL_ADC_EnableDeepPowerDown(ADC1);

2. At wake-up from MCU low-power stop mode, you shoud activate and calibrate the ADC:

  • Using HAL driver:

    HAL_ADC_Init();

    HAL_ADCEx_Calibration_Start()

    HAL_ADC_ConfigChannel();

  • Using LL driver:

    LL_ADC_DisableDeepPowerDown(ADC1);

    LL_ADC_EnableInternalRegulator(ADC1);

    <wait for ADC internal voltage regulator stabilization>

    LL_ADC_StartCalibration(ADC1, LL_ADC_SINGLE_ENDED);

    <Poll for ADC effectively calibrated>

    #LL_ADC_Enable(ADC1);

To save time, you can avoid to recalibrate the ADC at each wake-up:

You can perform a calibration once and save calibration factor in RAM using '

LL_ADC_GetCalibrationFactor(ADC1, LL_ADC_SINGLE_ENDED)

',

then apply it at each wake-up using function '

LL_ADC_SetCalibrationFactor(ADC1, LL_ADC_SINGLE_ENDED)

'.

The LL driver provides a solution more optimized in code size and speed.

It allows you to update only ADC operation parameters, other ADC configuration parameters (channels, sampling time, ...) remains unchanged.

LL driver for STM32L4 can be managed by cubeMx (in Project Settings -> Advanced Settings -> Driver -> {HAL; LL})

or in STM32L4 FW package and can be downloaded here:

http://www.st.com/en/embedded-software/stm32cubel4.html

You can find an example here: STM32Cube_FW_L4_V1.7.0\Projects\STM32L476RG-Nucleo\Examples_LL\ADC\ADC_MultiChannelSingleConversion\

#