DAT BIT P0.0
CLK BIT P0.1
CS BIT P0.2
ORG 0000H
LJMP START
ORG 0030H
START: MOV SP,#60H
MOV TMOD,#10H
SETB TR1
SETB ET0
SETB EA
SETB DAT
LOOP2: MOV 30H,#00H
MOV 31H,#00H
MOV R2,#00H
MOV R5,#05H
LOOP: LCALL TLC549_ADC
ADD A,30H
MOV 30H,A
JC REL
LJMP TEL
REL: INC 31H
JNC TEL
TEL: DJNZ R2,LOOP
MOV P1,31H
MOV A,31H
CJNE A,#80H,CEL
CEL: JNC LOOP3
JC LOOP2
SJMP LOOP6
LOOP3: JNB TF1,$
CLR TF1
MOV TL1,#0ECH
MOV TH1,#0FEH
CPL P1.0
DJNZ R5,LOOP3
LOOP6: SETB P1.0
LCALL DELAY
LJMP LOOP2
TLC549_ADC:
PUSH 07H
CLR A
SETB CS
CLR CLK
MOV R7,#08H
CLR CS
NOP
LOOP1: SETB CLK
MOV C,DAT
RLC A
CLR CLK
DJNZ R7,LOOP1
SETB CS
CLR CLK
SETB DAT
POP 07H
RET
DELAY: PUSH 01H
MOV R1,#00H
DJNZ R1,$
POP 01H
RET
END
|