AT89C2051單片機(jī)紅外遙控學(xué)習(xí)器源程序
WRITNRT3: DEC RO
WRITNET2: LCALL WRITEBYTE
INC RO
INC R3
LJMP WRITNE1
RET
WRITBYTE: MOV R2,#08H
BOUT1: CLR CLK
RLC A
MOV DATADUAN,C
NOP
SETB CLK
NOPDJNZ R2,BOUT1
CLRDATADUAN
RET
READBYTE: SETB DATAUAN
MOV R2,#08H
BIN1: CLR CLK
NOP
SETB CLK
NOP
MOV C,DATADUAN
RLC A
DJNZ R2,BIN1
RET
READCOM: CLR CS
CLR CLK
SETB DATADUAN
SETB CS
NOP
SETB CLK ;1
NOP
CLR CLK
NOP
SETB CLK ;1
NOP
CLR DATAUAN
CLR CLK
NOP
SETB CLK ;0
RET
WRITECOM: CLR CS
NOP
CLR CLK
SETB DATADUAN
SETB CS
NOP
SETB CLK ;1
NOP
CLR DATADUAN
NOP
CLR CLK
NOP
SETB CLK ;0
NOP
SETB DATADUAN
NOP
CLR CLK
NOP
SETB CLK ;1
RET
WRITEADRESS: MOV R2,#07H
RLC A ;TIAO GUO
DI 7 WEI
BOUT2: CLR CLK
RLC A
MOV DATADUAN,C
NOP
DJNA R2,BOUT2
CLR DATAUAN
RET
EQEN: CLR CS
CLR CLK
SETB DATADUAN
SETB CS
SETB CLK ;1
NOP
CLR CLK
NOP
CLR DATADUAN
SETB CLK ;0
NOP
NOP
CLR CLK
NOP
SETB CLK ;0
NOP
NOP
SETB DATADUAN
CLR CLK
NOP
SETB CLK ;1
NOP
NOP
SETB CLK ;1
NOP
NOP
CLR CLK
NOP
NOP
CLR CS
RET
EWDS: CLR CS
CLR CLK
SETB DATADUAN
SETB CS
SETB CLK ;1
NOP
CLR CLK
NOP
CLR DATADUAN
SETB CLK ;0
NOP
NOP
CLR CLK
NOP
SETB CLK ;0
NOP
NOP
CLR CLK
NOP
NOP
RETB CLK ;0
NOP
NOP
SETB CLK ;0
NOP
NOP
CLR CLK
NOP
NOP
SETB CLK ;0
NOP
NOP
CLR CS
CLR CLK
RET
DELAY: MOV R3,#96H
DEL1: MOV R4,#OFFH
DEL2: DJNZ R4,DEL2
DJNZ R3,#DEL1
RET
END
本文引用地址:http://m.butianyuan.cn/article/171903.htm
評(píng)論