十年单片机开发方案公司深圳金沙js5线路分享读写PIC16F877单片机內部EEPROM的实例。
LIST P=16f877
#INCLUDE
;
;- RAM LOCATIONS------
;
; Reserve RAM location 0x70 for ICD
;
Data_EE_Addr equ 0X71
Data_EE_Data equ 0X72
;--------VECTORS------------
org 0x0
nop
goto START
;-------PROGRAM--------------
org 0X20
START
call INIT
;
;---- Test the WRITE EEPROM Routine ----
;
movlw 0x0
movwf Data_EE_Addr
movlw '0' ; Load a ASCII code "0" to W
movwf Data_EE_Data
EE_Write
call WRITE_EEPROM
incf Data_EE_Data,F ; 0x30+ N
incf Data_EE_Addr,F ; Point to next EEPROM Address
btfss Data_EE_Addr,5 ; Write 32 bytes ?
goto EE_Write
;
;---- Test the READ EEPROM Routine ----
;
movlw 0x20 ; Get back EEPROM data to RAM with start addr at 0x20
movwf FSR
;
movlw 0x0 ; Point to EEPROM start address at 0x00
movwf Data_EE_Addr
EE_Read
call READ_EEPROM ; Read EEPROM data with curent address to W registre
movwf INDF ; move W --> RAM
;
incf FSR,F
incf Data_EE_Addr,F ; Point to next EEPROM Address
btfss Data_EE_Addr,6 ; Read 32 bytes ?
goto EE_Read
;
GOTO