通过计算设置周期。
#include
void main( void )
{
// Stop watchdog timer to prevent TIme out reset
WDTCTL = WDTPW + WDTHOLD; //WDTCTL = 0X5A80;关狗
CCTL0 = CCIE; //使能CCR0中断
CCR0 = 4095; //设置周期为0.5s
TACTL = TASSEL_2 + ID_2 + MC_1; //时钟源的选择,分频,模式
P2DIR = 0XFF;
// P2OUT = 0XFF;
_EINT();
LPM0;
}
#pragma vector = TIMERA0_VECTOR
__interrupt void TImer_A()
{
P2OUT = ~P2OUT;
// CCR0 += 50000;
}