-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/stm32_common: minimize power consumption on STM32L1 #10052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@MichelRottleuthner this is a good candidate for you to review, right :-)? |
@olegart would you address the codacy issue please? |
First one addressed, on the second issue (whether uint32_t is an unsigned int or a long unsigned int) Codacy is in disagreement with gcc-7. |
05bfeaf
to
08398f3
Compare
@@ -49,6 +49,20 @@ void cpu_init(void) | |||
periph_clk_en(APB1, BIT_APB_PWREN); | |||
/* initialize the system clock as configured in the periph_conf.h */ | |||
stmclk_init_sysclk(); | |||
|
|||
#if defined(CPU_FAM_STM32L1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is valid for the whole stm32 family AFAIK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's valid, but not needed at least on L0 and L4 - they have GPIO configured as analog inputs by default (see default MODER value in the Reference Manual).
Not sure about F1 (not an energy-efficient series anyway), but probably newer F-series don't need it either.
Added option (enabled by default) to preserve the state of JTAG pins - PA13, PA14, PA15, PB2 and PB3 configured as Alternate Function Mode. Doesn't affect power consumption if those pins are left floated. |
Closing since ##11832 was merged. |
Contribution description
Automatically configure all STM32L1 GPIOs as analog inputs.
GPIOs on STM32L1 MCUs are configured as digital inputs with Schmitt triggers, which means, if they are left floating, their power consumption is not 0 but few microamperes per GPIO due to random noise on high-impedance pin and constant random trigger switching.
To achieve minimum possible consumption, GPIOs must be reconfigured as analog inputs. It can be done automatically during MCU initialization.
Function needs cpu_check_address to check what GPIOs are available (it depends on MCU package and so can't be deduced from MCU model data available to RIOT).
Newer STM32 energy-efficient series (L0, L4) already have GPIO configured as AIN by default.
Testing procedure
STM32L1 power consumption without this patch in STOP+RTC mode and GPIOs left floating may be as high as 100 uA. With the patch, it should be < 2 uA.
Issues/PRs references
Depends on PR #10051