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 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 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 Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC,
K
logo, rfPIC and UNI/O are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor,
MXDEV, MXLAB, SEEVAL 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, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN,
ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial
Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified
logo, MPLIB, MPLINK, mTouch, Omniscient Code
Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit,
PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance,
TSHARC, UniWinDriver, WiperLock and ZENA 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 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC
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.
®
MCUs and dsPIC® DSCs, KEELOQ
®
code hopping
DS39977C-page 2Preliminary 2011 Microchip Technology Inc.
PIC18F66K80 FAMILY
28/40/44/64-Pin, Enhanced Flash Microcontrol lers
with ECAN™ and nanoWatt XLP Technology
Power-Managed Modes:
• Run: CPU on, Peripherals on
• Idle: CPU off, Peripherals on
• Sleep: CPU off, Peripherals off
• Two-Speed Oscillator Start-up
• Fail-Safe Clock Monitor (FSCM)
• Power-Saving Peripheral Module Disable (PMD)
• Ultra Low-Power Wake-up
• Fast Wake-up, 1 s, Typical
• Low-Power WDT, 300 nA, Typical
• Run mode Currents Down to Very Low 3.8 A, Typical
• Idle mode Currents Down to Very Low 880 nA, Typical
• Sleep mode Current Down to Very Low 13 nA, Typical
ECAN Bus Module Features:
• Conforms to CAN 2.0B Active Specification
• Three Operating modes:
- Legacy mode (full backward compatibility with
existing PIC18CXX8/FXX8 CAN modules)
- Enhanced mode
- FIFO mode or programmable TX/RX buffers
• Message Bit Rates up to 1 Mbps
• DeviceNet™ Data Byte Filter Support
• Six Programmable Receive/Transmit Buffers
• Three Dedicated Transmit Buffers with Prioritization
• Two Dedicated Receive Buffers
TABLE 1:DEVICE COMPARISON
ECAN Bus Module Features (Continued):
• 16 Full, 29-Bit Acceptance Filters with Dynamic
Association
• Three Full, 29-Bit Acceptance Masks
• Automatic Remote Frame Handling
• Advanced Error Management Features
Special Microcontroller Features:
• Operating Voltage Range: 1.8V to 5.5V
• On-Chip 3.3V Regulator
• Operating Speed up to 64 MHz
• Up to 64 Kbytes On-Chip Flash Program Memory:
- 10,000 erase/write cycle, typical
- 20 years minimum retention, typical
• 1,024 Bytes of Data EEPROM:
- 100,000 Erase/write cycle data EEPROM
memory, typical
• 3.6 Kbytes of General Purpose Registers (SRAM)
• Three Internal Oscillators: LF-INTOSC (31 KHz),
MF-INTOSC (500 kHz) and HF-INTOSC (16 MHz)
• Self-Programmable under Software Control
• Priority Levels for Interrupts
• 8 x 8 Single-Cycle Hardware Multiplier
• Extended Watchdog Timer (WDT):
- Programmable period from 4 ms to 4,194s
• In-Circuit Serial Programming™ (ICSP™) via Two Pins
2.0Guidelines for Getting Started with PIC18FXXKXX Microcontrollers......................................................................................... 47
7.0Flash Program Memory............................................................................................................................................................ 135
12.0 Data Signal Modulator .............................................................................................................................................................. 201
18.0 Charge Time Measurement Unit (CTMU) ................................................................................................................................ 241
21.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 293
28.0 Special Features of the CPU.................................................................................................................................................... 461
29.0 Instruction Set Summary.......................................................................................................................................................... 487
30.0 Development Support............................................................................................................................................................... 537
Appendix B: Migration to PIC18F66K80 Family ................................................................................................................................. 609
Index ................................................................................................................................................................................................. 611
The Microchip Web Site..................................................................................................................................................................... 625
Customer Change Notification Service .............................................................................................................................................. 625
Customer Support .............................................................................................................................................................................. 625
DS39977C-page 10Preliminary 2011 Microchip Technology Inc.
PIC18F66K80 FAMILY
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at docerrors@microchip.com or fax the Reader Response Form in the back of this data sheet to (480) 792-4150. We
welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000A is version A of document DS30000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision
of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
DS39977C-page 12Preliminary 2011 Microchip Technology Inc.
PIC18F66K80 FAMILY
1.0DEVICE OVERVIEW
This document contains device-specific information for
the following devices:
• PIC18F25K80• PIC18LF25K80
• PIC18F26K80• PIC18LF26K80
• PIC18F45K80• PIC18LF45K80
• PIC18F46K80• PIC18LF46K80
• PIC18F65K80• PIC18LF65K80
• PIC18F66K80• PIC18LF66K80
This family combines the traditional advantages of all
PIC18 microcontrollers – namely, high computational
performance and a rich feature set – with an extremely
competitive price point. These features make the
PIC18F66K80 family a logical choice for many
high-performance applications where price is a primary
consideration.
1.1Core Features
1.1.1nanoWatt TECHNOLOGY
All of the devices in the PIC18F66K80 family incorporate a range of features that can significantly reduce
power consumption during operation. Key items include:
• Alternate Run Modes: By clocking the controller
from the Timer1 source or the Internal RC oscillator, power consumption during code execution
can be reduced.
• Multiple Idle Modes: The controller can also run
with its CPU core disabled but the peripherals still
active. In these states, power consumption can be
reduced even further.
• On-the-Fly Mo de Switching: The power-managed
modes are invoked by user code during operation,
allowing the user to incorporate power-saving ideas
into their application’s software design.
• nanoW at t XL P: An extra low-power BOR and
low-power Watchdog timer
1.1.2OSCILLATOR OPTIONS AND
FEATURES
All of the devices in the PIC18F66K80 family offer
different oscillator options, allowing users a range of
choices in developing application hardware. These
include:
• External Resistor/Capacitor (RC); RA6 available
• External Resistor/Capacitor with Clock Out
(RCIO)
• Three External Clock modes:
- External Clock (EC); RA6 available
- External Clock with Clock Out (ECIO)
- External Crystal (XT, HS, LP)
• A Phase Lock Loop (PLL) frequency multiplier,
available to the external oscillator modes which
allows clock speeds of up to 64 MHz. PLL can
also be used with the internal oscillator.
• An internal oscillator block that provides a 16 MHz
clock (±2% accuracy) and an INTOSC source
(approximately 31 kHz, stable over temperature
DD)
and V
- Operates as HF-INTOSC or MF-INTOSC
when block is selected for 16 MHz or
500 kHz
- Frees the two oscillator pins for use as
additional general purpose I/O
The internal oscillator block provides a stable reference
source that gives the family additional features for
robust operation:
• Fail-Safe Clock Monitor: This option constantly
monitors the main clock source against a reference
signal provided by the internal oscillator. If a clock
failure occurs, the controller is switched to the
internal oscillator, allowing for continued low-speed
operation or a safe application shutdown.
• Two-Speed Start-up: This option allows the
internal oscillator to serve as the clock source
from Power-on Reset, or wake-up from Sleep
mode, until the primary clock source is available.
1.1.3MEMORY OPTIONS
The PIC18F66K80 family provides ample room for
application code, from 32 Kbytes to 64 Kbytes of code
space. The Flash cells for program memory are rated
to last up to 10,000 erase/write cycles. Data retention
without refresh is conservatively estimated to be
greater than 20 years.
The Flash program memory is readable and writable.
During normal operation, the PIC18F66K80 family also
provides plenty of room for dynamic application data
with up to 3.6 Kbytes of data RAM.
1.1.4EXTENDED INSTRUCTION SET
The PIC18F66K80 family implements the optional
extension to the PIC18 instruction set, adding eight
new instructions and an Indexed Addressing mode.
Enabled as a device configuration option, the extension
has been specifically designed to optimize re-entrant
application code originally developed in high-level
languages, such as ‘C’.
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 28-pin,
40-pin, 44-pin and 64-pin members, or even jumping
from smaller to larger memory devices.
The PIC18F66K80 family is also largely pin compatible
with other PIC18 families, such as the PIC18F4580,
PIC18F4680, and PIC18F8680 families of microcontrollers with an ECAN module. This allows a new
dimension to the evolution of applications, allowing
developers to select different price points within
Microchip’s PIC18 portfolio, while maintaining a similar
feature set.
1.2Other Special Features
• Communications: The PIC18F66K80 family incor-
porates a range of serial communication peripherals
including two Enhanced USART that support
LIN/J2602, one Master SSP module capable of both
SPI and I
operation and an Enhanced CAN module.
• CCP Modules: PIC18F66K80 family devices
incorporate four Capture/Compare/PWM (CCP)
modules. Up to four different time bases can be
used to perform several different operations at
once.
• ECCP Modules: The PIC18F66K80 family has
one Enhanced CCP (ECCP) module to maximize
flexibility in control applications:
- Up to four different time bases for performing
- Up to four PWM outputs
- Other beneficial features, such as polarity
• 12-Bit A/D Converter: The PIC18F66K80 family
has a differential ADC. It incorporates programmable acquisition time, allowing for a channel to
be selected and a conversion to be initiated
without waiting for a sampling period, and thus,
reducing code overhead.
2
C™ (Master and Slave) modes of
several different operations at once
selection, programmable dead time,
auto-shutdown and restart, and Half-Bridge
and Full-Bridge Output modes
• Charge Time Measurement Unit (CTMU): The
CTMU is a flexible analog module that provides
accurate differential time measurement between
pulse sources, as well as asynchronous pulse
generation.
Together with other on-chip analog modules, the
CTMU can precisely measure time, measure
capacitance or relative changes in capacitance, or
generate output pulses that are independent of the
system clock.
• LP Watchdog T im er (WDT): This enhanced
version incorporates a 22-bit prescaler, allowing
an extended time-out range that is stable across
operating voltage and temperature. See
Section 31.0 “Electrical Characteristics” for
time-out periods.
1.3Details on Individual Family
Members
Devices in the PIC18F66K80 family are available in
28-pin, 40/44-pin and 64-pin packages. Block diagrams
for each package are shown in Figure 1-1, Figure 1-2
and Figure 1-3, respectively.
The devices are differentiated from each other in these
ways:
• Flash Program Memory:
- PIC18FX5K80 (PIC18F25K80, PIC18F45K80
and PIC18F45K80) – 32 Kbytes
- PIC18FX6K80 (PIC18F26K80, PIC18F46K80
and PIC18F66K80) – 64 Kbytes
• I/O Ports:
- PIC18F2XK80 (28-pin devices) – Three
bidirectional ports
- PIC18F4XK80 (40/44-pin devices) – Five
bidirectional ports