This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TimerA0 溢出中断的问题



首先看两个程序:

1》

#include  <msp430x14x.h>

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P2DIR |= 0x0f;
  P2OUT |= 0x0f;
  TACTL = TASSEL_1 + MC_2+TAIE;         // ACLK, contmode, interrupt
  CCR0=50000; 
  CCTL0=CCIE;                     

  _BIS_SR(LPM3_bits + GIE);                 // Enter LPM3 w/ interrupt
}

#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A0(void)

{
P2OUT ^= 0x01;
}

这个程序运行的结果是1.52S的高电平,0.5S的低电平,说明CCR0=50000的时候产生了一个比较中断CCIFG,运行了一次中断,然后定时器一直计数到65535又产生了一个溢出中断TAIG,又运行了一次中断,如此重复,分析没有问题吧

2》

#include  <msp430x14x.h>

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P2DIR |= 0x0f;
  P2OUT |= 0x0f;
  TACTL = TASSEL_1 + MC_2+TAIE;         // ACLK, contmode, interrupt
                                                                           去掉了CCRO的比较中断                  

  _BIS_SR(LPM3_bits + GIE);                 // Enter LPM3 w/ interrupt
}

#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A0(void)

{
P2OUT ^= 0x01;
}

这个只有溢出中断TAIE,运行结果应该是2S高电平,2S低电平,但是我的测试结果是一直为低电平,这是什么原因?