Other Parts Discussed in Thread: MSP430G2553
Hello there,
I want to try a little programm from Aldo Briano, here is the wiki link:
processors.wiki.ti.com/.../MSP430_LaunchPad_Low_Power_Mode.
Programm goes in low power mode (CPUOFF and GIE in status register are 1),
but I cannot wake up the CPU by pressing P1.3 button.
I have launchpad MSP-EXP430G2 with MSP430G2553 Rev. 1.5, there is no crystal soldered and Pullup resistor R34 and capacitor C24 on P1.3 are removed. I work with CCS Version: 6.2.0.00050.
I am using VLOCLK and ACLK for energy saving. I think it doesn´t matter witch low power mode I am selecting. Code should work with any mode.
Here is the code:
//******************************************************************************
// MSP430G2xx Demo - WDT, Low Power Mode, Interval Overflow ISR, DCO SMCLK
//
// Description: Go to LowPowerMode using software timed by the WDT ISR. The LED
// will turn off when sleeping, Port 1 interrupt will awake the mcu and turn on
// LED. The mcu will sleep at approximately 250 * 32ms based on default
// DCO/SMCLK clock source used in this example for the WDT.
// ACLK = n/a, MCLK = SMCLK = default
//
// MSP430G2xxx
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
// Aldo Briano
// Texas Instruments Inc.
// July 2010
//******************************************************************************
#include <msp430g2553.h>
unsigned int wdtCounter = 0;
void main(void)
{
WDTCTL = WDT_MDLY_32; // Set Watchdog Timer interval to ~32ms
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR |= BIT0;// Set P1.0 to output direction
P1OUT |= BIT0; // Turn on LED at 1.0
P1REN |= BIT3;// Enable resistor on SW2 (P1.3)
P1DIR |= BIT3;// Set P1.3 to output direction to prevent floating
P1OUT |= BIT3; // Enable Pull Up on SW2 (P1.3)
P1IE |= BIT3; // enable P1.3 interrupt
//P1IES |= BIT3;
BCSCTL3 =LFXT1S_2; // run ACLK from VLO
__enable_interrupt();
for(;;)
{
}
}
// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
#pragma INTERRUPT(watchdog_timer)
void watchdog_timer(void)
{
if(wdtCounter == 249)
{
P1OUT = 0x00; // P1.0 turn off
wdtCounter = 0;
__bis_SR_register(LPM0_bits + GIE); // Enter LPM w/interrupt
}
else
{
wdtCounter++;
}
}
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
#pragma INTERRUPT (Port_1)
void Port_1(void)
{
wdtCounter = 0; // reset watchdog timer counter
P1OUT |= 0x01; // turn LED on
P1IFG = 0x0;
__bic_SR_register_on_exit(LPM0_bits); // wake up from low power mode
}