PIC18F2XXX/4XXX FAMILY
DS30009622M-page 24 2010-2015 Microchip Technology Inc.
3.2 Code Memory Programming
Programming code memory is accomplished by first loading data into the write buffer and then initiating a programming
sequence. The write and erase buffer sizes, shown in Table 3-4, can be mapped to any location of the same size,
beginning at 000000h. The actual memory write sequence takes the contents of this buffer and programs the proper
amount of code memory that contains the Table Pointer.
The programming duration is externally timed and is controlled by PGC. After a Start Programming command is issued
(4-bit command, ‘1111’), a NOP is issued, where the 4th PGC is held high for the duration of the programming time, P9.
After PGC is brought low, the programming sequence is terminated. PGC must be held low for the time specified by
Parameter P10 to allow high-voltage discharge of the memory array.
The code sequence to program a PIC18F2XXX/4XXX Family device is shown in Table 3-5. The flowchart, shown in
Figure 3-4, depicts the logic necessary to completely write a PIC18F2XXX/4XXX Family device. The timing diagram
that details the Start Programming command and Parameters P9 and P10 is shown in Figure 3-5.
Note: The TBLPTR register must point to the same region when initiating the programming sequence as it did
when the write buffers were loaded.
TABLE 3-4: WRITE AND ERASE BUFFER SIZES
Devices (Arranged by Family) Write Buffer Size (Bytes) Erase Buffer Size (Bytes)
PIC18F2221, PIC18F2321, PIC18F4221, PIC18F4321 8 64
PIC18F2450, PIC18F4450 16 64
PIC18F2410, PIC18F2510, PIC18F4410, PIC18F4510
32 64
PIC18F2420, PIC18F2520, PIC18F4420, PIC18F4520
PIC18F2423, PIC18F2523, PIC18F4423, PIC18F4523
PIC18F2480, PIC18F2580, PIC18F4480, PIC18F4580
PIC18F2455, PIC18F2550, PIC18F4455, PIC18F4550
PIC18F2458, PIC18F2553, PIC18F4458, PIC18F4553
PIC18F2515, PIC18F2610, PIC18F4515, PIC18F4610
64 64
PIC18F2525, PIC18F2620, PIC18F4525, PIC18F4620
PIC18F2585, PIC18F2680, PIC18F4585, PIC18F4680
PIC18F2682, PIC18F2685, PIC18F4682, PIC18F4685