English
Language : 

PIC18F47J53 Datasheet, PDF (117/586 Pages) Microchip Technology – 28/44-Pin, High-Performance USB Microcontrollers with nanoWatt XLP Technology
PIC18F47J53 FAMILY
7.5.2
FLASH PROGRAM MEMORY WRITE
SEQUENCE (WORD PRORAMMING).
The PIC18F47J53 family of devices has a feature that
allows programming a single word (two bytes). This
feature is enabled 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. (It must be an even
address.)
2. Write the 2 bytes into the holding registers by
performing table writes. (Do not post-increment
on the second table write.)
3. Set the WREN bit (EECON1<2>) to enable
writes and the WPROG bit (EECON1<5>) to
select Word Write mode.
4. Disable interrupts.
5. Write 55h to EECON2.
6. Write 0AAh to EECON2.
7. Set the WR bit; this will begin the write cycle.
8. The CPU will stall for the 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
CODE_ADDR_UPPER
TBLPTRU
CODE_ADDR_HIGH
TBLPTRH
CODE_ADDR_LOW
MOVWF TBLPTRL
; Load TBLPTR with the base address
; The table pointer must be loaded with an even
address
MOVLW DATA0
MOVWF TABLAT
TBLWT*+
MOVLW DATA1
MOVWF TABLAT
TBLWT*
; LSB of word to be written
; MSB of word to be written
; The last table write must not increment the table
pointer! The table pointer needs to point to the
MSB before starting the write operation.
PROGRAM_MEMORY
BSF
BSF
BCF
MOVLW
Required MOVWF
Sequence MOVLW
MOVWF
BSF
BSF
BCF
BCF
EECON1, WPROG
EECON1, WREN
INTCON, GIE
55h
EECON2
0AAh
EECON2
EECON1, WR
INTCON, GIE
EECON1, WPROG
EECON1, WREN
; enable single word write
; enable write to memory
; disable interrupts
; write 55h
; write AAh
; start program (CPU stall)
; re-enable interrupts
; disable single word write
; disable write to memory
 2010 Microchip Technology Inc.
Preliminary
DS39964B-page 117