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.

MSP430FR4133: LPM3 consuming 60 uW instead of 6 uW :)

Guru 18385 points
Part Number: MSP430FR4133
Other Parts Discussed in Thread: ENERGYTRACE, MSP430FR5969

Dear,

I am starting my way with MSP430FR4133.

I have some tests with EnergyTrace, free run mode, I remove the UART jumpers and also the LED jumpers of the Launchpad.

For the following code, I obtain a 60 uW value for LPM3, which is clearly incorrect. However, the code is so simple but I am not able to see what am I missing, maybe because of jet-lag ;)

So, give me your opinions and tell me what I am doing so wrong in my first steps with this MCU!


#include <msp430.h>



///
/// @brief Inits GPIOs in low-power mode and functions
///
void gpio_init()
{
    P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;
    P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;
    P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;
    P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;
    P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;
    P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;

    // remove GPIO default high-impedance and applies previous
    PM5CTL0 &= ~LOCKLPM5;
}



///
/// @brief SuperLoop
///
/// Inits, senses and sends
///
int main(void)
{
    // stop watchdog timer
    WDTCTL = WDTPW | WDTHOLD;


    // init stuff
    gpio_init();


    // Enter LPM
    __bis_SR_register(LPM3_bits + GIE);
}

  • Are you in debug mode when measuring the power?
  • Hi ,
    what I do is pressing the "debug" button and when the debugger stops at first line of the code, I press "Free Run" so the consumption of the debugger is not accounted. Am I doing this right?
  • Device will not enter LPM3 mode when you are connected to the debugger. Download the code into the device. Then stop the debug session. Reset the device and you'll be able to enter LPM3 mode.
  • Like in this link? :)
    Is this different from "free run"?



  • Still no luck :)
  • Any answer on this?

  • I am currently working with the Energy Trace to take some measurement.

    Meanwhile please check out,

     

    ULP Advisor

    http://processors.wiki.ti.com/index.php/ULP_Advisor?DCMP=MSP430&HQS=Other+OT+ULPADVISOR

    MSP430™ Advanced Power Optimizations: ULP Advisor™ Software and EnergyTrace™ Technology

    http://www.ti.com/lit/an/slaa603/slaa603.pdf

    MSP430 Workshop Series 7 of 12 - Low-Power Optimization

    https://training.ti.com/msp430-workshop-series-7-12-low-power-optimization

  • Thanks  

    did not know the 3rd one, will check.

    Please let me know if you find the issu meanwhile.

  • hi  

    are you obtaining the same value?

  • Yes I did get the same value. Could you try lpm 0 mode and see what result you get?
  • Kazola,

    I am still working on resolving this issue. I will let you know what I find.

    -Nima

  • #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);
    }
    

    I tested the code above with MSP430FR5969, and this is the result I got.

  • Dear  

    sorry, I was away for some days! Norway, nice country :)

    These are the values I obtain with msp430fr4133:

    lmp0 600 uW  = 0.6   mW
    lpm3  60 uW  = 0.06  mW
    lpm4   2 uW  = 0.002 mW

    Maybe I am missing this XT1 Setup part?

    Please let me know!

  • Dear  

    any update or explanation on this? should I buy a multimeter if I cannot trust EnergyTrace? :)

  • Sorry I was out of office for a couple of days. The numbers I got was correct with respect to the data sheet. Could you try the same code and send me a screenshot of your results?

  • Dear  

    your numbers were for the msp430fr5969 but the question was for msp430fr4133...

    can TI provide the LPM3 code for msp430fr4133, if mine is not correct, as well as the launchpad configuration if some change has to be made?

    thanks

  • /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, 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--*/
    //******************************************************************************
    //  MSP430FR413x Demo - Enters LPM3 with ACLK = XT1CLK = 32768Hz.
    //
    //  Description: Configures ACLK to be sourced from XT1 crystal. Enter LPM3 until
    //               WDT ISR is executed and toggles the LED on P1.0.
    //
    //           MSP430FR4133
    //         ---------------
    //     /|\|               |
    //      | |               |
    //      | |      XIN(P4.1)|--
    //      --|RST            |  ~32768Hz
    //        |     XOUT(P4.2)|--
    //        |               |
    //        |           P1.0|-->LED
    //
    //  William Goh
    //  Texas Instruments Inc.
    //  January 2014
    //  Built with IAR Embedded Workbench v5.60 & Code Composer Studio v5.5
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDT_ADLY_1000;                 // WDT 1000ms, ACLK, interval timer
    
        SFRIE1 |= WDTIE;                        // Enable WDT interrupt
    
        P4SEL0 |= BIT2 + BIT1;                  // P4.2: XOUT; P4.1: XI1
    
        CSCTL4 = SELMS__DCOCLKDIV + SELA__XT1CLK;  // MCLK=SMCLK=DCO; ACLK=XT1
    
        // Port Configuration all un-used pins to output low
        P1OUT = 0x00;
        P2OUT = 0x00;
        P3OUT = 0x00;
        P4OUT = 0x00;
        P5OUT = 0x00;
        P6OUT = 0x00;
        P7OUT = 0x00;
        P8OUT = 0x00;
    
        P1DIR = 0xff;
        P2DIR = 0xff;
        P3DIR = 0xff;
        P4DIR = 0xff;
        P5DIR = 0xff;
        P6DIR = 0xff;
        P7DIR = 0xff;
        P8DIR = 0x0f;
    
        // Disable the GPIO power-on default high-impedance mode
        // to activate previously configured port settings
        PM5CTL0 &= ~LOCKLPM5;
    
        do
        {
            CSCTL7 &= ~(XT1OFFG | DCOFFG);      // Clear XT1 and DCO fault flag
            SFRIFG1 &= ~OFIFG;
        }while (SFRIFG1 & OFIFG);               // Test oscillator fault flag
    
        __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3
        __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) every 1s
    }
    
    

  • /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, 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--*/
    //******************************************************************************
    //  MSP430FR413x Demo - LPM3 entry with MCLK 16MHz
    //
    //  Description: When MCLK is 16MHz, and if the temperature changes signicantly 
    //                    for entering LPM3 and exiting from LPM3, the MCLK frequency at 
    //                    wake-up may be significantly different from when the LPM3 is 
    //                    entered, and may be out of the specified operation range. To avoid
    //                    this, the MCLK can be set to be divided from DCOCLKDIV. 
    // 
    //           MSP430FR4133
    //         ---------------
    //     /|\|               |
    //      | |               |
    //      --|RST       P1.0 |---> LED
    //        |               |
    
    //
    //
    //  Kathryn Adamsky
    //  Texas Instruments Inc.
    //  June 2016 (Updated) | June 2014 (Created)
    //  Built with IAR Embedded Workbench v6.10.2 & Code Composer Studio v5.5
    //******************************************************************************
    #include <msp430.h>
    
    void Init_GPIO(void);
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;                                              // Stop watchdog timer
        
        // Configure GPIO
        Init_GPIO();
        P1OUT &= ~BIT0;                                                        // Clear P1.0 output latch for a defined power-on state
        P1DIR |= BIT0;                                                         // Set P1.0 to output direction
        
        // Disable the GPIO power-on default high-impedance mode
        // to activate previously configured port settings
        PM5CTL0 &= ~LOCKLPM5;
    
        __bis_SR_register(SCG0);                                               // disable FLL
        CSCTL3 |= SELREF__REFOCLK;                                             // Set REFO as FLL reference source
        CSCTL0 = 0;                                                            // clear DCO and MOD registers
        CSCTL1 &= ~(DCORSEL_7);                                                // Clear DCO frequency select bits first
        CSCTL1 |= DCORSEL_5;                                                   // Set DCO = 16MHz
        CSCTL2 = FLLD_0 + 487;                                                 // DCOCLKDIV = 16MHz
        __delay_cycles(3);   
        __bic_SR_register(SCG0);                                               // enable FLL
        while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1));                             // FLL locked
        FRCTL0 = FRCTLPW | NWAITS0;                                            // Set number of FRAM waitstates to 0
        CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK;                             // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
                                                                               // default DCOCLKDIV as MCLK and SMCLK source
       
        // Configure RTC
        RTCMOD = 10-1;                                                         // Interrupt and reset happen every 10*1000*(1/10KHz) = ~1S
        RTCCTL |= RTCSS__VLOCLK | RTCSR |RTCPS__1000;                          
        RTCCTL |= RTCIE;
       
        while(1)
        {  
            CSCTL5 |= DIVM_1;                                                  // MCLK = 0.5* DCOCLKDIV = 8MHz - only for case of temperature changes significantly for LPM3 entry and LPM3 exit
    
            P1OUT ^= BIT0;
            
            __bis_SR_register(LPM3_bits | GIE);                                // Enter LPM3, Stop all clocks
            __no_operation();                                                  // For debugger
        }
    }
    
    // RTC interrupt service routine
    #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
    {
        // Configure the CS
        __bic_SR_register(SCG0);                                               // enable FLL
        while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1));                             // FLL locked
      
        CSCTL5 &= DIVM_1;                                                      // MCLK = DCOCLKDIV = 16MHz - only for case of temperature changes significantly for LPM3 entry and LPM3 exit
    
        switch(__even_in_range(RTCIV,RTCIV_RTCIF))
        {
            case RTCIV_NONE :  break;                                          // No interrupt
            case RTCIV_RTCIF:  __bic_SR_register_on_exit(LPM3_bits);           // RTC Overflow
                                                                               // Exit LPM3 on reti
                               break;
            default: break;
        }
    }
    
    void Init_GPIO()
    {
        P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF; 
        P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF; 
        P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;
        P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;
        P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00; 
        P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;
    }
    

  • The two examples above are for your device. Could you please try them and screenshot the results for me?
  • Hi  

    thanks! sure I will do along the weekend! :)

  • Dear  

    after one of these procedures of Code Composer Studio Warnings which updates the firmware of the launchpad, values seem to be ok!

    Is it possible this fixed something regarding the power consumption and EnergyTrace?

  • Ah I'm glad its finally working. It is possible that for some reason it was never exiting debug mode and after the update it is working. I'm not sure. I will report that to the internal team. Meanwhile I would like to thank you for your patience and I am glad to see the problem is resolved.

    Nima

**Attention** This is a public forum