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.

measuring current in sleep mode

Other Parts Discussed in Thread: MSP430G2553

Sir/Madam

      I'm using MSP430G2553.I measured the current during sleep mode by setting low power mode as LPM0 at that time I got current value in 150uA instead of 55uA and in LPM4 mode I got current value in 80 uA instead of 0.1 uA.I don't know where I went wrong.I'll attach my code here with

#include <msp430x20x3.h>
void main(void)
{
// Set up 32768Hz crystal
BCSCTL1 |= DIVA_3; // divide by 8
BCSCTL3 |= XCAP_3; // select 12pF caps
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x04; // Set P1.2 to output direction
P1IE |= 0x10; // P1.4 interrupt enabled
P1IES |= 0x10; // P1.4 Hi/lo edge
P1IFG &= ~0x10; // P1.4 IFG cleared
_BIS_SR(LPM4_bits + GIE); // Enter LPM4 w/interrupt
}
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1OUT ^= 0x04; // P1.2 = toggle
P1IFG &= ~0x10; // P1.4 IFG cleared
}

  • Hi Karthiga!

    First thing you should do is initializing all unused pins - don't leave them floating. Make them outputs, either high or low.

    Dennis
  • Hi Karthiga,
    And second thing what you should do is a correct initialization of your clock system. A stable current of 80uA sounds like an active fault flag of your clock system. Please check in our code examples on the product page how to initialize a LF crystal.

    Best regards,
    Tobias
  • thank you for ur reply...

    I have initialized the clock frequency ...even then for LPM4 i'm not getting current value as 0.1 uA getting 50 micro amps..here is my code

    #include <msp430g2553.h>

    #define LED0 BIT0
    #define LED1 BIT6
    #define BUTTON BIT3

    static int control; //to make the value non-volatile

    int main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

    BCSCTL1 = CALBC1_1MHZ;
    DCOCTL = CALDCO_1MHZ;

    P1DIR = 0x00;
    P1OUT = 0x00;
    P1DIR |= (LED0 + LED1); // Set P1.0 to output direction
    P1OUT &= ~(LED0 + LED1); // set P1.0 to 0 (LED OFF)
    P1IE |= BUTTON; // P1.3 interrupt enabled
    P1IES |= BUTTON; // P1.3 Hi/lo edge
    P1IFG &= ~BUTTON; // P1.3 IFG cleared
    __enable_interrupt(); // enable all interrupts
    _BIS_SR(LPM4_bits + GIE); // Enter LPM4 w/interrupt
    }


    // Port 1 interrupt service routine
    #pragma vector=PORT1_VECTOR
    __interrupt void Port_1(void)
    {
    P1IFG &= ~BUTTON; // P1.3 IFG cleared
    control++; //incrementing interrupt count
    if(control == 10) //checking the count value
    {
    P1OUT ^= (LED0 + LED1); // P1.0 = toggle
    control = 0;//making control to zero
    }

    }
  • "P1DIR = 0x00" makes all pins inputs, which is the default anyway. For how to initialize the unused pins, see section 2.5 of the User's Guide.

**Attention** This is a public forum