English
Language : 

PIC18F97J60_11 Datasheet, PDF (110/492 Pages) Microchip Technology – 64/80/100-Pin, High-Performance, 1-Mbit Flash Microcontrollers with Ethernet
PIC18F97J60 FAMILY
7.4 Erasing Flash Program Memory
The minimum erase block is 1024 bytes. Only through
the use of an external programmer, or through ICSP
control, can larger blocks of program memory be Bulk
Erased. Word Erase in the Flash array is not supported.
When initiating an erase sequence from the micro-
controller itself, a block of 1024 bytes of program
memory is erased. The Most Significant 11 bits of the
TBLPTR<20:10> point to the block being erased.
TBLPTR<9:0> are ignored.
The EECON1 register commands the erase operation.
The WREN bit must be set to enable write operations.
The FREE bit is set to select an erase operation.
For protection, the write initiate sequence for EECON2
must be used.
A long write is necessary for erasing the internal
Flash. Instruction execution is halted while in a long
write cycle. The long write will be terminated by the
internal programming timer. An on-chip timer controls
the erase time. The write/erase voltages are
generated by an on-chip charge pump, rated to
operate over most of the voltage range of the device.
See Parameter D132B (VPEW) for specific limits.
7.4.1
FLASH PROGRAM MEMORY
ERASE SEQUENCE
The sequence of events for erasing a block of internal
program memory location is:
1. Load Table Pointer register with the address of
row being erased.
2. Set the EECON1 register for the erase operation:
• set WREN bit to enable writes;
• set FREE bit to enable the erase.
3. Disable interrupts.
4. Write 55h to EECON2.
5. Write 0AAh to EECON2.
6. Set the WR bit. This will begin the Row Erase
cycle.
7. The CPU will stall for the duration of the erase.
8. Re-enable interrupts.
EXAMPLE 7-2: ERASING A FLASH PROGRAM MEMORY ROW
ERASE_ROW
Required
Sequence
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BSF
BCF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BSF
CODE_ADDR_UPPER
TBLPTRU
CODE_ADDR_HIGH
TBLPTRH
CODE_ADDR_LOW
TBLPTRL
EECON1, WREN
EECON1, FREE
INTCON, GIE
55h
EECON2
0AAh
EECON2
EECON1, WR
INTCON, GIE
; load TBLPTR with the base
; address of the memory block
; enable write to memory
; enable Row Erase operation
; disable interrupts
; write 55h
; write 0AAh
; start erase (CPU stall)
; re-enable interrupts
DS39762F-page 110
 2011 Microchip Technology Inc.