PIC18 (L) F2XK22/4XK22: Flash Memory Programming Specification
PIC18 (L) F2XK22/4XK22: Flash Memory Programming Specification
MCLR/VPP/RE3 1 28 RB7/PGD
RA0 2 27 RB6/PGC
RA1 3 26 RB5
RA2 4 25 RB4
RA3 5 24 RB3
PIC18F2XK22
RA4 6 23 RB2
RA5 7 22 RB1
VSS 8 21 RB0
OSC1 9 20 VDD
OSC2 10 19 VSS
RC0 11 18 RC7
RC1 12 17 RC6
RC2 13 16 RC5
RC3 14 15 RC4
Note: The following devices are included in 28-pin SDIP, SSOP and SOIC parts: PIC18F23K22, PIC18LF23K22,
PIC18F24K22, PIC18LF24K22, PIC18F25K22, PIC18LF25K22, PIC18F26K22, PIC18LF26K22.
MCLR/VPP/RE3
RB7/PGD
RB6/PGC
RA1
RA0
RB5
RB4
28 27 26 25 24 23 22
RA2 1 21 RB3
RA3 2 20 RB2
RA4 3 19 RB1
RA5 PIC18F2XK22
4 18 RB0
VSS 5 17 VDD
OSC1 6 16 VSS
OSC2 7 15 RC7
8 9 10 11 12 13 14
RC1
RC2
RC3
RC4
RC5
RC0
Note 1: RC6
The following devices are included in 28-pin QFN parts: PIC18F23K22, PIC18LF23K22, PIC18F24K22,
PIC18LF24K22, PIC18F25K22, PIC18LF25K22, PIC18F26K22, PIC18LF26K22.
2: The following devices are included in 28-pin UQFN parts: PIC18F23K22, PIC18LF23K22, PIC18F24K22,
PIC18LF24K22.
MCLR/VPP/RE3 1 40 RB7/PGD
RA0 2 39 RB6/PGC
RA1 3 38 RB5
RA2 4 37 RB4
RA3 5 36 RB3
RA4 6 35 RB2
RA5 7 34 RB1
PIC18F4XK22
RE0 8 33 RB0
RE1 9 32 VDD
RE2 10 31 VSS
VDD 11 30 RD7
VSS 12 29 RD6
OSC1 13 28 RD5
OSC2 14 27 RD4
RC0 15 26 RC7
RC1 16 25 RC6
RC2 17 24 RC5
RC3 18 23 RC4
RD0 19 22 RD3
RD1 20 21 RD2
Note: The following devices are included in 40-pin PDIP parts: PIC18F43K22, PIC18LF43K22, PIC18F44K22,
PIC18LF44K22, PIC18F45K22, PIC18LF45K22, PIC18F46K22, PIC18LF46K22.
RC6
RC5
RC4
RD3
RD2
RD1
RD0
RC3
RC2
RC1
NC
41
40
39
37
36
35
34
42
44
43
38
RC7 1 33 NC
RD4 2 32 RC0
RD5 3 31 OSC2
RD6 4 30 OSC1
RD7 5 PIC18F4XK22 29 VSS
VSS 6 28 VDD
VDD 7 27 RE2
RB0 8 26 RE1
RB1 9 25 RE0
RB2 10 24 RA5
RB3 11 23 RA4
15
16
17
18
19
20
21
22
12
13
14
NC
NC
RB4
RB6/PGC
RB7/PGD
MCLR/VPP/RE3
RA0
RA1
RA2
RA3
RB5
Note: The following devices are included in 44-pin TQFP parts: PIC18F43K22, PIC18LF43K22,
PIC18F44K22, PIC18LF44K22, PIC18F45K22, PIC18LF45K22, PIC18F46K22, PIC18LF46K22.
37
36
35
34
42
44
43
38
RC7 1 33 OSC2
RD4 2 32 OSC1
RD5 3 31 VSS
RD6 4 30 VSS
RD7 5 PIC18F4XK22 29 VDD
VSS 6 28 VDD
VDD 7 27 RE2
VDD 8 26 RE1
RB0 9 25 RE0
RB1 10 24 RA5
RB2 11 23 RA4
15
16
17
18
19
20
21
22
12
13
14
RB6/PGC
RB7/PGD
RB5
RA0
RA1
RA3
RA2
RB4
MCLR/VPP/RE3
RB3
NC
Note: The following devices are included in 44-pin QFN parts: PIC18F43K22, PIC18LF43K22, PIC18F44K22,
PIC18LF44K22, PIC18F45K22, PIC18LF45K22, PIC18F46K22, PIC18LF46K22.
FIGURE 2-6: MEMORY MAP AND THE CODE MEMORY SPACE FOR PIC18(L)FX3K22
DEVICES
000000h
Code Memory
01FFFFh MEMORY SIZE/DEVICE
8 Kbytes Address
(PIC18(L)FX3K22) Range
000000h
Boot Block
0001FFh
Unimplemented 000200h
Read as 0 Block 0
000FFFh
001000h
Block 1
001FFFh
200000h
Unimplemented
Configuration Read 0s
and ID
Space
01FFFFh
3FFFFFh
FIGURE 2-7: MEMORY MAP AND THE CODE MEMORY SPACE FOR PIC18(L)FX4K22
DEVICES
000000h
Code Memory
01FFFFh MEMORY SIZE/DEVICE
16 Kbytes Address
(PIC18(L)FX4K22) Range
000000h
Boot Block
0007FFh
Unimplemented 000800h
Read as 0 Block 0
001FFFh
002000h
Block 1
003FFFh
200000h
Unimplemented
Configuration Read 0s
and ID
Space
3FFFFFh 01FFFFh
FIGURE 2-8: MEMORY MAP AND THE CODE MEMORY SPACE FOR PIC18(L)FX5K22
DEVICES
000000h
Code Memory
01FFFFh MEMORY SIZE/DEVICE
32 Kbytes Address
(PIC18(L)FX5K22) Range
000000h
Boot Block
0007FFh
Unimplemented 000800h
Read as 0 Block 0
001FFFh
002000h
Block 1
003FFFh
004000h
Block 2
200000h 005FFFh
006000h
Block 3
007FFFh
Configuration
and ID
Space
Unimplemented
Read 0s
01FFFFh
3FFFFFh
FIGURE 2-9: MEMORY MAP AND THE CODE MEMORY SPACE FOR PIC18(L)FX6K22
DEVICES
000000h
Code Memory
01FFFFh MEMORY SIZE/DEVICE
64 Kbytes Address
(PIC18(L)FX6K22) Range
000000h
Boot Block
0007FFh
Unimplemented 000800h
Read as 0 Block 0
003FFFh
004000h
Block 1
007FFFh
008000h
Block 2
200000h 00BFFFh
00C000h
Block 3
0FFFFh
Configuration
and ID
Space
Unimplemented
Read 0s
01FFFFh
3FFFFFh
000000h
Code Memory
01FFFFh ID Location 1 200000h
ID Location 2 200001h
ID Location 3 200002h
ID Location 4 200003h
ID Location 5 200004h
Unimplemented ID Location 6 200005h
Read as 0 ID Location 7 200006h
ID Location 8 200007h
CONFIG1L 300000h
CONFIG1H 300001h
CONFIG2L 300002h
P1
Program Memory D110
MCLR/VPP/RE3
PGD
Program Data EE
PGC
PGD = Input
Verify Program
P16 P17
Verify Data
P1
MCLR/VPP/RE3
D110
Program
Configuration Bits
VDD
Verify PGD
Configuration Bits
PGC
Done
PGD = Input
VDD
Program/Verify Entry Code = 4D434850h
PGD
0 1 0 0 1 ... 0 0 0 0
b31 b30 b29 b28 b27 b3 b2 b1 b0
PGC
P18 P2B
P2A
MCLR VIH
VDD
VIH
PGD
PGC
PGD = Input
P4
P3
PGD 1 0 1 1 0 0 0 0 0 0 1 0 0 0 1 1 1 1 0 0 n n n n
0 4 C 3
4-bit Command 16-bit Data Payload Fetch Next 4-bit Command
PGD = Input
0E 3C MOVLW 3Ch
3.1.1 HIGH-VOLTAGE ICSP BULK ERASE 0000
PGD 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 n n
4-bit Command 16-bit 4-bit Command 16-bit 4-bit Command Erase Time 16-bit
Data Payload Data Payload Data Payload
PGD = Input
Start
Addr = 0
Configure
Device for
Row Erases
Perform Erase
Sequence
Addr = Addr + 64
WR Bit No
Clear?
Yes
No All
Rows
done?
Yes
Done
Start
N=1
LoopCount = 0
Configure
Device for
Writes
Load 2 Bytes
N=N+1 to Write
Buffer at <Addr>
All
No bytes
written?
N=1 Yes
LoopCount = Start Write Sequence
LoopCount + 1 and Hold PGC
High until Done
and Wait P9
No All
locations
done?
Yes
Done
P5 P5A
PGD 1 1 1 1 n n n n n n n n 0 0 0 0 0 0 0
4-bit Command 16-bit Data Payload 4-bit Command Programming Time 16-bit
Data Payload
PGD = Input
PGC
P5 P5A P5A P11A
PGD 0 0 0 0 n n
4-bit Command BSF EECON1, WR 2 NOP commands Poll WR bit, Repeat until Clear 16-bit Data
(see below) Payload
PGD = Input
1 2 3 4 1 2 15 16 1 2 3 4 1 2 15 16
PGC
P5 P5A P5 P5A
Poll WR bit
0 0 0 0 0 0 0 0
PGD
4-bit Command MOVF EECON1, W, 0 4-bit Command MOVWF TABLAT Shift Out Data
(see Figure 4-4)
Program Program
LSB MSB
Done Done
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4
PGC
P5 P6 P5A
P14
(Note 1)
PGD 1 0 0 1 LSb 1 2 3 4 5 6 MSb n n n n
Note 1: Magnification of the high-impedance delay between PGC and PGD is shown in Figure 4-6.
Start
Does Does
No No
Word = Expect Failure, Word = Expect Failure,
data? Report data? Report
Error Error
Yes Yes
All
No All
code memory No ID locations
verified? verified?
Yes Yes
Done
P14
(Note 1)
Note 1: Magnification of the High-Impedance delay between PGC and PGD is shown in Figure 4-5.
Is
device Yes
Continue
blank?
No
Abort
Done
Param
Sym. Characteristic Min. Max. Units Conditions
No.
Param
Sym. Characteristic Min. Max. Units Conditions
No.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
ISBN: 978-1-60932-156-7
01/05/10