nCONFIG EQU P1.7
nSTATUS EQU P1.5
RDYnBSY EQU P1.3
CONF_DONE EQU P1.4
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
MOV DPTR,#0000H
MOVX A,@DPTR
MOV R3,A
MOV DPTR,#0001H
MOVX A,@DPTR
MOV R4,A
MOV R5,#00H
MOV R6,#00H
COFIG:
MOV DPTR,#0002H
CLR P1.7
ACALL DELAY4
JB nSTATUS,COFIG
SETB nCONFIG
STA_JUDGE:
JB nSTATUS,COFIG_BEG
LJMP STA_JUDGE
COFIG_BEG:
ACALL DELAY2
LJMP SEND_DATA
READY_DATA1:
JNB nSTATUS,COFIG
SEND_DATA:
MOVX A,@DPTR
PUSH DPH
PUSH DPL
MOV DPTR,#7000H
JNB P1.3,$
MOVX @DPTR,A
POP DPL
POP DPH
INC DPTR
CLR C;
MOV A,#01H
ADD A,R5
MOV R5,A
MOV A,#00H
ADDC A,R6
MOV R6,A
MOV A,R5
CJNE A,03H,RESESH_COFIG
MOV A,R6
CJNE A,04H,RESESH_COFIG
CON_REFRESH:
ACALL DELAY2
JB P1.4,END1
LJMP COFIG
PESESH_COFIG:
LJMP READY_DATA1
DELAY2:
NOP
NOP
NOP
NOP
NOP
RET
MOV R1,#08H
DJNZ R1,$
RET
END1:
END