2017-03-07 05:32 AM
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 #stm32l42017-03-07 05:57 AM
Hi
TARRAGO.DANIEL
Please try to refer to
application note abouthow to get the best ADC accuracy in STM32 microcontrollers,it may be helpful.-Nesrine-
2017-03-08 09:48 AM
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.
HAL_ADC_DeInit();
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:
HAL_ADC_Init();
HAL_ADCEx_Calibration_Start()
HAL_ADC_ConfigChannel();
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\
#