Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 21954

MSP430FR5994: LPM3 using timer interrupt.

$
0
0

Part Number:MSP430FR5994

Dear Sirs:

    I have a simple program that runs on the 430fr5994 launch pad board.  It is always in lpm 3 but a timer runs and operates an interrupt which toggles the LED.  Have everything pulled down.  Unit supposed to be running at 8Mhz.  

    The sleep current I'm measuring is 94ua and led current is 3ma.   I'm wondering if the 94ua is correct.  Was hoping this would be less than 10us.

The program is as follows:


#include <msp430.h>
/*
* DEFINE LED PORT & PIN
*/
#define LED_PDIR P1DIR
#define LED_POUT P1OUT
#define LED_PIN BIT0

void ConfigTimerA(unsigned int delayCycles);
/*****************************************************************
*
* FUNCTION: blinkInterrupt
*
* PURPOSE: Blink an LED using TimerA and interrupts
*
* PARAMETERS: none
*
*                       .43ma and 3.28ma
*
*                       .094 and 2.97ma  extra jumpers removed
*
*****************************************************************/
void main(void)
{
    WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    PM5CTL0 &= ~LOCKLPM5;                   // Disable the GPIO power-on default high-impedance mode

    // Init clocks and I/O:
    // Startup clock system with max DCO setting ~8MHz
    CSCTL0_H = CSKEY >> 8;                    // CSKey=A500.  Unlock clock registers
    CSCTL1 = DCOFSEL_3 | DCORSEL;             // Set DCO to 8MHz.  6|40
    CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
    CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
    CSCTL0_H = 0;                             // Lock CS registers


    //Configure the LED
    P1SEL0 &= ~BIT0;          //select GPIO for P1.0
    P1SEL1 &= ~BIT0;
    P1DIR = 0; // Set P1 port to input direction
    P1REN = 0;  //pulldowns

    LED_PDIR |= LED_PIN; //Set P1.0 as an Output pin
    LED_POUT &= ~LED_PIN; //Set P1.0 LOW (turn LED off)


    //set unused ports to pulldown:
    P2SEL0 &= ~BIT0;          //select GPIO for P1.0
    P2SEL1 &= ~BIT0;
    P2DIR =0; // Set P2 to input direction
    P2REN = 0;      //pulldowns

    P3SEL0 &= ~BIT0;          //select GPIO for P1.0
    P3SEL1 &= ~BIT0;
    P3DIR =0; // Set P2 to input direction
    P3REN = 0;      //pulldowns

    P4SEL0 &= ~BIT0;
    P4SEL1 &= ~BIT0;
    P4DIR =0;           //to input direction
    P4REN = 0;      //pulldowns


    P5SEL0 &= ~BIT0;          //this has push buttons
    P5SEL1 &= ~BIT0;
    P5DIR =0;           //to input direction
    P5REN = 0;      //pulldowns

    P6SEL0 &= ~BIT0;
    P6SEL1 &= ~BIT0;
    P6DIR =0;           //to input direction
    P6REN = 0;      //pulldowns

    P7SEL0 &= ~BIT0;
    P7SEL1 &= ~BIT0;
    P7DIR =0;           //to input direction
    P7REN = 0;      //pulldowns

    P8SEL0 &= ~BIT0;
    P8SEL1 &= ~BIT0;
    P8DIR =0;           //to input direction
    P8REN = 0;      //pulldowns

    ConfigTimerA(50000); //Configure the timer
    while (1)
    {
        _bis_SR_register(LPM3_bits + GIE); //Enter Low Power Mode 3 with interrupts
    }
}
/*****************************************************************
*
* FUNCTION: configTimerA
*
* PURPOSE: Configure the TimerA
*
* PARAMETERS: delayCycles: number of clock cycles to delay
*
*****************************************************************/
void ConfigTimerA(unsigned int delayCycles)
{

    TA0CCTL0 |= CCIE; //Enable Interrupts on Timer
    TA0CCR0 = delayCycles; //Number of cycles in the timer
    TA0CTL |= TASSEL_1; //Use ACLK as source for timer
    TA0CTL |= MC_1; //Use UP mode timer

}
/*****************************************************************
*
* FUNCTION: Timer_A0
*
* PURPOSE: Interrupt Handler to service the TimerA0 interrupt
*
* PARAMETERS: none
*
*****************************************************************/
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A0(void)
{
    LED_POUT ^= LED_PIN; //Toggle the LED
//When we exit the interrupt routine we return to Low Power Mode
}

Please let me know.

Thanks,

John


Viewing all articles
Browse latest Browse all 21954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>