Skip to content

cpu/sam0_common: implement pm_off() #14999

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

Merged
merged 1 commit into from
Jun 20, 2025

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Sep 10, 2020

Contribution description

Use the OFF mode instead of whatever lowest standby / hibernate mode was provided my pm_set()

Testing procedure

pm off should turn off the CPU.

You can verify this in tests/periph/gpio:

init_out 1 5
set 1 5
pm off

master

PB05 will stay HIGH

this PR

PB05 will become floating / LOW

Issues/PRs references

@benpicco benpicco added Area: cpu Area: CPU/MCU ports Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Sep 10, 2020
@dylad dylad self-assigned this Sep 10, 2020
@dylad dylad added this to the Release 2020.10 milestone Sep 10, 2020
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 10, 2020
@dylad
Copy link
Member

dylad commented Sep 10, 2020

Overall looks good. SAMD21 is still the black sheep of SAM0 family but that's the life.
I'll run some tests later.

@dylad
Copy link
Member

dylad commented Sep 16, 2020

I have a good one for you:
SAME54 MCU power consumption in master with pm_off() -> 0.15 mA
SAME54 MCU power consumption with your PR and pm_off() -> 0.50 mA

SAML11 and SAML21 looks good so far.

@benpicco
Copy link
Contributor Author

@dylad I don't have saml10 or sam21 to measure right now - did you see an improvement there?
If so, I'll just add pm_off() to their respective pm.c implementations.

@dylad
Copy link
Member

dylad commented Sep 25, 2020

I don't have saml10 or sam21 to measure right now - did you see an improvement there?

When I did these measurements, I did not see any regression for these families (unlike SAME54) but my amperemeter is not accurate enough to see improvement on a few uA.

@dylad
Copy link
Member

dylad commented Sep 25, 2020

My only issue right now is with SAME54 family for this PR.

@benpicco
Copy link
Contributor Author

The thing is, if this is no improvement over the status quo, I don't see why we should have it.
I'll try to measure for different sam0 boards if it makes a difference anywhere when I'm at the office again.

@benpicco benpicco added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 7, 2020
@benpicco benpicco removed this from the Release 2021.04 milestone Feb 25, 2021
@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 21, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@benpicco benpicco force-pushed the cpu/sam0_common-pm_off branch from aebecac to 1d1f9d5 Compare November 29, 2021 13:56
@github-actions github-actions bot added the Platform: ARM Platform: This PR/issue effects ARM-based platforms label Nov 29, 2021
@benpicco benpicco added State: stale State: The issue / PR has no activity for >185 days and removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Nov 29, 2021
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Nov 29, 2021
@benpicco benpicco added the State: stale State: The issue / PR has no activity for >185 days label Nov 29, 2021
@stale stale bot closed this Mar 2, 2022
@benpicco benpicco reopened this Jun 19, 2025
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Jun 19, 2025
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 19, 2025
@benpicco benpicco force-pushed the cpu/sam0_common-pm_off branch from 1d1f9d5 to 3a52bc6 Compare June 19, 2025 13:03
@benpicco
Copy link
Contributor Author

I'm restoring this because there is an important difference between OFF mode and what we currently have: OFF mode will cut the output of all pins.

@benpicco benpicco requested a review from HendrikVE June 19, 2025 13:59
@riot-ci
Copy link

riot-ci commented Jun 19, 2025

Murdock results

✔️ PASSED

fea0e0f cpu/sam0_common: implement pm_off()

Success Failures Total Runtime
10379 0 10379 13m:28s

Artifacts

PM->SLEEPCFG.bit.SLEEPMODE = PM_SLEEPCFG_SLEEPMODE_OFF;
while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_OFF) {}

cortexm_sleep(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we call sam0_cortexm_sleep instead like we do in pm_set()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nah, this turns off everything with no way to wake up again, so no need to switch clocks are configure GPIOs.

@benpicco benpicco force-pushed the cpu/sam0_common-pm_off branch from 3a52bc6 to 6a7bcea Compare June 19, 2025 15:17
Copy link
Contributor

@HendrikVE HendrikVE left a comment

Choose a reason for hiding this comment

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

I can confirm that the GPIOs turn off with this power mode.

Copy link
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

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

I don't have the hardware to test this, but if you and HendrikVE tested it successfully, that is sufficient for me.

You can squash the changes directly.

@benpicco benpicco force-pushed the cpu/sam0_common-pm_off branch from 2f4dba2 to fea0e0f Compare June 20, 2025 13:33
@crasbe crasbe added this pull request to the merge queue Jun 20, 2025
Merged via the queue into RIOT-OS:master with commit 3d7b5b0 Jun 20, 2025
25 checks passed
@benpicco benpicco deleted the cpu/sam0_common-pm_off branch June 23, 2025 08:58
@Teufelchen1 Teufelchen1 added this to the Release 2025.07 milestone Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports 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: 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.

9 participants