Jump to content
athornsb

Unusual Power Draw - Launchpad

Recommended Posts

The same question is posted on reddit here: http://redd.it/18bkdl

We are meeting with our project sponsors tonight and would love to have some kind of answer as to what's going on with our power draw.

 

 

We are using an MSP430 Launchpad to develop a small project to be powered by a solar cell.  Eventually we will have a single hardware interrupt, and a 30 Hz counter interrupt to update an LCD.  We have estimated our power budget to be around 20 micro Watts.  Oddly, with the software I have written and provided below, we are getting around 30 micro amps at 2.2V when we separate the MSP from the board.  Stranger still, no matter if we try to fully load the processor, or just drop it into LPM4 we always get roughly the same power draw which doesn't make sense.  I'm hoping you redditors can either find a problem with my code or how we are testing power draw.  We are using the LEDs to confirm functionality of the interrupts, and then we detach the MSP from the board to test power.  I have tried to comment the code well, if anything is unclear I'll try to explain.  Thanks!
 
#include <msp430g2553.h>
 
#define greenLED 0x40                    // BIT6
#define redLED 0x01                        // BIT0
#define TRIGGER 400                        // VLO interrupt delay.  Base frequency is 12kHz.
void main(void) {
 
    //Set up system clocks
    WDTCTL = WDTPW | WDTHOLD;             // Stop WDT
    BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0;          // DCO clock with divide by 1
    if (CALBC1_1MHZ != 0xFF) {
        DCOCTL = 0x00;
        BCSCTL1 = CALBC1_1MHZ;             // Set DCO to 1MHz
        DCOCTL = CALDCO_1MHZ;
    }
    BCSCTL1 |= XT2OFF + DIVA_0;               // Disable XT2CLK and set to divide by 1
 
    //Set up port 1
    P1DIR = 0xff;                  // Configure all of Port 1 to output to reduce power consumption
 
    //Set up A0 timer and VLO clock source
    BCSCTL3 = XT2S_0 + LFXT1S_2 + XCAP_1;        //Set the ACLK clock to the internal VLO, 6pF cap, low frequency operation.
    TACCR0 = TRIGGER-1;                    // Trigger is the timer A count limit.  (# of counts until the interrupt fires)
    TACCTL0 |= CCIE;                    // Enable timer A interrupt
    TACTL = TASSEL_1 + MC_1 + TACLR;      // ACLK, up mode, clear timer.
 
    //Set up LEDs
    P1DIR |= greenLED;                     // Set P1.6 to output direction
    P1OUT &= ~greenLED;                 // Set green LED off
    P1DIR |= redLED;                     // Set P1.0 to output direction
    P1OUT &= ~redLED;                     // Set red LED on
 
    //Set up Push Button (P1.3)
    P1SEL &= ~0x08;                        // Select Port 1 P1.3 (push button)
    P1DIR &= ~0x08;                        // Port 1 P1.3 (push button) as input, 0 is input
    P1REN |= 0x08;                        // Enable Port P1.3 (push button) pull-up resistor
    P1IE |= 0x08;                        // Port 1 Interrupt Enable P1.3 (push button)
    P1IFG &= ~0x08;                        // Clear interrupt flag (just to be sure)
 
    _BIS_SR(LPM3_bits + GIE);                           // Enable interrupts
}
#pragma vector=PORT1_VECTOR                // Port 1 interrupt service routine
      __interrupt void Port_1(void) {
        P1IFG &= ~0x08;                 // P1.3 Interrupt Flag cleared
        P1OUT ^= greenLED;                 // Toggle LED state
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A(void) {
        P1OUT ^ = redLED;
}
 

power_sim.c

Share this post


Link to post
Share on other sites

P.S.  Any power optimizations that can be made to that code that you guys spot, even if its not the core of the problem, would still be greatly appreciated!  Clock precision isn't much of an issue for what we're doing, which is why I'm already using VLO for the interrupt.

Share this post


Link to post
Share on other sites

Not to mention configure P2DIR, similar to what you're doing with P1DIR...

 

 

G2553 is also capable of a P3 (in 28-pin TSSOP models), this means all models of G2553 will have a P3 onboard (but for the 20-pin DIP and TSSOP versions, none of the P3.x ports are broken out to physical pins; however the hardware is still there, using up power from the schmitt triggers responding to noise on-die.)

 

So set P3DIR = 0xFF; too.

 

 

Actually another variation of this is to keep the P3 in input mode (P3DIR = 0x00;) but enable the Pull-down resistor (the datasheet explicitly says this for the 20-pin variants anyhow):

P3DIR = 0x00;

P3OUT = 0x00;

P3REN = 0xFF;

P3SEL = 0x00;

P3SEL2 = 0x00;  // for completeness

 

If you're not using P2 at all, for completeness here's the total solution for quieting P2 & P3:

P2SEL = 0x00;

P2SEL2 = 0x00;

P2OUT = 0x00;

P2DIR = 0x00;

P2REN = 0xFF;

 

P3SEL = 0x00;

P3SEL2 = 0x00;

P3OUT = 0x00;

P3DIR = 0x00;

P3REN = 0xFF;

Share this post


Link to post
Share on other sites

Are there any other devices when you're detaching from the main LP board?  Have you tested a simple LPM3 code example to eliminate any possible hardware issues?

At this point no.  Eventually we will be connecting a gray code switch and LCD panel.  And yes we tried both a program that immediately (first line of code) puts it in LPM4, as well as a LPM example copy pasted from the MSP430 wiki.  Both produced the same result as my code.

Share this post


Link to post
Share on other sites

Have you taken LED power usage in account?

Have you connected a resistor from RST to Vcc and a capacitor from RST to ground?

Set P2SEL to 0 to set P1.6 and P1.7 to IO mode instead of crystal mode.

Thanks for the P2SEL tip.  We havent connected any other components to the board, and we are actually DETACHING the MSP430 chip from the board to test power draw.  We are using the board for development and code deployment only, and it won't be used in our final build.  (mainly because yes, we noticed that the LEDs and their resistors use quite a bit of power)

Share this post


Link to post
Share on other sites

Not to mention configure P2DIR, similar to what you're doing with P1DIR...

 

 

G2553 is also capable of a P3 (in 28-pin TSSOP models), this means all models of G2553 will have a P3 onboard (but for the 20-pin DIP and TSSOP versions, none of the P3.x ports are broken out to physical pins; however the hardware is still there, using up power from the schmitt triggers responding to noise on-die.)

 

So set P3DIR = 0xFF; too.

 

 

Actually another variation of this is to keep the P3 in input mode (P3DIR = 0x00;) but enable the Pull-down resistor (the datasheet explicitly says this for the 20-pin variants anyhow):

P3DIR = 0x00;

P3OUT = 0x00;

P3REN = 0xFF;

P3SEL = 0x00;

P3SEL2 = 0x00;  // for completeness

 

If you're not using P2 at all, for completeness here's the total solution for quieting P2 & P3:

P2SEL = 0x00;

P2SEL2 = 0x00;

P2OUT = 0x00;

P2DIR = 0x00;

P2REN = 0xFF;

 

P3SEL = 0x00;

P3SEL2 = 0x00;

P3OUT = 0x00;

P3DIR = 0x00;

P3REN = 0xFF;

Thanks!  Will do.

 

Change I made as well that might change things:  I changed my IDE to deploy in release mode rather than debug mode.  I wondered if maybe debug code in main was breaking me out of low power mode.

Also, have I configured the main clock for 1Mhz correctly?  We want it to run at the lowest speed regardless of supply voltage.

Share this post


Link to post
Share on other sites

Yep your clock config looks right!  These things are pretty simple to configure clock-wise.

 

Some of the higher-end parts, like the F5xxx, F6xxx and FR5xxx series have a far more complex clocking system--an FLL referencing a stable 32.768KHz crystal is used to configure & auto-trim the DCO, etc... along with Supply Voltage Supervisor and configurable LDO that must be stepped up/down in an orderly and monitored manner to obtain different clock speeds; but these Value LIne chips are much, much simpler than that :)

