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 improving the code protect ion 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, dsPIC,
K
EELOQ, MPLAB, PIC, PICmicro, PICSTART , PRO MA TE and
PowerSmart are registered trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
FilterLab, microID, MXDEV, MXL AB, PICMASTER, SEEVAL
and The Embedded Control Solutions Company are
registered trademarks of Microchip Technology Incorporated
in the U.S.A.
Accuron, Application Maestro, dsPICDEM, dsPICDEM.net,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, InCircuit Serial Programming, ICSP, ICEPIC, microPort,
Migratable Memory, MPASM, MPLIB, MPLINK, MPSIM,
PICC, PICkit, PICDEM, PICDEM.net, PowerCal, PowerInfo,
PowerMate, PowerTool, rfLAB, rfPIC, Select Mode,
SmartSensor, SmartShunt, SmartT el and T otal 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 received QS-9000 quality system
certification for its worldwide headquarters,
design and wafer fabrication facilities in
Chandler and Tempe, Arizona in July 1999
and Mountain View, California in March 2002.
The Company’s quality system processes and
procedures are QS-9000 compliant for its
PICmicro
devices, Serial EEPROMs, microperipherals,
non-volatile memory and analog products. In
addition, Microchip’s quality system for the
design and manufacture of development
systems is ISO 9001 certified.
®
8-bit MCUs, KEELOQ
®
code hopping
DS39612A-page iiAdvance Information 2003 Microchip Technology Inc.
PIC18F6X2X/8X2X
64/80-Pin High Performance, 64-Kbyte Enhanced FLASH
Microcontrollers with A/D
High Performance RISC CPU:
• Linear program memory addressing to 64 Kbytes
• Linear data memory addressing to 4 Kbytes
• 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
Peripheral Features:
• High current sink/so ur ce 25 mA/25 mA
• Four external interrup t pin s
• Timer0 module: 8-bit/16-bit tim er/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 oscilla to r c lo ck option - Timer1/Timer3
18.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 175
22.0 Comparator Voltage Reference Module................................................................................................................................... 249
23.0 Low Voltage Detect ..................................................................................................................................................................253
24.0 Special Features of th e CPU.............. ................ ................. ................. .................................................................................... 259
25.0 Instruction Set Summary.......................................................................................................................................................... 277
26.0 Development Support............................................................................................................................................................... 319
28.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 359
29.0 Packaging Inform a tio n..... ................. ................ ................. ....................................................................................................... 361
Appendix D: Migration from Mid-Range to Enhanced Devices..........................................................................................................366
Appendix E: Migration from High-End to Enhanced Devices............................................................................................................. 367
Index .................................................................................................................................................................................................. 369
Systems Information and Upgrade Hot Line......................................................................................................................................379
DS39612A-page 4Advance Information 2003 Microchip Technology Inc.
PIC18F6X2X/8X2X
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 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 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)
• 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 liter-
ature 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.
DS39612A-page 6Advance Information 2003 Microchip Technology Inc.
PIC18F6X2X/8X2X
1.0DEVICE OVERVIEW
This documen t conta i ns dev ic e spec if i c in for m at i on fo r
the following devices:
• PIC18F6525
• PIC18F6621
• PIC18F8525
• PIC18F8621
This family offers the advantages of all
PIC18 microcontrollers - namely, high computational
performance at an economical price - with the
addition of high endurance enhanced FLASH program
memory. The PIC18F6X2X/ 8X2X famil y also provi des
an enhanced range of program memory options and
versatile analog fea tures that mak e it ideal fo r complex,
high performance applications.
1.1Key Features
1.1.1EXPANDED MEMORY
The PIC18F6X2X/8X2X family provides ample room
for application code, and includes members with
48 Kbytes or 64 Kbytes of code space.
Other memory features are:
• Data RAM and Data EEPROM: The
PIC18F6X2X/8X2X family also provides plenty of
room for application data. The devices have
3840 bytes of data RAM as well as 1024 bytes of
data EEPROM for lon g term retention of non-volatile
data.
• Memory Endurance: The enhanced FLASH cells
for both program memory and data EEPROM are
rated to last for many thousands of erase/write
cycles - up to 100,000 for program memory, and
1,000,000 for EEPROM. Data retention without
refresh is conservatively estimated to be greater
than 40 years.
1.1.2EXTERNAL MEMORY INTERFACE
In the unlikely event t hat 64 Kbytes of program memo ry
is inadequate for an application, the PIC18F8X2X
members of the family also implement an external
memory interface. This allows the controller’s internal
program counter to address a memory space of up to
2 MBytes, permitting a level of data access that few
8-bit devices can claim.
With the addition of new operati ng mode s, the ext ernal
memory interface offers many new options, including:
• Operating the microcontr oller entirely f rom external
memory
• Using combinations of on-chip and external
memory, up to the 2-Mbyte limit
• Using external FLASH me mory for reprogrammable
application code or large data tables
• Using external RAM devices for storing large
amounts of variable data
1.1.3EASY MIGRATION
Regardless of the memory size, all devices share the
same rich set of peripherals, allowing for a smooth
migration path as applications grow and evolve.
The consistent pinout scheme used throughout the
entire family also aids in migrating to the next larger
device. This is true when moving between the 64-pin
members, between the 80-pin members, or even
jumping fr om 64-pin to 80-pin devic es.
1.1.4OTHER SPECI AL FE A TU RES
• Communications: The PIC18F6X2X/8X2X family
incorporates a range of serial communication
peripherals, including 2 independent enhanced
USARTs and a Master SSP module capable of both
SPI and I2C (Master and Slave) mod es of op era tio n.
Also, for PIC18F6X2X/8X2X devices, one of the
general purpose I/O port s can be recon figured as an
8-bit parallel slave port for direct processor to
processor communi ca tio ns.
• CCP Modules: All devices in the family incorporate
two Capture/Compare/PWM (CCP) modules and
three enhanced CCP modu les to maximize flexibility
in control applications. Up to four different time
bases may be used to perform several different
operations at once. Each of the three ECCPs offer
up to four PWM outputs, allowing for a total of 12
PWMs. The ECCPs also offer many beneficial features, including polarity selection, programmable
dead-time, auto shutdown and restart, and
Half-Bridge and Full-Bridge Output mo des.
• Analog Features: All devices in the family feature
10-bit A/D converters with up to 16 input channels,
as well a s the a bility t o perfor m conver sions du ring
SLEEP mode and auto-acquisition conversions.
Also included are dual analog comparators with
programmable input and output configuration, a
programmable Low Voltage Detect module, and a
The PIC18F6X2X/8X2X dev ices a re available in 64-pi n
and 80-pin packages. They are differentiated from
each other in four ways:
1.FLASH program memory (48 Kbytes for
PIC18FX525 devices and 64 Kbytes for
PIC18FX621 devices)
2.A/D channels (12 for PIC18F6X2X devices ,
16 for PIC1 8F8X2X)
3.I/O ports (7 on PIC18F6X2X devices, 9 on
PIC18F8X2X)
4.External program memory interface (present
only on PIC18F8X2X devices)
All other features for devic es in the PIC1 8F6X2X/8 X2X
family are identical. These are summarized in
Table 1-1.
Block diagrams of the PIC18F6X2X and PIC18F8X2X
devices are provided in Figure 1-1 and Figure 1-2,
respectively. The pinouts for these device families are
listed in Table 1-2.
TABLE 1-1:PIC18F6X2X/8X2X DEVICE FEATURES
FeaturesPIC18F6525PIC18F6621PIC18F8525PIC18F8621
Operating Frequency
Program Memory (Bytes)48K64K48K64 K
Program Memory (Instruction s)2457632768245763 276 8
Data Memory (Bytes)384038403840384 0
Data EEPROM Memory (Bytes)1024102410241024
External Memory InterfaceNoNoYesYes
Interrupt Sources17171717
I/O PortsPorts A, B, C, D,
Note 1: CCP2/P2A are multiplexed with RC1 when CCP2MX is set; with RE7 when CCP2MX is cleared and the device is configured in
Microcontroller mode; or with RB3 when CCP2MX is cleared in all other Program Memory modes.
2: P1B/P1C/P3B/P3C are multiplexed with RE6:RE3 when ECCPMX is set, and with RH7:RH4 when ECCPMX is not set.
3: RG5 is multiplexed with MCLR
4: External memory interface pins are multiplexed with PORTD (AD7:AD0), PORTE (AD15:AD8) and PORTH (A19:A16).
Timer2Timer1Timer3Timer4Timer0
MSSP
CCP4 CCP5
, and is only available when the MCLR Resets are disabled.
Note 1:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open Drain (no P diode to V
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X de vices when ECCP MX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microcontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devic es when ECCPM X (CON FIG3H<1>) is not set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
79
I
P
I
3949
IICMOS/ST
4050
O
O
I/O
ST
—
ST
CMOS
—
—
TTL
Master Clear (input) or programming
voltage (output).
Master Clea r (Res et) inpu t. Thi s pi n is an
active low RESET to the device.
Programming voltage input.
Digital input.
Oscillator crystal or external clock input.
Oscillator crystal input or ex te rn al cl ock
source input. ST buffer when configured
in RC mode; otherwise CMOS.
External clock source input. Always
associated with pin func t io n O SC 1 (see
OSC1/CLKI, OSC2/CLKO pins).
Oscillator crystal or clock out put.
Oscillator crystal output.
Connects to crystal or resonator in
Crystal Oscillator mod e.
In RC mode, OSC2 pin ou tp uts CLKO
which has 1/4 the freque ncy of OSC1
and denotes the instru ct ion cycle rate.
Note 1:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open Drain (no P diode to V
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devices when ECCPMX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microc ontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/ P3B /P3C for PIC18F8 X2X devic es when ECCPM X (CON FIG3H<1>) is no t set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
Pin
Type
I/O
I/O
I/O
I/O
Buffer
Type
TTL
I
Analog
TTL
I
Analog
TTL
I
Analog
I
Analog
TTL
I
Analog
I
Analog
I/OIST/OD
ST
I/O
I
I
TTL
Analog
Analog
Description
PORTA is a bi-directional I/O port.
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.
DD)
DS39612A-page 12Advance Information 2003 Microchip Technology Inc.
Note 1:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open Drain (no P diode to V
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X de vices when ECCP MX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microcontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devic es when ECCPM X (CON FIG3H<1>) is not set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
Pin
Type
I/O
I
I/O
I
I/O
I
I/O
I/O
I/O
O
I/O
I
I/O
I
I/O
I/O
I
I/O
I/O
I
I/O
Buffer
Type
TTL
ST
TTL
ST
TTL
ST
TTL
ST
ST
—
TTL
ST
TTL
ST
ST
TTL
ST
ST
TTL
ST
ST
Description
PORTB is a bi-directional I/O port. PORTB
can be software programmed for internal
weak pull-ups on all inputs.
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/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devices when ECCPMX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microc ontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/ P3B /P3C for PIC18F8 X2X devic es when ECCPM X (CON FIG3H<1>) is no t set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
Pin
Type
I/O
O
I
I/O
I
I/O
O
I/O
I/O
O
I/O
I/O
I/O
I/O
I
I/O
I/O
O
I/O
O
I/O
I/O
I
I/O
Buffer
Type
ST
—
ST
ST
CMOS
ST
—
ST
ST
—
ST
ST
ST
ST
ST
ST
ST
—
ST
—
ST
ST
ST
ST
Description
PORTC is a bi-directional I/O port.
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/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X de vices when ECCP MX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microcontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devic es when ECCPM X (CON FIG3H<1>) is not set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
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
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
Description
PORTD is a bi-directional I/O port. These
pins have TTL i nput buffer s wh en external
memory is enabled.
Digital I/O.
External memory addre ss/data 0.
Parallel slave port data.
Digital I/O.
External memory addre ss/data 1.
Parallel slave port data.
Digital I/O.
External memory addre ss/data 2.
Parallel slave port data.
Digital I/O.
External memory addre ss/data 3.
Parallel slave port data.
Digital I/O.
External memory addre ss/data 4.
Parallel slave port data.
Digital I/O.
External memory addre ss/data 5.
Parallel Slave Port data.
Digital I/O.
External memory addre ss/data 6.
Parallel slave port data.
Digital I/O.
External memory addre ss/data 7.
Parallel slave port data.
Note 1:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open Drain (no P diode to V
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devices when ECCPMX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microc ontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/ P3B /P3C for PIC18F8 X2X devic es when ECCPM X (CON FIG3H<1>) is no t set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
6377
6276
6175
6074
5973
Pin
Type
I/O
I/O
I
O
I/O
I/O
I
O
I/O
I/O
I
O
I/O
I/O
O
I/O
I/O
O
I/O
I/O
O
I/O
I/O
O
I/O
I/O
I/O
O
Buffer
Type
ST
TTL
TTL
—
ST
TTL
TTL
ST
ST
TTL
TTL
—
ST
TTL
—
ST
TTL
—
ST
TTL
—
ST
TTL
—
ST
TTL
ST
—
Description
PORTE is a bi-directional I/O port.
Digital I/O.
External memory addre ss/data 8.
Read control for paralle l slave port.
Enhanced CCP2 output P2D.
Digital I/O.
External memory addre ss/data 9.
Write control for parallel slave port.
Enhanced CCP2 output P2C.
Digital I/O.
External memory addre ss/data 10.
Chip select control for parallel slave port.
Enhanced CCP2 output P2B.
Digital I/O.
External memory address/data 11.
Enhanced CCP3 output P3C.
Note 1:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
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
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X de vices when ECCP MX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microcontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devic es when ECCPM X (CON FIG3H<1>) is not set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
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/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devices when ECCPMX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microc ontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/ P3B /P3C for PIC18F8 X2X devic es when ECCPM X (CON FIG3H<1>) is no t set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
Note 1:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX (CONFIG3H<0>) is not set (all Program
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open Drain (no P diode to V
Memory modes except Microcontroller).
2:Default assignment for CCP2/P2A when CCP2MX is set (all devices).
3:External memory interface functions are only available on PIC18F8X2X devices.
4:Default assignment for P1B/P1C/P3B/P3C for PIC18F8X2X devices when ECCPMX (CONFIG3H<1>) is set, and for all
PIC18F6X2X devices.
5:Alternate assignment for CCP2/P2A in PIC18F8X2X devices when CCP2MX is not set (Microc ontroller mode).
6:PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8X2X devices.
7:Alternate assignment for P1B/P1C/ P3B /P3C for PIC18F8 X2X devic es when ECCPM X (CON FIG3H<1>) is no t set.
8:AV
DD must be connected to a positive supply and AVSS must be connected to a ground reference for proper operation of
the part in User or ICSP modes. See parameter D001A for details.
2026P—Ground reference for analog modul es.
1925P—Positive supply for analog modules.
11, 31,
51, 70
12, 32,
48, 71
Pin
Type
I/O
I/O
I/O
I/O
I/O
I/O
I/O
I/O
Buffer
Type
PORTJ is a bi-directional I/O port
ST
O
TTL
ST
O
TTL
ST
O
TTL
ST
O
TTL
ST
O
TTL
ST
O
TTL
ST
O
TTL
ST
O
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 addres s 0 control.
Digital I/O
External memory access indicator.
Digital I/O.
External memory low byte select.
Digital I/O.
External memory high byte select.
Description
(6)
P—Ground reference for logic and I/O pins.
P—Po sit iv e supply for logic and I/O pins.
DD)
.
DS39612A-page 20Advance Information 2003 Microchip Technology Inc.
PIC18F6X2X/8X2X
2.0OSCILLATOR
CONFIGURATIONS
2.1Oscillator Types
The PIC18F6X2X/8X2X devices can be operated in
twelve different Oscillator modes. The user can program four configuration bits (FOSC3, FOSC2, FOSC1,
OSC0) to select one of these eight modes:
and F
1.LPLow Power Crystal
2.XTCrystal/Resonator
3.HSHigh Speed Crystal/Resonator
4.RCEx tern al R esi st or/C apacitor
5.ECExternal Clock
6.ECIOExternal Clock with I/O pin
enabled
7.HS+PLLHigh Speed Crystal/Resonator
with PLL enabled
8.RCIOExternal Resist or/C apacitor 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
12. RC IOE x tern al Resi stor/Capacitor with
I/O pin enabled
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 oscil lation. Figure 2-1 shows
the pin connections.
The PIC18F6X2X/8X2X oscillator design requires the
use of a parallel cut crysta l.
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
2:A series resistor (R
3:R
OSC1
To
Internal
XTAL
(2)
RS
OSC2
recommended values of C1 and C2.
AT strip cut crystals.
F varies with the Oscillator mode chosen.
(3)
RF
PIC18F6X2X/8X2X
S) may be required for
Logic
SLEEP
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 did not have bui lt-in capacitors.
Note 1: Higher capacita nce increa ses the st ability
of the oscillator but also increases the
start-up time.
2: When operating below 3V V
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.
Note 1: Higher capacitanc e increase s the stabi lity
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
specification.
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 sourc e may also be conne cted to th e
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 CONFIGURATION)
Clock from
Ext. System
Open
OSC1
PIC18F6X2X/8X2X
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 uni t to unit due to
normal process parameter variation. Furthermore, the
difference in le ad fram e c apacitance betwee n package
types will also affect the oscillation frequency, especially for low C
EXT values. The user also needs to 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Ω
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).
EXT) and capacitor (CEXT) val-
OSC1
PIC18F6X2X/8X2X
OSC2/CLKO
OSC/4
C
EXT > 20pF
Internal
Clock
DS39612A-page 22Advance Information 2003 Microchip Technology Inc.
PIC18F6X2X/8X2X
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 r equired
after a Power-on Reset or Wak e-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 functions like the EC mode
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
Clock from
Ext. System
RA6
OSC1
PIC18F6X2X/8X2X
OSC2
OPERATION
(ECIO CONFIG URATION)
OSC1
PIC18F6X2X/8X2X
I/O (OSC2)
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 pro grammed fo r High Spee d Oscill ator or External Clock mode. If they are programmed for
any other mode, the PLL is no t enabled and the s ystem
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, PIC18 F6X2X/8X2X executes at regular clock frequency after all RESET conditi ons. During
execution, the 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, the PLL operation cann ot be chan ged “onthe-fly”. To enable or disable it, the controller must
either cycle through a Power-on Re set, or switch the
clock source from the main oscillator to the Timer1
oscillator and bac k again ( see Section2.6 for details on
oscillator switching).
The type of PLL is selected by programming
OSC<3:0> configuration bit s in CO NFIG1 H Conf igur a-
F
tion 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
The PIC18F6X2X/8X2X devices include a feature that
allows the system c lock sour ce to be swit ched from the
main oscillator to an alternate low frequency clock
source. For the PIC18F6X2X/8X2X devices, this
alternate c lock source is th e Timer1 osci llat or. If a low
frequency crystal (32 kHz, for example) has been
attached to the Timer1 oscillator pins and the Timer1
oscillator has been ena bled, the devi ce can swit ch to a
FIGURE 2-7:DEVICE CLOCK SOURCES
PIC18F6X2X/8X2X
OSC2
OSC1
T1OSO
T1OSI
Main Oscillator
SLEEP
Timer1 Oscillator
T1OSCEN
Enable
Oscillator
Low Power Execution mode. Fig ure2-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 the
CONFIG1H Configuration register to a ‘0’. Clock
switching is disabled in an erased device. See
Section 12.0 for further details of the Timer1 oscillator.
See Section 24.0 for Configuration register details.
4 x PLL
TOSC
TT1P
TOSC/4
MUX
Clock
Source
TSCLK
Clock Source Option
for Other Modules
DS39612A-page 24Advance Information 2003 Microchip Technology Inc.
PIC18F6X2X/8X2X
2.6.1SYSTEM CLOCK SWITCH BIT
The system clock sourc e sw it ching is performed 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 clock
source comes from the main oscillator that is selected
by the F
ration register. When the SCS0 bit is set, the system
clock sourc e will c ome fro m the Timer1 oscill ator. The
SCS0 bit is cleared on all forms of RESET.
When F
mode, SCS1 bit can be u sed to s elect bet ween primar y
oscillator/clock and P LL ou tput . SCS1 b it w ill o nly hav e
an effect on the system clock if the PLL is enabled
(PLLEN = 1) and locked (LOCK = 1), else it will be
forced cleared. When programmed with Configuration
Controlled PLL, SCS1 bit will be forced clear.
OSC configuration bits in CONFIG1H Configu-
OSC bits are programmed for Software PLL
REGISTER 2-1:OSCCON REGISTER
U-0U-0U-0U-0R/W-0R/W-0R/W-0R/W-0
————LOCKPLLENSCS1SCS0
bit 7bit 0
bit 7-4Unimplemented: 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
bit 2PLLEN
bit 1SCS1: System Clock Switch bit 1
bit 0SCS0
(1)
: Phase Lock Loop Enable bit
1 = Enable phase lock loop output as system clock
0 = Disable phase lock loop
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.
(2)
: System Clock Switch bit 0
When OSCSEN configuration bit = 0 and T1OSCEN bit = 1:
1 = Switch to Timer1 oscillator/clock pin
0 = Use primary oscillator/clock input pin
OSCSEN and T1OSCEN are in other states:
When
Bit is forced clear.
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.
Note 1: PLLEN bit is forced set when configured for ECIO+PLL and HS+PLL. This bit is
writable for ECIO+SPLL and HS+SPLL modes only; forced cleared for all other
Oscillator modes.
2: The setting of SCS0 = 1 supersedes SCS1 = 1.
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
PIC18F6X2X/8X2X devices con tai n circuit ry to prevent
“glitches” when switching between oscillator sources.
Essentially, the circuitry waits for eight rising edges of
the clock source that the processor is swit ching to. This
ensures that the n ew c lo ck s ourc e is s t able and that its
pulse width will not be less than the shortest pulse
width of the two clock sources.
A timing diagram indicating the transition from the main
oscillator to the Timer1 oscillator is s hown in Figure2-8.
The Timer1 oscillator is assumed to be running all the
time. After the SCS0 bit is set, the processor i s 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
Q4Q1
Q1
T1OSI
OSC1
Internal
System
Clock
SCS
(OSCCON<0>)
Program
Counter
Note:T
Q1
TOSC
TDLY
DLY is delay from SCS high to first count of transition circuit.
TT1P
21345678
TSCS
PC + 2PC
Q3Q2Q1Q4Q3Q2
Q2Q3Q4Q1
PC + 4
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 t ak e pl ac e aft er
an oscillator st art-up time (T
OST) has occurred. A timing
diagram, indicating the transit ion from th e T imer1 os cillator to the main oscillator for HS, XT and LP modes, is
shown in Figure 2-9.
FIGURE 2-9:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (HS, XT, LP)
Q1 Q2 Q3 Q4 Q1 Q2
T1OSI
OSC1
Internal
System Clock
Program
Counter
Note 1: T
SCS
OST = 1024 TOSC (drawing not to scale).
(OSCCON<0>)
Q3Q4
PCPC + 2
Q1
TOST
TOSC
TT1P
12345678
TSCS
Q3
PC + 6
DS39612A-page 26Advance Information 2003 Microchip Technology Inc.
PIC18F6X2X/8X2X
If the main oscillator is configured for HS mode with
PLL active, an oscillator start-up time (T
additional PLL time -out (T
PLL) will occur . The PLL tim e-
out is typically 2 ms and allows the PLL to lock to the
main oscillator frequency. A timing diagram, indicating
the transition from the Timer1 oscillator to the main
oscillator for HS-PLL mode, is shown in Figure 2-10.
FIGURE 2-10:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1
(HS WITH PLL ACTIVE, SCS1 = 1)
OST) plus an
T1OSI
OSC1
PLL Clock
Input
Internal System
Program Counter
Note 1: T
Clock
(OSCCON<0>)
SCS
OST = 1024 TOSC (drawing not to scale).
Q4Q1
TOST
PCPC + 2
TPLL
TOSC
TT1P
TSCS
12345678
Q1 Q2 Q3 Q4 Q1 Q2
If the main oscillator is configured for EC mode with PLL
active, only PLL time-out (T
PLL) will occur . The PLL time-
out is typically 2 ms and allows the PLL to lock to the
main oscillator frequency. A timing diagram, indicating
the transition from the Timer1 oscillator to the main
oscillator for EC with PLL active, is shown in Figure 2-1 1.
FIGURE 2-11:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1
If the main oscillato r is c onfigur ed in th e RC, R CIO, EC
or ECIO modes, th ere is no os cillator start-up time-out.
Operation will resume after eight cycles of the main
oscillator have been counted. A timing diagram, indicating the transition from the Timer1 oscillator to the
main oscillator for RC, RCIO, EC and ECIO modes, is
shown in Figure 2-12.
FIGURE 2-12:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (RC, EC)
Q3Q4Q1Q1 Q2 Q3 Q4 Q1 Q2 Q3
T1OSI
OSC1
Internal System
Clock
(OSCCON<0>)
Note:RC Oscillator mode assumed.
SCS
Program
Counter
PC
2.7Effects of SLEEP Mode on the
On-Chip Oscillator
When the device e xecutes a SLEEP i nstructio n, the onchip clocks and oscillator are turn ed off and the device
is held at the beginning of an instruction cycle (Q1
state). With the oscillator off, the OSC1 and OSC2
TT1P
TOSC
1
45678
23
TSCS
PC + 2
switching currents have been removed, SLEEP mode
achieves the lowest current consumption of the device
(only leakage currents). Enabling any on-chip feature
that will operate during SL EEP will incre ase the current
consumed during SLEEP. The user can wake from
SLEEP through external RESET, Watchdog Timer
Reset, or through an interrupt.
signals will stop oscillating. Since all the transistor
TABLE 2-3:OSC1 AND OSC2 PIN STATES IN SLEEP MODE
OSC ModeOSC1 PinOSC2 Pin
RCFloating, external resistor should pull highAt logic low
RCIOFloating, external resistor should pull highConfigured as PORTA, bit 6
ECIOFloatingConfigured as PORTA, bit 6
ECFloatingAt logic low
LP, XT, and HSFeedback inverter disabled, at
quiescent voltage level
Note:See Table 3-1 in Section 3.0, “Reset” for time-outs due to SLEEP and MCLR
Feedback invert er di sa bled, at
quiescent voltage level
Reset.
Q4
PC + 4
DS39612A-page 28Advance Information 2003 Microchip Technology Inc.
Loading...
+ 356 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.