Jump to content
Sign in to follow this  
Magnum

Sleep mode

Recommended Posts

I am using LauncPad MSP430G2 revision 1.5, MSP430G2553, Grove base boosterpack, Energia 0016, Windows 7 64-bit

 

My project will need to start in the sleep mode. When I press the button P1.3, it will display on the LCD. And after 10sec, it will go back to sleep mode. Can somebody help me with the coding. 

 

PS : I am new to Energia and have never touched programming before. Sorry if i didnt make it clear enough. 

Share this post


Link to post
Share on other sites

Hi @@Magnum,

 

It sounds like you need to go through some of the examples and training  that is available.  I suggest something like this to get started:

 

1) Get your button working - there is an example in Energia

2) Add the LCD and get it working - again there are examples in Energia and in 43oh for using various LCDs

3) Learn about external interrupts at energia.nu and get them working with the button

 

EDIT:  If you have already made it this far then please paste your code

 

Good luck with your project!

Share this post


Link to post
Share on other sites

 

 

void setup()
{
pinMode(P1_3,INPUT_PULLUP); //Enable inputs on P1_3 (onboard button)
pinMode(P1_0,OUTPUT); //Enable output on P1_0 (onboard red LED)
attachInterrupt(P1_3,Interrupt, FALLING); //attach our interrupt routine to P1_3
}

void loop()
{
LPM4; //whenever the loop runs, switch back into LPM4
//we could put code here that would run after every Interrupt - see warning in text.
}

void Interrupt(void) //Our interrupt routine
{
digitalWrite(P1_0,!digitalRead(P1_0)); //toggle the red LED
};

 

 Hi @@Fmilburn, sorry to trouble you. 

 

Do you happen to know about low power mode. I need to make use of LPM3 and LPM0 in my project instead of the external interrupts. ( I already understand the external interupts in the energia.nu )

 

I found the above quote at another post. But i would like to switch back to LPM3 instead of LPM4 , and also want it to wake up to LPM0 so that it can execute a command and then back to LPM3.

 

Sorry if it is too messy. 

Share this post


Link to post
Share on other sites

Hi @@Magnum

 

It looks like you are making progress.  The suspend() function puts the sketch into LPM4.  See this example.  Note that when an interrupt (in this case caused by the button) occurs, the ISR calls the wakeup() function which returns control to the line following suspend().  It is best to minimize time spent in the ISR.  This example also demonstrates how to use sleep() and sleepSeconds() which use LPM3.  Hope this helps.

Share this post


Link to post
Share on other sites

@@Magnum

 

I should think so....  A good way to approach things like this is to get one thing working at a time and then move it into your code.  So, get the LCD working with the appropriate example and then move the global variables if any above setup() and the setup() portion into the setup() of what you already have working.  Add a lcd.print() where the flashing LED is and you should be there.

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  

×