We are using the MSP430F2418 in a battery powered application. System will go into low power mode LPM3 using the instruction _BIS_SR(LPM3_bits + GIE) and comes out of LPM3 using the instruction __bic_SR_register_on_exit(LPM3_bits);
While in LPM3 the current consumption is not constant but periodically it spikes as shown below. main.c is the source code also attached. Thank you.
#include <msp430f2418.h> #define XTAL_32KHZ void floorit (void); void main(void) { unsigned int X = 0; unsigned int Toggle = 0; WDTCTL = WDTPW + WDTHOLD; //Stop the WatchDog Timer P1OUT = 0X00; // Turn off 2.5V Reference (set P1.4=0) 12/11/2017 P1DIR = 0xff; // Set P1.0 pin directions to output P2OUT = 0x0F; //Set bits 0 to 3 P2DIR = 0xff; //P2 is all output P3OUT = 0x00; P3DIR = 0xff; P3REN = 0x20; //Enable pull up on P3.5 P4OUT = 0xD4; P4DIR = 0xFF; P5OUT = 0x01; P5DIR = 0xEF; P5REN = 0x10; P6DIR = 0xE0; P6SEL = 0x1F; //CCTL0 = CCIE; //. TACCTL0. TimerA, Compare Control 0. Compare 0, Interrupt Enable. //CCR0 += 164; // TACCR0. Compare Contorl 0 up Mode Count is 164 floorit(); //8MHz MCLK and 2MHz SMCLK TACTL = TASSEL_1 + MC_1; //ACLK/1, Activate Timer A in Up Count Mode, TACCR0 = 164; //5msec at 32.768 KHz Clock TACCTL0 |= CCIE; //CCR0 Interrupt Enable _BIS_SR(GIE); // Enable interrupts while (1) { X++; _BIS_SR(LPM3_bits + GIE); //Enable LPM3 and Global Interrupts Toggle++; /*if ((Toggle > 0) && (Toggle <= 1)) P5OUT = 0x01; else if ((Toggle >= 2) && (Toggle < 3))P5OUT = 0x00; else Toggle = 0;*/ } } //TimerA is called every 5 msec //Clock Time Period is 1/32KHz. //(1/32000)*164 = 0.005125 OR 5.1 msec. #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A(void) { static unsigned int Exit_Time = 0; static unsigned int Toggle = 0; TACCR0 = 164; Toggle++; /*if ((Toggle > 0) && (Toggle < 2)) P5OUT = 0x01; else if ((Toggle >= 2) && (Toggle < 3))P5OUT = 0x00; else Toggle = 0;*/ Exit_Time++; if (Exit_Time > 100) //if runs true every 500 msec { __bic_SR_register_on_exit(LPM3_bits); //Exit low power mode Exit_Time = 0; } } void floorit(void) // 8MHz MCLK 2MHz SMCLK 09/28/2017 { DCOCTL = *(unsigned char *) (0x10f8 + CAL_DCO_8MHZ); BCSCTL1 = *(unsigned char *) (0x10f8 + CAL_BC1_8MHZ); _NOP(); _NOP(); _NOP(); BCSCTL2 = DIVM_0 + DIVS_2; // DCOLCK for MCLK and SMCLK. //8MHz/1 for MCLK (8MHz), 8MHz/4 for SMCLK (2MHz) _NOP(); _NOP(); _NOP(); }
Can any body explain why this is happening.