Note the following details of the code protection feature on Microchip devices:
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•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 impro ving the cod e 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.
Information contained in this publication regarding device
applications and the like is intended through suggestion only
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
No representation or warranty is given and no liability is
assumed by Microchip Technology Incorporated with respect
to the accuracy or use of such information, or infringement of
patents or other intellectual property rights arising from such
use or otherwise. Use of Microchip’s products as critical
components in life support systems is not authorized except
with express written approval by Microchip. No licenses are
conveyed, implicitly or otherwise, under any intellectual
property rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, MPLAB, PIC, PICmic ro, PI C START,
PRO MATE, PowerSmart and rfPIC are registered
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
AmpLab, FilterLab, microID, MXDEV, MXLA B, PICMASTER,
SEEVAL, SmartShunt and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Application Maestro, dsPICDEM, dsPICDEM.net,
dsPICworks, ECAN, ECONOMONITOR, FanSense,
FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP,
ICEPIC, Migratable Memory, MPASM, MPLIB, MPLINK,
MPSIM, PICkit, PICDEM, PICDEM.net, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, rfLAB, Select Mode,
SmartSensor, SmartTel and Total Endurance are trademarks
of Microchip Technology Incorporated in the U.S.A. and other
countries.
Serialized Quick Turn Programming (SQTP) is a service mark
of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
Microchip re cei v ed I S O/T S - 16 949 : 20 02 qu ality system c er ti f ic at io n f or
its worldwide headquarters, design and wafer fabrication facilities in
Chandler and Tempe, Arizona and Mountain View, California in October
2003. The Com pany’s quality sy stem proces ses and pro cedures are for
its PICmicro
EEPROMs, microperipherals, nonvolatile memory and analog
products. In addition, Microchip’s quality system for the design and
manufacture of development systems is ISO 9001:2000 certified.
17.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 189
24.0 Special Features of the CPU......................................................................................... ........................................................... 345
25.0 Instruction Set Summary ..........................................................................................................................................................365
26.0 Development Support. .............................................................................................................................................................. 407
28.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 449
Appendix D: Migration from Mid-Range to Enhanced Devices.......................................................................................................... 470
Appendix E: Migration from High-End to Enhanced Devices.............................................................................................................471
Index .................................................................................................................................................................................................. 473
Systems Information and Upgrade Hot Line......................................................................................................................................487
PIC18F6585/8585/6680/8680 Product Identification System ............................................................................................................ 489
DS30491C-page 6 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
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 t o better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or c omm ents regarding t his publication, p lease c ontact the M arket ing Co mmunications Department via
E-mail at docerrors@mail.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 determ ine 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)
• The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, 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/cn to receive the most current information on all of our products.
2004 Microchip Technology Inc.DS30491C-page 7
PIC18F6585/8585/6680/8680
NOTES:
DS30491C-page 8 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
1.0DEVICE OVERVIEW
All other features for devices in the
PIC18F6585/8585/6680/8680 family are identical.
This documen t conta i ns dev ic e spec if i c in for m at i on fo r
the following devices:
• PIC18F6585• PIC18F8585
• PIC18F6680• PIC18F8680
PIC18F6X8X devices are av ailable in 64-pin TQFP an d
These are summarized in Table 1-1.
Block diagrams of the PIC18F6X8X and PIC18F8X8X
devices are provided in Figure 1-1 and Figure 1-2,
respectively. The pinouts for these device families are
listed in Table 1-2.
68-pin PLCC packages. PIC18F8X8X devices are
available in the 80-pin TQFP package. They are
differentiated from each other in four way s :
1.Flash program memory (48 Kbytes for
PIC18FX585 devices, 64Kbytes for
PIC18FX680)
2.A/D channels (1 2 for PIC18F6X8X devices,
16 for PIC1 8F8X8X)
3.I/O ports (7 on PIC18F6X8X devices, 9 on
PIC18F8X8X)
4.External program memory interface (present
only on PIC18F8X8X devices)
T ABLE 1-1:PIC18F6585/8585/6680/8680 DEVICE FEATURES
DC–25MHzw/EMA
Program Memory (Bytes)48K64K48K (2 MB EMA)64K (2 MB EMA)
Program Memory (Instructions)24576327682457632768
Data Memory (Bytes)3328332833283328
Data EEPROM Memory (Bytes)10241024102410 24
External Memory InterfaceNoNoYesYes
Interrupt Sourc e s29292929
I/O PortsPorts A
Timers4444
Capture/Compare/PWM M odule1111
Enhanced Capture/Compare/PWM
Module
Serial CommunicationsMSSP,
Enhanced AUSAR T ,
Parallel CommunicationsPSPPSPPSP
10-bit Analog-to-Digital Module12 input cha nnels12 input ch annels16 inp ut cha nnels16 inpu t chan nels
Resets (and Delays)POR, BOR,
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
/VPP
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
7169
395049
405150
I
I
P
IICMOS/ST
O
O
I/O
ST
ST
CMOS
TTL
Master Clear (input) or programming
voltage (input).
General purpose input pin.
Master Clear (Reset ) in pu t. This pin is
an active-low Reset to the device.
Programming voltage inp ut.
Oscillator crystal or external clock input.
Oscillator crystal input or external clock
source input. ST buffer when configured
in RC mode; otherwise CMOS.
External cloc k source input. Always
associated with pin function OSC1
(see OSC1/CLKI, OSC2/CLKO pins).
Oscillator crystal or clock output.
—
—
Oscillator crystal output.
Connects to crystal or resonator in
Crystal Oscillator mode.
In RC mode, OSC2 pi n o utpu ts CLKO
which has 1/4 the frequency of OSC1
and denotes the instruction cycle rate.
General purpose I/O pin.
DD)
DS30491C-page 12 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
T ABLE 1-2:PIC18F6585/8585/6680/8680 PINOUT I/O DESCRIPTIONS (CONTINUED)
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
REF-
REF-
REF+
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
243430
233329
223228
213127
283934
273833
Pin
Type
I/O
I/O
I/O
I/O
I/OIST/OD
I/O
Buffer
Type
PORTA is a bidirectional I/O port.
TTL
I
Analog
TTL
I
Analog
TTL
I
Analog
I
Analog
TTL
I
Analog
I
Analog
ST
TTL
I
Analog
I
Analog
Digital I/O.
Analog input 0.
Digital I/O.
Analog input 1.
Digital I/O.
Analog input 2.
A/D reference voltage (Low) input.
Digital I/O.
Analog input 3.
A/D reference voltage (High) input.
Digital I/O – Open-drain when
configured as output.
Timer0 external clock input.
Digital I/O.
Analog input 4.
Low-voltage detect input.
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
486058
475957
465856
455755
445654
435553
425452
374847
Pin
Type
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
Buffer
Type
PORTB is a bidirectional I/O port. PORTB
can be software programmed for internal
weak pull-ups on all inputs.
TTL
I
I
I
I
I
I
ST
TTL
ST
TTL
ST
TTL
ST
ST
TTL
ST
TTL
ST
ST
TTL
ST
ST
TTL
ST
Digital I/O.
External interrupt 0.
Digital I/O.
External interrupt 1.
Digital I/O.
External interrupt 2.
Digital I/O.
External interrupt 3.
Capture 2 input/Compare 2 output/
PWM 2 output.
Digital I/O.
Interrupt-on-change pin.
Digital I/O.
Interrupt-on-change pin.
Low-Voltage ICSP Programming
enable pin.
Digital I/O.
Interrupt-on-change pin.
In-circuit debugger and ICSP
programming clock.
Digital I/O.
Interrupt-on-change pin.
In-circuit debugger and ICSP
programming data.
DescriptionPIC18F6X8X PIC18F8X8X
DD)
DS30491C-page 14 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
T ABLE 1-2:PIC18F6585/8585/6680/8680 PINOUT I/O DESCRIPTIONS (CONTINUED)
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
304136
294035
334443
344544
354645
364746
314237
324338
Pin
Type
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
Buffer
Type
PORTC is a bidirectional I/O port.
ST
O
I
I
I
O
O
I
—
ST
ST
CMOS
ST
ST
ST
ST
ST
ST
ST
ST
ST
ST
ST
—
ST
—
ST
ST
ST
ST
Digital I/O.
Timer1 oscillator output.
Timer1/Timer3 external clock input.
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
Buffer
Type
ST
TTL
TTL
ST
TTL
TTL
ST
TTL
TTL
ST
TTL
TTL
ST
TTL
TTL
ST
TTL
TTL
ST
TTL
TTL
ST
TTL
TTL
DescriptionPIC18F6X8X PIC18F8X8X
PORTD is a bidirectional I/O port. These
pins have TTL input buf fers when ex ternal
memory is enabled.
Digital I/O.
Parallel Slave Port data.
External memory address/data 0.
Digital I/O.
Parallel Slave Port data.
External memory address/data 1.
Digital I/O.
Parallel Slave Port data.
External memory address/data 2.
Digital I/O.
Parallel Slave Port data.
External memory address/data 3.
Digital I/O.
Parallel Slave Port data.
External memory address/data 4.
Digital I/O.
Parallel Slave Port data.
External memory address/data 5.
Digital I/O.
Parallel Slave Port data.
External memory address/data 6.
Digital I/O.
Parallel Slave Port data.
External memory address/data 7.
DD)
DS30491C-page 16 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
T ABLE 1-2:PIC18F6585/8585/6680/8680 PINOUT I/O DESCRIPTIONS (CONTINUED)
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
Buffer
Type
DescriptionPIC18F6X8X PIC18F8X8X
PORTE is a bidirectional I/O port.
ST
I
TTL
TTL
ST
I
TTL
TTL
ST
I
TTL
TTL
ST
TTL
ST
TTL
ST
TTL
ST
ST
TTL
ST
ST
ST
Digital I/O.
Read control for Parallel Slave Port
(see WR
and CS pins).
External memory address/data 8.
Digital I/O.
Write control for Parallel Slave Port
(see CS
and RD pins).
External memory address/data 9.
Digital I/O.
Chip select control for Parallel Slave
Port (see RD
and WR).
External memory address/data 10.
Digital I/O.
External memory address/data 11.
Digital I/O.
External memory address/data 12.
Digital I/O.
External memory address/data 13.
ECCP1 PWM output C.
Digital I/O.
External memory address/data 14.
ECCP1 PWM output B.
Digital I/O.
Capture 2 input/Compare 2 output/
PWM 2 output.
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
182824
172723
162618
152517
142416
REF
132315
122214
112113
Pin
Type
I/O
I/O
O
I/O
O
I/O
I/O
I/O
O
I/O
I/O
Buffer
Type
PORTF is a bidirectional I/O port.
ST
I
Analog
ST
I
Analog
ST
ST
I
Analog
ST
ST
I
Analog
I
Analog
ST
I
Analog
I
Analog
ST
I
Analog
I
Analog
Analog
ST
I
Analog
I
Analog
ST
I
TTL
Digital I/O.
Analog input 5.
Digital I/O.
Analog input 6.
Comparator 2 output.
Digital I/O.
Analog input 7.
Comparator 1 output.
Digital I/O.
Analog input 8.
Comparator 2 input (+).
Digital I/O.
Analog input 9.
Comparator 2 input (-).
Digital I/O.
Analog input 10.
Comparator 1 input (+).
Comparator V
Digital I/O.
Analog input 11.
Comparator 1 input (-)
Digital I/O.
SPI slave select input.
DescriptionPIC18F6X8X PIC18F8X8X
REF output.
DD)
DS30491C-page 18 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
T ABLE 1-2:PIC18F6585/8585/6680/8680 PINOUT I/O DESCRIPTIONS (CONTINUED)
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
——79
——80
——1
——2
——22
——21
——20
——19
Pin
Type
I/O
O
I/O
O
I/O
O
I/O
O
I/O
I/O
I/O
I/O
I/O
Buffer
Type
PORTH is a bidirectional I/O port
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
I
Analog
ST
I
Analog
ST
I
Analog
ST
ST
I
Analog
Digital I/O.
External memory address 16.
Digital I/O.
External memory address 17.
Digital I/O.
External memory address 18.
Digital I/O.
External memory address 19.
Digital I/O.
Analog input 12.
Digital I/O.
Analog input 13.
Digital I/O.
Analog input 14.
Alternate CCP1 PWM out put C.
Digital I/O.
Analog input 15.
Alternate CCP1 PWM out put B.
DescriptionPIC18F6X8X PIC18F8X8X
(5)
.
DD)
DS30491C-page 20 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
T ABLE 1-2:PIC18F6585/8585/6680/8680 PINOUT I/O DESCRIPTIONS (CONTINUED)
ST= Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Note 1:Alternate assignment for CCP2 in all operating modes except Microcontroller – applies to PIC18F8X8X only.
2:Default assignment when CCP2MX is set.
3:External memory interface functions are only available on PIC18F8X8X devices.
4:CCP2 is multiplexed with this pin by default when configured in Microcontroller mode; otherwise, it is
multiplexed with either RB3 or RC1.
5:PORTH and PORTJ are only available on PIC18F8X8X (80-pin) devices.
6:PSP is available in Microcontroller mode only.
7:On PIC18F8X8X devices, these pins can be multiplexed with RH7/RH6 by changing the ECCPMX
configuration bit.
——62
——61
——60
——59
——39
——40I/O
——42
——41
41, 56
38, 57
19, 36,
53, 68
2, 20,
37, 49
35, 52
11, 31,
51, 70
12, 32,
48, 71
———No connect.
Pin
Type
I/O
I/O
I/O
I/O
I/O
I/O
I/O
Buffer
Type
PORTJ is a bidirectional I/O port
ST
O
O
O
O
O
O
O
O
P—Ground reference for logic and I/O pins.
P—Positive supply for logic and I/O pins.
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
Digital I/O.
External memory address latch
enable.
Digital I/O.
External memory output enable.
Digital I/O.
External memory write low control.
Digital I/O.
External memory write high control.
Digital I/O.
System bus byte address 0 control.
Digital I/O
External memory chip enable.
Digital I/O.
External memory low byte sele ct.
Digital I/O.
External memory high byte select.
DescriptionPIC18F6X8X PIC18F8X8X
(5)
.
DD)
2004 Microchip Technology Inc.DS30491C-page 21
PIC18F6585/8585/6680/8680
NOTES:
DS30491C-page 22 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
2.0OSCILLATOR
CONFIGURATIONS
2.1Oscillator Types
The PIC18F6585/8585/6680/8680 devices can be
operated in eleven different oscillator modes. The user
can program four configuration bits (FOSC3, FOSC2,
FOSC1 and FOSC0) to select one of these eleven
modes:
1.LPLow-Power Crystal
2.XTCrystal/Resonator
3.HSHigh-Speed Crystal/Resonator
4.RCExternal Resistor/Cap ac ito r
5.ECExternal Clock
6.ECIOExternal Clock with I/O
pin enabled
7.HS+PLLHigh-Speed Crystal/Resonator
with PLL enabled
8.RCIOExternal Resist or/Capacitor with
I/O pin enabled
9.ECIO+SPLL External Clock with software
controlled PLL
10. ECIO+PLLExternal Clock with PLL and I/O
pin enabled
11. HS+SPLLHigh-Speed Crystal/Resonator
with software control
2.2Crystal Oscillator/Ceramic
Resonators
In XT, LP, HS, HS+PLL or HS+SPLL Oscillator modes,
a crystal or ceramic resonator is connected to the OSC1
and OSC2 pins to establish oscillation. Figure 2-1
shows the pin connections.
The PIC18F6585/8585/6680/8680 oscillator design
requires the use of a parallel cut crystal.
Note:Use of a series cut crystal may give a fre-
quency out of the crystal manufacturers
specifications.
FIGURE 2-1:CRYSTAL/CERAMIC
RESONATOR OPERATION
(HS, XT OR LP
CONFIGURATION)
(1)
C1
(1)
C2
Note 1: See Table 2-1 and Table 2-2 for recommended
2: A series resistor (R
3: R
OSC1
XTAL
(2)
RS
OSC2
values of C1 and C2.
strip cut crystals.
F varies with the oscillator mode chosen.
(3)
RF
Sleep
PIC18FXX80/XX85
S) may be required for AT
To
Internal
Logic
T ABLE 2-1:CAPACITOR SELECTION FOR
CERAMIC RESONATORS
Ranges Tested:
ModeFreqC1C2
XT455 kHz
2.0 MHz
4.0 MHz
HS8.0 MHz
16.0 MHz
These values are for design guid ance only.
See notes following this table.
Resonators Used:
2.0 MHz Murata Erie CSA2.00MG± 0.5%
4.0 MHz Murata Erie CSA4.00MG± 0.5%
8.0 MHz Murata Erie CSA8.00MT± 0.5 %
16.0 MHz Murata Erie CSA16.00MX± 0.5%
All resonators used di d not have built-in capac itors.
68-100 pF
15-68 pF
15-68 pF
10-68 pF
10-22 pF
68-100 pF
15-68 pF
15-68 pF
10-68 pF
10-22 pF
Note 1: Hig her cap acitance increase s the stabi lity
of the oscillator, but also increases the
start-up time.
2: When operating below 3V V
DD, or when
using certain ceramic resonators at any
voltage, it may be necessary to use high
gain HS mode, try a lower frequency
resonator, or switch to a crystal oscillator.
3: Since each resonator/crystal has its own
characteristics, the user should consul t the
resonator/crystal manufacturer for appropriate values of external components, or
verify oscillator performance.
2004 Microchip Technology Inc.DS30491C-page 23
PIC18F6585/8585/6680/8680
TABLE 2-2:CAPACITOR SELECTION FOR
CRYSTAL OSCILLATOR
Ranges Tested:
ModeFreqC1C2
LP32.0 kHz33 pF33 pF
200 kHz15 pF15 pF
XT200 kHz47-68 pF47-68 pF
1.0 MHz15 pF15 pF
4.0 MHz15 pF15 pF
HS4.0 MHz15 pF15 pF
8.0 MHz15-33 pF15-33 pF
20.0 MHz15-33 pF15-33 pF
25.0 MHzTBDTBD
These values are for de sign guid ance only.
See notes following this table.
Note 1: Hi gher capac itance inc reases th e stabilit y
of the oscillator, but also increases the
start-up time.
2: Rs (see Figure 2-1) may be required in
HS mode, as we ll as XT mode , to avoid
overdriving crystals with low drive level
specifications.
3: Since each resonator/crystal has its own
characteristics, the user should consult the
resonator/crystal manufacturer for appropriate values of external components, or
verify oscillator performance.
An external clock source may also be connected to the
OSC1 pin in the HS, XT and LP modes, as shown in
Figure 2-2.
FIGURE 2-2:EXTERNAL CLOCK INPUT
OPERATION (HS, XT OR
LP OSC CONFIG URAT ION)
Clock from
Ext. System
Open
OSC1
PIC18FXX80/XX85
OSC2
2.3RC Oscillator
For timing insensitive applications, the “RC” and
“RCIO” device options offer additional cost savings.
The RC oscillator frequency is a function of the supply
voltage, the resistor (R
ues and the operating temperature. In addition to this,
the oscillator frequency will vary from unit to unit, due
to normal process parameter variation. Furthermore,
the difference in lead frame cap acitance bet ween package types will also affect the oscillation frequency,
especially for low C
take into account variation due to tolerance of external
R and C components used. Figure 2-3 shows how the
R/C combination is connected.
In the RC Oscillator mode, the oscillator frequency
divided by 4 is available on the OSC2 pin. This signal
may be used f or t e st pu r pos es or t o sy nc hr o n iz e ot he r
logic.
FIGURE 2-3:RC OSCILLATOR MODE
VDD
REXT
CEXT
VSS
F
Recommended values: 3 kΩ ≤ REXT ≤ 100 kΩ
EXT) and capacitor (CEXT) val-
EXT values. Th e user also needs to
OSC1
Internal
Clock
PIC18FXX80/XX85
OSC2/CLKO
OSC/4
EXT > 20pF
C
The RCIO Oscillator mode functions like the RC mode
except that the OSC2 pin becomes an additional general purpose I/O pin. The I/O pin becomes bit 6 of
PORTA (RA6).
DS30491C-page 24 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
2.4External Clock Input
The EC, ECIO, EC+PLL and EC+SPLL Oscillator
modes require an external clock source to be connected to the OSC 1 pin. T he feed back device b etwee n
OSC1 and OSC2 is turned off in these modes to save
current. There is a maximum 1.5 µs start-up requ ired
after a Power-on Reset, or wake-up from Sleep mode.
In the EC Oscillator mode, the oscillator frequency
divided by 4 is available on the OSC2 pin. This signal
may be used f or t e st pu r pos es or t o sy nc hr o n iz e ot he r
logic. Figure 2-4 shows the pin connections for the EC
Oscillator mode.
FIGURE 2-4:EXTERNAL CLOCK INPUT
OPERATION
(EC CONFIGURATION)
Clock from
Ext. System
F
OSC/4
The ECIO Oscillator mode func ti ons li ke t he EC m od e,
except that the OSC2 pin becomes an additional general purpose I/O pin. The I/O pin becomes bit 6 of
PORTA (RA6). Figure 2-5 shows the pin connections
for the ECIO Oscillator mode.
FIGURE 2-5:EXTERNAL CLOCK INPUT
OSC1
PIC18FXX80/XX85
OSC2
OPERATION
(ECIO CONFIGURATION)
2.5Phase Locked Loop (PLL)
A Phase Locked Loop circuit is provided as a
programmable option for us ers that want to multip ly the
frequency of the in com in g osc il lat or s ig nal by 4 . For an
input clock frequency of 10 MHz, the internal clock
frequency will b e multipli ed to 40 MHz. This is usefu l for
customers who are concerned with EMI due to
high-frequency crystals.
The PLL can only be enabled when the oscillator configuration bits are programmed for High-Speed Oscillator
or External Clock mode. If they are programmed for any
other mode, the PLL is not enabled and the system clock
will come directly from OSC1. There are two types of
PLL modes: Software Controlled PLL and Configuration
bits Controlled PLL. In Software Controlled PLL mode,
PIC18F6585/8585/6680/8680 executes at regular clock
frequency after all Reset conditions. During execution,
application can enable PLL and switch to 4x clock
frequency operation by setting the PLLEN bit in the
OSCCON register. In Configuration bits Controlled PLL
mode, PIC18F6585/8585/6680/8680 always executes
with 4x clock frequency.
The type of PLL is selected by programming the
FOSC<3:0> configuration bits in the CONFIG1H
Configuration register. The oscillator mode is specified
during device programming.
A PLL lock timer is used to ensure that the PLL has
locked before device execution starts. The PLL lock
timer has a time-out that is called T
PLL.
Clock from
Ext. System
RA6
OSC1
PIC18FXX80/XX85
I/O (OSC2)
FIGURE 2-6:PLL BLOCK DIAGRAM
PLL Enable
Phase
Comparator
F
IN
FOUT
Loop
Filter
Divide by 4
VCO
SYSCLK
MUX
2004 Microchip Technology Inc.DS30491C-page 25
PIC18F6585/8585/6680/8680
2.6Oscillator Switching Feature
The PIC18F6585/8585/6680/8680 devices include a
feature that allows the system clock source to be
switched from the main oscillator to an alternate
low-frequency clock source. For the
PIC18F6585/8585/6680/8680 devices, this alternate
clock source is the Timer1 oscillator. If a low-frequency
crystal (32 kHz, for ex am pl e ) ha s bee n at tac he d to the
Timer1 oscillator pins and the Timer1 oscillator has
been enabled, the device can switch to a low-power
FIGURE 2-7:DEVICE CLOCK SOURCES
PIC18FXX80/XX85
OSC2
OSC1
T1OSO
T1OSI
Main Oscillator
Sleep
Timer1 Oscillator
T1OSCEN
Enable
Oscillator
execution mode. Figure 2-7 shows a block diagram of
the system clock sources. The clock switching feature
is enabled by programming the Oscillator Switching
Enable (OSCSEN
) bit in configuration register,
CONFIG1H, to a ‘0’. Clock switching is disabled in an
erased device. See Se ction 12.0 “Timer1 Module” for
further details of the Timer1 oscillator . See Section 24.0“Special Features of the CPU” for configuration
register details.
4 x PLL
TOSC
TT1P
Tosc/4
MUX
Clock
Source
TSCLK
Clock Source Option
for other Modules
DS30491C-page 26 2004 Microchip Technology Inc.
PIC18F6585/8585/6680/8680
2.6.1SYSTEM CLOCK SWITCH BIT
The system clock source switching is p erformed under
software control. The System Clock Switch bits,
SCS1:SCS0 (OSCCON<1:0>), control the clock switching. When the SCS0 bit is ‘ 0’, the system cl ock source
comes from the main oscillator that is selected by the
FOSC configuration bits in configuration register,
CONFIG1H. When the SCS0 bit is set, the system clock
source will come from the Timer1 oscillator. The SCS0
bit is clear ed on al l fo rm s of R eset.
When FOSC bits are programmed for software PLL
mode, the SCS1 bit c an be us ed to select between primary oscillator/clo ck and PLL output . The SCS1 bit wil l
only have an effect on the system clock if the PLL is
REGISTER 2-1:OSCCON REGISTER
U-0U-0U-0U-0R/W-0R/W-0R/W-0R/W-0
————LOCKPLLENSCS1SCS0
bit 7bit 0
bit 7-4 Unimplemented: Read as ‘0’
bit 3LOCK: Phase Lock Loop Lock Status bit
1 = Phase Lock Loop output is stable as system clock
0 = Phase Lock Loop output is not stable and output cannot be used as system clock
(1)
bit 2PLLEN
1 = Enable Phase Lock Loop output as system clock
0 = Disable Phase Lock Loop
bit 1SCS1: System Clock Switch bit 1
When PLLEN and LOCK bits are set:
1 = Use PLL output
0 = Use primary oscillator/clock input pin
When PLLEN or LOCK bit is cleared:
Bit is forced clear.
bit 0SCS0
When
1 = Switch to Timer1 oscillator/clock pin
0 = Use primary oscillator/clock input pin
When
Bit is forced clear.
: Phase Lock Loop Enable bit
(2)
: System Clock Switch bit 0
OSCSEN configuration bit = 0 and T1OSCEN bit = 1:
OSCSEN and T1OSCEN are in other states:
Note 1: PLLEN bit is ignored when configured for ECIO+PLL and HS+PLL. This bit is used
in ECIO+SPLL and HS+SPLL modes only.
2: The setting of SCS0 = 1 supersedes SCS1 = 1.
enabled (PLLEN = 1) and locked (LOCK = 1), else it will
be forced clear. When programmed with Configuration
Controlled PLL mode, the SCS1 bit w ill be forced c lear .
Note:The Timer1 oscillator must be enabled
and operating to switch the system clock
source. The Timer1 oscillator is enabled
by setting the T1OSCEN bit in the Timer1
Control register (T1CON). If the Timer1
oscillator is not enabled, then any write to
the SCS0 bit will be ignored (SCS0 bit
forced cleared) and the main osci llator w ill
continue to be the system clock source.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
2004 Microchip Technology Inc.DS30491C-page 27
PIC18F6585/8585/6680/8680
2.6.2OSCILLATOR TRANSITIONS
PIC18F6585/8585/6680/8680 devices contain circuitry
to prevent “glitches” when switching between oscillator
sources. Essentially, the circuitry waits for eight rising
edges of the clock source that the processor is switching to. This e ns ures t hat the new clock source is st abl e
and that its pulse wid th will not be less than the sho rtest
pulse width of the two clock sources.
A timing diagram, indicating the transition from the
main oscillator to the Timer1 oscillator, is shown in
Figure 2-8. The Timer1 oscillator is assu med to be run-
The sequence of events that takes place when switching from the Timer1 oscillator to the main oscillator will
depend on the mode of the main oscillator. In addition
to eight clock cycles of the main oscillator, additional
delays may take place.
If the main oscillator is configured for an external
crystal (HS, XT, LP), then the transition will take place
after an oscillator start-up time (T
OST) has occurred. A
timing diagram, indicating the transition from the
Timer1 oscillator to the main oscillator for HS, XT and
LP modes, is shown in Figure 2-9.
ning all the time. After the SCS0 bit is set, the processor
is frozen at the next occurring Q1 cycle. After eight
synchronization cycles are counted from the Timer1
oscillator, operation resumes. No additional delays are
required after the synchronization cycles.
FIGURE 2-8:TIMING DIAGRAM FOR TRANSITION FROM OSC1 TO TIMER1 OSCILLATOR
Q1
T1OSI
OSC1
Internal
System
Clock
SCS
(OSCCON<0>)
Program
Counter
TOSC
Q1
TDLY
TT1P
21345678
TSCS
PC + 2PC
Q3Q2Q1Q4Q3Q2
Q4Q1
Q2Q3Q4Q1
PC + 4
Note:TDLY is the delay from SCS high to first count of transition circuit.
FIGURE 2-9:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (HS, XT, LP)
Q3Q4
T1OSI
OSC1
Internal
System Clock
(OSCCON<0>)
Note:TOST = 1024 TOSC (drawing not to scale).
SCS
Program
Counter
PCPC + 2
Q1
TOST
TT1P
12345678
TSCS
TOSC
Q1 Q2 Q3 Q4 Q1 Q2
Q3
PC + 6
DS30491C-page 28 2004 Microchip Technology Inc.
Loading...
+ 466 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.