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.

MSP430F4132 LPM3 Wake Up on Basic Timer

Other Parts Discussed in Thread: MSP430F4132, MSP-FET

Hello,

I am working with MSP430F4132 code that has been brought over from IAR Embedded Workbench v6.40.4 to Code Composer Studio v6.1.3.00033, compiler v16.3.0.STS, and I'm struggling to get the device to wake up from LPM3 using the basic timer.

Here is the code from my main function:

BTCTL = BTHOLD | BTDIV;
IE2 |= BTIE;
_BIS_SR(GIE);

BTCNT1 = 0;
BTCNT2 = 0;
BTCTL = BT_fCLK2_DIV64 | BT_fCLK2_ACLK_DIV256;
__bis_SR_register(LPM3_bits);

And here is the code for my basic timer ISR:

#pragma vector=BASICTIMER_VECTOR
__interrupt void basicTimer(void)
{
    __bic_SR_register_on_exit(LPM3_bits);
}

Oddly enough, the ISR is called correctly when running a debug session from IAR using an MSP-FET.  However, when running a debug session from CCS using the same MSP-FET, it looks like I enter into LPM3, but then never come out.  Anything I'm missing?

Thank you.

  • Hello Jerry,

    Try the following example and let us know if it enters the ISR correctly.  Work backwards from there to figure out what is wrong with your setup.

    /* --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--*/
    //******************************************************************************
    //  MSP-FET430P410 Demo - FLL+, LPM3 Using Basic Timer ISR, 32kHz ACLK
    //
    //  Description: System runs normally in LPM3 with basic timer clocked by
    //  32kHz ACLK. At a 2 second interval the basic timer ISR will wake the
    //  system and flash the LED on P5.1 inside of the Mainloop.
    //  ACLK = LFXT1 = 32768, MCLK = SMCLK = DCO = 32xACLK = 1.048576MHz
    //  //*External watch crystal on XIN XOUT is required for ACLK*//	
    //
    //
    //            MSP430F413
    //         ---------------
    //     /|\|            XIN|-
    //      | |               | 32kHz
    //      --|RST        XOUT|-
    //        |               |
    //        |           P5.1|-->LED
    //
    //  M. Buccini
    //  Texas Instruments Inc.
    //  Feb 2005
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
    //*****************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      FLL_CTL0 |= XCAP14PF;                     // Configure load caps
      IE2 |= BTIE;                              // Enable BT interrupt
      BTCTL = BTDIV+BTIP2+BTIP1+BTIP0;          // 2s Interrupt
      P1DIR = 0xFF;                             // All P1.x outputs
      P1OUT = 0;                                // All P1.x reset
      P2DIR = 0xFF;                             // All P2.x outputs
      P2OUT = 0;                                // All P2.x reset
      P3DIR = 0xFF;                             // All P3.x outputs
      P3OUT = 0;                                // All P3.x reset
      P4DIR = 0xFF;                             // All P4.x outputs
      P4OUT = 0;                                // All P4.x reset
      P5DIR = 0xFF;                             // All P5.x outputs
      P5OUT = 0;                                // All P5.x reset
      P6DIR = 0xFF;                             // All P6.x outputs
      P6OUT = 0;                                // All P6.x reset
    
      while(1)
      {
        int i;
        __bis_SR_register(LPM3_bits + GIE);     // Enter LPM3 w/ interrupts
        P5OUT |= 0x02;                          // Set P5.1 LED on
        for (i = 5000; i>0; i--);               // Delay
        P5OUT &= ~0x02;                         // Clear P5.1 LED off
      }
    }
    
    // Basic Timer interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=BASICTIMER_VECTOR
    __interrupt void basic_timer(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(BASICTIMER_VECTOR))) basic_timer (void)
    #else
    #error Compiler not supported!
    #endif
    {
        __bic_SR_register_on_exit(LPM3_bits);   // Clear LPM3 bits from 0(SR)
    }

    Regards, Ryan

  • This example showed me that LPM3 and the basic timer work correctly on my chip. I worked backwards from this sample and realized that I forgot to rename my "__low_level_init" (IAR) function to "_system_pre_init" (CCS). My "_system_pre_init" function is responsible for initializing "FLL_CTL0", which is critical to the basic timer.

    Thank you very much, Ryan!

**Attention** This is a public forum