謝謝大神,您費心了,當時編譯時時將這句屏蔽掉的。以下是重新整理過的,煩請大神給看看。
;***********************
;Copy Ee24 to Ee24
;************************
Debug equ 01
JbE24Bak bit 00h;=1 Slave
sda bit p3.2
scl bit p3.3
sda_bak bit p3.5;bak ee24c16
scl_bak bit scl
Led1 bit p3.7
Led2 bit p3.4
;*********************************
AdrL equ 08h
AdrH Equ AdrL+1
AdrMaxL Equ AdrH+1
AdrMaxh Equ AdrmaxL+1
;***********************************
Temp equ 21h
SpData equ Temp+64
;*************************************
ORG 0000H;
LJMP start1
ORG 0003H;
ORG 000BH;
ORG 0013H
ORG 001BH;
ORG 0023H;
;**************************************
start1:
mov b,#7fh
MOV R0,#01H;
clrram: INC R0;
MOV @R0,#00h;
Djnz r1,$;
Djnz r1,$
Djnz r1,$
djnz b,clrram
MOV SP,#spdata;
;**** read ee24 if =err then led_err =1
Lcall ReadEe24data
jnb f0,DoNext1
;***** led1 =Ligh
clr Led1
Ljmp Delay2S
DoNext1:
setb JbE24bak
Lcall ReadEe24data ;Read Slave
jnb f0,Main
clr Led2
Delay2S:
mov r7,#0
Led11:
Lcall Delay;call Delay
djnz r7,Led11
Sjmp Main1
;################################
Main:
Clr JbE24Bak
mov Dpl,AdrL
mov Dph,AdrH
Lcall ReadEe24Data
Setb JbE24Bak
mov Dpl,AdrL
mov Dph,AdrH
Lcall WriteEe24Data
;**********************
Lcall ReadDip
add a,AdrL
mov Adrl,a
mov a,AdrH
addc a,#0
mov AdrH,a
;**********************
EE24c01 equ 128
;**********************
mov AdrMaxL,#EE24c01
mov AdrMaxH,#0
mov a,b
jz JbOver
RlAdr:
mov a,AdrMaxl
rlc a
mov AdrMaxL,a
mov a,AdrmaxH
rlc a
mov AdrMaxH,a
djnz b,RlAdr
;******** jb Over
JbOver:
mov a,Adrl
add a,#01
mov R7,a
mov a,AdrH
addc a,#0
mov r6,a; r6r7=Adr+1
;************ sub
clr c
mov a,r7
subb a,AdrMaxL
mov r7,a
mov a,r6
subb a,Adrmaxh
jc main
;Over
Main1:
nop
if Debug =1
mov p1,#0ffh
mov p3,#0ffh
mov Pcon,#02
Else
endif
;************************
ReadDip:
mov a,p1
anl a,#0f0h
swap a
mov b,a
cjne a,#05,rdd1
mov a,#32
ret
rdd1:
cjne a,#06,rdd2
mov a,#32
ret
rdd2:
cjne a,#07,rdd3
rdd4:
mov a,#64
ret
rdd3:
jnc rdd4
mov a,#16
ret
;*****************
IntEe24:
Lcall ReadDip
mov r1,a
cjne a,#16,Ee24Type
clr a
sjmp rade1
Ee24type:
mov a,#01
Rade1:
mov R0,#Temp
ret
;************************
ReadEe24Data:
Lcall IntEe24
;********************
;Dptr=Ee24Adr
;R0=RamAdrCpu
;R1=DataNumber
;a=0 24c01~14c16
;a=1 24c32~24c512
;use a,b
;********************
rdee:
Lcall star_ee
mov R7,a
;*************************
;a=0 24c01~24c16
;a=1 >24c16
jz Rree32
;>24c32
;in order: 1010,000 r/w
mov a,#0a0h
Lcall w1bt
Lcall cack
jb f0,rdee_end
;** in adr_h
mov a,dph
sjmp Rree321
Rree32:
mov a,dph
;**************************
rl a;
orl a,#0a0h
;**************************
Rree321:
Lcall w1bt
Lcall cack
jb f0,rdee_end
mov a,dpl
Lcall w1bt
Lcall cack
jb f0,rdee_end
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Lcall star_ee
;*************************
mov a,r7
;*************************
jz Rr32
;****************** 24c32 slave =10100001h
mov a,#0a1h
sjmp Rr33
Rr32:
mov a,dph
;**************************
rl a
orl a,#0a1h; slar
;**************************
Rr33:
Lcall w1bt
Lcall cack
jb f0,rdee_end
;************ Read @R1 Number
ReadNext:
Lcall r1bt
mov @r0,a
inc r0
Lcall mack
djnz r1,ReadNext
Lcall mnack
Lcall stop_ee
rdee_end:
ret
;****************************
delay:
push acc
mov b,#04
delay2:
mov a,#0ffh
delay1:
dec a
jnz delay1
djnz b,delay2
pop acc
ret
;**************************
Jbsda1:
jb JbE24Bak,ste11
setb sda
sjmp ste12
ste11:
setb sda_bak
ste12:
ret
Jbsda0:
jb JbE24Bak,ste13
clr sda
sjmp ste14
ste13:
clr sda_bak
ste14:
ret
;*****************************
star_ee:
Lcall jbsda1
setb scl
Lcall jbsda0
clr scl
ret
stop_ee:
Lcall jbsda0
setb scl
Lcall jbsda1
ret
mack:
Lcall jbsda0
setb scl
nop
nop
clr scl
Lcall jbsda1
ret
mnack:
Lcall jbsda1
setb scl
nop
nop
clr scl
Lcall jbsda0
ret
cack:
Lcall jbsda1
setb scl
nop
nop
clr f0
jb jbE24bak,jee23
jnb sda,cend
sjmp jee24
jee23:
jnb sda_bak,cend
jee24:
setb f0
cend:
clr scl
ret
w1bt:
mov B,#08
wlp:
rlc a
jc wr1
wr0:
Lcall jbsda0
setb scl
nop
nop
clr scl
;**************************
Ljmp wlp1
wr1:
Lcall jbsda1
setb scl
nop
nop
clr scl
Lcall jbsda0
wlp1:
nop
djnz B,wlp
ret
r1bt:
mov b,#08
rlp:
Lcall jbsda1
setb scl
nop
;****************
jb jbE24bak,jee12
jnb sda ,rd0
sjmp rd1
jee12:
jnb sda_bak,rd0
rd1:
setb c
rlc a
clr scl
Ljmp rlp1
rd0:
clr c
rlc a
clr scl
rlp1:
nop
djnz b,rlp
ret
;*******************************
WriteEe24Data:
Lcall IntEe24
;******************************
;Dptr=Ee24Adr
;R0=RamAdrCpu
;R1=DataNumber
;a=0 24c01~14c16
;a=1 24c32~24c512
;use a,b
;*****************************
wree:
Lcall star_ee
;*************************
;a=0 24c01~24c16
;a=1 >24c16
jz Wree32
;>24c32
;in order: 1010,000 r/w
mov a,#0a0h
Lcall w1bt
Lcall cack
jb f0,wree_end
;** in adr_h
mov a,dph
sjmp wree321
Wree32:
mov a,dph
;**************************
rl a
orl a,#0a0h;slaw
;**************************
wree321:
Lcall w1bt
Lcall cack
jb f0,wree_end
mov a,dpl
Lcall w1bt
Lcall cack
jb f0,wree_end
;*******************************
Wrnext:
mov a,@r0
inc r0
Lcall w1bt
Lcall cack
jb f0,wree_end
djnz r1,WrNext
Lcall stop_ee
Lcall Delay;10Ms
wree_end:
ret
END
|