English
Language : 

PIC18F67J11T-I Datasheet, PDF (103/466 Pages) Microchip Technology – 64/80-Pin, High-Performance, 1-Mbit Flash Microcontrollers
PIC18F87J11 FAMILY
7.5.2
FLASH PROGRAM MEMORY WRITE
SEQUENCE (WORD
PROGRAMMING).
The PIC18F87J11 family of devices have a feature that
allows programming a single word (two bytes). This
feature is enable when the WPROG bit is set. If the
memory location is already erased, the following
sequence is required to enable this feature:
1. Load the Table Pointer register with the address
of the data to be written
2. Write the 2 bytes into the holding registers and
perform a table write
3. Set the WREN bit (EECON1<2>) to enable byte
writes.
4. Disable interrupts.
5. Write H'55' to EECON2.
6. Write H'AA' to EECON2.
7. Set the WR bit. This will begin the write cycle.
8. The CPU will stall for duration of the write for TIW
(see Parameter D133A).
9. Re-enable interrupts.
EXAMPLE 7-4: SINGLE-WORD WRITE TO FLASH PROGRAM MEMORY
MOVLW
MOVWF
MOVLW
MOVWF
MOVLW
MOVWF
CODE_ADDR_UPPER
TBLPTRU
CODE_ADDR_HIGH
TBLPTRH
CODE_ADDR_LOW
TBLPTRL
; Load TBLPTR with the base address
MOVLW
MOVWF
TBLWT*+
MOVLW
MOVWF
TBLWT*
DATA0
TABLAT
DATA1
TABLAT
PROGRAM_MEMORY
BSF
BSF
BCF
MOVLW
Required MOVWF
Sequence MOVLW
MOVWF
BSF
BSF
BCF
BCF
EECON1, WPROG
EECON1, WREN
INTCON, GIE
H'55'
EECON2
H'AA'
EECON2
EECON1, WR
INTCON, GIE
EECON1, WPROG
EECON1, WREN
; enable single word write
; enable write to memory
; disable interrupts
; write H'55'
; write H'AA'
; start program (CPU stall)
; re-enable interrupts
; disable single word write
; disable write to memory
 2007-2012 Microchip Technology Inc.
DS39778E-page 103