void PCA_isr() interrupt 7 using 1
{
if (CCF0)
{
CCF0 = 0;
if (CF && ((CCAP0H & 0x80) == 0))
{
CF = 0;
cnt++;
}
count0 = count1; //备份上一次的捕获值
((BYTE *)&count1)[3] = CCAP0L; //保存本次的捕获值
((BYTE *)&count1)[2] = CCAP0H;
((BYTE *)&count1)[1] = cnt;
((BYTE *)&count1)[0] = 0;
//我想知道这上面的四条语句的意思,最终count1的值是多少?
length = count1 - count0; //计算两次捕获的差值,即得到时间长度
((BYTE *)&length)[0] = 0;
}
if (CF)
{
CF = 0;
cnt++; //PCA计时溢出次数+1
}
}
|