STC單片機(jī)EEPROM的讀寫(xiě)程序
stc的eeprom 功能還是不錯(cuò)的,可以簡(jiǎn)化我們的外圍電路,但是缺點(diǎn)是是有就那就是寫(xiě)入速度太慢了,只能按扇區(qū)的寫(xiě),不能字節(jié)寫(xiě).
下面是代碼
AUXR1 EQU 0A2HISPDATA EQU 0E2HISPADDRH EQU 0E3H ISPADDRL EQU 0E4HISPCMD EQU 0E5HISPTRIG EQU 0E6HISPCONTR EQU 0E7HORG 0000HAJMP MAINORG 0030HMAIN:MOV AUXR1,#0INC AUXR1MOV DPTR,#2000HACALL ERASEMOV A,#0FEHACALL EEPROMWACALL EEPROMRINC AUXR1AJMP MAINERASE:;擦除MOV ISPCONTR,#81HMOV ISPCMD,#03HMOV ISPADDRH,DPHMOV ISPADDRL,DPLCLR EAMOV ISPTRIG,#46HMOV ISPTRIG,#0B9HNOPSETB EAACALL ISPXXRETEEPROMW:;寫(xiě)MOV ISPCONTR,#81HMOV ISPCMD,#02HMOV ISPADDRH,DPHMOV ISPADDRL,DPLMOV ISPDATA,ACLR EAMOV ISPTRIG,#46HMOV ISPTRIG,#0B9HNOP SETB EAACALL ISPXXRETEEPROMR:;讀MOV ISPCONTR,#81HMOV ISPCMD,#01HMOV ISPADDRH,DPHMOV ISPADDRL,DPLCLR EAMOV ISPTRIG,#46HMOV ISPTRIG,#0B9HNOPMOV A,ISPDATASETB EAACALL ISPXXRET ISPXX:MOV ISPCONTR,#0MOV ISPCMD,#0MOV ISPTRIG,#0RETDEL:MOV R2,#0FFHD1:MOV R1,#0FFHDJNZ R1,$DJNZ R2,D1RETEND
c語(yǔ)言相關(guān)文章:c語(yǔ)言教程
評(píng)論