我很郁闷,连续试了几个sample code都有问题
我的程序:
void main( void )
{
volatile unsigned int i;
// Stop the watchdog timer so it doesn't reset our chip
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
_BIS_SR(OSCOFF + SCG0 + GIE);
SCFI0|=FN_8;
FLL_CTL0 |= OSCCAP0+DCOPLUS; // set oscillator capacitance
do
{
IFG1 &= ~OFIFG; // Clear oscillator fault flag
for ( i=50000; i==0; i--); // Delay
}
while (IFG1 & OFIFG); // Test osc fault flag // DCO to stabilize.
__delay_cycles( 1000 );
TACCTL0 = CCIE; // TACCR0 interrupt enabled
TACCR0 = 2000;
TACTL = TASSEL_2 + MC_1+ID_3+TAIE; // SMCLK, up mode
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
while(1);
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
timer++;
}
问题是无法进入中断,timer这个变量始终为0,很简单一个程序出现这个问题我真不知道哪错了,请高人指点!
此帖出自
小平头技术问答
一周热门 更多>