2008-2015 Microchip Technology Inc. DS30009687F-page 13
PIC18F2XJXX/4XJXX FAMILY
FIGURE 3-5: PROGRAM CODE MEMORY FLOW
FIGURE 3-6: TABLE WRITE AND START PROGRAMMING INSTRUCTION TIMING (1111)
Start Write Sequence
All
Locations
Done?
No
Done
Start
Yes
Load 2 Bytes
to Write
Buffer at <Addr>
All
Bytes
Written?
No
Yes
and Hold PGC
High Until Done
LoopCount = 0
Configure
Device for
Writes
LoopCount =
LoopCount + 1
and Wait P9
1234
1 2 15 16
123 4
PGC
P5A
PGD
PGD = Input
n
11
1
1
34 65
P9
P5
Programming Time
nnn
nn n n
00
12
0
00
16-Bit
Data Payload
0
3
0
P5
4-Bit Command 16-Bit Data Payload
4-Bit Command
PIC18F2XJXX/4XJXX FAMILY
DS30009687F-page 14 2008-2015 Microchip Technology Inc.
3.2.1 MODIFYING CODE MEMORY
The previous programming example assumed that the
device had been Bulk Erased prior to programming. It
may be the case, however, that the user wishes to
modify only a section of an already programmed device.
As described in Section 4.2 “Verify Code Memory
and Configuration Word”, the appropriate number of
bytes required for the erase buffer must be read out of
code memory and buffered. Modifications can be made
on this buffer. Then, the block of code memory that was
read out must be erased and rewritten with the modified
data. The code sequence is shown in Table 3-4.
The WREN bit must be set if the WR bit in EECON1 is
used to initiate a write sequence.
3.2.2 CONFIGURATION WORD
PROGRAMMING
Since the Flash Configuration Words are stored in
program memory, they are programmed as if they were
program data. Refer to Section 3.2 “Code Memory
Programming” and Section 3.2.1 “Modifying Code
Memory for methods and examples on programming
or modifying program memory. See also Section 5.0
“Configuration Word” for additional information on
the Configuration Words.
TABLE 3-4: MODIFYING CODE MEMORY
4-Bit
Command
Data Payload Core Instruction
Step 1: Set the Table Pointer for the block to be erased.
0000
0000
0000
0000
0000
0000
0E <Addr[21:16]>
6E F8
0E <Addr[8:15]>
6E F7
0E <Addr[7:0]>
6E F6
MOVLW <Addr[21:16]>
MOVWF TBLPTRU
MOVLW <Addr[8:15]>
MOVWF TBLPTRH
MOVLW <Addr[7:0]>
MOVWF TBLPTRL
Step 2: Read and modify code memory (see Section 4.1 “Read Code Memory”).
Step 3: Enable memory writes and set up an erase.
0000
0000
84 A6
88 A6
BSF EECON1, WREN
BSF EECON1, FREE
Step 4: Initiate erase.
0000
0000
82 A6
00 00
BSF EECON1, WR
NOP - hold PGC high for time P10.
Step 5: Load write buffer. The correct bytes will be selected based on the Table Pointer.
0000
0000
0000
0000
0000
0000
1101
.
.
.
1111
0000
0E <Addr[21:16]>
6E F8
0E <Addr[8:15]>
6E F7
0E <Addr[7:0]>
6E F6
<MSB><LSB>
.
.
.
<MSB><LSB>
00 00
MOVLW <Addr[21:16]>
MOVWF TBLPTRU
MOVLW <Addr[8:15]>
MOVWF TBLPTRH
MOVLW <Addr[7:0]>
MOVWF TBLPTRL
Write 2 bytes and post-increment address by 2.
Repeat write operation 30 more times to fill the write buffer
Write 2 bytes and start programming.
NOP - hold PGC high for time P9.
Step 6: Repeat Step 5 for a total of 16 times (if rewriting the entire 1024 bytes of the erase page size).
Step 7: To continue modifying data, repeat Steps 1 through 5, where the Address Pointer is incremented by 1024 bytes at each
iteration of the loop.
Step 8: Disable writes.
0000 94 A6 BCF EECON1, WREN
2008-2015 Microchip Technology Inc. DS30009687F-page 15
PIC18F2XJXX/4XJXX FAMILY
3.3 Endurance and Retention
To maintain the endurance specification of the Flash
program memory cells, each byte should never be
programmed more than once between erase operations.
Before attempting to modify the contents of a specific
byte of Flash memory a second time, an erase operation
(either a Bulk Erase or a Row Erase which includes that
byte) should be performed.

PIC18F25J50-I/SS

Mfr. #:
Manufacturer:
Microchip Technology
Description:
8-bit Microcontrollers - MCU Full Spd USB 32KB Flsh 4KBRAM nanoWatt
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union