AnalogIn and low power sleep #254
Unanswered
timIdeaTech
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Orininally posted over on the mbed forums but no takers...
I’m working with the STM32L072CZ, but this would apply to the STM32L0x range and even more general.
When I add an AnalogIn, either by global declaration or via new(), my sleep current increases by about 270 uA. In this case the AnalogIn is only used during wake up events and very intermittently.
My first stab was to enable the auto low power feature in analogin_device.c target file:
obj->handle.Init.LowPowerAutoPowerOff = ENABLE;
This got me a fair ways by about 240uA.
A further 30 uA I tracked down to both the ADC (CR_ADEN) and ADC voltage regulator (CR_ADVREGEN) being on.
The default is to be clocked by PCLK rather than HSI16, so that is taken care of by sleep(). I noticed that the .read_u16() functions actually check if the ADEN bit is enabled, but only if the auto power off bit isn't enabled. My quick bit bang solution is a simple disable function I call after my last .read_u16() during event processing (yes, I'm sure there is a more elegant HAL way to do this...):
It seems odd that there is no mbed standard way to to reduce (deep)sleep power when using an AnalogIn, or am I missing something? I'm thinking a semaphore mechanism or similar that auto powers down the relevant ADCx during "sleep()" if all the associated inputs are configured for deep sleep? Given some time I might try to figure that out.
Beta Was this translation helpful? Give feedback.
All reactions