Jump to content
Sign in to follow this  
YVO

Energia ide + msp430f5529lp + low power mode.

Recommended Posts

Hi all,

I want to use the "low power mode" function in my project but it doesn't work properly. My Platform of development is Energia IDE.

I would put the msp430f5529lp in "low power mode" and leave it with the push2 button.

 

 

#include <Energia.h>
#include <msp430f5529.h>

 

volatile int state = HIGH;
volatile int flag = HIGH;
int count = 0;

void setup()
{
  Serial.begin(9600);

interrupts();

  pinMode(GREEN_LED, OUTPUT);
  digitalWrite(GREEN_LED, state);

  /* Enable internal pullup.
   * Without the pin will float and the example will not work */
  pinMode(PUSH2, INPUT_PULLUP);
  attachInterrupt(PUSH2, interrupt, FALLING); // Interrupt is fired whenever button is pressed

}

void loop()
{
  digitalWrite(GREEN_LED, state); //LED starts ON
  if(flag)

   {
    count++;
    Serial.println(count);
    flag = LOW;
   }
 _BIS_SR(LPM3_bits);
}

void interrupt()
{
  state = !state;
  flag = HIGH; 
}

 

 

 

That's fine compile but don't work.  

 

Why ?

WHere is the problem ?

 

Thank you,

Share this post


Link to post
Share on other sites

Thank you for your answer,

 

What do you mean ?

 

My board is in low power mode but can't wake up.

 

Where do I to write the line for that ?

Share this post


Link to post
Share on other sites

There is an easy way to do this using Energia functions that was posted by spirilis elsewhere.  Here is an example:

/*
  Demonstrates a way to utilize LaunchPad low power modes with the
  sleep(), sleepSeconds(), suspend() and wakeup() functions in
  Energia. The LaunchPad will blink the red LED 3 times and
  demonstrate sleep() and sleepSeconds().  It then goes into suspend()
  but will wake up and start over again if the button is pushed.
  sleep() and sleepSeconds() use LPM3. suspend() uses LPM4.
*/
void setup()
{
 pinMode(RED_LED, OUTPUT);                  // Make red LED an output
 pinMode(PUSH1, INPUT_PULLUP);              // Make push button input
 attachInterrupt(PUSH1, interrupt, FALLING);// Attach ISR to PUSH1
}

void loop()
{
  // Flash the LED - use sleep and sleepSeconds to save power by going
  // into LPM3
  for (int i = 0; i < 3; i++)           
  {
    digitalWrite(RED_LED, HIGH);
    sleep(200);                        // use sleep for millis
    digitalWrite(RED_LED, LOW);
    sleepSeconds(1);                   // use sleepSeconds for seconds
  }
  // Suspend and go into LPM4
  suspend();
}
void interrupt()
{
  wakeup();                            // wake up if button is pushed
}

Share this post


Link to post
Share on other sites

Hi Fmilburn,

 

I test this code but it's not good. The function "sleep();", "sleepSeconds();" and "wakeup();" aren't declared.

Share this post


Link to post
Share on other sites

Great...Thank you all,

 

I worked with version 12 and with the version 15, it's okay.

 

With my board, I have 2.5mA when it's in suspend().

 

Is what I could have even less ?

Share this post


Link to post
Share on other sites

Great...Thank you all,

 

I worked with version 12 and with the version 15, it's okay.

 

With my board, I have 2.5mA when it's in suspend().

 

Is what I could have even less ?

Probably.  Make sure all I/O ports are set to a stable value, not just left floating in input mode (which they are by default)... that goes for ALL I/O ports.  Also make sure you're not counting the power consumption of the FET up above.  Should get sub-10uA when you're golden.  Assuming nothing else in your circuit is also drawing power (no LEDs on, no power sinks/etc)

Share this post


Link to post
Share on other sites

Thank you for you anwser Spirilis,

 

I have all my pin not use in configure   PXDIR = 0x00,  PXIN = 0x00 and PXOUT = 0xFF.

 

That is correct to have all pin in configure High Impedance ?

 

On my launchpad, I have take off all jumper for communicate between  msp430f5529 and emulator eZ-FET Lite.

 

Is what the power cut for eZ-FET Lite and USB HUB ?

Share this post


Link to post
Share on other sites

Thank you for your assistance, I have changes the PUSH variable but it doesn't works.

I've discovered another example here in the forum so that it works as desired.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×