PIC16F87X
DS30292B-page 46
1999 Microchip Technology Inc.
4.8
Protection Against Spurious Write
4.8.1
EEPROM DATA MEMORY
There are conditions when the device may not want to
write to the data EEPROM memory. To protect against
spurious EEPROM writes, various mechanisms have
been built-in. On power-up, the WREN bit is cleared.
Also, the Power-up Timer (72 ms duration) prevents
EEPROM write.
The write initiate sequence and the WREN bit together
help prevent an accidental write during brown-out,
power glitch, or software malfunction.
4.8.2
PROGRAM FLASH MEMORY
To protect against spurious writes to FLASH program
memory, the WRT bit in the configuration word may be
programmed to ‘0’ to prevent writes. The write initiate
sequence must also be followed. WRT and the config-
uration word cannot be programmed by user code, only
through the use of an external programmer.
4.9
Operation during Code Protect
Each reprogrammable memory block has its own code
protect mechanism. External Read and Write opera-
tions are disabled if either of these mechanisms are
enabled.
4.9.1
DATA EEPROM MEMORY
The microcontroller itself can both read and write to the
internal Data EEPROM, regardless of the state of the
code protect configuration bit.
4.9.2
PROGRAM FLASH MEMORY
The microcontroller can read and execute instructions
out of the internal FLASH program memory, regardless
of the state of the code protect configuration bits. How-
ever the WRT configuration bit and the code protect bits
have different effects on writing to program memory.
Table 4-1 shows the various configurations and status
of reads and writes. To erase the WRT or code protec-
tion bits in the configuration word requires that the
device be fully erased.
TABLE 4-2:
REGISTERS ASSOCIATED WITH DATA EEPROM/PROGRAM FLASH
TABLE 4-1:
READ/WRITE STATE OF INTERNAL FLASH PROGRAM MEMORY
Configuration Bits
Memory Location
Internal
Read
Internal
Write
ICSP Read
ICSP Write
CP1
CP0
WRT
0
0
0
0
0
1
1
1
1
1
1
0
1
1
1
1
0
0
0
0
1
1
x
0
0
1
1
0
0
1
1
0
1
All program memory
Unprotected areas
Protected areas
Unprotected areas
Protected areas
Unprotected areas
Protected areas
Unprotected areas
Protected areas
All program memory
All program memory
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
No
No
No
Yes
No
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
Yes
No
No
No
No
No
No
No
No
No
Yes
Yes
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on:
POR,
BOR
Value on
all other
resets
0Bh, 8Bh,
10Bh, 18Bh
INTCON
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0000 000x
0000 000u
10Dh
EEADR
EEPROM address register
xxxx xxxx
uuuu uuuu
10Fh
EEADRH
—
—
—
EEPROM address high
xxxx xxxx
uuuu uuuu
10Ch
EEDATA
EEPROM data resister
xxxx xxxx
uuuu uuuu
10Eh
EEDATH
—
—
EEPROM data resister high
xxxx xxxx
uuuu uuuu
18Ch
EECON1
EEPGD
—
—
—
WRERR
WREN
WR
RD
x--- x000
x--- u000
18Dh
EECON2
EEPROM control resister2 (not a physical resister)
8Dh
PIE2
—
(1)
—
EEIE
BCLIE
—
—
CCP2IE
-r-0 0--0
-r-0 0--0
0Dh
PIR2
—
(1)
—
EEIF
BCLIF
—
—
CCP2IF
-r-0 0--0
-r-0 0--0
Legend:
x
= unknown,
u
= unchanged, r = reserved,
-
= unimplemented read as ’0’. Shaded cells are not used during FLASH/
EEPROM access.
Note 1:
These bits are reserved; always maintain these bits clear.