-
遥控解码程序,弄了一天,哪错了?
void T0ISR(void) interrupt 1 { TL0=0x4A; TH0=0XFF; TF0=0; if (!RF) { ll_w++;old_rc5=0; } else { hh_w++; if (!old_rc5) { if ((hh_w>=2)&&(hh_w<=8)&&(ll_w>=100)&&(ll_w<=190)&&(!tb_ok)) { ma_x=0; tb_ok=1; bma1=bma2=bma3=0; // LED=~LED;会执行该语句,因为接收模块在无接收信号时,也会有高电平脉冲输出 // hh_w=ll_w=0; } else if((tb_ok)&&(ll_w>=11)&&(ll_w<=15)) { ma_x++; if (ma_x>23) { if (!rf_ok1) { mma1=bma1;mma2=bma2;mma3=bma3; rf_ok1=1; tb_ok=0; s=1000; } else { mma1=bma1;mma2=bma2;mma3=bma3; rf_ok2=1; tb_ok=0; s=1000; } } } else if((tb_ok)&&(ll_w>=3)&&(ll_w<=6)) { switch (ma_x) { case 0:{bma1=bma1|0x80;break;} case 1:{bma1=bma1|0x40;break;} case 2:{bma1=bma1|0x20;break;} case 3:{bma1=bma1|0x10;break;} case 4:{bma1=bma1|0x08;break;} case 5:{bma1=bma1|0x04;break;} case 6:{bma1=bma1|0x02;break;} case 7:{bma1=bma1|0x01;break;} case 8:{bma2=bma2|0x80;break;} case 9:{bma2=bma2|0x40;break;} case 10:{bma2=bma2|0x20;break;} case 11:{bma2=bma2|0x10;break;} case 12:{bma2=bma2|0x08;break;} case 13:{bma2=bma2|0x04;break;} case 14:{bma2=bma2|0x02;break;} case 15:{bma2=bma2|0x01;break;} case 16:{bma3=bma3|0x80;break;} case 17:{bma3=bma3|0x40;break;} case 18:{bma3=bma3|0x20;break;} case 19:{bma3=bma3|0x10;break;} case 20:{bma3=bma3|0x08;break;} case 21:{bma3=bma3|0x04;break;} case 22:{bma3=bma3|0x02;break;} case 23:{bma3=bma3|0x01; if (!rf_ok1) { tb_ok=0; rf_ok1=1; mma1=bma1;mma2=bma2;mma3=bma3; s=1000; break; } else { tb_ok=0; rf_ok2=1; mmb1=bma1;mmb2=bma2;mmb3=bma3; s=1000; break; } } } ma_x++; } else { ma_x=0; tb_ok=0; bma1=bma2=bma3=0; ll_w=0;hh_w=1; } ll_w=0;hh_w=1; } old_rc5=1; } if (rf_ok1) { s--; if(!s) rf_ok1=0; if(rf_ok2) { if ((mma1==mmb1)&&(mma2==mmb2)&&(mma3=mmb3)) { rf_ok=1; rf_ok1=0; rf_ok2=0; } else { rf_ok=0; rf_ok1=0; rf_ok2=0; } } } if (rf_ok) { EA=0; rf_ok=0; // D3=!(mma3&0x08); // D2=!(mma3&0x04); // D1=!(mma3&0x02); // D0=!(mma3&0x01); D3=mma3&0x08; D2=mma3&0x04; D1=mma3&0x02; D0=mma3&0x01; decode_ok=1; s1=1500; VT=0; EA=1; } if (decode_ok) { s1--; if (!s1) { decode_ok=0; VT=1; } } } ======================================================== 就是用的STC89C52RC,定时器0,100us,基本上照着原样敲的,我要崩溃了 下载视频
2837浏览量 4回复量 关注量