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/MSP430FR2355: Problem with LPM3 current (it is extremely high)

Part Number: MSP430FR2355
Other Parts Discussed in Thread: CCSTUDIO, ENERGYTRACE

Tool/software: Code Composer Studio

Hello!

I'm pretty new to MSP430 and ccstudio. I'm trying to read from a moisture sensor connected to the microcontroller, compare the sensor data against a randomly generated set of 10 numbers and then go to the sleep mode. A timer interrupt wakes the microcontroller up and it reads from the sensor again. 

The sensor output is connected to Pin 1.1. Pin 1.0 is used to turn the sensor on/off. The sensor data needs to be converted from an analog signal to a digital value for which the ADC is used. I used the ADC code from one of the examples.

I measured the current by hooking up a multimeter between the power supply and the board. The code was flashed on the device and jumpers connecting the debug probe were removed. I see a current of around 400uA in LPM3 mode - does that mean the device isn't going into the low power mode? Is there an issue in the set up I have? Any help in this regard or pointers to where I could check would be greatly appreciated. 

Here's the code:

#include <msp430.h>

unsigned int ADC_Result;

int trigger;

int main(void)

{

    WDTCTL = WDTPW | WDTHOLD;                                // Stop WDT

    // Configure GPIO

    P1DIR |= BIT0;                                           // Set P1.0/LED to output direction

    P1OUT &= ~BIT0;                                          // P1.0 LED off

    // Configure ADC A1 pin

    P1SEL0 |= BIT1;

    P1SEL1 |= BIT1;

    // Disable the GPIO power-on default high-impedance mode to activate

    // previously configured port settings

    PM5CTL0 &= ~LOCKLPM5;

    // Configure ADC

    ADCCTL0 |= ADCSHT_2 | ADCON;                             // ADCON, S&H=16 ADC clks

    ADCCTL1 |= ADCSHP;                                       // ADCCLK = MODOSC; sampling timer

    ADCCTL2 &= ~ADCRES;                                      // clear ADCRES in ADCCTL

    ADCCTL2 |= ADCRES_2;                                     // 12-bit conversion results

    ADCMCTL0 |= ADCINCH_1;                                   // A1 ADC input select; Vref=AVCC

    ADCIE |= ADCIE0;                                         // Enable ADC conv complete interrupt

    int k, p, in[10], out[10], match[10];

    //Initialise input array with random numbers for comparison

    for(k=0; k<10; k++)

    {

        in[k] = k*(k+1);

    }

    while(1)

    {

        P1OUT = 1;

        ADCCTL0 |= ADCENC | ADCSC;                           // Sampling and conversion start

//        P1OUT = 1;

        __bis_SR_register(LPM0_bits | GIE);                  // LPM0, ADC_ISR will force exit

//        __no_operation();                                    // For debug only

        for(p=0; p<10; p++)

        {

            //Compare with array initialised above

            out[p] = in[p] ^ ADC_Result;

            if(out[p] == 0x00)

            {

                //P1OUT |= BIT0;      //Set P1.0 LED on to indicate match

                match[p] = 0x01;

 //               __delay_cycles(5000);

            }

            else

            {

                P1OUT = 1;     //Set P1.0 LED on to indicate no match for debug only

                match[p] = 0x00;

                __delay_cycles(5000);

            }

        } //end for

        //configure timer and start it.

        TB0CCTL0 = CCIE;

        TB0CTL = MC_1|ID_3|TBSSEL_1|TBCLR;  //set up timer and start it

        TB0CCR0 = 100000*100000;                   // Set Timer Period 

        trigger = 1;                        //for debug purposes

        P1OUT = 0;

        //enter lpm3

        __bis_SR_register(LPM3_bits | GIE);

        //at timer interrupt, ISR takes care of going out of lpm and setting timer off.

    } //end while

} //end main

// ADC interrupt service routine

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)

#pragma vector=ADC_VECTOR

__interrupt void ADC_ISR(void)

#elif defined(__GNUC__)

void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)

#else

#error Compiler not supported!

#endif

{

    switch(__even_in_range(ADCIV,ADCIV_ADCIFG))

    {

        case ADCIV_NONE:

            break;

        case ADCIV_ADCOVIFG:

            break;

        case ADCIV_ADCTOVIFG:

            break;

        case ADCIV_ADCHIIFG:

            break;

        case ADCIV_ADCLOIFG:

            break;

        case ADCIV_ADCINIFG:

            break;

        case ADCIV_ADCIFG:

            ADC_Result = ADCMEM0;

            P1OUT = 0;

            __bic_SR_register_on_exit(LPM0_bits);            // Clear CPUOFF bit from LPM0

            break;

        default:

            break;

    }

}

