PIC18FXX20
DS39583C-page 10 2010 Microchip Technology Inc.
3.2 Code Memory Programming
Programming code memory is accomplished by first
loading data into the appropriate write buffers and then
initiating a programming sequence. Each panel in the
code memory space (see Figure 2-2) has an 8-byte
deep write buffer that must be loaded prior to initiating
a write sequence. The actual memory write sequence
takes the contents of these buffers and programs the
associated EEPROM code memory.
Typically, all of the program buffers are written in
parallel (Multi-Panel Write mode). In other words, in the
case of a 128-Kbyte device (16 panels with an 8-byte
buffer per panel), 128 bytes will be simultaneously
programmed during each programming sequence. In
this case, the offset of the write within each panel is the
same (see Figure 3-5). Multi-Panel Write mode is
enabled by appropriately configuring the Programming
Control register located at 3C0006h.
The programming duration is externally timed and is
controlled by SCLK. After a “Start Programming”
command is issued (4-bit command, ‘1111’), a NOP is
issued, where the 4th SCLK is held high for the
duration of the programming time, P9.
After SCLK is brought low, the programming sequence
is terminated. SCLK 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 PIC18FXX20 device
is shown in Figure 3-3. The flowchart shown in
Figure 3-6 depicts the logic necessary to completely
write a PIC18FXX20 device. The timing diagram that
details the “Start Programming” command, and
parameters P9 and P10, is shown in Figure 3-7.
Note: The TBLPTR register must contain the
same offset value when initiating the pro-
gramming sequence as it did when the
write buffers were loaded.
2010 Microchip Technology Inc. DS39583C-page 11
PIC18FXX20
FIGURE 3-5: ERASE AND WRITE BOUNDARIES
TBLPTR<2:0> = 0
TBLPTR<2:0> = 1
TBLPTR<2:0> = 2
TBLPTR<2:0> = 3
TBLPTR<2:0> = 4
TBLPTR<2:0> = 5
TBLPTR<2:0> = 6
TBLPTR<2:0> = 7
Offset = TBLPTR<12:3>
TBLPTR<21:13> = 0
Offset = TBLPTR<12:6>
Panel 1
Erase Region
(64 bytes)
8-byte Write Buffer
TBLPTR<2:0> = 0
TBLPTR<2:0> = 1
TBLPTR<2:0> = 2
TBLPTR<2:0> = 3
TBLPTR<2:0> = 4
TBLPTR<2:0> = 5
TBLPTR<2:0> = 6
TBLPTR<2:0> = 7
Offset = TBLPTR<12:3>
TBLPTR<21:13> = 1
Offset = TBLPTR<12:6>
Panel 2
Erase Region
(64 bytes)
8-byte Write Buffer
TBLPTR<2:0> = 0
TBLPTR<2:0> = 1
TBLPTR<2:0> = 2
TBLPTR<2:0> = 3
TBLPTR<2:0> = 4
TBLPTR<2:0> = 5
TBLPTR<2:0> = 6
TBLPTR<2:0> = 7
Offset = TBLPTR<12:3>
TBLPTR<21:13> = 2
Offset = TBLPTR<12:6>
Panel 3
Erase Region
(64 bytes)
8-byte Write Buffer
TBLPTR<2:0> = 0
TBLPTR<2:0> = 1
TBLPTR<2:0> = 2
TBLPTR<2:0> = 3
TBLPTR<2:0> = 4
TBLPTR<2:0> = 5
TBLPTR<2:0> = 6
TBLPTR<2:0> = 7
Offset = TBLPTR<12:3>
TBLPTR<21:13> = (n – 1)
Offset = TBLPTR<12:6>
Panel n
Erase Region
(64 bytes)
8-byte Write Buffer
Note: TBLPTR = TBLPTRU:TBLPTRH:TBLPTRL.
PIC18FXX20
DS39583C-page 12 2010 Microchip Technology Inc.
TABLE 3-3: WRITE CODE MEMORY CODE SEQUENCE
4-Bit
Command
Data Payload Core Instruction
Step 1: Direct access to config memory.
0000
0000
0000
8E A6
8C A6
86 A6
BSF EECON1, EEPGD
BSF EECON1, CFGS
BSF EECON1, WREN
Step 2: Configure device for multi-panel writes.
0000
0000
0000
0000
0000
0000
1100
0E 3C
6E F8
0E 00
6E F7
0E 06
6E F6
00 40
MOVLW 3Ch
MOVWF TBLPTRU
MOVLW 00h
MOVWF TBLPTRH
MOVLW 06h
MOVWF TBLPTRL
Write 40h to 3C0006h to enable multi-panel writes.
Step 3: Direct access to code memory.
0000
0000
8E A6
9C A6
BSF EECON1, EEPGD
BCF EECON1, CFGS
Step 4: Load write buffer for Panel 1.
0000
0000
0000
0000
0000
0000
1101
1101
1101
1100
0E <Addr[21:16]>
6E F8
0E <Addr[15:8]>
6E F7
0E <Addr[7:0]>
6E F6
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
MOVLW <Addr[21:16]>
MOVWF TBLPTRU
MOVLW <Addr[15:8]>
MOVWF TBLPTRH
MOVLW <Addr[7:0]>
MOVWF TBLPTRL
Write 2 bytes and post-increment address by 2
Write 2 bytes and post-increment address by 2
Write 2 bytes and post-increment address by 2
Write 2 bytes
Step 5: Repeat for Panel 2.
Step 6: Repeat for all but the last panel (N – 1).
Step 7: Load write buffer for last panel.
0000
0000
0000
0000
0000
0000
1101
1101
1101
1111
0000
0E <Addr[21:16]>
6E F8
0E <Addr[15:8]>
6E F7
0E <Addr[7:0]>
6E F6
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
00 00
MOVLW <Addr[21:16]>
MOVWF TBLPTRU
MOVLW <Addr[15:8]>
MOVWF TBLPTRH
MOVLW <Addr[7:0]>
MOVWF TBLPTRL
Write 2 bytes and post-increment address by 2
Write 2 bytes and post-increment address by 2
Write 2 bytes and post-increment address by 2
Write 2 bytes and start programming
NOP - hold SCLK high for time P9
To continue writing data, repeat steps 2 through 5, where the Address Pointer is incremented by 8 in each panel at each iteration of
the loop.

PIC18F8620-I/PT

Mfr. #:
Manufacturer:
Microchip Technology
Description:
8-bit Microcontrollers - MCU 64KB 3840 RAM 68I/O
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet