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/msp430: implement power management #20613

Merged
merged 3 commits into from
May 7, 2024
Merged

Conversation

maribu
Copy link
Member

@maribu maribu commented Apr 23, 2024

Contribution description

This implements power management for the MSP430.

Testing procedure

Flash this on any MSP430 board. No regressions should occur, but power consumption should drop. Your mileage may wary, though:

  • There will be zero power safe while the CPU is still in use
  • There will be more power saving when clock domains can be disabled

Benchmarks

I attached a power monitor in-between the USB connection to our Olimex MSP430Hxxx breakout board and monitored the power consumption in the following scenarios:

  1. Nothing connected to the USB (e.g. Noise of the monitor)
  2. The breakout board without the header board connected and the USB2UART adapter in use (/dev/ttyUSB0 open). This is the baseline, as this power is used even without the MCU actually attached
  3. The breakout + header board plugged in, exmaples/default from master flashed, and first help then ps run
  4. The breakout + header board plugged in, exmaples/default from this PR flashed, and first help then ps run
Benchmark on the olimex-msp430h1611

olimex-msp430h1611

Benchmark on the olimex-msp430h2618

olimex-msp430h2618

Conclusion

The power consumption goes down pretty much to the base line for each MCU family while the MCU is not in use, but spikes when there is activity. It looks pretty much like one would expect.

Issues/PRs references

@github-actions github-actions bot added Platform: MSP Platform: This PR/issue effects MSP-based platforms Area: cpu Area: CPU/MCU ports labels Apr 23, 2024
@maribu maribu marked this pull request as ready for review April 24, 2024 19:17
@maribu maribu added the State: waiting for other PR State: The PR requires another PR to be merged first label Apr 25, 2024
@maribu
Copy link
Member Author

maribu commented Apr 25, 2024

Now with low symbol rates working on the MSP430 F2xx, it turned out that the auxiliary clock will not be auto-acquired by the USCI. (The datasheet indeed does only claim that the SMCLK will be acquired as needed by the UART peripheral, so this does check out.)

Anyway, fixed :)

@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Apr 26, 2024
@riot-ci
Copy link

riot-ci commented Apr 26, 2024

Murdock results

✔️ PASSED

d5839ca examples,tests: Bump Makefile.ci for MSP430 boards

Success Failures Total Runtime
10083 0 10083 15m:35s

Artifacts

The register r2 is the status register, which has the SR alias. Using
SR is a lot more readable than r2.
This implements `pm_set_lowest()` for the MSP430. Unlike most other
platforms, it intentionally does not use pm_layered. It is pretty
similar to `pm_layered` in that is does use reference counters, but it
uses them for two independent clock sources.

The main difference is that the low frequency clock domain can be
disabled even when the high frequency clock is still active. With the
layers, disabling layer n-1 while layer n is still blocked would not
work.
@maribu
Copy link
Member Author

maribu commented Apr 26, 2024

rebased on top of #20623

@benpicco benpicco enabled auto-merge May 6, 2024 14:39
@benpicco benpicco added this pull request to the merge queue May 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 6, 2024
@maribu maribu enabled auto-merge May 7, 2024 05:58
@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: examples Area: Example Applications labels May 7, 2024
@maribu maribu added this pull request to the merge queue May 7, 2024
Merged via the queue into RIOT-OS:master with commit 59956fd May 7, 2024
25 checks passed
@maribu maribu deleted the cpu/msp430/pm branch May 7, 2024 11:05
@maribu
Copy link
Member Author

maribu commented May 7, 2024

Thx a bunch :)

@mguetschow mguetschow added this to the Release 2024.07 milestone Jul 5, 2024
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 Area: examples Area: Example Applications Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: MSP Platform: This PR/issue effects MSP-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants