English
Language : 

PIC16F627A_05 Datasheet, PDF (94/180 Pages) Microchip Technology – Flash-Based, 8-Bit CMOS Microcontrollers with nanoWatt Technology
PIC16F627A/628A/648A
13.7 Using the Data EEPROM
The data EEPROM is a high endurance, byte
addressable array that has been optimized for the storage
of frequently changing information (e.g., program
variables or other data that are updated often). When
variables in one section change frequently, while
variables in another section do not change, it is possible
to exceed the total number of write cycles to the EEPROM
(specification D124) without exceeding the total number
of write cycles to a single byte (specifications D120 and
D120A). If this is the case, then an array refresh must be
performed. For this reason, variables that change
infrequently (such as constants, IDs, calibration, etc.)
should be stored in Flash program memory.
A simple data EEPROM refresh routine is shown in
Example 13-4.
Note:
If data EEPROM is only used to store
constants and/or data that changes rarely,
an array refresh is likely not required. See
specification D124.
EXAMPLE 13-4: DATA EEPROM REFRESH ROUTINE
BANKSEL
CLRF
BCF
BTFSC
GOTO
BSF
Loop
BSF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BTFSC
GOTO
0X80
EEADR
INTCON, GIE
INTCON, GIE
$-2
EECON1, WREN
;select Bank1
;start at address 0
;disable interrupts
;see AN576
;enable EE writes
EECON1, RD
0x55
EECON2
0xAA
EECON2
EECON1, WR
EECON1, WR
$-1
;retrieve data into EEDATA
;first step of ...
;... required sequence
;second step of ...
;... required sequence
;start write sequence
;wait for write complete
#IFDEF __16F648A
;256 bytes in 16F648A
INCFSZ
#ELSE
INCF
BTFSS
#ENDIF
EEADR, f
EEADR, f
EEADR, 7
;test for end of memory
;128 bytes in 16F627A/628A
;next address
;test for end of memory
;end of conditional assembly
GOTO
Loop
;repeat for all locations
BCF
EECON1, WREN ;disable EE writes
BSF
INTCON, GIE ;enable interrupts (optional)
DS40044D-page 92
© 2005 Microchip Technology Inc.