English
Language : 

PIC16F87X_02 Datasheet, PDF (7/22 Pages) Microchip Technology – EEPROM Memory Programming Specification
2.5 Erasing Program and Data
Memory
Depending on the state of the code protection bits, pro-
gram and data memory will be erased using different
procedures. The first set of procedures is used when
both program and data memories are not code pro-
tected. The second set of procedures must be used
when either memory is code protected. A device pro-
grammer should determine the state of the code pro-
tection bits and then apply the proper procedure to
erase the desired memory.
2.5.1
ERASING NON-CODE PROTECTED
PROGRAM AND DATA MEMORY
When both program and data memories are not code
protected, they must be individually erased using the
following procedures. The only way that both memories
are erased using a single procedure is if code protec-
tion is enabled for one of the memories. These proce-
dures do not erase the configuration word or ID
locations.
Procedure to bulk erase program memory:
1. Execute a Load Data for Program Memory com-
mand (000010) with a ’1’ in all locations
(0x3FFF)
2. Execute a Bulk Erase Setup1 command
(000001)
3. Execute a Bulk Erase Setup2 command
(000111)
4. Execute a Begin Erase/Programming command
(001000)
5. Wait 8 ms
6. Execute a Bulk Erase Setup1 command
(000001)
7. Execute a Bulk Erase Setup2 command
(000111)
Procedure to bulk erase data memory:
1. Execute a Load Data for Data Memory com-
mand (000011) with a ’1’ in all locations
(0x3FFF)
2. Execute a Bulk Erase Setup1 command
(000001)
3. Execute a Bulk Erase Setup2 command
(000111)
4. Execute a Begin Erase/Programming command
(001000)
5. Wait 8 ms
6. Execute a Bulk Erase Setup1 command
(000001)
7. Execute a Bulk Erase Setup2 command
(000111)
PIC16F87X
2.5.2
ERASING CODE PROTECTED
MEMORY
For the PIC16F87X devices, once code protection is
enabled, all protected program and data memory loca-
tions read all ’0’s and further programming is disabled.
The ID locations and configuration word read out
unscrambled and can be reprogrammed normally. The
only procedure to erase a PIC16F87X device that is
code protected is shown in the following procedure.
This method erases program memory, data memory,
configuration bits and ID locations. Since all data
within the program and data memory will be erased
when this procedure is executed, the security of
the data or code is not compromised.
1. Execute a Load Configuration command
(000000) with a ’1’ in all locations (0x3FFF)
2. Execute Increment Address command
(000110) to set address to configuration word
location (0x2007)
3. Execute a Bulk Erase Setup1 command
(000001)
4. Execute a Bulk Erase Setup2 command
(000111)
5. Execute a Begin Erase/Programming command
(001000)
6. Wait 8 ms
7. Execute a Bulk Erase Setup1 command
(000001)
8. Execute a Bulk Erase Setup2 command
(000111)
 2002 Microchip Technology Inc.
DS39025F-page 7