#pragma vector = TIMER0_B0_VECTOR

__interrupt void TB0_ISR (void)

{

    __bic_SR_register_on_exit(LPM3_bits);

    TB0CTL &= ~MC_1;                            // Turn off Timer

}

Thank you for the help!

  • On an FR2355 Launchpad with the LED (P1.0) jumper and the SBW jumpers all removed, My DMM shows about 30uA. It takes a while for the averaging to settle. EnergyTrace (no LED jumper) in Free Run shows mostly about 0.22mW (maybe 70uA). I trust EnergyTrace more than my DMM.

    Can you show a schematic for your board? I wonder if your sensor and LED are really getting turned off.
  • Hi Yaman,

    Any feedback for Bruce's reply?
  • Hi Bruce,

    Here's a picture of the set up (without the sensor for now) and a circuit diagram. I removed the jumpers and added the following lines to the code and the current now is 26uA. LPM3 current should be less than 1uA so this is still very high for what I expect:

    Lines added to the code: 

    //Make all pins go to 0

        /*P1OUT = 0x00;*/ P2OUT = 0x00;

        P3OUT = 0x00; P4OUT = 0x00;

        P5OUT = 0x00; P6OUT = 0x00;

        /*P1DIR = 0xff;*/ P2DIR = 0xff;

        P3DIR = 0xff; P4DIR = 0xff;

        P5DIR = 0xff; P6DIR = 0xff;

    Moreover, the current drawn increases only by 2 or 3 uA when the LED turns on and the board goes into active mode. Do you think the microcontroller is going to LPM3 at all? 

    I added a couple of breakpoints to track the flow of instructions and it all seemed to be going as I expect it. 

    Thanks for checking it on your system, please let me know if there's any more information you need. 

    Thanks,

    Yaman

  • > /*P1OUT = 0x00;*/ P2OUT = 0x00;
    > /*P1DIR = 0xff;*/ P2DIR = 0xff;

    I un-commented these, and reduced from 24uA to about 18uA. I then added:

    > CSCTL4 = SELA__VLOCLK | SELMS__DCOCLKDIV; // BMC

    to set ACLK to be VLOCLK (last user of REFOCLK) and EnergyTrace claims 0.8uA, and an LPM01A claims 1.0uA (average). Other measurements I've made indicate REFOCLK costs about 15uA on an FR2311, so this is a plausible effect.

    I tried replacing the VLO line with

    > CSCTL3 |= REFOLP; // BMC

    and got 1.7/2.25uA, but for the (small) extra cost that would (I suppose) give you a 32kHz ACLK rather than a 10kHz one.

    I expect that the relatively small "blip" you see when your program goes active is due to averaging in your DMM.

    [Edit: I also removed the jumpers for P3.1-3 and P6.6, which didn't by itself make a visible difference.]

  • I was traveling and just got back. I'll try this tomorrow and let you know if it works. 

    Thanks for all the help!

  • Hi Bruce,
    This worked - I'll have to go read more on the clocks; thanks for all your help!
    I have two follow up questions, however - first is that the current in the active mode is just a couple of uA. This seems weird because the rated active mode current is in the order of mA. I'm not sure why the current is so low.
    The second one is when the clock is set to 10kHz, does that mean the clock used in active mode is also set to 10kHz or is that only for the sleep mode.
    Once again, thank you for the help!

  • Per Data Sheet (SLASEC4A) Sec 5.4, Active mode at 1MHz should be 250-550 uA. I took apart my setup, but I recall seeing Active times which were fairly short, maybe a few 10s of msec. Any DMM averaging would make that very difficult to see.

    I only set ACLK to VLOCLK (10kHz), the CPU (MCLK) when Active is still using the DCO (1MHz) disciplined by REFOCLK. TB0 is running at about 1/3rd what it was before, but I thought a slow timer was the intent.

    I see you have a Launchpad; I encourage you to try EnergyTrace for yourself.
  • I see, the active time is indeed extremely small, certainly around 10s of msec if not less than that. 

    One thing I might try is to reduce the clock in Active too, I doubt it'll be a significant reduction in power there. 

    I have used EnergyTrace also but we need data measured on a multimeter so I've been doing all my measurements there. I'll check on EnergyTrace as well. 

    Thanks for all your help Bruce!

**Attention** This is a public forum