Chương trình
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP NGAT_NGOAI_0
;ORG 000BH
;LJMP NGAT_TIMER0
ORG 0030H
MAIN:
MOV IE, #10000001B; NGAT NGOAI 0
MOV 0028H,#00H
MOV 0029H,#00H
MOV P1, #0FFH
SETB P3.2
SETB IT0
LJMP $
NGAT_NGOAI_0:
CLR EX0
MOV R0,0028H
MOV R1,0029H
MOV R7,#00H
CLR C
MOV A,#40H
CHOLENIR1:
JNB P3.2,CHOLENIR1
CHOXUONGIR1:
JB P3.2,KT
MOV R7,#00H
LCALL DELAY1000
JB P3.2,NHAPC0IR1
SETB C
RRC A
JC MAINIR2 ;KT VA THUC HIEN
SJMP CHOLENIR1
NHAPC0IR1:
CLR C
RRC A
JC MAINIR2 ;KT VA THUC HIEN
SJMP CHOXUONGIR1
MAINIR2:
RR A
CJNE A, #15H,KTIR0
MOV 0027H,A
MOV P1,#11100111B ; tat het
LCALL DELAY1S
MOV P1,#11101111B ; tat het, TAT COI
SJMP NHAY
KTIR0:
CJNE A,#00H,KTIR1
MOV 0027H,A
MOV P1,#11010110B; SO 1
LCALL DELAY1S
MOV P1,#11011110B; SO 1 , TAT COI
SJMP NHAY
KTIR1:
CJNE A,#01H,KTIR2
MOV 0027H,A
MOV P1,#10110101B; SO 2
LCALL DELAY1S
MOV P1,#10111101B; SO 2, TAT COI
SJMP NHAY
KTIR2:
CJNE A,#02H,NHAY
MOV 0027H,A
MOV P1,#01110011B; SO 3
LCALL DELAY1S
MOV P1,#01111011B; SO 3 , TAT COI
SJMP NHAY
KT:
INC R7
CJNE R7,#150,CHOXUONGIR1
MOV R7,#00H
SJMP NHAY
NHAY: SETB EX0
RETI
DELAY1000: ;DELAY DO MA
PUSH 00H
PUSH 01H
MOV R0,#2
DL1000:
MOV R1,#250
DJNZ R1,$
DJNZ R0,DL1000
POP 01H
POP 00H
RET
DELAY1S:
MOV R4, #100
HERE1: MOV R5,#4
HERE: LCALL DELAY1000
DJNZ R5, HERE
DJNZ R4, HERE1
RET
END
Nguồn Sưu tầm
Nguồn Sưu tầm
0 Response to "Điều khiển hồng ngoại bằng remote tv sony"
Đăng nhận xét