想通过这段中断程序来控制定时器1的捕获,但是发现只能接收一次串口的指令,不知道哪里有问题,还望大神指点一下~
oid interrupt usart(void)
{
if(RCIE&&RCIF) //判断是否为串口接收中断
{
RD0=!RD0;
stage4=stage3;
stage3=RCREG;
if((stage4==0XFE)&&(stage3==0X68))
{ begin=1;j=0; }
if(begin==1)
{
receive[j++]=stage3;
if((receive[j-1]==0X16)&&(j==9))
{ begin=0;j=0;
data=receive[3];
if((receive[1]==0x13)&&(receive[3]==0x01))
ccpint();
if((receive[1]==0X13)&&(receive[3]==0x00))
PIE1=0x00;
}
if(j==20)
{ j=0; begin=0;}
}}
if(CCP1IF==1)
{ CCP1IF=0;
counter++;
RD4=!RD4;
TXREG=counter;
}
} |