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.

如果同时使用TimerA、TimerB而不产生干扰?



需求:使用MSP430的TimerB产生1秒1次的LED闪烁,同时对闪烁次数时行计数。
问题:发现启用TimerB后,主程序产生不确定的复位现象,而屏蔽后不会发生这种异常复位。
代码如下:

void TimerA1_Init(void)
{
  TA1CCTL0 |= CCIE;    // TBCCR0 interrupt enabled  
  TA1CCR0 = 32750;   // 最大允许数为65535
  TA1CTL = TASSEL_1 + MC_1 + TACLR;       // TACLK = ACLK, upmode, clear TAR
  __bis_SR_register(GIE);                 //不需要进入低功耗
}

// Timer1_A0 interrupt service routine
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TA1_ISR (void)
{
  TA1CTL = TASSEL_1 + MC_1 + TACLR;       // TACLK = ACLK, upmode, clear TBR 
  TA1_Cnt1++;                             // 计数器 
   if (TA1_Cnt1 >= 1000)
      while(1);   //利用看门狗进行复位
  P1OUT ^= BIT1;   // 用P1.1接LED表示看门狗的工作状态
  WDTCTL = WDT_ARST_1000;                 //喂看门狗,设置看门狗的时间为1000ms
}

在主程序中,同时使用了TimerA0定时器用于需要的延时,结果发现只要启用了 TimerA1_Init(),就会发生异常的复位、且复位的发生时机也是不确定的。