Hi all ! I'm doing "energy harvester" with wireless sensor node that includes msp430g2553 MCU. Trying to measure power consumtion, but no do not go for now. Using shunt resistor (1k 5%) i have got 345uA for active and 320uA for LPM3 mode. I thout that is something wrong here. Measured using multimeter - got almost the same results - 319uA for LMP3 mode ! Do not understand...It means that MCU do not go sleep ? Testing algorythm is : waiting for button press, then send some data using UART (150 in my code), after that go to sleep (LPM3) and wake up when UART RX or P1 BIT4 interrupt occures. Now everything is acting as is should, only current consumtion is very high in LPM3. Maybe someone can find mistake in my code. Thanks !
#include <stdio.h>
#include "serial.h"
#define LED0 BIT0
#define LED1 BIT6
#define RXD 0x02
#define TXD 0x04
#define PUSH 0x08
volatile unsigned int run=0, sleep=0;
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
uart_init(); //is header failo
P1DIR &=~PUSH; // Mygtukas kaip įėjimas BUTTON as INPUT
P1OUT |= PUSH;
P1REN |= PUSH; // Enables pullup resistor on button
P1DIR |= LED0;
P1DIR |= LED1;
P1OUT &= ~LED0; //pradine busena - off
P1OUT &= ~LED1;
P1IE |= BIT4; // igaliname P1.4 pertraukti interrupt fot P1 BIT4
UC0IE |= UCA0RXIE; // Enable USCI_A0 RX interrupt
__enable_interrupt();
while(1)
{
P1OUT|=LED1; // LED for indicating active mode
if((P1IN & PUSH)==!PUSH) { // Was button pressed?
P1OUT ^=LED0 ;
run^=0xFF;
__delay_cycles(500000);
}
if (run==0xff) //START FLAG
{
//SENT DATA FOR RF MODULE
send_int(9); //duomenu nusistovejimui
__delay_cycles(23000);
send_int(1);
send_int(2);
__delay_cycles(23000);
sleep++; //counter for sleep mode
}
if (sleep>=150) { //go to sleep
P1OUT &= ~LED1; //LED1 OFF
P1OUT &= ~LED0; //LED0 OFF
sleep=0x00; //clear sleep mode counter
run=0x00; //clear start flag
_BIS_SR(LPM3_bits + GIE); //Go to LPM3 mode
}
} //while
} //main
//----------------------------------P1 BIT 4 interrupt -----------------------------------------
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1IFG &= ~BIT4; // P1.4 IFG cleared
P1IES &= ~BIT4; // toggle the interrupt edge,
_BIC_SR(LPM3_EXIT); // LPM3 WAKE UP
}
//----------------------------------UART RECEIVED interrupt---------------------------------------
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
if (UCA0RXBUF == '1')
{
//for future
}
_BIC_SR(LPM3_EXIT); // LPM3 WAKE UP
}