2010 Microchip Technology Inc. DS39583C-page 13
PIC18FXX20
FIGURE 3-6: PROGRAM CODE MEMORY FLOW
FIGURE 3-7: TABLE WRITE AND START PROGRAMMING INSTRUCTION TIMING (1111)
Start Write Sequence
All
Locations
Done?
No
Done
Start
Yes
Delay P9+P10 Time
for Write to Occur
Load 8 Bytes
to Panel N Write
Buffer at <Addr>
All
Panel Buffers
Written?
No
Yes
and Hold SCLK
High Until Done
N = 1
LoopCount = 0
Configure
Device for
Multi-Panel Writes
N = 1
LoopCount =
LoopCount + 1
N = N + 1
Panel Base Address =
(N – 1) x 2000h
Addr = Panel Base Address
+ (8 x LoopCount)
1234
12 1516
123 4
SCLK
P5A
SDATA
SDATA = Input
n
11
1
1
34 65
P9
P10
Programming Time
nnn
nn n n 0 0
12
000
16-bit
Data Payload
0
3
0
P5
4-bit Command 16-bit Data Payload
4-bit Command
PIC18FXX20
DS39583C-page 14 2010 Microchip Technology Inc.
3.2.1 SINGLE PANEL PROGRAMMING
The programming example presented in Section 3.2
utilizes multi-panel programming. This technique
greatly decreases the total amount of time necessary to
completely program a device and is the recommended
method of completely programming a device.
There may be situations, however, where it is
advantageous to limit writes to a single panel. In such
cases, the user only needs to disable the multi-panel
write feature of the device by appropriately configuring
the programming control register located at 3C0006h.
The single panel that will be written will automatically
be enabled based on the value of the Table Pointer.
3.2.2 MODIFYING CODE MEMORY
All of the programming examples up to this point have
assumed that the device has been bulk erased prior to
programming (see Section 3.1). It may be the case,
however, that the user wishes to modify only a section
of an already programmed device.
The minimum amount of data that can be written to the
device is 8 bytes. This is accomplished by placing the
device in Single Panel Write mode (see Section 3.2.1),
loading the 8-byte write buffer for the panel, and then
initiating a write sequence. In this case, however, it is
assumed that the address space to be written already
has data in it (i.e., it is not blank).
The minimum amount of code memory that may be
erased at a given time is 64 bytes. Again, the device
must be placed in Single Panel Write mode. The
EECON1 register must then be used to erase the
64-byte target space prior to writing the data.
When using the EECON1 register to act on
code memory, the EEPGD bit must be set
(EECON1<7> = 1) and the CFGS bit must be cleared
(EECON1<6> = 0). The WREN bit must be set
(EECON1<2> = 1) to enable writes of any sort (e.g.,
erases), and this must be done prior to initiating a
write sequence. The FREE bit must be set
(EECON1<4> = 1) in order to erase the program
space being pointed to by the Table Pointer. The
erase sequence is initiated by the setting the WR bit
(EECON1<1> = 1). It is strongly recommended that
the WREN bit be set only when absolutely necessary.
To help prevent inadvertent writes when using the
EECON1 register, EECON2 is used to “enable” the WR
bit. This register must be sequentially loaded with 55h
and then AAh, immediately prior to asserting the WR bit
in order for the write to occur.
The erase will begin on the falling edge of the 4th
SCLK, after the WR bit is set. After the erase sequence
terminates, SCLK must still be held low for the time
specified by parameter #P10 to allow high voltage
discharge of the memory array.
Note: Even though multi-panel writes are dis-
abled, the user must still fill the 8-byte write
buffer for the given panel.
2010 Microchip Technology Inc. DS39583C-page 15
PIC18FXX20
TABLE 3-4: MODIFYING CODE MEMORY
4-Bit
Command
Data Payload Core Instruction
Step 1: Direct access to config memory.
0000
0000
8E A6
8C A6
BSF EECON1, EEPGD
BSF EECON1, CFGS
Step 2: Configure device for single panel writes.
0000
0000
0000
0000
0000
0000
1100
0E 3C
6E F8
0E 00
6E F7
0E 06
6E F6
00 00
MOVLW 3Ch
MOVWF TBLPTRU
MOVLW 00h
MOVWF TBLPTRH
MOVLW 06h
MOVWF TBLPTRL
Write 00h to 3C0006h to enable single panel writes.
Step 3: Direct access to code memory.
0000
0000
8E A6
9C A6
BSF EECON1, EEPGD
BCF EECON1, CFGS
Step 4: 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 5: Enable memory writes and set up an erase.
0000
0000
84 A6
88 A6
BSF EECON1, WREN
BSF EECON1, FREE
Step 6: Perform required sequence.
0000
0000
0000
0000
0E 55
6E A7
0E AA
6E A7
MOVLW 55h
MOVWF EECON2
MOVLW 0AAh
MOVWF EECON2
Step 7: Initiate erase.
0000
0000
82 A6
00 00
BSF EECON1, WR
NOP
Step 8: Wait for P11+P10 and then disable writes.
0000 94 A6 BCF EECON1, WREN
Step 9: Load write buffer for panel. The correct panel will be selected based on the Table Pointer.
0000
0000
0000
0000
1101
1101
1101
1111
0000
0E <Addr[8:15]>
6E F7
0E <Addr[7:0]>
6E F6
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
00 00
MOVLW <Addr[8:15]>
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 step 8, where the Address Pointer is incremented by 8 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