Share this post


Link to post
Share on other sites

Oh is there anything I need to know about testing the power draw?  If your suggestions don't reduce the power dramatically, I'll be totally at a loss.  We have been connecting the Vcc and ground to a 2.2V power supply (after removing the MSP430 from the launchpad board).  Then we connect a multimeter to measure the current draw.  

Share this post


Link to post
Share on other sites

Oh is there anything I need to know about testing the power draw?  If your suggestions don't reduce the power dramatically, I'll be totally at a loss.  We have been connecting the Vcc and ground to a 2.2V power supply (after removing the MSP430 from the launchpad board).  Then we connect a multimeter to measure the current draw.  

There is some information in the "getting started" labs about testing the device for low-current - might be helpful for reference.

 

 

 

Hmm, not that I know of... I assume your multimeter is designed to handle uA measurements?  If not, something like the "uCurrent" might be needed for accurate measuring-- http://www.eevblog.com/projects/ucurrent/

I was going to mention a potential issue with your DMM as well - the TI lab workbook mentions that some can't measure the tiny amounts of current used by the MSP.  

Share this post


Link to post
Share on other sites

There is some information in the "getting started" labs about testing the device for low-current - might be helpful for reference.

 

 

 

I was going to mention a potential issue with your DMM as well - the TI lab workbook mentions that some can't measure the tiny amounts of current used by the MSP.  

