Jump to content

Simple LPM4 serial demo ... does not work

Recommended Posts

Energia doesn't work that nicely with low power modes.

Serial.println does not actually print the line to the serial interface, it prints it to a buffer that is written to the interface after an iteration of loop is done.

If you really want to do LPM4, don't use Energia (for now), it won't play nice with you. Rather write a plain program in CCS/GCC.

Also, to keep your pipelines clear, it is recommended that you always do a nop after entering LPM. I think thee is this intrinsic called __no_operation().

Link to post
Share on other sites

Energia does work nicely with LPM modes.


Use the newly minted (as of Energia 13) suspend(), sleep(), sleepSeconds() and wakeup() (latter can be run inside the interrupt routine) calls to perform your sleep operations.


suspend() in particular performs LPM4.  Millis should not increment during this time.


Also, I highly recommend issuing "Serial.flush()" before running any of the sleep/suspend calls.  Moreover, serial data won't really work correctly inside an ISR, so don't depend on it; structure your sketch so your loop() performs all serial calls and your ISR just issues wakeup().

Link to post
Share on other sites

Thanks for the instructions,

i have changed the code , now I 'm going to measure the current

int test;

void setup() 
pinMode(P1_3, INPUT_PULLUP); 
attachInterrupt(P1_3, awake, FALLING);


void loop() 
 if (test == 1) {
   Serial.println("Button pressed");
   Serial.println("doing some special stuff");
   Serial.println("doing NOOP");
   test = 0;
 suspend(); // start in ultra low power mode, all work is done in the ISR routines

void awake(void)
  test = 1;
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...