#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT0;
P1OUT |= BIT0;
TA0CCTL0 = CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 50000;
TA0CTL = TASSEL_2 + MC_2; // SMCLK, continuous mode
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
// Timer A0 interrupt service routine
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
P1OUT ^= BIT0;
TA0CCR0 += 50000; // Add Offset to TACCR0
}
这个程序中
TA0CCTL0 = CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 50000;
TA0CTL = TASSEL_2 + MC_2; // SMCLK, continuous mode
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupt |