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.

430F122进中断问题

Other Parts Discussed in Thread: MSP430F122
在MSP430F122上写了一段很简单的程序,想用定时器控制LED灯,一段时间后翻转LED引脚。但发现无法进入定时器中断,用仿真器单步调试,发现运行到BCSCTL2 |=SELM_2+SELS; 就无法继续执行,绿颜色的提示行消失,下面debug log也没有报错。XIN--XOUT 接的是8MHZ的。求助这是为什么,哪里设置有问题?谢谢!

代码:

#include <msp430f122.h>
int count=0;

int main( void )
{
  int j;    
    WDTCTL = WDTPW + WDTHOLD;       //关闭看门狗  
    BCSCTL2 |=SELM_2+SELS; 
    CCTL0 = CCIE;                   //使能CCR0中断
    CCR0 = 40000;                    //设定周期               
    TACTL = TASSEL_1 + ID_3 + MC_1; //定时器A的时钟源选择ACLK,增计数模式
    P2DIR = 0xff;                   //设置P2口方向为输出
    P2OUT = 0xff;

    __enable_interrupt();                        //使能全局中断
    while(1)
    {
      j=count;
    }
}

/*******************************************
函数名称:Timer_A 
功    能:定时器A的中断服务函数
参    数:无
返回值  :无
********************************************/
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{  
  if(count==50) 
  {
    count=0;
    P2OUT ^= 0xff;                  //P2口输出取反  
  }
  else
  {
    count++;
  }
}