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’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 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
Programming, ICSP, ICEPIC, Linear Active Thermistor,
MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM,
PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo,
PowerMate, PowerTool, Real ICE, rfLAB, rfPICDEM, Select
Mode, Smart Serial, SmartTel, Total Endurance, UNI/O,
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 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.
6.0Flash Program Memory.............................................................................................................................................................. 73
7.08 x 8 Hardware Multiplier............................................................................................................................................................ 83
14.0 Universal Serial Bus (USB) ...................................................................................................................................................... 129
18.0 Special Features of the CPU.................................................................................................................................................... 189
19.0 Instruction Set Summary .......................................................................................................................................................... 211
20.0 Development Support............................................................................................................................................................... 261
22.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 293
Appendix D: Migration From Baseline to Enhanced Devices ............................................................................................................ 304
Appendix E: Migration From Mid-Range to Enhanced Devices ......................................................................................................... 305
Appendix F: Migration From High-End to Enhanced Devices............................................................................................................ 305
Index ................................................................................................................................................................................................. 307
The Microchip Web Site..................................................................................................................................................................... 315
Customer Change Notification Service .............................................................................................................................................. 315
Customer Support .............................................................................................................................................................................. 315
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.
This document contains device-specific information for
the following devices:
• PIC18F2450• PIC18F4450
This family of devices 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. In
addition to these features, the PIC18F2450/4450 family
introduces design enhancements that make these microcontrollers a logical choice for many high-performance,
power sensitive applications.
1.1New Core Features
1.1.1nanoWatt TECHNOLOGY
All of the devices in the PIC18F2450/4450 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 by as much as 90%.
• 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, to as little as 4% of normal
operation requirements.
• On-the-Fly Mode Switching: The powermanaged modes are invoked by user code during
operation, allowing the user to incorporate powersaving ideas into their application’s software
design.
• Low Consumption in Key Modules: The
power requirements for both Timer1 and the
Watchdog Timer are minimized. See
Section 21.0 “Electrical Characteristics” for
values.
1.1.3MULTIPLE OSCILLATOR OPTIONS
AND FEATURES
All of the devices in the PIC18F2450/4450 family offer
twelve different oscillator options, allowing users a wide
range of choices in developing application hardware.
These include:
• Four Crystal modes using crystals or ceramic
resonators.
• Four External Clock modes, offering the option of
using two pins (oscillator input and a divide-by-4
clock output) or one pin (oscillator input, with the
second pin reassigned as general I/O).
• An INTRC source (approximately 31 kHz, stable
over temperature and V
oscillator pin for use as an additional general
purpose I/O.
• A Phase Lock Loop (PLL) frequency multiplier,
available to both the High-Speed Crystal and
External Oscillator modes, which allows a wide
range of clock speeds from 4 MHz to 48 MHz.
• Asynchronous dual clock operation, allowing the
USB module to run from a high-frequency
oscillator while the rest of the microcontroller is
clocked from an internal low-power oscillator.
The internal oscillator 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.
DD). This option frees an
1.1.2UNIVERSAL SERIAL BUS (USB)
Devices in the PIC18F2450/4450 family incorporate a
fully featured Universal Serial Bus communications
module that is compliant with the USB Specification
Revision 2.0. The module supports both low-speed and
full-speed communication for all supported data
transfer types. It also incorporates its own on-chip
transceiver and 3.3V regulator and supports the use of
external transceivers and voltage regulators.
• Memory Endurance: The Enhanced Flash cells
for program memory are rated to last for many
thousands of erase/write cycles – up to 100,000.
• 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 memory, it becomes possible to
create an application that can update itself in the
field.
• Extended Instruction Set: The PIC18F2450/
4450 family introduces an optional extension to
the PIC18 instruction set, which adds 8 new
instructions and an Indexed
Literal Offset Addressing mode. This extension,
enabled as a device configuration option, has
been specifically designed to optimize re-entrant
application code originally developed in high-level
languages such as C.
• Enhanced Addressable USART: This serial
communication module is capable of standard
RS-232 operation and provides support for the LIN
bus protocol. Other enhancements include
Automatic Baud Rate Detection and a 16-bit Baud
Rate Generator for improved resolution.
• 10-Bit A/D Converter: This module 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.
• Dedicated ICD/ICSP Port: These devices
introduce the use of debugger and programming
pins that are not multiplexed with other microcontroller features. Offered as an option in select
packages, this feature allows users to develop I/O
intensive applications while retaining the ability to
program and debug in the circuit.
1.3Details on Individual Family
Members
Devices in the PIC18F2450/4450 family are available
in 28-pin and 40/44-pin packages. Block diagrams for
the two groups are shown in Figure 1-1 and Figure 1-2.
The devices are differentiated from each other in the
following two ways:
1.A/D channels (10 for 28-pin devices, 13 for
40/44-pin devices).
2.I/O ports (3 bidirectional ports and 1 input only
port on 28-pin devices, 5 bidirectional ports on
40/44-pin devices).
All other features for devices in this family are identical.
These are summarized in Table 1-1.
The pinouts for all devices are listed in Table 1-2 and
Table 1-3.
Like all Microchip PIC18 devices, members of the
PIC18F2450/4450 family are available as both standard
and low-voltage devices. Standard devices with
Enhanced Flash memory, designated with an “F” in the
part number (such as PIC18F2450), accommodate an
operating V
designated by “LF” (such as PIC18LF2450), function
over an extended VDD range of 2.0V to 5.5V.
ST = Schmitt Trigger input with CMOS levels I= Input
O= Output P= Power
PDIP,
QFN
SOIC
1
96
107
26
Pin
Buffer
Typ e
I
P
I
IIAnalog
Analog
O
O
I/O
Type
ST
ST
—
—
TTL
Description
Master Clear (input) or programming voltage (input).
Master Clear (Reset) input. This pin is an active-low
Reset to the device.
Programming voltage input.
Digital input.
Oscillator crystal or external clock input.
Oscillator crystal input or external clock source input.
External clock source input. Always associated with pin
function OSC1. (See OSC2/CLKO pin.)
Oscillator crystal or clock output.
Oscillator crystal output. Connects to crystal or resonator
in Crystal Oscillator mode.
In select modes, OSC2 pin outputs CLKO which has
1/4 the frequency of OSC1 and denotes the instruction
cycle rate.
General purpose I/O pin.
ST = Schmitt Trigger input with CMOS levels I= Input
O= Output P= Power
Note 1:These pins are No Connect unless the ICPRT Configuration bit is set. For NC/ICPORTS, the pin is No
Connect unless ICPRT is set and the DEBUG
Pin Number
PDIP QFN TQFP
11818
133230
143331
Pin
Buffer
Typ e
I
P
I
IIAnalog
Analog
O
O
I/O
Type
Master Clear (input) or programming voltage (input).
ST
ST
—
—
TTL
Configuration bit is cleared.
Master Clear (Reset) input. This pin is an
active-low Reset to the device.
Programming voltage input.
Digital input.
Oscillator crystal or external clock input.
Oscillator crystal input or external clock source input.
External clock source input. Always associated with
pin function OSC1. (See OSC2/CLKO pin.)
Oscillator crystal or clock output.
Oscillator crystal output. Connects to crystal or
resonator in Crystal Oscillator mode.
In select modes, OSC2 pin outputs CLKO which has
1/4 the frequency of OSC1 and denotes the instruction
cycle rate.
General purpose I/O pin.
Devices in the PIC18F2450/4450 family incorporate a
different oscillator and microcontroller clock system
than the non-USB PIC18F devices. The addition of the
USB module, with its unique requirements for a stable
clock source, make it necessary to provide a separate
clock source that is compliant with both USB low-speed
and full-speed specifications.
To accommodate these requirements, PIC18F2450/
4450 devices include a new clock branch to provide a
48 MHz clock for full-speed USB operation. Since it is
driven from the primary clock source, an additional
system of prescalers and postscalers has been added
to accommodate a wide range of oscillator frequencies.
An overview of the oscillator structure is shown in
Figure 2-1.
Other oscillator features used in PIC18 enhanced
microcontrollers, such as the internal RC oscillator and
clock switching, remain the same. They are discussed
later in this chapter.
2.1.1OSCILLATOR CONTROL
The operation of the oscillator in PIC18F2450/4450
devices is controlled through two Configuration
registers and two control registers. Configuration
registers, CONFIG1L and CONFIG1H, select the
oscillator mode and USB prescaler/postscaler options.
As Configuration bits, these are set when the device is
programmed and left in that configuration until the
device is reprogrammed.
The OSCCON register (Register 2-1) selects the Active
Clock mode; it is primarily used in controlling clock
switching in power-managed modes. Its use is
discussed in Section 2.4.1 “Oscillator Control
Register”.
2.2Oscillator Types
PIC18F2450/4450 devices can be operated in twelve
distinct oscillator modes. In contrast with the non-USB
PIC18 enhanced microcontrollers, four of these modes
involve the use of two oscillator types at once. Users
can program the FOSC3:FOSC0 Configuration bits to
select one of these modes:
1.XTCrystal/Resonator
2.XTPLLCrystal/Resonator with PLL enabled
3.HSHigh-Speed Crystal/Resonator
4.HSPLL High-Speed Crystal/Resonator
with PLL enabled
5.ECExternal Clock with F
6.ECIOExternal Clock with I/O on RA6
7.ECPLL External Clock with PLL enabled
and F
OSC/4 output on RA6
8.ECPIO External Clock with PLL enabled,
I/O on RA6
9.INTHSInternal Oscillator used as
microcontroller clock source, HS
Oscillator used as USB clock source
10. INTXTInternal Oscillator used as
microcontroller clock source, XT
Oscillator used as USB clock source
11. INTIOInternal Oscillator used as
microcontroller clock source, EC
Oscillator used as USB clock source,
digital I/O on RA6
12. INTCKO Internal Oscillator used as
microcontroller clock source, EC
Oscillator used as USB clock source,
FOSC/4 output on RA6
Because of the unique requirements of the USB module,
a different approach to clock operation is necessary. In
previous PICmicro
clocks were driven by a single oscillator source; the usual
sources were primary, secondary or the internal
oscillator. With PIC18F2450/4450 devices, the primary
oscillator becomes part of the USB module and cannot
be associated to any other clock source. Thus, the USB
module must be clocked from the primary clock source;
®
devices, all core and peripheral
however, the microcontroller core and other peripherals
can be separately clocked from the secondary or internal
oscillators as before.
Because of the timing requirements imposed by USB,
an internal clock of either 6 MHz or 48 MHz is required
while the USB module is enabled. Fortunately, the
microcontroller and other peripherals are not required
to run at this clock speed when using the primary
oscillator. There are numerous options to achieve the
USB module clock requirement and still provide
flexibility for clocking the rest of the device from the
primary oscillator source. These are detailed in
In HS, HSPLL, XT and XTPLL Oscillator modes, a
crystal or ceramic resonator is connected to the OSC1
and OSC2 pins to establish oscillation. Figure 2-2
shows the pin connections.
The oscillator design requires the use of a parallel cut
crystal.
Note:Use of a series cut crystal may give a fre-
quency out of the crystal manufacturer’s
specifications.
FIGURE 2-2:CRYSTAL/CERAMIC
RESONATOR OPERATION
(XT, HS OR HSPLL
CONFIGURATION)
(1)
C1
(1)
C2
Note 1: See Table 2-1 and Table 2-2 for initial values of
C1 and C2.
2: A series resistor (R
strip cut crystals.
3: R
OSC1
To
Internal
XTAL
(2)
RS
OSC2
F varies with the oscillator mode chosen.
(3)
RF
PIC18FXXXX
S) may be required for AT
Logic
Sleep
TABLE 2-1:CAPACITOR SELECTION FOR
CERAMIC RESONATORS
Typical Capacitor Values Used:
ModeFreqOSC1OSC2
XT4.0 MHz33 pF33 pF
HS8.0 MHz
16.0 MHz
Capacitor values are for design guidance only.
These capacitors were tested with the resonators
listed below for basic start-up and operation. Thesevalues are not optimized.
Different capacitor values may be required to produce
acceptable oscillator operation. The user should test
the performance of the oscillator over the expected
DD and temperature range for the application.
V
See the notes following Table 2-2 for additional
information.
Resonators Used:
16.0 MHz
4.0 MHz
8.0 MHz
27 pF
22 pF
27 pF
22 pF
TABLE 2-2:CAPACITOR SELECTION FOR
CRYSTAL OSCILLATOR
Osc Type
Crystal
Freq
XT4 MHz27 pF27 pF
HS4 MHz27 pF27 pF
8 MHz22 pF22 pF
20 MHz15 pF15 pF
Capacitor values are for design guidance only.
These capacitors were tested with the crystals listed
below for basic start-up and operation. These values
are not optimized.
Different capacitor values may be required to produce
acceptable oscillator operation. The user should test
the performance of the oscillator over the expected
DD and temperature range for the application.
V
See the notes following this table for additional
information.
Crystals Used:
Note 1: Higher capacitance increases the stability
of oscillator but also increases the startup time.
2: When operating below 3V V
using certain ceramic resonators at any
voltage, it may be necessary to use the
HS mode or switch to a crystal oscillator.
3: Since each resonator/crystal has its own
characteristics, the user should consult
the resonator/crystal manufacturer for
appropriate values of external
components.
4: Rs may be required to avoid overdriving
crystals with low drive level specification.
5: Always verify oscillator performance over
DD and temperature range that is
the V
expected for the application.
An internal postscaler allows users to select a clock
frequency other than that of the crystal or resonator.
Frequency division is determined by the CPUDIV Configuration bits. Users may select a clock frequency of
the oscillator frequency, or 1/2, 1/3 or 1/4 of the
frequency.
An external clock may also be used when the microcontroller is in HS Oscillator mode. In this case, the
OSC2/CLKO pin is left open (Figure 2-3).
The EC, ECIO, ECPLL and ECPIO Oscillator modes
require an external clock source to be connected to the
OSC1 pin. There is no oscillator start-up time required
after a Power-on Reset or after an exit from Sleep
mode.
In the EC and ECPLL Oscillator modes, the oscillator
frequency divided by 4 is available on the OSC2 pin.
This signal may be used for test purposes or to
synchronize other logic. Figure 2-4 shows the pin
connections for the EC Oscillator mode.
FIGURE 2-4:EXTERNAL CLOCK
INPUT OPERATION
(EC AND ECPLL
CONFIGURATION)
2.2.4PLL FREQUENCY MULTIPLIER
PIC18F2450/4450 devices include a Phase Locked
Loop (PLL) circuit. This is provided specifically for USB
applications with lower speed oscillators and can also
be used as a microcontroller clock source.
The PLL is enabled in HSPLL, XTPLL, ECPLL and
ECPIO Oscillator modes. It is designed to produce a
fixed 96 MHz reference clock from a fixed 4 MHz input.
The output can then be divided and used for both the
USB and the microcontroller core clock. Because the
PLL has a fixed frequency input and output, there are
eight prescaling options to match the oscillator input
frequency to the PLL.
There is also a separate postscaler option for deriving
the microcontroller clock from the PLL. This allows the
USB peripheral and microcontroller to use the same
oscillator input and still operate at different clock
speeds. In contrast to the postscaler for XT, HS and EC
modes, the available options are 1/2, 1/3, 1/4 and 1/6
of the PLL output.
The HSPLL, ECPLL and ECPIO modes make use of
the HS mode oscillator for frequencies up to 48 MHz.
The prescaler divides the oscillator input by up to 12 to
produce the 4 MHz drive for the PLL. The XTPLL mode
can only use an input frequency of 4 MHz which drives
the PLL directly.
Clock from
Ext. System
OSC/4
F
OSC1/CLKI
PIC18FXXXX
OSC2/CLKO
The ECIO and ECPIO Oscillator modes function like the
EC and ECPLL modes, 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 OPERATION
(ECIO AND ECPIO
CONFIGURATION)
Clock from
Ext. System
RA6
The internal postscaler for reducing clock frequency in
XT and HS modes is also available in EC and ECIO
modes.
The PIC18F2450/4450 devices include an internal RC
oscillator (INTRC) which provides a nominal 31 kHz output. INTRC is enabled if it is selected as the device clock
source; it is also enabled automatically when any of the
following are enabled:
• Power-up Timer
• Fail-Safe Clock Monitor
• Watchdog Timer
• Two-Speed Start-up
These features are discussed in greater detail in
Section 18.0 “Special Features of the CPU”.
2.2.5.1Internal Oscillator Modes
When the internal oscillator is used as the microcontroller clock source, one of the other oscillator
modes (External Clock or External Crystal/Resonator)
must be used as the USB clock source. The choice of
USB clock source is determined by the particular
internal oscillator mode.
There are four distinct modes available:
1.INTHS mode: The USB clock is provided by the
oscillator in HS mode.
2.INTXT mode: The USB clock is provided by the
oscillator in XT mode.
3.INTCKO mode: The USB clock is provided by an
external clock input on OSC1/CLKI; the OSC2/
CLKO pin outputs F
4.INTIO mode: The USB clock is provided by an
external clock input on OSC1/CLKI; the OSC2/
CLKO pin functions as a digital I/O (RA6).
Of these four modes, only INTIO mode frees up an
additional pin (OSC2/CLKO/RA6) for port I/O use.
OSC/4.
2.3Oscillator Settings for USB
When the PIC18F2450/4450 is used for USB
connectivity, it must have either a 6 MHz or 48 MHz
clock for USB operation, depending on whether LowSpeed or Full-Speed mode is being used. This may
require some forethought in selecting an oscillator
frequency and programming the device.
The full range of possible oscillator configurations
compatible with USB operation is shown in Table 2-3.
2.3.1LOW-SPEED OPERATION
The USB clock for Low-Speed mode is derived from
the primary oscillator chain and not directly from the
PLL. It is divided by 4 to produce the actual 6 MHz
clock. Because of this, the microcontroller can only use
a clock frequency of 24 MHz when the USB module is
active and the controller clock source is one of the
primary oscillator modes (XT, HS or EC, with or without
the PLL).
This restriction does not apply if the microcontroller
clock source is the secondary oscillator or internal
oscillator.
2.3.2RUNNING DIFFERENT USB AND
MICROCONTROLLER CLOCKS
The USB module, in either mode, can run
asynchronously with respect to the microcontroller core
and other peripherals. This means that applications can
use the primary oscillator for the USB clock while the
microcontroller runs from a separate clock source at a
lower speed. If it is necessary to run the entire
application from only one clock source, full-speed
operation provides a greater selection of microcontroller
clock frequencies.