IRDecode: USING 2 PUSH PSW MOV PSW,#010H MOV R1,#200; MOV R2,#90; MOV R3,#00; MOV R4,#24; MOV R5,#00; MOV R6,#00; MOV R7,#00; CLR IRFcodeEN; ;解码正确标志 Playhead: JB iIRF,Playdata ;为1跳 NOP ;0.5 DJNZ R1,Playhead ;1.5 0.5+200*0.5+1.5=102us MOV R1,#200; DJNZ R2,Playhead JMP IRDecodeEnd ;超时退出 Playdata: ;说明10MS之内有高电平出现 JB IRreleaseEN,IRDecodeEnd1 MOV R1,#80 PlaydataLOOP: JNB iIRF,nextdata1 CALL delay100us DJNZ R1,PlaydataLOOP JMP IRDecodeEnd ;为0,高电平大于600US,退出 nextdata1: ;if(300<hihg<600) c=1 MOV A,#56 SUBB A,R1 JNC datahigh ;是高电平出现,跳到高电平的低出现 ;======================================================当<300时,看是否在90<>200之间 MOV A,#76 SUBB A,R1 JNC datalow JMP IRDecodeEnd ;R<90,错误退出 datalow: ; MOV A,#50 ; SUBB A,R1 ; JNC IRDecodeEnd ;R>20,错误退出 ;====================================================低电平的高检测 MOV R1,#80 datalowLOOP: JB iIRF,datalow1 ;1.5 CALL delay100us ;11.5 DJNZ R1,datalowLOOP ;12.5 JMP IRDecodeEnd ;>600退出 datalow1: MOV A,#56 SUBB A,R1 JC IRDecodeEnd ;300>退出 CLR C JMP STARTBIT ;====================================================高电平的低检测 datahigh: MOV R1,#30 datahighlooop: JB iIRF,datahigh1 CALL delay100us DJNZ R1,datahighlooop JMP IRDecodeEnd ;说明低电平时间大于200,退出 datahigh1: MOV A,#23 ;90<low<200 SUBB A,R1 JNC _1BIYOVER JMP IRDecodeEnd ;LOW>80,数据错误退出 _1BIYOVER: SETB C STARTBIT: MOV A,R5 RRC A MOV R5,A
MOV A,R6 RRC A MOV R6,A
MOV A,R7 RRC A MOV R7,A
DJNZ R4,Playdata SETB IRFcodeEN ;解码正确标志位为1 MOV IRcode3,R5 MOV IRcode2,R6 MOV IRcode1,R7 SETB IRreleaseEN JMP IRDecodeEnd1 IRDecodeEnd: CLR IRreleaseEN IRDecodeEnd1: POP PSW RET ;===================================== RSEG ?PR?delay100us?2262 delay100us: ;10us MOV R2,#10 delay100loop: DJNZ R2,delay100loop RET END |