PIC18FXX20
DS39583C-page 16 2010 Microchip Technology Inc.
3.3 Data EEPROM Programming
Data EEPROM is accessed one byte at a time via an
Address Pointer (register pair EEADR:EEADRH) and a
data latch (EEDATA). Data EEPROM is written by
loading EEADR:EEADRH with the desired memory
location, EEDATA with the data to be written, and
initiating a memory write by appropriately configuring
the EECON1 and EECON2 registers. A byte write
automatically erases the location and writes the new
data (erase-before-write).
When using the EECON1 register to perform a data
EEPROM write, both the EEPGD and CFGS bits must
be cleared (EECON1<7:6> = 00). The WREN bit must
be set (EECON1<2> = 1) to enable writes of any sort,
and this must be done prior to initiating a write
sequence. The write sequence is initiated by 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 write begins on the falling edge of the 4th SCLK
after the WR bit is set. It ends when the WR bit is
cleared by hardware.
After the programming sequence terminates, SCLK
must still be held low for the time specified by
parameter P10 to allow high voltage discharge of the
memory array.
FIGURE 3-8: PROGRAM DATA FLOW
FIGURE 3-9: DATA EEPROM WRITE TIMING
Start
Start Write
Set Data
Done
No
Yes
Done
?
Enable Write
Unlock Sequence
55h - EECON2
AAh - EECON2
Sequence
Set Address
WR bit
Clear ?
No
Yes
n
SCLK
SDATA
SDATA = Input
0000
BSF EECON1, WR
4-bit Command
1234
1
21516
P5
P5A
P10
12
n
Poll WR bit, Repeat Until Clear
16-bit Data
Payload
1234
1
21516
123
P5
P5A
4
1 2 15 16
P5 P5A
0000
MOVF EECON1, W, 0
4-bit Command
0000
4-bit Command
Shift Out Data
MOVWF TABLAT
SCLK
SDATA
(see below)
(see Figure 4-6)
SDATA = Input SDATA = Output
Poll WR bit
2010 Microchip Technology Inc. DS39583C-page 17
PIC18FXX20
TABLE 3-5: PROGRAMMING DATA MEMORY
4-Bit
Command
Data Payload Core Instruction
Step 1: Direct access to data EEPROM.
0000
0000
9E A6
9C A6
BCF EECON1, EEPGD
BCF EECON1, CFGS
Step 2: Set the data EEPROM Address Pointer.
0000
0000
0000
0000
0E <Addr>
6E A9
OE <AddrH>
6E AA
MOVLW <Addr>
MOVWF EEADR
MOVLW <AddrH>
MOVWF EEADRH
Step 3: Load the data to be written.
0000
0000
0E <Data>
6E A8
MOVLW <Data>
MOVWF EEDATA
Step 4: Enable memory writes.
0000 84 A6 BSF EECON1, WREN
Step 5: Perform required sequence.
0000
0000
0000
0000
0E 55
6E A7
0E AA
6E A7
MOVLW 0X55
MOVWF EECON2
MOVLW 0XAA
MOVWF EECON2
Step 6: Initiate write.
0000 82 A6 BSF EECON1, WR
Step 7: Poll WR bit, repeat until the bit is clear.
0000
0000
0010
50 A6
6E F5
<LSB><MSB>
MOVF EECON1, W, 0
MOVWF TABLAT
Shift out data
(1)
Step 8: Disable writes.
0000 94 A6 BCF EECON1, WREN
Repeat steps 2 through 8 to write more data.
Note 1: See Figure 4-4 for details on Shift Out Data timing.
PIC18FXX20
DS39583C-page 18 2010 Microchip Technology Inc.
3.4 ID Location Programming
The ID Locations are programmed much like the code
memory, except that multi-panel writes must be
disabled. The single panel that will be written will
automatically be enabled, based on the value of the
Table Pointer. The ID registers are mapped in
addresses 200000h through 200007h. These locations
read out normally, even after code protection.
Figure 3-6 demonstrates the code sequence required
to write the ID locations.
TABLE 3-6: WRITE ID SEQUENCE
In order to modify the ID locations, refer to the
methodology described in Section 3.2.2, “Modifying
Code Memory”. As with code memory, the ID locations
must be erased before modified.
Note: Even though multi-panel writes are dis-
abled, the user must still fill the 8-byte data
buffer for the panel.
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: Load write buffer. Panel will be automatically determined by address.
0000
0000
0000
0000
0000
0000
1101
1101
1101
1111
0000
0E 20
6E F8
0E 00
6E F7
0E 00
6E F6
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
<LSB><MSB>
00 00
MOVLW 20h
MOVWF TBLPTRU
MOVLW 00h
MOVWF TBLPTRH
MOVLW 00h
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

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