用阻容式电源 PIC16F630控制 接受红外信号 用外中断解码
按键时 由于遥控器是连续发码(108MS) 中间有短暂熄灭 现象
有谁知道 怎么回事么
给出中断部分先,帮着看看
void interrupt ISR() { //定时器0用作中断 if(T0IF==1) {
T0IF = 0; //清中断标志 TMR0 = 155; //设定timer0的初值 timer0_cnt++; timer0_cnt1++;
}
if(RAIF&&RAIE)//电平变化中断 {
RAIF = 0;//清中断标志 RA0 = RA0;//重新读RA0口参数 start_flag=1;
}
if(INTF&&INTE) //外中断用于红外解码 { INTF=0; //GIE=0;
// delay_cpp1_cnt++; ccp1_cnt++; //flag_flag=1;
if(head_ok==0) //通讯开始 { //过头码 if((timer0_cnt>0x28)&&(timer0_cnt<0x32))//4mS-5mS { head_ok = 1; ccp1_cnt=0; timer0_cnt=0; TMR0 = 155; } else { wrong(); } }
else {
TMR0 = 155; temp_code=temp_code>>1; temp_code&=0x7f; if(zero_or_one()==1) {
temp_code|=0x80; } timer0_cnt = 0;
add = temp_code;
if(ccp1_cnt==8) { if(add!=0x84) { wrong(); } }
else if(ccp1_cnt==16) {
if(add!=0x52) { wrong(); } }
if(ccp1_cnt==24) {
code=temp_code; } else if(ccp1_cnt==32) { ccp1_cnt =0; head_ok = 0; if(code+temp_code==0xff) {
if(code==0xF7||code==0xE7)//ON/OFF { if(led_light==0) { led_light_up=1; led_light_down=0;
}
if(led_light<=30&&led_light>0) { led_light_up=0; led_light_down=1;
}
}
else if(code==0xFA||code==0xEA)//UP { if (led_light>=0&&led_light<=29)
led_light++;
led_light_up=0; led_light_down=0; }
else if(code==0xF3||code==0xE3)//DOWN {
if (led_light>=1&&led_light<=30)
led_light--;
led_light_up=0; led_light_down=0; }
flag=1;
// GIE=1; // INTF=0; } else { wrong(); }
} }
}
}
|