Skip to content

cpu: lpc1768: provide periph_pm#8861

Merged
aabadie merged 1 commit intoRIOT-OS:masterfrom
basilfx:feature/lpc1768_pm
Apr 4, 2018
Merged

cpu: lpc1768: provide periph_pm#8861
aabadie merged 1 commit intoRIOT-OS:masterfrom
basilfx:feature/lpc1768_pm

Conversation

@basilfx
Copy link
Copy Markdown
Member

@basilfx basilfx commented Apr 1, 2018

Contribution description

This provides power management for the LPC1768. It's based on this application note.

Tested using #8848 on the Seeeduino Arch-Pro. Although I could only measure milli-amps, I do see a difference when forcing different power modes.

Issues/PRs references

None

@basilfx basilfx added Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 1, 2018
@basilfx basilfx force-pushed the feature/lpc1768_pm branch from 59bfd39 to 587a41c Compare April 3, 2018 16:33
@basilfx
Copy link
Copy Markdown
Member Author

basilfx commented Apr 3, 2018

Decided to modify the board to measure power on the 3V3 rail instead of the USB 5V rail. It's still connected to additional IC's, but it should give an idea.

power

@basilfx basilfx requested a review from aabadie April 4, 2018 08:17
Copy link
Copy Markdown
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.

Untested ACK (trusting your results)

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Apr 4, 2018

And go!

@aabadie aabadie merged commit 4b5e364 into RIOT-OS:master Apr 4, 2018
LPC_SC->PCON = 0x00;
cortexm_sleep(1);
break;
case 2:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be the default case, or is there a use-case for blocking mode 2?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The way I interpret pm_layered.h is as follows:

  • Mode 0 to PM_NUM_MODES - 1 apply power management
  • Mode PM_NUM_MODES (the implicit one) doesn't.

That's what I have implemented here (PM_NUM_MODES is 3).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK!

It's just that the mode PM_NUM_MODES sets the CPU to idle on the other cortex-m. So I was wondering if LPC_SC->PCON = 0x00; means "no power management other than CPU idle", in which case I suggest setting PM_NUM_MODES=2.

Copy link
Copy Markdown
Member Author

@basilfx basilfx Apr 4, 2018

Choose a reason for hiding this comment

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

LPC_SC->PCON = 0x00; is needed to ensure that it doesn't erroneously enter deep sleep on __WFI(). This could be the case if another piece of code sets this before entering idle mode.

So now I understand that PM_NUM_MODES == 3 should enter idle mode (instead of while(1))? Then I should change PM_NUM_MODES to 2, so that the implicit idle power mode is __WFI(), right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, thanks! I'll create another PR to fix this.

Just one more question: should I then add the default case, or case 2 in combination with an assert(mode <= PM_NUM_MODES)?

IMHO mode > PM_NUM_MODES is wrong.

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 Apr 4, 2018

Choose a reason for hiding this comment

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

IMHO mode > PM_NUM_MODES is wrong.

True, but we should rather catch that in pm_layered.c instead of adding those asserts to every pm_set implementation. IMO the default case will cause the least maintanance in the future. ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Created #8874 to address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants