#include "msp430.h"
// set names for bits to improve code readability
#define LED0 BIT0
#define LED1 BIT6
#define LED_DIR P1DIR
#define LED_OUT P1OUT
void main (void)
{
WDTCTL = WDTPW + WDTHOLD; // halt the watchdog timer
LED_DIR |= LED0 + LED1; // set both pins with our two LEDs as ouputs
LED_OUT &= ~(LED0 + LED1); // make sure both LEDs are off to begin with
TACCTL0 = CCIE; // enable timer interrupt
TACCR0 = 16384; // set timer value to count
// Start timer A0, in UP mode. which counts from 0x0000 to the value
// in TACCR0, then generate an interrupt.
TACTL = TASSEL1 + MC_1;
// Enter low power mode one, with general interrupts enabled.
__bis_SR_register(LPM1_bits + GIE);
}
#pragma vector=TIMERA0_VECTOR // timer A0 interrupt routine
__interrupt void timerA0_isr(void) {
// Flip the output state of both LEDs.
// After each interrupt, the state changes, which makes the LEDs blink.
LED_OUT ^= (LED0 + LED1);
}
Puede cambiar el temporizador para que parpadee en el intervalo adecuado. Además, si inicialmente activa un led y el otro, cuando se produzca la interrupción, parpadearán alternativamente.