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/MSP430FR5949: how to move controller to sleep mode

Part Number: MSP430FR5949

Tool/software: Code Composer Studio

hi,

i am using CCS and MSP430FR5949 controller, i want to know how to move the controller into sleep mode, we are working on battery based application, so the prime factor is power consumption, so when the controller is in in idle condition, it should stop consuming power, please guide me how to achieve this.

thanks

  • Hi,

    MSP430 has different Low Power Mode. The difference between them can be seen in the picture bellow. You should choose according to your application.

    To use and better understand LPM, you can refer to our code example.

    msp430fr59xx_lpm0.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR59xx Demo - Enters LPM0 with ACLK = LFXT, MCLK = 1MHz
    //
    //   Description: Configure ACLK = LFXT and enters LPM0.
    //
    //   NOTE: On the FET board: MSP-TS430RGZ48C drives an LED that can show high power numbers
    //   when turned ON. Measure current with LED jumper JP9 disconnected.
    //   LED jumper disconnected.
    //   ACLK = LFXT, MCLK = SMCLK = 1MHz
    //
    //          MSP430FR5969
    //         ---------------
    //     /|\|            XIN|-
    //      | |               |  32KHz Crystal
    //      --|RST        XOUT|-
    //        |               |
    //        |               |
    //        |          P1.0 |---> Disconnect JP9 for power meas.
    //
    //   T. Witt/ P. Thanigai
    //   Texas Instruments Inc.
    //   November 2011
    //   Built with IAR Embedded Workbench V5.30 & Code Composer Studio V5.5
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTTMSEL | WDTSSEL_1 | WDTIS_5; // ACLK, ~1s interrupts
      SFRIE1 |= WDTIE;                          // Enable WDT interrupt
    
      // Configure GPIO
      P1OUT = 0;
      P1DIR = 0xFF;
    
      P2OUT = 0;
      P2DIR = 0xFF;
    
      P3OUT = 0;
      P3DIR = 0xFF;
    
      P4OUT = 0;
      P4DIR = 0xFF;
    
      PJOUT = 0;
      PJSEL0 = BIT4 | BIT5;                     // For XT1
      PJDIR = 0xFFFF;
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
      CSCTL1 = DCOFSEL_0;                       // Set DCO to 1MHz
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers to 1
      CSCTL4 &= ~LFXTOFF;                       // Enable LFXT1
      do
      {
        CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
        SFRIFG1 &= ~OFIFG;
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
      CSCTL0_H = 0;                             // Lock CS registers
    
      P1DIR |= BIT0;                            // Turn on LED
    
      __bis_SR_register(LPM0_bits | GIE);
      __no_operation();                         // For debugger
    }
    
    // Watchdog Timer interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=WDT_VECTOR
    __interrupt void WDT_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(WDT_VECTOR))) WDT_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      P1OUT ^= 0x01;                            // Toggle P1.0 (LED)
    }
    

    msp430fr59xx_lpm3_02.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR59xx Demo - Enters LPM3 with ACLK = VLO
    //
    //   Description: Configures WDT and ACLK to be sourced from VLO and enters LPM3.
    //   Note: On the FET board P1.0 drives an LED that can show high power numbers
    //   when turned ON. Measure current with LED jumper JP3 disconnected.
    //   LED jumper disconnected.
    //   ACLK = VLOCLK = ~9.4KHz, MCLK = SMCLK = 1MHz
    //
    //          MSP430FR5969
    //         ---------------
    //     /|\|               |
    //      | |               |
    //      --|RST            |
    //        |               |
    //        |               |
    //        |          P1.0 |---> Disconnect JP9 for power meas.
    //
    //   T. Witt/ P. Thanigai
    //   Texas Instruments Inc.
    //   December 2011
    //   Built with IAR Embedded Workbench V5.30 & Code Composer Studio V5.5
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTTMSEL | WDTSSEL_2 | WDTIS_5; // VLOCLK, 1s interrupts
      SFRIE1 |= WDTIE;                          // Enable WDT interrupt
    
      // Configure GPIO
      P1OUT = 0;
      P1DIR = 0xFF;
    
      P2OUT = 0;
      P2DIR = 0xFF;
    
      P3OUT = 0;
      P3DIR = 0xFF;
    
      P4OUT = 0;
      P4DIR = 0xFF;
    
      PJOUT = 0;
      PJDIR = 0xFFFF;
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      // Clock System Setup
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
      CSCTL1 = DCOFSEL_0;                       // Set DCO to 1 MHz
      CSCTL2 = SELM__DCOCLK | SELS__DCOCLK | SELA__VLOCLK;
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers to 1
      CSCTL4 = LFXTOFF | HFXTOFF;
      CSCTL0_H = 0;                             // Lock CS registers
    
      P1DIR |= BIT0;                            // Turn on LED
    
      __bis_SR_register(LPM3_bits | GIE);
      __no_operation();                         // For debugger
    }
    
    // Watchdog Timer interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=WDT_VECTOR
    __interrupt void WDT_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(WDT_VECTOR))) WDT_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      P1OUT ^= BIT0;                            // Toggle P1.0 (LED)
    }
    

    msp430fr59xx_lpm3_03.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR59xx Demo - Enters LPM3 with ACLK = LFXT1
    //
    //   Description: Configure ACLK = LFXT1 and enters LPM3.
    //   ACLK = LFXT1 = 32kHz, MCLK = SMCLK = 1MHz
    //   Note: Disconnect debugger session prior to power measurement
    //
    //          MSP430FR5969
    //         ---------------
    //     /|\|            XIN|-
    //      | |               |  32KHz Crystal
    //      --|RST        XOUT|-
    //        |               |
    //        |               |
    //
    //   P. Thanigai
    //   Texas Instruments Inc.
    //   December 2011
    //   Built with IAR Embedded Workbench V5.30 & Code Composer Studio V5.5
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;
    
      // Configure GPIO
      P1OUT = 0;
      P1DIR = 0xFF;
    
      P2OUT = 0;
      P2DIR = 0xFF;
    
      P3OUT = 0;
      P3DIR = 0xFF;
    
      P4OUT = 0;
      P4DIR = 0xFF;
    
      PJOUT = 0;
      PJSEL0 = BIT4 | BIT5;                     // For XT1
      PJDIR = 0xFFFF;
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      // XT1 Setup
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
      CSCTL1 = DCOFSEL_0;                       // Set DCO to 1MHz
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers to 1
      CSCTL4 &= ~LFXTOFF;                       // Enable LFXT1
      do
      {
        CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
        SFRIFG1 &= ~OFIFG;
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
      CSCTL0_H = 0;                             // Lock CS registers
    
      __bis_SR_register(LPM3_bits);
    }
    

    msp430fr59xx_lpm3-5_01.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR59xxx Demo - RTC_B, LPM3.5, & alarm
    //
    //   Description: The RTC_B module is used to set the time, start RTC operation,
    //   and read the time from the respective RTC registers. Software will set the
    //   original time to 11:59:30 am on Friday October 7, 2011. Then the RTC will
    //   be activated through software, and an alarm will be created for the next
    //   minute (12:00:00 pm). The device will then enter LPM3.5 awaiting
    //   the event interrupt. Upon being woken up by the event, the LED on the board
    //   will be set.
    //
    //   ACLK = 32.768kHz, MCLK = SMCLK = DCO = ~1MHz
    //
    //               MSP430FR59xx
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P1.0|--> LED
    //
    //   T. Witt
    //   Texas Instruments Inc.
    //   January 2012
    //   Built with Code Composer Studio V5.5
    //******************************************************************************
    #include <msp430.h>
    
    void Board_Init(void);
    void RTC_Init(void);
    void EnterLPM35(void);
    void WakeUpLPM35(void);
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT
    
      // Determine whether we are coming out of an LPMx.5 or a regular RESET.
      if (SYSRSTIV == SYSRSTIV_LPM5WU)
      {
        // When woken up from LPM3.5, reinit
        WakeUpLPM35();                          // LPMx.5 wakeup specific init code
        __enable_interrupt();                   // The RTC interrupt should trigger now...
        while (1);                              // Forever loop after returning from RTC ISR.
      }
      else
      {
        // Init board & RTC, then enter LPM3.5
        Board_Init();                           // Regular init code for GPIO and CS
        RTC_Init();                             // Regular init code for RTC_B
        EnterLPM35();                           // This function will NOT return.
      }
    }
    
    void Board_Init(void)
    {
      // Port Configuration
      P1OUT = 0x00;
      P1DIR = 0xFF;
      P2OUT = 0x00;
      P2DIR = 0xFF;
      P3OUT = 0x00;
      P3DIR = 0xFF;
      P4OUT = 0x00;
      P4DIR = 0xFF;
      PJOUT = 0x00;
      PJSEL0 |= BIT4 | BIT5;
      PJDIR = 0xFFFF;
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;
    
      // Setup Clocks
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
      CSCTL1 = DCOFSEL_0;                       // Set DCO to 1MHz
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK; // set ACLK = XT1; MCLK = DCO
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers to 1
      CSCTL4 &= ~LFXTOFF;                       // Enable LFXT1
      do
      {
        CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
        SFRIFG1 &= ~OFIFG;
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
      CSCTL0_H = 0;                             // Lock CS registers
    }
    
    void RTC_Init(void)
    {
      // Configure RTC_B
      RTCCTL01 = RTCBCD | RTCHOLD | RTCTEV__MIN | RTCTEVIE; // BCD mode, RTC hold, enable RTC
                                                // event interrupt for each minute
      RTCYEAR = 0x2011;                         // Year = 0x2011
      RTCMON = 0x10;                            // Month = 0x10 = October
      RTCDAY = 0x07;                            // Day = 0x07 = 7th
      RTCDOW = 0x05;                            // Day of week = 0x05 = Friday
      RTCHOUR = 0x11;                           // Hour = 0x11
      RTCMIN = 0x59;                            // Minute = 0x59
      RTCSEC = 0x30;                            // Seconds = 0x30
    
      RTCCTL01 &= ~RTCHOLD;                     // Start RTC calendar mode
    }
    
    void EnterLPM35(void)
    {
      PMMCTL0_H = PMMPW_H;                      // Open PMM Registers for write
      PMMCTL0_L |= PMMREGOFF;                   // and set PMMREGOFF
    
      // 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.
      __bis_SR_register(LPM4_bits | GIE);
    }
    
    void WakeUpLPM35(void)
    {
      // Restore Port settings
      P1OUT = 0x00;
      P1DIR = 0xFF;
      P2OUT = 0x00;
      P2DIR = 0xFF;
      P3OUT = 0x00;
      P3DIR = 0xFF;
      P4OUT = 0x00;
      P4DIR = 0xFF;
      PJOUT = 0x00;
      PJSEL0 |= BIT4 | BIT5;
      PJDIR = 0xFFFF;
    
      // Reconfig/start RTC
      RTCCTL01 |= RTCBCD | RTCHOLD | RTCTEV__MIN | RTCTEVIE; // BCD mode, RTC hold, enable RTC
                                                // event interrupt for each minute
      RTCCTL01 &= ~RTCHOLD;
    
      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings. This will also re-activate the RTC
      // settings.
      PM5CTL0 &= ~LOCKLPM5;
    
      // Restore Clocks so that RTC will be read
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
      CSCTL1 = DCOFSEL_0;                       // Set DCO to 1MHz
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK; // Set ACLK = XT1; MCLK = DCO
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers to 1
      CSCTL4 &= ~LFXTOFF;                       // Enable LFXT1
      do
      {
        CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
        SFRIFG1 &= ~OFIFG;
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
      CSCTL0_H = 0;                             // Lock CS registers
    }
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=RTC_VECTOR
    __interrupt void RTC_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(RTC_VECTOR))) RTC_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch (__even_in_range(RTCIV, RTCIV_RTCOFIFG)){
        case RTCIV_NONE: break;
        case RTCIV_RTCRDYIFG: break;
        case RTCIV_RTCTEVIFG:
          P1OUT |= BIT0;                        // Turn on LED
          break;
        case RTCIV_RTCAIFG: break;
        case RTCIV_RT0PSIFG: break;
        case RTCIV_RT1PSIFG: break;
        case RTCIV_RTCOFIFG: break;
      }
    }
    

    msp430fr59xx_lpm3-5_02.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR59xx Demo - RTC_B in LPM3.5 with 2 second wake-up interval
    //
    //   Description: The RTC_B module is in counter mode with counter interrupt
    //   triggers every 2 seconds. The device will then enter LPM3.5 waiting for
    //   RT1PSIFG interrupt. Upon wake-up from LPMx.5, the device restores the
    //   previous state of P1.0 LED based on the ledState variable. It then toggles
    //   the P1.0 LED on the board and stores the LED state into FRAM memory.
    //   This is a good example to demonstrate how to save the GPIO state before
    //   entering LPMx.5 and restoring the GPIO state upon wake-up.
    //   P4.6 is used as a heartbeat showcasing that the device is either waking
    //   up from a BOR reset or LPMx.5.
    //
    //   ACLK = 32.768kHz, MCLK = SMCLK = DCO = ~1MHz
    //
    //               MSP430FR59xx
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P1.0|--> LED
    //            |             P4.6|--> Probe out/LED
    //
    //   William Goh
    //   Texas Instruments Inc.
    //   January 2013
    //   Built with Code Composer Studio v5.5 and Embedded Workbench v5.60
    //******************************************************************************
    #include <msp430.h>
    
    void initBoard(void);
    void initRtc(void);
    void WakeUpLPM35(void);
    
    // Stores the state of the LED in FRAM where this variable
    // is not C-initialized during start-up. This allows
    // certain variables to easily be restored and managed
    // in a non-volatile memory with no flash charge-pump required.
    // This allows faster start-up time.
    #if defined(__TI_COMPILER_VERSION__)
    #pragma PERSISTENT(ledState);
    unsigned char ledState = 0;
    #elif  defined(__IAR_SYSTEMS_ICC__)
    __persistent unsigned char ledState;
    #else
    // For other compilers, insert this variable into FRAM memory
    unsigned char ledState;
    #endif
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop WDT
    
        // Initialize board
        initBoard();                            // Regular init code for GPIO and CS
    
        // Determine whether we are coming out of an LPMx.5 or a regular RESET.
        if (SYSRSTIV == SYSRSTIV_LPM5WU)
        {
            // When woken up from LPM3.5, reinit
            WakeUpLPM35();                      // LPMx.5 wakeup specific init code
            __enable_interrupt();               // The RTC interrupt should trigger now...
        }
        else
        {
            ledState = 0;                       // Initialize LED state variable
            P1OUT = 0x00;                       // For initialize P1OUT to zero initially
            initRtc();                          // Regular init code for RTC_B
        }
    
        // Use P4.6 LED as a heart beat for to represent device restarted either
        // from LPMx.5 or a complete power-up
        P4OUT |= BIT6;
    
        // Use Timer A for a short delay to blink P1.0 LED
        TA0CCTL0 = CCIE;                        // TACCR0 interrupt enabled
        TA0CCR0 = 1000;
        TA0CTL = TASSEL__ACLK | MC__UP;         // SMCLK, UP mode
        __bis_SR_register(LPM3_bits | GIE);
        TA0CTL &= ~(MC__UP);                    // Stop Timer
    
        P4OUT &= ~BIT6;                         // Clear P4.6 LED
    
        // Sequence to enter LPM3.5.
        PMMCTL0_H = PMMPW_H;                    // Open PMM Registers for write
        PMMCTL0_L |= PMMREGOFF;                 // and set PMMREGOFF
    
        // 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.
        __bis_SR_register(LPM3_bits | GIE);
        __no_operation();
    
        return 1;
    }
    
    void initBoard(void)
    {
        // Port Configuration
        // Restore P1.0 LED state before reset from a variable
        // stored in FRAM
        P1OUT = ledState;
        P1DIR = 0xFF;
        P2OUT = 0x00;
        P2DIR = 0xFF;
        P3OUT = 0x00;
        P3DIR = 0xFF;
        P4OUT = 0x00;
        P4DIR = 0xFF;
        PJOUT = 0x00;
        PJSEL0 |= BIT4 | BIT5;
        PJDIR = 0xFFFF;
    
        // Disable the GPIO power-on default high-impedance mode to activate
        // previously configured port settings
        PM5CTL0 &= ~LOCKLPM5;
    
        // Setup Clocks
        CSCTL0_H = CSKEY >> 8;                  // Unlock CS registers
        CSCTL1 = DCOFSEL_0;                     // Set DCO to 1MHz
        CSCTL2 = SELA_0 | SELS_3 | SELM_3;      // set ACLK = XT1; MCLK = DCO
        CSCTL3 = DIVA_0 | DIVS_0 | DIVM_0;      // Set all dividers to 1
        CSCTL4 &= ~LFXTOFF;                     // Enable LFXT1
    
        do
        {
            CSCTL5 &= ~LFXTOFFG;                // Clear XT1 fault flag
            SFRIFG1 &= ~OFIFG;
        } while (SFRIFG1 & OFIFG);              // Test oscillator fault flag
        CSCTL0_H = 0;                           // Lock CS registers
    }
    
    void initRtc(void)
    {
        // Configure RTC_B
        // Configure BCD mode, stop the RTC, and enable RTC
        RTCCTL01 = RTCBCD | RTCHOLD | RTCTEV_0;
        // Set the RTC second stage divider to 256
        // RTC interrupts every 2 seconds
        RTCPS1CTL = RT1IP_7 | RT1PSIE;
    
        // Start RTC calendar mode
        RTCCTL01 &= ~RTCHOLD;
    }
    
    void WakeUpLPM35(void)
    {
        // Re-configure / start RTC
        // Configure BCD mode, stop the RTC, and enable RTC
        RTCCTL01 |= RTCBCD | RTCHOLD | RTCTEV_0;
        // Set the RTC second stage divider to 256
        // RTC interrupts every 2 seconds
        RTCPS1CTL = RT1IP_7 | RT1PSIE;
    
        // Start RTC calendar mode
        RTCCTL01 &= ~RTCHOLD;
    }
    
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=RTC_VECTOR
    __interrupt void RTC_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(RTC_VECTOR))) RTC_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch (__even_in_range(RTCIV, RTCIV_RTCOFIFG))
        {
            case RTCIV_NONE:      break;
            case RTCIV_RTCRDYIFG: break;
            case RTCIV_RTCTEVIFG: break;
            case RTCIV_RTCAIFG:   break;
            case RTCIV_RT0PSIFG:  break;
            case RTCIV_RT1PSIFG:
                // Toggle the LED on P1.0
                P1OUT ^= BIT0;
    
                // Store P1.0 output state to a variable
                ledState = (P1OUT & BIT0);
                break;
            case RTCIV_RTCOFIFG: break;
        }
    }
    
    // Timer A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=TIMER0_A0_VECTOR
    __interrupt void Timer_A(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer_A (void)
    #else
    #error Compiler not supported!
    #endif
    {
        __bic_SR_register_on_exit(LPM4_bits);
    }
    

    msp430fr59xx_lpm4-5_01.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR59xx Demo - Entering and waking up from LPM4.5 via P1.1 interrupt
    //
    //   Description: Download and run the program. LED1 (or P4.6) will remain ON if
    //                LPM4.5 is correctly entered. Use a button S2 (or P1.1) on the
    //                EXP board to wake the device up from LPM4.5. This will enable
    //                the LFXT oscillator and blink the LED2 (on P1.0).
    //
    //                This demo was tested on MSP-EXP430FR5969 LaunchPad.
    //
    //           MSP430FR5969
    //         ---------------
    //     /|\|            XIN|-
    //      | |               | 32KHz Crystal
    //      --|RST        XOUT|-
    //        |               |
    //        |           P1.0|---> LED2 (MSP-EXP430FR5969)
    //        |           P4.6|---> LED1 (MSP-EXP430FR5969)
    //        |               |
    //        |           P1.1|<--- S2 push-button (MSP-EXP430FR5969)
    //
    //   William Goh / Andreas Dannenberg
    //   Texas Instruments Inc.
    //   August 2013
    //   Built with IAR Embedded Workbench V5.52.1 & Code Composer Studio V5.5
    //******************************************************************************
    
    #include <msp430.h>
    
    int main(void) {
        WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    
        // Configure GPIO
        P1OUT = 0;                              // Pull-up resistor on P1.1
        P1DIR = 0xFF;                           // Set all but P1.1 to output direction
    
        P2OUT = 0;
        P2DIR = 0xFF;
    
        P3OUT = 0;
        P3DIR = 0xFF;
    
        P4OUT = 0;
        P4DIR = 0xFF;
    
        PJOUT = BIT4;                           // Set PJ.4 / LFXTIN to high
        PJDIR = 0xFFFF;
    
        // Determine whether we are coming out of an LPMx.5 or a regular RESET.
        if (SYSRSTIV == SYSRSTIV_LPM5WU) {
            PJSEL0 = BIT4;                      // For XT1
    
            // Clock System Setup
            CSCTL0_H = CSKEY >> 8;              // Unlock CS registers
            CSCTL1 = DCOFSEL_0;                 // Set DCO to 1MHz
            CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
            CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
            CSCTL4 &= ~LFXTOFF;
    
            // Configure LED pin for output
            P1DIR |= BIT0;
    
            // Disable the GPIO power-on default high-impedance mode to activate
            // previously configured port settings. The oscillator should now start...
            PM5CTL0 &= ~LOCKLPM5;
    
            do {
                CSCTL5 &= ~LFXTOFFG;            // Clear XT1 fault flag
                SFRIFG1 &= ~OFIFG;
            } while (SFRIFG1 & OFIFG);          // Test oscillator fault flag
        }
        else {
            // Configure P1.1 Interrupt
            P1OUT |= BIT1;                      // Pull-up resistor on P1.1
            P1REN |= BIT1;                      // Select pull-up mode for P1.1
            P1DIR = 0xFF ^ BIT1;                // Set all but P1.1 to output direction
            P1IES |= BIT1;                      // P1.1 Hi/Lo edge
            P1IFG = 0;                          // Clear all P1 interrupt flags
            P1IE |= BIT1;                       // P1.1 interrupt enabled
    
            P4OUT |= BIT6;                      // Turn on P4.6 (LED1) on EXP board
                                                // to indicate we are about to enter
                                                // LPM4.5
    
            // Disable the GPIO power-on default high-impedance mode to activate
            // previously configured port settings
            PM5CTL0 &= ~LOCKLPM5;
    
            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);
    
            // Should never get here...
            while (1);
        }
    
        // Now blink the LED in an endless loop.
        while (1) {
            P1OUT ^= BIT0;                      // P1.0 = toggle
            __delay_cycles(100000);
        }
    }
    

    msp430fr59xx_lpm4-5_02.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430FR59xx Demo - Entering and waking up from LPM4.5 via P1.1 interrupt
    //                       with SVS disabled
    //
    //   Description: Download and run the program. LED1 (or P4.6) will remain ON if
    //                LPM4.5 is correctly entered. Use a button S2 (or P1.1) on the
    //                EXP board to wake the device up from LPM4.5. This will enable
    //                the LFXT oscillator and blink the LED2 (on P1.0).
    //
    //                This demo was tested on MSP-EXP430FR5969 LaunchPad.
    //
    //           MSP430FR5969
    //         ---------------
    //     /|\|            XIN|-
    //      | |               | 32KHz Crystal
    //      --|RST        XOUT|-
    //        |               |
    //        |           P1.0|---> LED2 (MSP-EXP430FR5969)
    //        |           P4.6|---> LED1 (MSP-EXP430FR5969)
    //        |               |
    //        |           P1.1|<--- S2 push-button (MSP-EXP430FR5969)
    //
    //   William Goh / Andreas Dannenberg
    //   Texas Instruments Inc.
    //   June 2014
    //   Built with IAR Embedded Workbench V6.10.3 & Code Composer Studio V6.0
    //******************************************************************************
    
    #include <msp430.h>
    
    int main(void) {
        WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    
        // Configure GPIO
        P1OUT = 0;                              // Pull-up resistor on P1.1
        P1DIR = 0xFF;                           // Set all but P1.1 to output direction
    
        P2OUT = 0;
        P2DIR = 0xFF;
    
        P3OUT = 0;
        P3DIR = 0xFF;
    
        P4OUT = 0;
        P4DIR = 0xFF;
    
        PJOUT = BIT4;                           // Set PJ.4 / LFXTIN to high
        PJDIR = 0xFFFF;
    
        // Determine whether we are coming out of an LPMx.5 or a regular RESET.
        if (SYSRSTIV == SYSRSTIV_LPM5WU) {
            PJSEL0 = BIT4;                      // For XT1
    
            // Clock System Setup
            CSCTL0_H = CSKEY >> 8;              // Unlock CS registers
            CSCTL1 = DCOFSEL_0;                 // Set DCO to 1MHz
            CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
            CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
            CSCTL4 &= ~LFXTOFF;
    
            // Configure LED pin for output
            P1DIR |= BIT0;
    
            // Disable the GPIO power-on default high-impedance mode to activate
            // previously configured port settings. The oscillator should now start...
            PM5CTL0 &= ~LOCKLPM5;
    
            do {
                CSCTL5 &= ~LFXTOFFG;            // Clear XT1 fault flag
                SFRIFG1 &= ~OFIFG;
            } while (SFRIFG1 & OFIFG);          // Test oscillator fault flag
        }
        else {
            // Configure P1.1 Interrupt
            P1OUT |= BIT1;                      // Pull-up resistor on P1.1
            P1REN |= BIT1;                      // Select pull-up mode for P1.1
            P1DIR = 0xFF ^ BIT1;                // Set all but P1.1 to output direction
            P1IES |= BIT1;                      // P1.1 Hi/Lo edge
            P1IFG = 0;                          // Clear all P1 interrupt flags
            P1IE |= BIT1;                       // P1.1 interrupt enabled
    
            P4OUT |= BIT6;                      // Turn on P4.6 (LED1) on EXP board
                                                // to indicate we are about to enter
                                                // LPM4.5
    
            // Disable the GPIO power-on default high-impedance mode to activate
            // previously configured port settings
            PM5CTL0 &= ~LOCKLPM5;
    
    
            PMMCTL0_H = PMMPW_H;                // Open PMM Registers for write
            PMMCTL0_L &= ~(SVSHE);              // Disable high-side SVS
            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);
    
            // Should never get here...
            while (1);
        }
    
        // Now blink the LED in an endless loop.
        while (1) {
            P1OUT ^= BIT0;                      // P1.0 = toggle
            __delay_cycles(100000);
        }
    }
    

    Eason

**Attention** This is a public forum