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

kinetis: Add LPM implementation #2605

Closed
wants to merge 11 commits into from

Conversation

jnohlgard
Copy link
Member

This PR depends on the atomic counters in #2321 - merged

Add support for Kinetis power modes: WAIT, STOP, VLPS, LLS.

Also included is a refactoring of the UART driver to allow low power modes while still being responsive to RX bytes and prevent deep sleep modes when the last TX byte has not yet been transmitted on the line. This requires using TX interrupts to detect when a transmission is done.

The deepest possible hardware sleep mode will be dynamically selected when lpm_set(LPM_IDLE).

Missing power modes:

  • VLLSx (requires substantial work in the startup code)
  • VLPW, VLPR (needs some updates in the bus drivers to reconfigure bus speeds for low power mode)

Tested on:

  • k60/mulle

@jnohlgard jnohlgard added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Platform: ARM Platform: This PR/issue effects ARM-based platforms labels Mar 16, 2015
@jfischer-no jfischer-no self-assigned this Mar 16, 2015
@jfischer-no jfischer-no added the State: waiting for other PR State: The PR requires another PR to be merged first label Mar 16, 2015
@jnohlgard jnohlgard added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Mar 28, 2015
@jnohlgard
Copy link
Member Author

Added a small bug fix for setting up the NVIC when initializing blocking mode.

@OlegHahm OlegHahm force-pushed the master branch 3 times, most recently from 9f184dd to 45554bf Compare March 31, 2015 13:01
@jnohlgard jnohlgard mentioned this pull request Apr 28, 2015
@jnohlgard jnohlgard removed the State: waiting for other PR State: The PR requires another PR to be merged first label May 8, 2015
@jnohlgard
Copy link
Member Author

Rebased since #2321 was merged.

@jnohlgard
Copy link
Member Author

ping @jfischer-phytec-iot

Ready for review

@jfischer-no
Copy link
Contributor

I will adapt and test it on pba-d-01-kw2x.

@jnohlgard
Copy link
Member Author

I should add a DSB instruction before the WFI.

@jnohlgard
Copy link
Member Author

rebased, added DSB before WFI

@jfischer-no
Copy link
Contributor

@gebart a0699b0 makes UART broken on the kw2x, the interrupts (from the uart) will be no longer triggered. If I comment out jnohlgard@a0699b0#diff-0f87a847fbd98c6b77134bcd0c723ee5R366 , uart interrupts works again. I still have not figured out why.

@jnohlgard
Copy link
Member Author

@jfischer-phytec-iot can you try again with the newly rebased version?
I fixed a bug where the system would deadlock if printf was called with interrupts disabled.

Did UART TX still work when you commented out the line you mentioned?

@jfischer-no
Copy link
Contributor

@gebart Well, I will try during the day.

@jfischer-no
Copy link
Contributor

@gebart I have tested fdaf098 on kw2x and k64f, uart works 🎆 . I will test LPM tomorrow.

KINETIS_LPM_EDGE_RISING = 0b01,
/** Wake on falling edge */
KINETIS_LPM_EDGE_FALLING = 0b10,
/** Wake on any logic change */
Copy link
Contributor

Choose a reason for hiding this comment

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

over-commented, the identifiers are self-explanatory

@jfischer-no
Copy link
Contributor

@gebart I've implemented a lpm command (lpm [sleep, powerdown, off]) for the shell and now I see that without proper power manager, we will not get anywhere.

@jnohlgard
Copy link
Member Author

I managed to get everything down to 100 µA in VLPS, and around 50 µA in LLS, using the hello-world example (so no processes are running except for the LPTMR overflow ISR handler every 2 seconds). To get low power I had to add initialization code for some of the on-board devices (flash memory and radio transceiver) to trigger low power modes during boot. It does not seem to affect the device initialization performed by the at86rf231 driver.

@jfischer-phytec-iot Do you have any opinions on this method? Hard coding small init sequences for on board devices inside the board_init function, even when the actual driver for the device has not been enabled in the build.

@jfischer-phytec-iot I looked at your suggestion, it was something like that I had in mind when I opened #2927. I like it, do you think we should merge this first and then do a separate PR for the power manager, or do the power manager first, or combine the two in one PR? I think this one (#2605) is pretty close to being mergable, but we will still have to rewrite it when we introduce the power manager.

@jonas-rem jonas-rem mentioned this pull request Jul 9, 2015
3 tasks
@jnohlgard jnohlgard added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 9, 2015
@OlegHahm OlegHahm added the Area: pm Area: (Low) power management label Dec 13, 2015
@zhuoshuguo
Copy link
Contributor

@gebart Ping. A kind reminder for rebase.

@miri64 miri64 modified the milestone: Release 2016.07 Mar 29, 2016
@jnohlgard jnohlgard removed this from the Release 2016.07 milestone Jul 12, 2016
@jnohlgard
Copy link
Member Author

on hold until xtimer catches up

@miri64
Copy link
Member

miri64 commented Jan 13, 2017

With #6160 merged: Is this still relevant?

@smlng
Copy link
Member

smlng commented Mar 6, 2017

lpm was removed in #6160, as @miri64 already said. Hence, +1 for closing this one

@PeterKietzmann PeterKietzmann added the State: archived State: The PR has been archived for possible future re-adaptation label Mar 28, 2017
@PeterKietzmann
Copy link
Member

Guess it's outdated. Will close with memo label set. @gebart please reopen if I'm mistaken.

@maribu
Copy link
Member

maribu commented Jun 4, 2020

This PR is still referred to from the mulle boards doc. Can someone familiar with the board update the doc?

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 CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms State: archived State: The PR has been archived for possible future re-adaptation 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.

8 participants