PIC18F2585/2680/4585/4680
28/40/44-Pin Enhanced Flash Microcontrollers with
ECAN™ Technology, 10-Bit A/D
Power Managed Modes:
•
•
•
•
•
•
•
•
Run: CPU on, peripherals on
Idle: CPU off, peripherals on
Sleep: CPU off, peripherals off
Idle mode currents down to 5.8
A
typical
Sleep mode currents down to 0.1
A
typical
Timer1 Oscillator: 1.1
A,
32 kHz, 2V
Watchdog Timer: 2.1
A
Two-Speed Oscillator Start-up
- One, two or four PWM outputs
- Selectable polarity
- Programmable dead time
- Auto-Shutdown and Auto-Restart
Master Synchronous Serial Port (MSSP) module
supporting 3-wire SPI (all 4 modes) and I
2
C™
Master and Slave modes
Enhanced Addressable USART module:
- Supports RS-485, RS-232 and LIN 1.3
- RS-232 operation using internal oscillator
block (no external crystal required)
- Auto-Wake-up on Start bit
- Auto-Baud Detect
10-bit, up to 11-channel Analog-to-Digital
Converter module (A/D), up to 100 Ksps
- Auto-acquisition capability
- Conversion available during Sleep
Dual analog comparators with input multiplexing
•
•
Flexible Oscillator Structure:
• Four Crystal modes, up to 40 MHz
• 4x Phase Lock Loop (PLL) – available for crystal
and internal oscillators
• Two External RC modes, up to 4 MHz
• Two External Clock modes, up to 40 MHz
• Internal oscillator block:
- 8 user selectable frequencies, from 31 kHz to 8 MHz
- Provides a complete range of clock speeds,
from 31 kHz to 32 MHz when used with PLL
- User tunable to compensate for frequency drift
• Secondary oscillator using Timer1 @ 32 kHz
• Fail-Safe Clock Monitor
- Allows for safe shutdown if peripheral clock stops
•
•
ECAN Module Features:
• Message bit rates up to 1 Mbps
• Conforms to CAN 2.0B ACTIVE Specification
• Fully backward compatible with PIC18XXX8 CAN
modules
• Three modes of operation:
- Legacy, Enhanced Legacy, FIFO
• Three dedicated transmit buffers with prioritization
• Two dedicated receive buffers
• Six programmable receive/transmit buffers
• Three full 29-bit acceptance masks
• 16 full 29-bit acceptance filters w/ dynamic association
• DeviceNet™ data byte filter support
• Automatic remote frame handling
• Advanced error management features
Special Microcontroller Features:
• C compiler optimized architecture with optional
extended instruction set
• 100,000 erase/write cycle Enhanced Flash
program memory typical
• 1,000,000 erase/write cycle Data EEPROM
memory typical
• Flash/Data EEPROM Retention: > 40 years
• Self-programmable under software control
• Priority levels for interrupts
• 8 x 8 Single Cycle Hardware Multiplier
• Extended Watchdog Timer (WDT):
- Programmable period from 41 ms to 131s
• Single-Supply 5V In-Circuit Serial
Programming™ (ICSP™) via two pins
• In-Circuit Debug (ICD) via two pins
• Wide operating voltage range: 2.0V to 5.5V
Peripheral Highlights:
•
•
•
•
High current sink/source 25 mA/25 mA
Three external interrupts
One Capture/Compare/PWM (CCP1) module
Enhanced Capture/Compare/PWM (ECCP1) module
(40/44-pin devices only):
2007-2018 Microchip Technology Inc.
DS30009625D-page 1
PIC18F2585/2680/4585/4680
Device
PIC18F2585
PIC18F2680
PIC18F4585
PIC18F4680
Flash # Single-Word SRAM EEPROM
(bytes) Instructions (bytes) (bytes)
48K
64K
48K
64K
24576
32768
24576
32768
3328
3328
3328
3328
1024
1024
1024
1024
I/O
28
28
44
40/44
CCP1/
10-Bit
ECCP1
A/D (ch)
(PWM)
8
8
11
11
1/0
1/0
1/1
1/1
EUSART
Program Memory
Data Memory
MSSP
SPI
Y
Y
Y
Y
Master
I
2
C™
Y
Y
Y
Y
Comp.
0
0
2
2
Timers
8/16-bit
1/3
1/3
1/3
1/3
1
1
1
1
Pin Diagrams
28-Pin PDIP, SOIC
MCLR/V
PP
/RE3
RA0/AN0
RA1/AN1
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RA4/T0CKI
RA5/AN4/SS/HLVDIN
V
SS
OSC1/CLKI/RA7
OSC2/CLKO/RA6
RC0/T1OSO/T13CKI
RC1/T1OSI
RC2/CCP1
RC3/SCK/SCL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
28
27
26
25
24
23
22
21
20
19
18
17
16
15
RB7/KBI3/PGD
RB6/KBI2/PGC
RB5/KBI1/PGM
RB4/KBI0/AN9
RB3/CANRX
RB2/INT2/CANTX
RB1/INT1/AN8
RB0/INT0/AN10
V
DD
V
SS
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
40-Pin PDIP
MCLR/V
PP
/RE3
RA0/AN0/CV
REF
RA1/AN1
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RA4/T0CKI
RA5/AN4/SS/HLVDIN
RE0/RD/AN5
RE1/WR/AN6/C1OUT
RE2/CS/AN7/C2OUT
V
DD
V
SS
OSC1/CLKI/RA7
OSC2/CLKO/RA6
RC0/T1OSO/T13CKI
RC1/T1OSI
RC2/CCP1
RC3/SCK/SCL
RD0/PSP0/C1IN+
RD1/PSP1/C1IN-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
PIC18F2585
PIC18F2680
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
RB7/KBI3/PGD
RB6/KBI2/PGC
RB5/KBI1/PGM
RB4/KBI0/AN9
RB3/CANRX
RB2/INT2/CANTX
RB1/INT1/AN8
RB0/INT0/FLT0/AN10
V
DD
V
SS
RD7/PSP7/P1D
RD6/PSP6/P1C
RD5/PSP5/P1B
RD4/PSP4/ECCP1/P1A
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3/C2IN-
RD2/PSP2/C2IN+
2007-2018 Microchip Technology Inc.
PIC18F4585
PIC18F4680
DS30009625D-page 2
PIC18F2585/2680/4585/4680
Pin Diagrams (Continued)
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3/C2IN-
RD2/PSP2/C2IN+
RD1/PSP1/C1IN-
RD0/PSP0/C1IN+
RC3/SCK/SCL
RC2/CCP1
RC1/T1OSI
NC
1
2
3
4
5
6
7
8
9
10
11
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
44-Pin TQFP
44-Pin QFN
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
RD3/PSP3/C2IN-
RD2/PSP2/C2IN+
RD1/PSP1/C1IN-
RD0/PSP0/C1IN+
RC3/SCK/SCL
RC2/CCP1
RC1/T1OSI
RC0/T1OSO/T13CKI
2007-2018 Microchip Technology Inc.
RB3/CANRX
NC
RB4/KBI0/AN9
RB5/KBI1/PGM
RB6/KBI2/PGC
RB7/KBI3/PGD
MCLR/V
PP
/RE3
RA0/AN0/CV
REF
RA1/AN1
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
12
13
14
15
16
17
18
19
20
21
22
RC7/RX/DT
RD4/PSP4/ECCP1/P1A
RD5/PSP5/P1B
RD6/PSP6/P1C
RD7/PSP7/P1D
V
SS
AV
DD
V
DD
RB0/INT0/FLT0/AN10
RB1/INT1/AN8
RB2/INT2/CANTX
1
2
3
4
5
6
7
8
9
10
11
44
43
42
41
40
39
38
37
36
35
34
NC
NC
RB4/KBI0/AN9
RB5/KBI1/PGM
RB6/KBI2/PGC
RB7/KBI3/PGD
MCLR/V
PP
/RE3
RA0/AN0/CV
REF
RA1/AN1
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
12
13
14
15
16
17
18
19
20
21
22
RC7/RX/DT
RD4/PSP4/ECCP1/P1A
RD5/PSP5/P1B
RD6/PSP6/P1C
RD7/PSP7/P1D
V
SS
V
DD
RB0/INT0/FLT0/AN10
RB1/INT1/AN8
RB2/INT2/CANTX
RB3/CANRX
PIC18F4585
PIC18F4680
NC
RC0/T1OSO/T13CKI
OSC2/CLKO/RA6
OSC1/CLKI/RA7
V
SS
V
DD
RE2/CS/AN7/C2OUT
RE1/WR/AN6/C1OUT
RE0/RD/AN5
RA5/AN4/SS/HLVDIN
RA4/T0CKI
PIC18F4585
PIC18F4680
33
32
31
30
29
28
27
26
25
24
23
OSC2/CLKO/RA6
OSC1/CLKI/RA7
V
SS
AV
SS
V
DD
AV
DD
RE2/CS/AN7/C2OUT
RE1/WR/AN6/C1OUT
RE0/RD/AN5
RA5/AN4/SS/HLVDIN
RA4/T0CKI
DS30009625D-page 3
PIC18F2585/2680/4585/4680
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 7
2.0 Oscillator Configurations ............................................................................................................................................................ 23
3.0 Power Managed Modes ............................................................................................................................................................. 33
4.0 Reset .......................................................................................................................................................................................... 41
5.0 Memory Organization ................................................................................................................................................................. 61
6.0 Flash Program Memory.............................................................................................................................................................. 95
7.0 Data EEPROM Memory ........................................................................................................................................................... 105
8.0 8 x 8 Hardware Multiplier.......................................................................................................................................................... 111
9.0 Interrupts .................................................................................................................................................................................. 113
10.0 I/O Ports ................................................................................................................................................................................... 129
11.0 Timer0 Module ......................................................................................................................................................................... 147
12.0 Timer1 Module ......................................................................................................................................................................... 151
13.0 Timer2 Module ......................................................................................................................................................................... 157
14.0 Timer3 Module ......................................................................................................................................................................... 159
15.0 Capture/Compare/PWM (CCP1) Modules ............................................................................................................................... 163
16.0 Enhanced Capture/Compare/PWM (ECCP1) Module.............................................................................................................. 173
17.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 187
18.0 Enhanced Universal Synchronous Receiver Transmitter (EUSART)....................................................................................... 227
19.0 10-Bit Analog-to-Digital Converter (A/D) Module ..................................................................................................................... 247
20.0 Comparator Module.................................................................................................................................................................. 257
21.0 Comparator Voltage Reference Module................................................................................................................................... 263
22.0 High/Low-Voltage Detect (HLVD)............................................................................................................................................. 267
23.0 ECAN™ Technology ................................................................................................................................................................ 273
24.0 Special Features of the CPU.................................................................................................................................................... 343
25.0 Instruction Set Summary .......................................................................................................................................................... 361
26.0 Development Support............................................................................................................................................................... 411
27.0 Electrical Characteristics .......................................................................................................................................................... 415
28.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 451
29.0 Packaging Information.............................................................................................................................................................. 453
Appendix A: Revision History............................................................................................................................................................. 461
Appendix B: Device Differences ........................................................................................................................................................ 461
Appendix C: Conversion Considerations ........................................................................................................................................... 462
Appendix D: Migration From Baseline to Enhanced Devices ............................................................................................................ 462
Appendix E: Migration from Mid-Range to Enhanced Devices .......................................................................................................... 463
Appendix F: Migration from High-End to Enhanced Devices............................................................................................................. 463
The Microchip Web Site ..................................................................................................................................................................... 477
Customer Change Notification Service .............................................................................................................................................. 477
Customer Support .............................................................................................................................................................................. 477
Reader Response .............................................................................................................................................................................. 478
PIC18F2585/2680/4585/4680 Product Identification System ............................................................................................................ 479
2007-2018 Microchip Technology Inc.
DS30009625D-page 4
PIC18F2585/2680/4585/4680
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.
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 Website 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., DS30000000A is version A of document DS30000000).
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 Website;
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 website at
www.microchip.com
to receive the most current information on all of our products.
2007-2018 Microchip Technology Inc.
DS30009625D-page 5