Thanks, I'll check out those getting started labs just to be sure.

Ok last 2 questions, hopefully!...

What is the most power efficient way to debounce a switch?  In the past I just incremented a global variable with a fast timer interrupt, but I would hate to wake our system that often.

Do I need to turn the ADC off in some way, or has switching off any unnecessary clocks already accomplished this?  I read elsewhere that the ADC is a power hog and can interfere with LPM.

 

Thanks.

Share this post


Link to post
Share on other sites

If you're using a timer-based debounce and putting the chip into LPM3 in between, that is pretty low power--and one distinct quality of these MSP430's (particularly Value Line chips) is that they wake up *fast*, like within the span of 1 or 2 clock cycles of the DCO they're awake.  It's cheap to wake up, check something real quick and return from the ISR (without doing the __bic_SR_register_on_exit()).

 

The ADC shouldn't be running if it's not doing a conversion.  Its ADC10OSC turns on/off as needed (assuming that is what you've selected for it).  I was just reading the MSP430 x2xx User's Guide on this last week, it's meant to facilitate very-low-power applications.

 

Also very minor/non-consequential nitpick: You don't need to set the XCAP_* settings with VLOCLK, those only apply when using an external 32.768KHz watch crystal on P2.6/P2.7 as your ACLK.

 

Lastly: Your pushbutton config should have a "P1OUT |= 0x08;" to make sure it's the pullUP resistor that gets turned on, not the pullDOWN resistor.  P1REN |= 0x08; enables the resistor; P1OUT determines whether it's pullUP (bit set to 1) or pullDOWN (bit set to 0).

Share this post


Link to post
Share on other sites

Not to mention configure P2DIR, similar to what you're doing with P1DIR...

 

 

G2553 is also capable of a P3 (in 28-pin TSSOP models), this means all models of G2553 will have a P3 onboard (but for the 20-pin DIP and TSSOP versions, none of the P3.x ports are broken out to physical pins; however the hardware is still there, using up power from the schmitt triggers responding to noise on-die.)

 

So set P3DIR = 0xFF; too.

 

 

Actually another variation of this is to keep the P3 in input mode (P3DIR = 0x00;) but enable the Pull-down resistor (the datasheet explicitly says this for the 20-pin variants anyhow):

P3DIR = 0x00;

P3OUT = 0x00;

P3REN = 0xFF;

P3SEL = 0x00;

P3SEL2 = 0x00;  // for completeness

 

If you're not using P2 at all, for completeness here's the total solution for quieting P2 & P3:

P2SEL = 0x00;

P2SEL2 = 0x00;

P2OUT = 0x00;

P2DIR = 0x00;

P2REN = 0xFF;

 

P3SEL = 0x00;

P3SEL2 = 0x00;

P3OUT = 0x00;

P3DIR = 0x00;

P3REN = 0xFF;

The guy from the launchpad workshop video mentioned setting all unused pins as output, then using the internal pullup/down to either set a pullup/down on those unused pins as well. Is this effectlivly the same thing ? I do notice that grace pretty much does exactly what you say here though too.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...