English
Language : 

PIC16F627A Datasheet, PDF (94/168 Pages) Microchip Technology – FLASH-Based 8-Bit CMOS Microcontrollers
PIC16F627A/628A/648A
13.7 Using the Data EEPROM
The data EEPROM is a high endurance, byte address-
able array that has been optimized for the storage of
frequently changing information (e.g., program vari-
ables or other data that are updated often). Frequently
changing values will typically be updated more often
than specification D124. If this is not the case, an array
refresh must be performed. For this reason, variables
that change infrequently (such as constants, IDs, cali-
bration, 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 con-
stants and/or data that changes rarely, an
array refresh is likely not required. See
specification D124.
EXAMPLE 13-4: DATA EEPROM REFRESH ROUTINE
Loop
clrf
bcf
bcf
bcf
bsf
EEADR
EECON1,CFGS
EECON1,EEPGD
INTCON,GIE
EECON1,WREN
bsf
movlw
movwf
movlw
movwf
bsf
btfsc
bra
incfsz
bra
EECON1,RD
55h
EECON2
AAh
EECON2
EECON1,WR
EECON1,WR
$-2
EEADR,F
Loop
; Start at address 0
; Set for memory
; Set for Data EEPROM
; Disable interrupts
; Enable writes
; Loop to refresh array
; Read current address
;
; Write 55h
;
; Write AAh
; Set WR bit to begin write
; Wait for write to complete
; Increment address
; Not zero, do it again
bcf
EECON1,WREN
bsf
INTCON,GIE
; Disable writes
; Enable interrupts
13.8 DATA EEPROM OPERATION
DURING CODE PROTECT
When the device is code protected, the CPU is able to
read and write data to the Data EEPROM.
TABLE 13-1: REGISTERS/BITS ASSOCIATED WITH DATA EEPROM
Address
Name
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3
Bit 2
Bit 1
Bit 0
9Ah
EEDATA EEPROM data register
9Bh
EEADR
EEPROM address register
9Ch
EECON1
—
—
—
— WRERR WREN
WR
RD
9Dh
EECON2(1) EEPROM control register 2
Legend: x = unknown, u = unchanged, - = unimplemented read as '0', q = value depends upon condition.
Shaded cells are not used by data EEPROM.
Note 1: EECON2 is not a physical register
Value on
Power-on
Reset
xxxx xxxx
xxxx xxxx
---- x000
---- ----
Value on all
other
RESETS
uuuu uuuu
uuuu uuuu
---- q000
---- ----
DS40044A-page 92
Preliminary
 2002 Microchip Technology Inc.