Skip to content
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

cpu/stm32: optimize power consumption #11359

Closed
wants to merge 6 commits into from

Conversation

fjmolinas
Copy link
Contributor

@fjmolinas fjmolinas commented Apr 8, 2019

Contribution description

This PR is based on previous work in #8403 & #10052. On start-up it configures all GPIO's as AIN.
On other boards of the STM32STM32L family (L0 & L4) this is done by default. There for this is only done for STM32L1 and STM32F0-7 (excluding F1, I don't have one to test).

As stated in this AN, doing this saves the consumption of the input Schmitt trigger. The only case where this shouldn't be done is when the pin is connected to an external driver that has a pull-up or pull-down setting, this should be handled by pertinent drivers.

Testing procedure

Supply voltage for all the below measurement was 3.3V. Al pin headers where disconnected where disconnected, supply was measured directly threw the IDD pin either with a multi meter or NUCLEO-LPM01A power measurement extension.

I don't have an F0 yet, will test as soon as I get one.

As of know when entering STOP mode consumption on stm32f7 is around 1.24mA, with this PR it drops to 350uA (270uA typ f746zg). To test run:

make BOARD=nucleo-f746zg -C tests/periph_pm/ flash

As of know when entering STOP mode consumption on stm32f4 is around 500uA, with this PR it drops to 120uA (datasheet 120uA typ for f446re). To test run:

make BOARD=nucleo-f446re -C tests/periph_pm/ flash

As of know when entering STOP mode consumption on stm32f3 is around 1mA, with this PR it drops to 15.3uA (datasheet 7.4uA typ for f303re). To test run:

make BOARD=nucleo-f303re -C tests/periph_pm/ flash

As of know when entering STOP mode consumption on stm32f2 is around 1.27mA, with this PR it drops to 200uA (datasheet 200uA typ for f207zg). To test run:

make BOARD=nucleo-f207zg -C tests/periph_pm/ flash

As of know when entering STOP mode consumption on stm32f1 is around 100uA, with this PR it drops to 11uA (13.5uA typ f103rb). Tested on nucleo-l103rb:

make BOARD=nucleo-f103rb -C tests/periph_pm/ flash

As of know when entering STOP mode consumption on stm32f0 is around 507uA, with this PR it drops to 10.7uA (3.5uA typ f072rb). To test run:

make BOARD=nucleo-f072rb -C tests/periph_pm/ flash

As of know when entering STOP mode consumption on stm32l1 is around 500uA, with this PR it drops to 1.5uA (datasheet typ 1.4uA for l152re). To test run:

make BOARD=nucleo-l152re -C tests/periph_pm/ flash

NOTE: on nucleo boards if power is measured directly after programming there will be around 200uA of current consumption coming from the stlink. The stlink must start without being connected to the board or power the board externally.

Issues/PRs references

Based on work from #8403 & #10052. Depends on #10051 or #11358. #11489

@fjmolinas fjmolinas changed the title Pr stm32l1 pm cpu/stm32l1: optimize power consumption Apr 8, 2019
cpu/stm32_common/cpu_init.c Outdated Show resolved Hide resolved
@fjmolinas fjmolinas force-pushed the pr_stm32l1_pm branch 2 times, most recently from 1e7c4dc to c08a447 Compare April 8, 2019 19:36
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to avoid hard coded values ?

cpu/stm32_common/cpu_init.c Outdated Show resolved Hide resolved
cpu/stm32_common/cpu_init.c Outdated Show resolved Hide resolved
cpu/stm32_common/cpu_init.c Outdated Show resolved Hide resolved
cpu/stm32_common/cpu_init.c Outdated Show resolved Hide resolved
tests/cpu_cortexm_address_check/main.c Outdated Show resolved Hide resolved
@fjmolinas
Copy link
Contributor Author

fjmolinas commented Apr 12, 2019

@aabadie @vincent-d I extended the PR for F* minus F1 and F0 (which I haven't tested), I moved around some code to periph_gpio.c, how do you fill about this? Also removed the use of cpu_check_addressed, It didn't work in some very specific cases, using IS_GPIO_INSTANCE() cmsis macro works better.

@fjmolinas fjmolinas changed the title cpu/stm32l1: optimize power consumption cpu/stm32: optimize power consumption Apr 12, 2019
@fjmolinas fjmolinas force-pushed the pr_stm32l1_pm branch 4 times, most recently from 676efb9 to 8ed7a80 Compare April 12, 2019 14:50
@fjmolinas
Copy link
Contributor Author

@kYc0o I remember you mentioning offline at IETF that you had some problems with this approach, Would you want to state them or is this approach different than what you where telling me?

@kYc0o
Copy link
Contributor

kYc0o commented Apr 18, 2019

Oh my only problem was to have "bricked" boards after the first flash. This was because the SWD pins were configured this way and thus the flasher couldn't read them. Did you experience something like that? To solve it I just needed to push the reset button until openocd was able to identify the board.

@fjmolinas fjmolinas added Area: pm Area: (Low) power management Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Apr 19, 2019
@fjmolinas
Copy link
Contributor Author

@aabadie I now included F1 so it optimizes for all STM32F and STM32L1. Since only STM32L1 is waiting for #11489 I can split up and you can test for STM32F, if you agree.

@fjmolinas
Copy link
Contributor Author

Closed in favor of #11832.

@fjmolinas fjmolinas closed this Jul 12, 2019
@fjmolinas fjmolinas deleted the pr_stm32l1_pm branch August 7, 2019 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: pm Area: (Low) power management Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants