PIC18FXX20
PIC18FXX20
RD0
RD1
RD2
RD3
RD4
RD5
RD6
RD7
RE2
RE3
RE4
RE5
RE6
RE7
VDD
VSS
64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49
RE1 1 48 RB0
RE0 2 47 RB1
RG0 3 46 RB2
RG1 4 45 RB3
PIC18F6520 RB4
RG2 5 44
RG3 6 PIC18F6620 43 RB5
MCLR/VPP 7 PIC18F6720 42 RB6
RG4 8 41 VSS
VSS 9 64L TQFP 40 OSC2/RA6
VDD 10 39 OSC1
RF7 11 38 VDD
RF6 12 37 RB7
RF5 13 36 RC5
RF4 14 35 RC4
RF3 15 34 RC3
RF2 16 33 RC2
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
RF1
RF0
RA3
RA2
RA5
RC1
RC0
RC6
RC7
AVSS
VSS
AVDD
RA1
RA0
VDD
RA4
RD0
RD1
RD2
RD3
RD4
RD5
RD6
RD7
RH0
RH1
RE2
RE3
RE4
RE5
RE6
RE7
VDD
RJ0
RJ1
VSS
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61
RH2 1 60 RJ2
RH3 2 59 RJ3
RE1 3 58 RB0
RE0 4 57 RB1
RG0 5 56 RB2
RG1 6 55 RB3
RG2 7 PIC18F8520 54 RB4
RG3 8 53 RB5
MCLR/VPP 9 PIC18F8620 52 RB6
RG4 10 51 VSS
PIC18F8720
VSS 11 50 OSC2/RA6
VDD 12 49 OSC1
RF7 13 80L TQFP 48 VDD
RF6 14 47 RB7
RF5 15 46 RC5
RF4 16 45 RC4
RF3 17 44 RC3
RF2 18 43 RC2
RH7 19 42 RJ7
RH6 20 41 RJ6
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
RF1
RF0
RJ4
RJ5
RA3
RA2
RA5
RC1
RC6
RC7
RH5
RH4
AVDD
RA1
RA0
VDD
RA4
AVSS
VSS
RC0
Note: Not all multiplexed pin definitions are shown. Refer to the appropriate data sheet for complete pin descriptions.
FIGURE 2-2: MEMORY MAP AND THE CODE MEMORY SPACE FOR PIC18FXX20 DEVICES
000000h
Code Memory
01FFFFh MEMORY SIZE / DEVICE
3FFFFFh
Users may store identification information (ID) in eight • TBLPTRU, at RAM address 0FF8h
ID registers. These ID registers are mapped in • TBLPTRH, at RAM address 0FF7h
addresses 200000h through 200007h. The ID locations • TBLPTRL, at RAM address 0FF6h
read out normally, even after code protection is applied.
Locations 300000h through 30000Dh are reserved for TBLPTRU TBLPTRH TBLPTRL
the Configuration bits. These bits select various device
Addr[21:16] Addr[15:8] Addr[7:0]
options, and are described in Section 5.0. These
Configuration bits read out normally, even after code
protection. The 4-bit command, ‘0000’ (Core Instruction), is used
Locations 3FFFFEh and 3FFFFFh are reserved for the to load the Table Pointer prior to using many Read or
Device ID bits. These bits may be used by the Write operations.
programmer to identify what device type is being
programmed, and are described in Section 5.0. These
Device ID bits read out normally, even after code
protection.
CONFIG1L 300000h
CONFIG1H 300001h
CONFIG2L 300002h
CONFIG2H 300003h
1FFFFFh CONFIG3L 300004h
CONFIG3H 300005h
Configuration CONFIG4L 300006h
and ID CONFIG4H 300007h
Space CONFIG5L 300008h
CONFIG5H 300009h
CONFIG6L 30000Ah
2FFFFFh CONFIG6H 30000Bh
CONFIG7L 30000Ch
CONFIG7H 30000Dh
3FFFFFh
MCLR/VPP
VDD
VDD VIH
PGM
SDATA
SDATA
SCLK
SCLK
SDATA = Input
SDATA = Input
P4
P3
SDATA 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
SDATA = Input
Delay P11+P10
Time
Done
SDATA 0 0 1 1 0 0 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
SDATA = Input
Step 5: Repeat step 4, with Address Pointer incremented by 64 until all panels are erased.
Start
Addr = 0
Configure
Device for
Multi-Panel Erase
Addr = Addr + 64
Delay P9 + P10
Time for Erase
to occur
All
No Panels
Done?
Yes
Done
Typically, all of the program buffers are written in The code sequence to program a PIC18FXX20 device
parallel (Multi-Panel Write mode). In other words, in the is shown in Figure 3-3. The flowchart shown in
case of a 128-Kbyte device (16 panels with an 8-byte Figure 3-6 depicts the logic necessary to completely
buffer per panel), 128 bytes will be simultaneously write a PIC18FXX20 device. The timing diagram that
programmed during each programming sequence. In details the “Start Programming” command, and
this case, the offset of the write within each panel is the parameters P9 and P10, is shown in Figure 3-7.
same (see Figure 3-5). Multi-Panel Write mode is Note: The TBLPTR register must contain the
enabled by appropriately configuring the Programming same offset value when initiating the pro-
Control register located at 3C0006h. gramming sequence as it did when the
write buffers were loaded.
Panel n
TBLPTR<21:13> = (n – 1)
Panel 3
TBLPTR<21:13> = 2
Panel 2
TBLPTR<21:13> = 1
Panel 1
TBLPTR<21:13> = 0
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.
Start
N=1
LoopCount = 0
Configure
Device for
Multi-Panel Writes
Load 8 Bytes
N=N+1 to Panel N Write
Buffer at <Addr>
All
No Panel Buffers
Written?
N=1 Yes
LoopCount =
LoopCount + 1 Start Write Sequence
and Hold SCLK
High Until Done
No All
Locations
Done?
Yes
Done
FIGURE 3-7: TABLE WRITE AND START PROGRAMMING INSTRUCTION TIMING (1111)
P10
1 2 3 4 1 2 3 4 5 6 15 16 1 2 3 4 1 2 3
SCLK P9
P5 P5A
SDATA 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
SDATA = Input
Step 9: Load write buffer for panel. The correct panel will be selected based on the Table Pointer.
To continue writing data, repeat step 8, where the Address Pointer is incremented by 8 at each iteration of the loop.
SCLK
P5 P5A
0 0 0 0 n n
SDATA
4-bit Command BSF EECON1, WR Poll WR bit, Repeat Until Clear 16-bit Data
(see below) Payload
SDATA = Input
1 2 3 4 1 2 15 16 1 2 3 4 1 2 15 16
SCLK
P5 P5A P5 P5A
Poll WR bit
0 0 0 0 0 0 0 0
SDATA
4-bit Command MOVF EECON1, W, 0 4-bit Command MOVWF TABLAT Shift Out Data
(see Figure 4-6)
Note 1: See Figure 4-4 for details on Shift Out Data timing.
Step 3(2): Set Table Pointer for config byte to be written. Write even/odd addresses.
Note 1: If the code protection bits are programmed while the program counter resides in the same block, then the interaction of
code protection logic may prevent further table write. To avoid this situation, move the program counter outside the code
protection area (e.g., GOTO 100000h).
2: Enabling the write protection of configuration bits (WRTC = 0 in CONFIG6H) will prevent further writing of configuration
bits. Always write all the configuration bits before enabling the write protection for configuration bits.
Program Program
LSB MSB
Done Done
Step 2: Read memory into Table Latch and then shift out on SDATA, LSb to MSb.
1001 00 00 TBLRD *+
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 4
SCLK
P5 P6 P5A
P14
Start
Does Does
No No
Word = Expect Failure, Word = Expect Failure,
Data? Report Data? Report
Error Error
Yes Yes
All All
No No ID Locations
Code Memory
Verified? Verified?
Yes Yes
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
SCLK
P5 P6 P5A
P14
OSCEN CONFIG1H Low Power System Clock Option (Timer1) Enable bit
1 = Disabled
0 = Timer1 oscillator system clock option enabled
FOSC2:FOSC0 CONFIG1H Oscillator Selection bits
111 = RC oscillator w/ OSC2 configured as RA6
110 = HS oscillator w/ PLL enabled
101 = EC oscillator w/ OSC2 configured as RA6
100 = RC oscillator w/ OSC2 configured as “divide by 4 clock output”
011 = RC oscillator
010 = HS oscillator
001 = XT oscillator
000 = LP oscillator
BORV1:BORV0 CONFIG2L Brown-out Reset Voltage bits
11 = VBOR set to 2.0V
10 = VBOR set to 2.7V
01 = VBOR set to 4.2V
00 = VBOR set to 4.5V
BOREN CONFIG2L Brown-out Reset Enable bit
1 = Brown-out Reset enabled
0 = Brown-out Reset disabled
PWRTEN CONFIG2L Power-up Timer Enable bit
1 = PWRT disabled
0 = PWRT enabled
WDTPS2:WDTPS0 CONFIG2H Watchdog Timer Postscaler Select bits
111 = 1:128
110 = 1:64
101 = 1:32
100 = 1:16
011 = 1:8
010 = 1:4
001 = 1:2
000 = 1:1
WDTEN CONFIG2H Watchdog Timer Enable bit
1 = WDT enabled
0 = WDT disabled (control is placed on SWDTEN bit)
WAIT(1) CONFIG3L External Bus Data Wait Enable bit
1 = Wait selections unavailable
0 = Wait selections determined by WAIT1:WAIT0 bits of MEMCOM
register
PM1:PM0(1) CONFIG3L Processor Mode Select bits
11 = Microcontroller mode
10 = Microprocessor mode
01 = Microprocessor with Boot Block mode
00 = Extended Microcontroller mode
Note 1: Unimplemented in PIC18F6X20 (64-pin) devices; maintain this bit set.
2: Unimplemented in PIC18FX620 devices; maintain this bit set.
3: PIC18F8520/8620 devices only.
Note 1: Do not allow excess time when transitioning MCLR between VIL and VIHH; this can cause spurious program
executions to occur. The maximum transition time is:
1 TCY + TPWRT (if enabled) + 1024 TOSC (for LP, HS, HS/PLL, and XT modes only)
+ 2 ms (for HS/PLL mode only) + 1.5 s (for EC mode only)
where TCY is the Instruction Cycle Time, TPWRT is the Power-up Timer Period, and TOSC is the Oscillator Period.
For specific values, refer to the Electrical Characteristics section of the Device Data Sheet for the particular device.
• 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 Microchip’s 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 Microchip’s 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.
01/05/10