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 protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digit al Millennium Copyright Act. If suc h a c t s
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 provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,
WRITTEN OR ORAL, STATUTORY OR OTHERWISE,
RELATED TO THE INFORMATION, INCLUDING BUT NOT
LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE,
MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and
its use. Use of M icrochip’s prod ucts 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 Microchip intellectual property
rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC, and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
PICMASTER, SEEVAL, SmartSensor and The Embedded
Control Solutions Company are registered trademarks of
Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programmin g, IC SP, ICEPI C, M PASM, MPLIB, MPLINK,
MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail,
PowerCal, PowerInfo, PowerMate, PowerTool, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartT el and Total
Endurance are trademarks of Microchip Technology
Incorporated in the U.S.A. and other countries.
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 ISO/TS-16949:2002 quality system certification for
its worldwide headquarters, design and wafer fabrication facilities in
Chandler and Tempe, Arizona and Mountain View, California in
October 2003. The Company’s quality system processes and
procedures are for its PICmicro
devices, Serial 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.
®
8-bit MCUs, KEELOQ
®
code hopping
DS39612B-page ii 2005 Microchip Technology Inc.
PIC18F6525/6621/8525/8621
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 os c. /c l ock in put w i th 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 lock option – Timer1/Timer3
5.0F la sh Program Memory............... ..................... ..................... ..................... ..................... ...........................................................61
18.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 173
22.0 Comparator Voltage Reference Module...................................................................................................................................249
24.0 Special Features of th e CPU.............. ..................... ..................... ........................................ .................................................... 259
25.0 Instruction Set Summary.......................................................................................................................................................... 275
26.0 Development Support...............................................................................................................................................................317
28.0 DC and AC Characteristics Graphs And Tables ............................................................................ .. ........................................357
29.0 Packaging Inform a tio n..... ..................... ..................... .......................................... ..................................................................... 373
Appendix D: Migration From Mid-Range to Enhanced Devices......................................................................................................... 378
Appendix E: Migration From High-End to Enhanced Devices............................................................................................................ 379
Index .................................................................................................................................................................................................. 381
Systems Information and Upgrade Hot Line...................................................................................................................................... 391
PIC18F6525/6621/8525/8621 Product Identification System ............................................................................................................393
DS39612B-page 4 2005 Microchip Technology Inc.
PIC18F6525/6621/8525/8621
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.
2005 Microchip Technology Inc.DS39612B-page 5
PIC18F6525/6621/8525/8621
NOTES:
DS39612B-page 6 2005 Microchip Technology Inc.
PIC18F6525/6621/8525/8621
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-end urance Enhan ced Flash pro gram memory.
The PIC18F6525/6621/8 525/8621 fa mily als o provide s
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 PIC18F6525/6621/8525/8621 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 PIC18F6525/
6621/8525/8621 family also provides plenty of room
for application da t a. T he devices have 3840 bytes of
data RAM, as well as 1024bytes of data EEPROM
for long term retention of nonvolatile data.
• Memory Endurance: The Enhanced Flash cells for
both program memory and data EEPROM are rated
to last for many thou sands of erase/write cycl es –
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 ap plica tion, th e PIC1 8F8525 /8621
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 memory 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 From 64-pin To 80-pin Devices.
1.1.4OTHER SPECI AL FE A TU RES
• Communications: The PIC18F6525/6621/8525/
8621 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) modes of
operation. Also, for PIC18F6525/6621/8525/8621
devices, one of the general purpose I/O ports can be
reconfigured as an 8-bit Parallel Slave Port for direct
processor to processor communications.
• CCP Modules: All devices in the family incorporate
two Capture/Compare/PWM (CCP) modules and
three Enhanced CCP (ECCP) modules 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 modes.
• 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
Programmable Brown-out Reset module.
• Self-programmability: These devices can write to
their own program memory spaces under internal
software control. By using a bootloader routine
located in the protected boot block at the top of
program memor y, it become s possible to crea te an
application that can update itself in the field.
2005 Microchip Technology Inc.DS39612B-page 7
PIC18F6525/6621/8525/8621
1.2Details on Individual Family
Members
The PIC18F6525/6621/8525/8621 devices are available in 64-pin (PIC18F6525/6621) and 80-pin
(PIC18F8525/8621) packages. They are differentiated
from each other in four ways:
1.Flash program memory (48 Kbytes for
PIC18F6525/8525 devices; 64 Kbytes for
PIC18F6621/8621 devic es).
2.A/D channels (12 for PIC18F6525/6621
devices; 16 for PIC18F8525/86 21 dev ic es ).
3.I/O ports (7 on PIC18F6525/6621 devices; 9 on
PIC18F8525/8621 devices).
4.External program memory interface (present
only on PIC18F8525/8621 devices)
All other features for devices in the PIC18F6525/6621/
8525/8621 family are iden tic al. These are summarized
in Table 1-1.
Block diagrams of the PIC18F6525/6621 and
PIC18F8525/8621 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:PIC18F6525/6621/8525/8621 DEVICE FEATURES
FeaturesPIC18F6525PIC18F6621PIC18F8525PIC18F8621
Operating FrequencyDC – 40 MHzDC – 40 MHzDC – 40 MHzDC – 40 MHz
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,
E, F, G
Timers5555
Capture/Compare/PWM Modules2222
Enhanced Capture/Compare/
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is not set.
8: AV
9: RG5 is multiplexed with MCLR
(9)
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
all PIC18F6525/6621 devices.
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 D001 for details.
PIC18F6X2XPIC18F8X2X
Pin Number
79
3949
4050
and is only available when the MCLR Resets are disabled.
Pin
Buffer
Type
O
O
I/O
Type
I
P
I
IICMOS/ST
ST
—
ST
CMOS
—
—
TTL
Description
Master Clear (input) or programming
voltage (output).
Master Clear (Res et) inpu t. Thi s pin is an
active-low Reset to the device.
Programming voltage inpu t.
Digital input.
Oscillator crystal or extern al cl ock in put .
Oscillator crystal input or ex te rnal clock
source input. ST buffer when configured
in RC mode; otherwise CMOS.
External clock source input. Alwa ys
associated with pin function OSC1 (see
OSC1/CLKI, OSC2/CLKO pins).
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
and is only available when the MCLR Resets are disabled.
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
TTL
I
Analog
I
Analog
Description
PORTA is a bidirectional 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) inp ut .
Digital I/O – Open-drain when configured
as output.
Timer0 external clock input.
Digital I/O.
Analog input 4.
Low-Voltage Detect input.
DD)
DS39612B-page 12 2005 Microchip Technology Inc.
PIC18F6525/6621/8525/8621
T ABLE 1-2:PIC18F6525/6621/8525/8621 PINOUT I/O DESCRIPTIONS (CONTINUED)
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
and is only available when the MCLR Resets are disabled.
Pin
Type
I/O
I
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
ST
TTL
ST
TTL
ST
TTL
ST
ST
—
TTL
ST
TTL
ST
ST
TTL
ST
ST
TTL
ST
ST
Description
PORTB is a bidirectional I/O port. PORTB
can be software program m ed for internal
weak pull-ups on all inputs.
Digital I/O.
External interrupt 0.
PWM Fau lt input fo r ECCP1 .
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
and is only available when the MCLR Resets are disabled.
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 bidirectional I/O port.
Digital I/O.
Timer1 oscillator outp ut.
Timer1/Timer3 external clock input.
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
and is only available when the MCLR Resets are disabled.
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 bidir ect ion al I /O p ort . T hese pi ns
have TTL input buffers when ex te rn al
memory is enabled.
Digital I/O.
External memory address/data 0.
Parallel Slave Port data.
Digital I/O.
External memory address/data 1.
Parallel Slave Port data.
Digital I/O.
External memory address/data 2.
Parallel Slave Port data.
Digital I/O.
External memory address/data 3.
Parallel Slave Port data.
Digital I/O.
External memory address/data 4.
Parallel Slave Port data.
Digital I/O.
External memory address/data 5.
Parallel Slave Port data.
Digital I/O.
External memory address/data 6.
Parallel Slave Port data.
Digital I/O.
External memory address/data 7.
Parallel Slave Port data.
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
6377
6276
6175
6074
5973
and is only available when the MCLR Resets are disabled.
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 bidirectional I/O port.
Digital I/O.
External memory address/data 8.
Read control for Parallel Slave Port.
ECCP2 output P2D.
Digital I/O.
External memory address/data 9.
Write control for Parallel Slave Port.
ECCP2 output P2C.
Digital I/O.
External memory address/data 10.
Chip select control for Parallel Slave Port.
ECCP2 output P2B.
Digital I/O.
External memory address/data 11.
ECCP3 output P3C.
Digital I/O.
External memory address/data 12.
ECCP3 output P3B.
Digital I/O.
External memory address/data 13.
ECCP1 output P1C.
Digital I/O.
External memory address/data 14.
ECCP1 output P1B.
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
and is only available when the MCLR Resets are disabled.
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
PIC18F6X2XPIC18F8X2X
Pin Number
35
46
57
68
810
and is only available when the MCLR Resets are disabled.
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
and is only available when the MCLR Resets are disabled.
Note 1: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX (CONFIG3H<0>) is not set (all
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
Program Memory modes except Microcontroller).
2: Default assignment for ECCP2/P2A when CCP2MX is set (all devices).
3: External memory interface functions are only available on PIC18F8525/8621 devices.
4: Default assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<1>) is set and for
all PIC18F6525/6621 devices.
5: Alternate assignment for ECCP2/P2A in PIC18F8525/8621 devices when CCP2MX is not set (Microcontroller mode).
6: PORTH and PORTJ (and their multiplexed functions) are only available on PIC18F8525/8621 devices.
7: Alternate assignment for P1B/P1C/P3B/P3C for PIC18F8525/8621 devices when ECCPMX (CONFIG3H<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 D001 for details.
9: RG5 is multiplexed with MCLR
2026P—Groun d re fe re nce for analog modules.
1925P—Positive supply for analog modules.
and is only available when the MCLR Resets are disabled.
11, 31,
51, 70
12, 32,
48, 71
Pin
Type
I/O
O
I/O
O
I/O
O
I/O
O
I/O
O
I/O
O
I/O
O
I/O
O
Buffer
Type
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
ST
TTL
Description
PORTJ is a bidirectional I/O port
(6)
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 i ndi c at or.
Digital I/O.
External memory low byte select.
Digital I/O.
External memory high byte select.
P—Ground reference for logic and I/O pins.
P—Positive supply for logic and I/O pins.
DD)
.
DS39612B-page 20 2005 Microchip Technology Inc.
PIC18F6525/6621/8525/8621
2.0OSCILLATOR
CONFIGURATIONS
2.1Oscillator Types
The PIC18F6525/6621/8525/8621 devices can be
operated in twelve different oscillator modes. The user
can program four configuration bits (FOSC3, FOSC2,
FOSC1 and FOSC0) to select one of these eight
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 Resistor/Capacito r with
I/O pin enabled
9. ECIO+SPLL External Clock with software
controlled PLL
10. ECIO +PL L External 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 Oscilla tor/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 PIC18F6525/6621/8525/8621 oscillator design
requires the use of a parallel cut crystal.
Note:Use of a series cut crystal may give a
frequency out of the cryst al manu facturer s
specifications.
FIGURE 2-1:CRYSTAL/CERAMIC
RESONATOR OPERATION
(HS, XT OR LP
CONFIGURATION)
Note 1:See Table 2-1 and Table 2-2 for
recommended values of C1 and C2.
2:A series resistor (R
S
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 guidance only.
See notes following this table.
Resonators Used:
2 kHz8 MHz
4 MHz16 MHz
Note 1: Higher capac itance inc reases th e stabilit y
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.
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
DD, or when
2005 Microchip Technology Inc.DS39612B-page 21
PIC18F6525/6621/8525/8621
TABLE 2-2:CAPACITOR SELECTION FOR
CRYSTAL OSCILLATOR
Ranges Tested:
ModeFreqC1C2
LP32.0 kHz33 pF33 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 MHz15-33 pF15-33 pF
These values are for design guidance only.
See notes following this table.
Crystals Used
32 kHz4 MHz
200 kHz8 MHz
1 MHz20 MHz
Note 1: Higher capacit ance increa ses the st ability
of the oscillator but also increases the
start-up time.
S (see Figure 2-1) may be required in
2: R
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.
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
values 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 capacitance
between package types will also affect the oscillation
frequency, especially for low C
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
OSC/4
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)
EXT values. The user
OSC1
Internal
Clock
PIC18F6X2X/8X2X
OSC2/CLKO
EXT > 20 pF
C
FIGURE 2-2:EXTERNAL CLOCK INPUT
OPERATION (HS, XT OR
LP OSCILLATOR
CONFIGURATION)
Clock from
Ext. System
Open
DS39612B-page 22 2005 Microchip Technology Inc.
OSC1
PIC18F6X2X/8X2X
OSC2
2005 Microchip Technology Inc.DS39612B-page 23
PIC18F6525/6621/8525/8621
2.6Oscillator Switching Feature
The PIC18F6525/6621/8525/8621 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 PIC18F6525/6621/
8525/8621 devices, this alternate clock source is the
Timer1 osc illator. If a low-frequency cryst al (32 kHz , for
example) has been attached to the Timer1 oscillator
pins and the Timer1 oscillator has been enabled, the
device can switch to a low-power execution mode.
FIGURE 2-7:DEVICE CLOCK SOURCES
PIC18F6X2X/8X2X
OSC2
OSC1
T1OSO
T1OSI
Main Oscillator
Sleep
Timer1 Oscillator
T1OSCEN
Enable
Oscillator
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 the CONFIG1H Configur ation regist er
to a ‘0’. Clock switchi ng is disabled i n an erased dev ice.
See Section 12.0 “Timer1 Module” for further details
of the Timer1 oscillator. See Section 24.0 “SpecialFeatures of the CPU” for Configuration register
details.
4 x PLL
TOSC
TT1P
TOSC/4
MUX
Clock
Source
TSCLK
Clock Source Option
for Other Modules
DS39612B-page 24 2005 Microchip Technology Inc.
PIC18F6525/6621/8525/8621
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 FOSC configuration bits in the CONFIG1H
Configurat ion register. When the SCS0 bi t is set, the
system clock source will come from the Timer1
oscillator . The SCS0 bit i s cleared on all form s of Reset.
When the FOSC bits are programmed for Soft ware PLL
mode, the SCS1 bit can be used to select between
primary oscillator/clock and PLL output. The SCS1 bit
will only have an effect on the system clock if the PLL
is enabled (PLLEN = 1) and locked (LOC K = 1), else it
will be forced cleared. When programmed with
Configuration Controlled PLL, the SCS1 bit will be
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.
REGISTER 2-1:OSCCON: OSCILLATOR CONTROL REGISTER
U-0U-0U-0U-0R/W-0R/W-0R/W-0R/W-0
————LOCKPLLEN
bit 7bit 0
(1)
SCS1SCS0
(2)
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: Phase Lock Loop Enable bit
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: 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
When
OSCSEN and T1OSCEN are in other states:
Bit is forced clear.
Note 1: PLLEN bit is forced set when configured for ECIO+PLL and HS+PLL modes. This
bit is writable fo r ECIO+SPLL and H S+SPLL modes only; forced cleared f or all other
oscillator modes.
2: The setting of SCS0 = 1 supersedes SCS1 = 1.
(1)
(2)
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
2005 Microchip Technology Inc.DS39612B-page 25
PIC18F6525/6621/8525/8621
2.6.2OSCILLATOR TRANSITIONS
PIC18F6525/6621/8525/8621 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 stable
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 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
Q3Q2Q1Q4Q3Q2
Q2Q3Q4Q1
PC + 4
T1OSI
OSC1
Internal
System
Clock
Program
Counter
Note: T
SCS
DLY is the delay from SCS high to first count of transition circuit.
(OSCCON<0>)
Q1
TOSC
Q1
TDLY
TT1P
21345678
TSCS
PC + 2PC
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.
FIGURE 2-9:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (HS, XT, LP)
Q1 Q2 Q3 Q4 Q1 Q2
T1OSI
OSC1
Internal
System Clock
(OSCCON<0>)
SCS
Program
Counter
Note: T
Q3Q4
PCPC + 2
OST = 1024 TOSC (drawing not to scale).
Q1
TOST
TT1P
12345678
TSCS
TOSC
Q3
PC + 6
DS39612B-page 26 2005 Microchip Technology Inc.
PIC18F6525/6621/8525/8621
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
Q4Q1
T1OSI
OSC1
PLL Clock
Input
InternalSystem
(OSCCON<0>)
Program Counter
Note: T
Clock
SCS
PCPC + 2
OST = 1024 TOSC (drawing not to scale).
TOST
TPLL
TT1P
TOSC
1234 5678
TSCS
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:T IMING FOR TRANSITION BETWEEN TIMER1 AND OSC1
(EC WITH PLL ACTIVE, SCS1 = 1)
Q3
PC + 4
Q4
2005 Microchip Technology Inc.DS39612B-page 27
PIC18F6525/6621/8525/8621
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
TT1P
Q4
T1OSI
OSC1
Internal System
(OSCCON<0>)
Note:RC Oscillator mode assumed.
Clock
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
TOSC
12345678
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 Sleep will increase 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
Oscillator 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 volt ag e leve l
Note:See Table 3-1 in Section 3.0 “Reset” for time-outs due to Sleep and MCLR
Feedback inverter disabled at
quiescent voltage level
Reset.
PC + 4
2.8Power-up Delays
Power-up delays are con trolled by two time rs so that no
external Reset circuitry is required for most
applications. The delays ensure that the device is kept
in Reset un til the device p ower supply and clock are
stable. For additional information on Reset operation,
see Section 3.0 “Reset”.
The first timer is the Power-up Timer (PWRT) which
optionally provid es a fix ed delay of 72 ms (nominal) on
power-up only (POR and BOR). The second timer is
With the PLL enable d (HS+PL L a nd EC + PLL oscillator
mode), the time-out sequence following a Power-on
Reset is different from other oscillator modes. The
time-out sequence is as follows: First, the PWRT timeout is invoked after a POR time delay has expired.
Then, the Oscillator Start-up Timer (OST) is invoked.
However, this is still not a sufficient amount of time to
allow the PLL to lock at high frequencies. The PWRT
timer is used to provide an additional fixed 2 ms
(nominal) t ime- ou t to al low t he P LL am ple t ime to lo ck
to the incoming clock frequency.
the Oscillator Start-up Timer (OST), intended to keep
the chip in Reset until the crystal oscillator is stable.
DS39612B-page 28 2005 Microchip Technology Inc.
Loading...
+ 366 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.