Hi,
I am trying to generate a LMP4.5 exit however the device never detects the interrupt on my PCB.
I have the MCU to go into deep sleep mode (LMP4.5) and as soon as I press a switch on pin 2.4 to come out of this mode.
My code is as follows:
int main() { WDTCTL = WDTPW + WDTHOLD; // stop watchdog timer P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF; P5DIR = 0xFF; P6DIR = 0xFF; P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF; P5REN = 0xFF; P6REN = 0xFF; P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00; P5OUT = 0x00; P6OUT = 0x00; // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Configure 16MHz XTAL // Configure one FRAM waitstate as required by the device datasheet for MCLK // operation beyond 8MHz _before_ configuring the clock system. FRCTL0 = FRCTLPW | NWAITS_1; CSCTL6 |= XTS + XT1HFFREQ_2; // Select XT1 HF mode // Set the appropriate high frequency for the crystal @16MHz CSCTL4 = SELMS__XT1CLK | SELA__REFOCLK; // Set MCLK = XT1CLK = 4MHz // XT1CLK = MCLK and SMCLK source P2SEL1 |= BIT6 | BIT7; // P2.6~P2.7: crystal pins do { CSCTL7 &= ~(XT1OFFG | DCOFFG); // Clear XT1 and DCO fault flag SFRIFG1 &= ~OFIFG; } while (SFRIFG1 & OFIFG); // Test oscillator fault flag CSCTL5 |= DIVM_0 | DIVS_1; // MCLK = XT1CLK = 16MHZ, // SMCLK = MCLK/2 = 8MHz // Determine whether we are coming out of an LPMx.5 or a regular RESET. if (SYSRSTIV == SYSRSTIV_LPM5WU) // MSP430 just woke up from LPMx.5 { //Do nothing let the FW run } else { // Device powered up from a cold start. // It configures the device and puts the device into LPM4.5 P2DIR &= ~(BIT4); // Configure P2.4 as input direction pin P2OUT &= ~(BIT4); // Configure P2.4 as pulled-down P2REN |= BIT4; // P2.4 pull-up register enable P2IES &= ~(BIT4); // P2.4 Low/Hi edge P2IFG = 0; // Clear all P2 interrupt flags P2IE |= BIT4; // P2.4 interrupt enabled // Explicitly clear RTC control registers to disable it // just in case if the RTC was previously enabled disable_RTC(); PMMCTL0_H = PMMPW_H; // Open PMM Registers for write PMMCTL0_L |= PMMREGOFF; // and set PMMREGOFF PMMCTL0_H = 0; // Lock PMM Registers // Enter LPM4 Note that this operation does not return. The LPM4.5 // will exit through a RESET event, resulting in a re-start // of the code. __bis_SR_register(LPM4_bits | GIE); } // Main program while(1) { }
The above enters in LMP4.5 and while debugging and applying a reset on reset pin it detects but does not detect the Pin2.4 interrupt. What am I doing wrong?
Thanks,
Vlad