
2009 Microchip Technology Inc.
Advance Information
DS41297F-page 15
PIC18F2XK20/4XK20
TABLE 3-3:
ERASE CODE MEMORY CODE SEQUENCE
4-bit
Command
Data Payload
Core Instruction
Step 1: Direct access to code memory and enable writes.
0000
8E A6
9C A6
84 A6
BSF
EECON1, EEPGD
BCF
EECON1, CFGS
BSF
EECON1, WREN
Step 2: Point to first row in code memory.
0000
6A F8
6A F7
6A F6
CLRF
TBLPTRU
CLRF
TBLPTRH
CLRF
TBLPTRL
Step 3: Enable erase and erase single row.
0000
88 A6
82 A6
00 00
BSF
EECON1, FREE
BSF
EECON1, WR
NOP
Erase starts on the 4th clock of this instruction
Step 4: Poll WR bit. Repeat until bit is clear.
0000
0010
50 A6
6E F5
00 00
<MSB><LSB>
MOVF EECON1, W, 0
MOVWF TABLAT
NOP
Shift out data(1)
Step 5: Hold PGC low for time P10.
Step 6: Repeat step 3 with Address Pointer incremented by 64 until all rows are erased.
Step 7: Disable writes.
0000
94 A6
BCF EECON1, WREN
Note 1:
See
Figure 4-4 for details on shift out data timing.