PIC18F6520/8520/6620/
8620/6720/8720
64/80-Pin High-Performance, 256 Kbit to 1 Mbit
Enhanced Flash Microcontrollers with A/D
High-Performance RISC CPU:
• C compiler optimized architecture/instruction set:
- Source code compatible with the PIC16 and
PIC17 instruction sets
• Linear program memory addressing to 128 Kbytes
• Linear data memory addressing to 3840 bytes
• 1 Kbyte of data EEPROM
• Up to 10 MIPs operation:
- DC – 40 MHz osc./clock input
- 4 MHz – 10 MHz osc./clock input with PLL active
• 16-bit wide instructions, 8-bit wide data path
• Priority levels for interrupts
• 31-level, software accessible hardware stack
• 8 x 8 Single Cycle Hardware Multiplier
Analog Features:
• 10-bit, up to 16-channel Analog-to-Digital
Converter (A/D):
- Conversion available during Sleep
• Programmable 16-level Low-Voltage Detection
(LVD) module:
- Supports interrupt on Low-Voltage Detection
• Programmable Brown-out Reset (PBOR)
• Dual analog comparators:
- Programmable input/output configuration
Special Microcontroller Features:
• 100,000 erase/write cycle Enhanced Flash
program memory typical
• 1,000,000 erase/write cycle Data EEPROM
memory typical
• 1 second programming time
• Flash/Data EEPROM Retention: > 40 years
• Self-reprogrammable under software control
• Power-on Reset (POR), Power-up Timer (PWRT)
and Oscillator Start-up Timer (OST)
• Watchdog Timer (WDT) with its own On-Chip
RC Oscillator for reliable operation
• Programmable code protection
• Power saving Sleep mode
• Selectable oscillator options including:
- 4X Phase Lock Loop (of primary oscillator)
- Secondary Oscillator (32 kHz) clock input
• In-Circuit Serial Programming™ (ICSP™) via
two pins
• MPLAB
®
In-Circuit Debug (ICD) via two pins
External Memory Interface
(PIC18F8X20 Devices Only):
• Address capability of up to 2 Mbytes
• 16-bit interface
Peripheral Features:
High current sink/source 25 mA/25 mA
Four external interrupt pins
Timer0 module: 8-bit/16-bit timer/counter
Timer1 module: 16-bit timer/counter
Timer2 module: 8-bit timer/counter
Timer3 module: 16-bit timer/counter
Timer4 module: 8-bit timer/counter
Secondary oscillator clock option – Timer1/Timer3
Five Capture/Compare/PWM (CCP) modules:
- Capture is 16-bit, max. resolution 6.25 ns (T
CY
/16)
- Compare is 16-bit, max. resolution 100 ns (T
CY
)
- PWM output: PWM resolution is 1 to 10-bit
• Master Synchronous Serial Port (MSSP) module
with two modes of operation:
- 3-wire SPI (supports all 4 SPI modes)
- I
2
C™ Master and Slave mode
• Two Addressable USART modules:
- Supports RS-485 and RS-232
• Parallel Slave Port (PSP) module
Program Memory
Device
Bytes
PIC18F6520
PIC18F6620
PIC18F8520
PIC18F8620
32K
64K
32K
64K
Data Memory
•
•
•
•
•
•
•
•
•
CMOS Technology:
•
•
•
•
Low-power, high-speed Flash technology
Fully static design
Wide operating voltage range (2.0V to 5.5V)
Industrial and Extended temperature ranges
# Single-Word SRAM EEPROM I/O
Instructions (bytes) (bytes)
16384
32768
65536
16384
32768
65536
2048
3840
3840
2048
3840
3840
1024
1024
1024
1024
1024
1024
52
52
52
68
68
68
10-bit
CCP
A/D
(PWM)
(ch)
12
12
12
16
16
16
5
5
5
5
5
5
Max
Timers
Ext
Master USART 8-bit/16-bit Bus F
OSC
SPI
(MHz)
I
2
C
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
2
2
2
2
2
2
2/3
2/3
2/3
2/3
2/3
2/3
N
N
N
Y
Y
Y
40
25
25
40
25
25
MSSP
PIC18F6720 128K
PIC18F8720 128K
2003-2013 Microchip Technology Inc.
DS39609C-page 1
PIC18F6520/8520/6620/8620/6720/8720
Pin Diagrams
64-Pin TQFP
RE6
RE7/CCP2
(1)
RD0/PSP0
V
DD
RD1/PSP1
RD2/PSP2
RD3/PSP3
RD4/PSP4
52
RD5/PSP5
64
63
62
61
60
59
58
57
56
55
54
53
51
50
49
RD6/PSP6
RD7/PSP7
RE2/CS
RE3
RE4
RE5
V
SS
RE1/WR
RE0/RD
RG0/CCP3
RG1/TX2/CK2
RG2/RX2/DT2
RG3/CCP4
MCLR/V
PP
RG4/CCP5
V
SS
V
DD
RF7/SS
RF6/AN11
RF5/AN10/CV
REF
RF4/AN9
RF3/AN8
RF2/AN7/C1OUT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
RB0/INT0
RB1/INT1
RB2/INT2
RB3/INT3
RB4/KBI0
RB5/KBI1/PGM
RB6/KBI2/PGC
V
SS
OSC2/CLKO/RA6
OSC1/CLKI
V
DD
RB7/KBI3/PGD
RC5/SDO
RC4/SDI/SDA
RC3/SCK/SCL
RC2/CCP1
PIC18F6520
PIC18F6620
PIC18F6720
17
18
29
30
31
RF1/AN6/C2OUT
RF0/AN5
Note 1:
CCP2 is multiplexed with RC1 when CCP2MX is set.
DS39609C-page 2
RC0/T1OSO/T13CKI
RC6/TX1/CK1
RC7/RX1/DT1
2003-2013 Microchip Technology Inc.
RA4/T0CKI
RC1/T1OSI/CCP2
(1)
RA5/AN4/LVDIN
AV
SS
RA3/AN3/V
REF
+
RA2/AN2/V
REF
-
RA1/AN1
RA0/AN0
AV
DD
V
SS
V
DD
32
19
20
21
22
23
24
25
26
27
28
PIC18F6520/8520/6620/8620/6720/8720
Pin Diagrams (Continued)
80-Pin TQFP
RH2/A18
RH3/A19
RE1/WR/AD9
(3)
RE0/RD/AD8
(3)
RG0/CCP3
RG1/TX2/CK2
RG2/RX2/DT2
RG3/CCP4
MCLR/V
PP
RG4/CCP5
V
SS
V
DD
RF7/SS
RF6/AN11
RF5/AN10/CV
REF
RF4/AN9
RF3/AN8
RF2/AN7/C1OUT
RH7/AN15
RH6/AN14
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
RH1/A17
RH0/A16
RE2/CS/AD10
(3)
RE3/AD11
RE4/AD12
RE5/AD13
RE6/AD14
RE7/CCP2/AD15
(2)
RD0/PSP0/AD0
(3)
V
DD
V
SS
RD1/PSP1/AD1
(3)
RD2/PSP2/AD2
(3)
RD3/PSP3/AD3
(3)
RD4/PSP4/AD4
(3)
RD5/PSP5/AD5
(3)
RD6/PSP6/AD6
(3)
RD7/PSP7/AD7
(3)
RJ0/ALE
RJ1/OE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
PIC18F8520
PIC18F8620
PIC18F8720
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
RJ2/WRL
RJ3/WRH
RB0/INT0
RB1/INT1
RB2/INT2
RB3/INT3/CCP2
(1)
RB4/KBI0
RB5/KBI1/PGM
RB6/KBI2/PGC
V
SS
OSC2/CLKO/RA6
OSC1/CLKI
V
DD
RB7/KBI3/PGD
RC5/SDO
RC4/SDI/SDA
RC3/SCK/SCL
RC2/CCP1
RJ7/UB
RJ6/LB
Note 1:
2:
3:
CCP2 is multiplexed with RC1 when CCP2MX is set.
CCP2 is multiplexed by default with RE7 when the device is configured in Microcontroller mode.
PSP is available only in Microcontroller mode.
2003-2013 Microchip Technology Inc.
RH5/AN13
RH4/AN12
RF1/AN6/C2OUT
RF0/AN5
AV
DD
AV
SS
RA3/AN3/V
REF
+
RA2/AN2/V
REF
-
RA1/AN1
RA0/AN0
V
SS
V
DD
RA5/AN4/LVDIN
RA4/T0CKI
RC1/T1OSI/CCP2
(1)
RC0/T1OSO/T13CKI
RC6/TX1/CK1
RC7/RX1/DT1
RJ4/BA0
RJ5/CE
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
DS39609C-page 3
PIC18F6520/8520/6620/8620/6720/8720
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 7
2.0 Oscillator Configurations ............................................................................................................................................................ 21
3.0 Reset .......................................................................................................................................................................................... 29
4.0 Memory Organization ................................................................................................................................................................. 39
5.0 Flash Program Memory .............................................................................................................................................................. 61
6.0 External Memory Interface ......................................................................................................................................................... 71
7.0 Data EEPROM Memory ............................................................................................................................................................. 79
8.0 8 X 8 Hardware Multiplier ........................................................................................................................................................... 85
9.0 Interrupts .................................................................................................................................................................................... 87
10.0 I/O Ports ................................................................................................................................................................................... 103
11.0 Timer0 Module ......................................................................................................................................................................... 131
12.0 Timer1 Module ......................................................................................................................................................................... 135
13.0 Timer2 Module ......................................................................................................................................................................... 141
14.0 Timer3 Module ......................................................................................................................................................................... 143
15.0 Timer4 Module ......................................................................................................................................................................... 147
16.0 Capture/Compare/PWM (CCP) Modules ................................................................................................................................. 149
17.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 157
18.0 Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART).............................................................. 197
19.0 10-Bit Analog-to-Digital Converter (A/D) Module ..................................................................................................................... 213
20.0 Comparator Module.................................................................................................................................................................. 223
21.0 Comparator Voltage Reference Module ................................................................................................................................... 229
22.0 Low-Voltage Detect .................................................................................................................................................................. 233
23.0 Special Features of the CPU .................................................................................................................................................... 239
24.0 Instruction Set Summary .......................................................................................................................................................... 259
25.0 Development Support............................................................................................................................................................... 301
26.0 Electrical Characteristics .......................................................................................................................................................... 305
27.0 DC and AC Characteristics Graphs and Tables ....................................................................................................................... 341
28.0 Packaging Information.............................................................................................................................................................. 355
Appendix A: Revision History............................................................................................................................................................. 361
Appendix B: Device Differences......................................................................................................................................................... 361
Appendix C: Conversion Considerations ........................................................................................................................................... 362
Appendix D: Migration from Mid-range to Enhanced Devices ........................................................................................................... 362
Appendix E: Migration from High-end to Enhanced Devices ............................................................................................................. 363
The Microchip Web Site ..................................................................................................................................................................... 375
Customer Change Notification Service .............................................................................................................................................. 375
Customer Support .............................................................................................................................................................................. 375
Reader Response .............................................................................................................................................................................. 376
PIC18F6520/8520/6620/8620/6720/8720 Product Identification System .......................................................................................... 377
DS39609C-page 4
2003-2013 Microchip Technology Inc.
PIC18F6520/8520/6620/8620/6720/8720
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at
docerrors@microchip.com
or fax the
Reader Response Form
in the back of this data sheet to (480) 792-4150. We
welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000A is version A of document DS30000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision
of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site;
http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
Customer Notification System
Register on our web site at
www.microchip.com
to receive the most current information on all of our products.
2003-2013 Microchip Technology Inc.
DS39609C-page 5