if(CCP1IF == 1) //过零点检测中断服务程序
{
CCP1IF =0;
CCPR1H=0;
CCPR1L=0;
CCP1CON = 0x00;
CCP1CON = 0x04;
count1=CCPR1H;
count1=(count1<<8)+CCPR1L;
}
if(CCP2IF == 1) //过零点检测中断服务程序
{
CCP2IF =0;
CCPR2H=0;
CCPR2L=0;
CCP2CON = 0x00;
CCP2CON = 0x04;
count2=CCPR2H;
count2=(count2<<8)+CCPR2L;
}
if(count1<count2)//&&(count2<500000)) //我的晶振是5mhz的
{RA5 = 1;test2=1;} //开灯
else
{
RA5 = 0;
test1=1;
}
count1=0;
count2=0;//每次都清零,这样能比较两个方波的相位谁超前么???
|