START:
MOV A, #01010101B
LCALL SENTINFRA
MOV A, #10101010B
LCALL SENTINFRA
JMP START
SENTINFRA: ;VALUE PUT A
MOV 32H, A ;SAVE FOR RE-USE
MOV 33H, #11110000B ;USER CODE
LCALL LEADINGBIT
;----------------USERCODE
MOV 30H, 33H
LCALL SENTBYTE
MOV A, 33H
CPL A
MOV 30H, A
LCALL SENTBYTE
;----------------SCANCODE
MOV 30H, 32H
LCALL SENTBYTE
MOV A, 32H
CPL A
MOV 30H, A
LCALL SENTBYTE
LCALL STOPBIT
LCALL DELAY3
RET
SENTBYTE:
MOV 31H, 30H
MOV 34H, #8
SENTBYTE1:
MOV A, 31H
RRC A
MOV 31H, A
JC BIT1
LCALL ZEROBIT
JMP BITEND
BIT1:
LCALL ONEBIT
BITEND:
DJNZ 34H, SENTBYTE1
RET
MOV 95H, #00000000B ;SETP2.7 AS HIGHOUTXURRENT FOR IR POWER
MOV 96H, #00010000B ;SETP2.7 AS HIGHOUTXURRENT
SETB P2.7
SETB EX1 ;ENABLE EXTERNAL INTERRUT P3.3
CLR PX1 ;SET EXTERNAL INTERRUT PARITY TO LOW
CLR IE1 ;CLEAR EXTERNAL INTERRUT FLAG
SETB IT1 ;SET AS H TO L AS INTERRUT METHOD
SETB EA
START:
LCALL DELAY3
;LCALL DELAY3
JMP START
EXT_INT1: ;USE FOR INFRA RED
CLR EX1 ;STOP THE INTERRUPT_1
LCALL INFRARED
SETB EX1 ;REOPEN EXTERNAL INTERRUPT 1
CLR IE1 ;CLEAR EXTERNAL INTERRUT FLAG
RETI
INFRARED: ;21-12-2018 NO MORE USING R0
CPL P2.7
MOV DPH, #0
PUSH ACC
IR: ;DETECT 9000US INIT LOW
MOV 62H,#2 ;TEST 5 TIMES 882uS=8820us
IR_SB1:
LCALL DELAY882 ;882us
DJNZ 62H,IR_SB1 ;
JB P3.3,IRNEW ;IF HIGH THEN NEW
CPL P2.7
MOV P0, #0
IREXIT:
POP ACC
RET
IRNEW: ;NEW CODE ;NO START BIT, ONE STOP BIT
CPL P2.7
LCALL DELAY800
LCALL DELAY800
CPL P2.7
JNB P3.3,IREXIT ;IF HIGH THEN NEW
LCALL DELAY250 ;START BIT
CPL P2.7
MOV R7, #8
IRNEW1:
LCALL DELAY450
CPL P2.7
MOV C,P3.3 ;STORE P3.3 TO C
RLC A
DJNZ R7, IRNEW1
MOV 67H, A
MOV R7, #8
IRNEW2:
LCALL DELAY450
CPL P2.7
MOV C,P3.3 ;STORE P3.3 TO C
RLC A
DJNZ R7, IRNEW2
MOV 68H, A
;-----------------STOPBIT
MOV A, 67H
CPL A
CJNE A, 68H, IRNEWEXIT
MOV P1, 68H
SETB 25H ;VALID CODE
IRNEWEXIT:
JMP IREXIT