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.

cc2530 捕获总是溢出,怎么办???



首先请问一下cc2530定时器 T1的捕获功能应该能实现对输入频率信号的周期的测量吧???

我的程序测出来的总是T1中断后到T1计时溢出的频率值,和输入频率一点关系都没有怎么回事,高手帮看看呗,谢谢

#pragma vector=T1_VECTOR
__interrupt void T1_ISR(void)
{
    P0_0=~P0_0;
    T1IF=0;
}

 

void Init_T1_IN()
{   P0SEL &= ~0x01;  //P0_0 I/O口普通功能
    P0DIR = 0x01; //P0_0 I/O口,设置为输出模式,P0-1,P0-4是输入
    P0INP = 0x01; //上拉  
   
    PERCFG &=0x10111111;//采用备用位置1 
    P0SEL = 0x10;    //P04作为捕获通道

    T1CTL =0x05;      // 定时器1控制/状态0x00000101  8分频后=4MHZ,自由模式反复运行   
    T1IF =0;           // 中断标志使能
    T1STAT=0x00111011;
    T1CCTL2= 0x01;    //上升沿捕获
    T1CCTL2&=~0x04;    //捕获模式
    T1IE   |= 1;       //TIMER1 enable
    TIMIF  |= 0x40;    //定时器1溢出中断屏蔽
    EA  =1;            //EA  enable
}

 

void main(void)
{
       Init_T1_IN();

      while(1)  {}

}