- UID
- 792415
- 性别
- 男
|
stc的eeprom 功能还是不错的,可以简化我们的外围电路,但是缺点是是有就那就是写入速度太慢了,只能按扇区的写,不能字节写.下面是代码(本文转自:中国广东IC网)
AUXR1 EQU 0A2H
ISPDATA EQU 0E2H
ISPADDRH EQU 0E3H
ISPADDRL EQU 0E4H
ISPCMD EQU 0E5H
ISPTRIG EQU 0E6H
ISPCONTR EQU 0E7H
ORG 0000H
AJMP MAIN
ORG 0030H
MAIN:
MOV AUXR1,#0
INC AUXR1
MOV DPTR,#2000H
ACALL ERASE
MOV A,#0FEH
ACALL EEPROMW
ACALL EEPROMR
INC AUXR1
AJMP MAIN
ERASE:;擦除
MOV ISPCONTR,#81H
MOV ISPCMD,#03H
MOV ISPADDRH,DPH
MOV ISPADDRL,DPL
CLR EA
MOV ISPTRIG,#46H
MOV ISPTRIG,#0B9H
NOP
SETB EA
ACALL ISPXX
RET
EEPROMW:;写
MOV ISPCONTR,#81H
MOV ISPCMD,#02H
MOV ISPADDRH,DPH
MOV ISPADDRL,DPL
MOV ISPDATA,A
CLR EA
MOV ISPTRIG,#46H
MOV ISPTRIG,#0B9H
NOP
SETB EA
ACALL ISPXX
RET
EEPROMR:;读
MOV ISPCONTR,#81H
MOV ISPCMD,#01H
MOV ISPADDRH,DPH
MOV ISPADDRL,DPL
CLR EA
MOV ISPTRIG,#46H
MOV ISPTRIG,#0B9H
NOP
MOV A,ISPDATA
SETB EA
ACALL ISPXX
RET
ISPXX:
MOV ISPCONTR,#0
MOV ISPCMD,#0
MOV ISPTRIG,#0
RET
DEL:
MOV R2,#0FFH
D1:
MOV R1,#0FFH
DJNZ R1,$
DJNZ R2,D1
RET
END |
|