TI中文支持网
TI专业的中文技术问题搜集分享网站

关于28335的CAP识别高低电平的问题。

interrupt void ISRCap1(void)
{

// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
ECap1Regs.ECCLR.all=0xFFFF;//clare all flag
t1= ECap1Regs.CAP1;
t2= ECap1Regs.CAP2;
t3= ECap1Regs.CAP3;
t4= ECap1Regs.CAP4; T1=t2-t1;
T2=t3-t2;
T3=t4-t3;
if(t1<50) { SampleTable[array_index++]=0;
}
else
{
{ SampleTable[array_index++]=0;
}
SampleTable[array_index++]=0;
}
if(T1<50) { SampleTable[array_index++]=1;
}
else
{
{ SampleTable[array_index++]=1;
}
SampleTable[array_index++]=1;
}
if(T2<50) { SampleTable[array_index++]=0;
}
else
{
{ SampleTable[array_index++]=0;
}
SampleTable[array_index++]=0;
}
if(T3<50) { SampleTable[array_index++]=1;
}
else
{
{ SampleTable[array_index++]=1;
}
SampleTable[array_index++]=1;
}

if(array_index>127)
array_index=0;
}

void SetCap1Mode(void)
{
ECap1Regs.ECCTL1.bit.CAP1POL = EC_RISING;
ECap1Regs.ECCTL1.bit.CAP2POL = EC_FALLING;
ECap1Regs.ECCTL1.bit.CAP3POL = EC_RISING;
ECap1Regs.ECCTL1.bit.CAP4POL = EC_FALLING;
ECap1Regs.ECCTL1.bit.CTRRST1 = EC_ABS_MODE;
ECap1Regs.ECCTL1.bit.CTRRST2 = EC_ABS_MODE;
ECap1Regs.ECCTL1.bit.CTRRST3 = EC_ABS_MODE;
ECap1Regs.ECCTL1.bit.CTRRST4 = 1;//4级事件清零
ECap1Regs.ECCTL1.bit.CAPLDEN = EC_ENABLE;
ECap1Regs.ECCTL1.bit.PRESCALE = EC_DIV1;
ECap1Regs.ECCTL2.bit.CAP_APWM = EC_CAP_MODE;
ECap1Regs.ECCTL2.bit.CONT_ONESHT = EC_CONTINUOUS;
ECap1Regs.ECCTL2.bit.SYNCO_SEL = EC_SYNCO_DIS;
ECap1Regs.ECCTL2.bit.SYNCI_EN = EC_DISABLE;
ECap1Regs.ECEINT.all=0x0000;//stop all interrupt
ECap1Regs.ECCLR.all=0xFFFF;//clare all flag
ECap1Regs.ECCTL2.bit.TSCTRSTOP = EC_RUN;// 启动
ECap1Regs.ECEINT.bit.CEVT4=1;// Enable cevt4 interrupt
}

识别的波形是那种400kR232电平信号,通过计算高电平时间判断数据是0还是1,在DSP结果寄存器中查看数据有很大误差,这是怎么回事呢?请各位指教

mangui zhang:没配置好400k速率比较低 了如果用CAP做两次沿的计数差值你不是做差的时候有益处
这个做差值时要判断被减数是否小于减数

赞(0)
未经允许不得转载:TI中文支持网 » 关于28335的CAP识别高低电平的问题。
分享到: 更多 (0)