This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430FR2000: Issues with LPM3.5

Part Number: MSP430FR2000

Tool/software: Code Composer Studio

Hello,

When the code starts I am planning to turn ON a switch (at P1.7). Then an interrupt at P1.3 should OFF the switch and turn ON RTC. With RTC interrupt switch should turn ON. Repeat. I am unable to make it work. I am unable to understand when MCU wakes up of LPM3.5 does the whole main code repeat or only some part of it. Does the ISR be executed first or after executing the main.

Regards,

Prudhvi Sagar

#include <msp430.h>


int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;        // Stop watchdog timer

    // Configure GPIO
    P1OUT = 0x00;                 // Clear P1.0 output latch /P1.3 Pulldown
    P1DIR = ~BIT3;                   // Set P1.3 to input direction
    P2OUT = 0x00;                    // Unused pins to LP State
    P2DIR = 0xFF;

    P2SEL1 = BIT6 | BIT7;            // P2.6~P2.7: crystal pins
    SYSCFG0 = FRWPPW;            // Enable FRAM write access

    PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance
                         // mode to activate previously configured port settings
 
    do
    {
        CSCTL7 = 0;             // Clear XT1 fault flag
        SFRIFG1 = 0;            // Clear fault flag
    } while (SFRIFG1 & OFIFG);  // Test oscillator fault flag
 
    if (SYSRSTIV == SYSRSTIV_LPM5WU)        // When woken up from LPM3.5, reinit
    {
        __enable_interrupt();

    }
    else
    {
        // Device powered up from a cold start.
      
        P1REN = BIT3;                    // P1.3 pull-down register enable
        P1IES = 0x00;                    // P1.3 Low/High edge
        P1IE  = BIT3;                    // P1.3 interrupt enabled
        CSCTL4 = SELA__XT1CLK;           // Set ACLK = XT1CLK = 32768Hz...CHANGE: initial for use internal clock REFO
    }
    P1OUT ^= BIT7;     //Turn on switch

    __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3, enable interrupt
}

/**
* RTC interrupt service routine
*/
//CHANGE: Keep switch ON and wait indefinitely unitl GPIO interrupt
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR(void)
{
    switch(__even_in_range(RTCIV,RTCIV__RTCIFG))
    {
        case  RTCIV__NONE:   break;          // No interrupt
        case  RTCIV__RTCIFG:                 // RTC Overflow

                    
                P1OUT ^= BIT7;     //Turn on switch
                P1OUT ^= BIT5;
                   
                    P1IE = BIT3;                 // Enable RTC STart Interrupt
                    RTCCTL = RTCSS_2 | RTCSR | RTCPS__1024; //Stop RTC
 
            // Enter LPM3.5 mode with interrupts enabled. Note that this
            //operation does not return. The LPM3.5 will exit through a
            //RESETevent, resulting in a re-start of the code.
             PMMCTL0_H = PMMPW_H;         // Open PMM Registers for write
             PMMCTL0_L |= PMMREGOFF;      // and set PMMREGOFF
             __bis_SR_register_on_exit(LPM3_bits | GIE);
             //__no_operation();
               break;
        default: break;
    }
}

/**
* Port 1 interrupt service routine
*/
//Every interrupt turn switch OFF....Start RTC....Enter LPM

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
    timeIncrement = 0;                        //Clear Software Counter
    P1OUT ^= BIT7;     //Turn OFF switch

    RTCMOD = (32-1)*10;
    // Source  = XT1, divided by 1024, Start RTC
    RTCCTL = RTCSS_2 | RTCSR | RTCPS__1024 | RTCIE;
    P1IE  = 0x00;
    P1IFG = 0x00;                            //Clear P1.3 IFG
    // Enter LPM3.5 mode with interrupts enabled. Note that this
    //operation does not return. The LPM3.5 will exit through a RESET
    //event, resulting in a re-start of the code.
     PMMCTL0_H = PMMPW_H;                // Open PMM Registers for write
    PMMCTL0_L |= PMMREGOFF;             // and set PMMREGOFF
     __bis_SR_register_on_exit(LPM3_bits | GIE);
     //__no_operation();
}

**Attention** This is a public forum