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.

定时器时钟定时一位时间与半位时间切换问题?

Other Parts Discussed in Thread: MSP430F5172

尊敬的工程师,你好!

我想用定时器的时钟实现一位与半位的时间转换,但是只测到一位的时间,不能测到半位的时间,代码如下,麻烦帮我看一下,谢谢!

void main()
{  
   P1DIR |=BIT7;
   TD0CCTL0 |=CCIE;
   TD0CTL0=TDSSEL_2+MC_1;
   Time_int();
   while(1)
  {
    ;
  }
}
unsigned int select=0;
void Time_int()
{
  
  select++;
  if(select%2==1)
  {
    Timer();
  }
  else
  {
     Timer_5();
  }
  if(select==1000)
  {
    select=0;
    TD0CCTL0&=~CCIE;
  }
}
void Timer()
{
 
  TD0CCR0=873;
 __bis_SR_register(GIE);
}
void Timer_5()
{
   TD0CCR0=436;
  __bis_SR_register(GIE); 
}
#pragma vector=TIMER0_D0_VECTOR                                   
 __interrupt void TIMER0_D0_ISR(void) 
 {
    P1OUT ^=BIT7;
 }