Skip to content

Support for Low Power Modes #15

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

Open
RossPorter506 opened this issue Apr 15, 2025 · 2 comments
Open

Support for Low Power Modes #15

RossPorter506 opened this issue Apr 15, 2025 · 2 comments

Comments

@RossPorter506
Copy link

Hi,

Is there any way to interact with the MSP430's various low power modes?
In C this is done through compiler intrinsics like __bis_SR_register() and __bic_SR_register_on_exit().

@cr1901
Copy link
Contributor

cr1901 commented Apr 15, 2025

This was discussed here. Short version:

  • LLVM doesn't implement the intrinsics.
  • An optimized inline asm implementation needs to know the surrounding codegen before codegen actually occurs.
  • A Rust implementation of the intrinsics requires an LLVM feature that is likely to never be stabilized.
  • A slightly less optimal version using naked functions should be possible, where the outer naked interrupt handler- the one that the vector points to- immediately calls an inner interrupt function. I've never personally implemented this, but @pftbest gave an example code snippet1. I also believe @vadixidav got it working, and I never followed up.
  1. Note that the code snippet implements a hypothetical __bis_SR_register_on_entry() :P. I think on_exit semantics would require pushing a fake return address and flags onto the stack, and then jmping to the inner function, and then bic, since the inner function will end with reti.

@vadixidav
Copy link

vadixidav commented Apr 16, 2025

It has been a while since I touched this. We ended up not using MSP430 ultimately, so I didn't feel the need to continue working on this. Everything I did should be available in the fork I have. If something is missing (downstream), let me know, and I might be able to dig it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants