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定时器1的使用咨询



你好,基于zstack3.0.2,用2530定时器1的通道4去捕获P0.6口输入的波形的脉宽

请帮忙分析一下下面的代码实现是否有问题?待捕获脉冲的最小宽度为10us左右的方波,

我测试了一下的代码,有的时候捕获的不对,脉宽应该是10us左右,有的时候捕获成了三四十这样?

我怀疑是不是那里没配置好?还是T1CC4H和T1CC4L的读取方法不对?

void Init_T1_IN(void)
{
PERCFG |= (1<<6);//采用备用位置2
P0SEL |= (1<<6); //P0.6作为捕获通道
P0DIR &= ~(1<<6); //输入
T1CTL |=0x09; //8分频2M,反复运行 
T1CCTL4|= 0x03; //上升下降沿捕获
T1CCTL4&=~0x04; //捕获模式
T1IF=0;
T1STAT &= ~0x10; //清除通道0中断标志
IEN1|=0X02; //使能定时器1的中断
EA =1; //EA enable
}

__interrupt void T1_IRQ(void)
{
  IRCON = 0;
  if(T1STAT & 0x10) 
  {
   T1STAT &= ~0x10;
   bufH[signle]=T1CC4H;
   bufL[signle]=T1CC4L;
  signle++;
  }
}