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, 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, Migratable Memory, MPASM,
MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net,
PICLAB, PICtail, PowerCal, PowerInfo, PowerMate,
PowerTool, rfLAB, rfPICDEM, Select Mode, Sm art Serial,
SmartTel 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
DS41159D-page ii 2004 Microchip Technology Inc.
PIC18FXX8
28/40-Pin High-Performance, Enhanced Flash
Microcontrollers with CAN
High-Performance RISC CPU:
• Linear program memory addressing up to
2Mbytes
• Linear data memory addressing to 4 Kbytes
• Up to 10 MIPS operation
• DC – 40 MHz clock input
• 4 MHz-10 MHz oscillator/clock inp ut with
PLL active
• 16-bit wide instructions, 8-bit wide data path
• Priority levels for interrupts
• 8 x 8 Single-Cycle Hardware Multiplier
Peripheral Features:
• High current sink/source 25 mA/25 mA
• Three external interrupt pins
•Timer0 module: 8-bit/16-bit timer/counter with
8-bit programmable prescaler
•Timer1 module: 16-bit timer/counter
•Timer2 module: 8-bit timer/counter with 8-bit
period register (time base for PWM)
•Timer3 module: 16-bit timer/counter
• Secondary osc il lat or c loc k option – Timer1/T i me r3
• Capture/Compare/PWM (CCP) modules;
CCP pins can be configured as:
- Capture input: 16-bit, max resolution 6.25 ns
- Compare: 16-bit, max resolution 100 ns (T
- PWM output: PWM resolution is 1 to 10-bit
Max. PWM freq. @:8-bit resolution = 156 kHz
10-bit resolution = 39 kHz
• Enhanced CCP modu le which has al l the features
of the standard CCP module, but also has the
following features for advanced motor control:
- 1, 2 or 4 PWM outputs
- Selectable PWM polar ity
- Programmable PWM dead time
• Master Synchronous Serial Port (MSSP) with two
modes of operation:
- 3-wire SPI™ (Supports all 4 SPI modes)
2
-I
C™ Master and Slave mode
• Addressable USART module:
- Supports interrupt-on-address bit
CY)
Advanced Analog Features:
• 10-bit, up to 8-channel Analog-to-Digital Converter
module (A/D) with:
17.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 143
19.0 CAN Module.............................................................................................................................................................................199
24.0 Special Features of the CPU.............. ..................... ..................... ............................................................................................ 265
25.0 Instruction Set Summary.......................................................................................................................................................... 281
26.0 Development Support...............................................................................................................................................................323
28.0 DC and AC Characteristics Graphs and Tables.......................................................................................................................361
29.0 Packaging Informa tio n..... ..................... .......................................... ..................... ..................................................................... 377
Appendix A: Data Sheet Revision History.......................................................................................................................................... 385
Index .................................................................................................................................................................................................. 387
Systems Information and Upgrade Hot Line...................................................................................................................................... 397
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@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.
2004 Microchip Technology Inc.DS41159D-page 5
PIC18FXX8
NOTES:
DS41159D-page 6 2004 Microchip Technology Inc.
PIC18FXX8
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:
• PIC18F248
• PIC18F258
•PIC18F448
•PIC18F458
These devices are available in 28-pin, 40-pin and
44-pin packages. They are differentiated from each
other in four ways:
1.PIC18FX58 devices have twice the Flash
program memory and data RAM of PIC18FX48
devices (32 Kbytes and 1536 bytes vs.
16 Kbytes and 768 bytes, respectively).
2.PIC18F2X8 devices imple me nt 5 A/D channels,
as opposed to 8 for PIC18F4X8 devices.
4.Only PIC18F4X8 devices implement the
Enhanced CCP module, analog comparators
and the Parallel Slave Port.
All other features for devices in the PIC18FXX8 family,
including the serial communications modules, are
identical. These are summarized in Table 1-1.
Block diagrams of the PIC18F2X8 and PIC18F4X8
devices are provided in Figure 1-1 and Figure 1-2,
respectively. The pinouts for these device families are
listed in Table 1-2.
Data Memory (Bytes)76815367681536
Data EEPROM Memory (Bytes)256256256256
Interrupt Sources17172121
I/O PortsPorts A, B, CPorts A, B, CPorts A, B, C, D, E Ports A, B, C, D, E
Timers4444
Capture/Compare/PWM Modules1111
Enhanced Capture/Compare/
PWM Modules
Serial Communic ationsMSSP, CAN,
Parallel Communications (PSP)NoNoYesYes
10-bit Analog-to-Digital Converter5 input channels5 input channels8 input channels8 input channels
Analog ComparatorsNoNo22
Analog Comparators V
Resets (and Delays)POR, BOR,
Programmable Low-Voltage DetectYesYesYesYes
Programmable Brown-out ResetYesYesYesYes
CAN ModuleYesYesYesYes
In-Circuit Serial Programming™
ST = Schmitt Trigger input with CMOS levels Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
11182
I
P
1, 17,
33, 34
9133014
10143115
28, 40
——These pins should be left
IICMOS/ST
O
O
I/O
ST
—
CMOS
—
—
TTL
Master Clear (input) or
programming voltage (output).
Master Clear (Reset) input.
This pin is an active low Reset
to the device.
Programming voltage inpu t.
unconnected.
Oscillator crystal or external clock
input.
Oscillator crystal input or
external clock sou rce inpu t. ST
buffer when configured in RC
mode; otherwise, CMOS.
External clock source input.
Always associated with pin
function OSC1 (see OSC1/
CLKI, OSC2/CLKO pins).
Oscillator crystal or clock output.
Oscillator crystal output.
Connects to crystal or
resonator in Crystal Oscillator
mode.
In RC mode, OSC2 pin output s
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 Analog = Analog input
I= Input O= Output
P= Power OD= Open-Drain (no P diode to V
—102711
I/O
I
I
O
ST
Analog
TTL
Analog
Digital I/O.
Analog input 7.
Chip select control for Parallel
Slave Port (see RD
pins).
Comparator 2 output.
I/O pins.
pins.
and WR
DD)
2004 Microchip Technology Inc.DS41159D-page 15
PIC18FXX8
NOTES:
DS41159D-page 16 2004 Microchip Technology Inc.
PIC18FXX8
2.0OSCILLATOR
CONFIGURATIONS
2.1Oscillator Types
The PIC18FXX8 can be operated in one of eight oscillator modes, programmable by three configuration bits
(FOSC2, FOSC1 and FOSC0).
1.LPLow-Power Crystal
2.XTCrystal/Resonator
3.HSHigh-Speed Crystal/Resonator
4.HS4High-Speed Crystal/Resonator with
PLL enabled
5.RCExternal Resistor/Capacito r
6.RCIOExternal Resistor/Capacitor with I/O
pin enabled
7.ECExternal Clock
8.ECIOExternal Clock with I/O pin enabled
2.2Crystal Oscillator/Ceramic
Resonators
In XT, LP, HS or HS4 (PLL) Oscillator modes, a crystal
or ceramic resonator is connected to the OSC1 and
OSC2 pins to establish oscillation. Figure 2-1 shows
the pin connections . An ext ernal clock source m ay also
be connected to the OSC1 pin, as shown in Figure 2-3
and Figure 2-4.
The PIC18FXX8 oscilla tor d esign 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-1:CRYSTAL/CERAMIC
RESONATOR OPERATION
(HS, XT OR LP OSC
CONFIGURATION)
(1)
C1
(1)
C2
Note 1: See Table 2-1 and Table 2-2 for recommended
values of C1 and C2.
2: A series resistor (R
strip cut crystals.
3: R
OSC1
XTAL
(2)
RS
OSC2
F varies with the crystal chosen.
(3)
RF
PIC18FXX8
S) may be required for AT
To
Internal
Logic
Sleep
TABLE 2-1:CERAMIC RESONATORS
Ranges Tested:
ModeFreqOSC1OSC2
XT455 kHz
2.0 MHz
4.0 MHz
HS8.0 MHz
16.0 MHz
These values are for design guidance only.
See notes following Table 2-2.
Resonators Used:
455 kHzPanasonic EFO-A455K04B±0.3%
2.0 MHzMurata Erie CSA2.00MG±0.5%
4.0 MHzMurata Erie CSA4.00MG±0.5%
8.0 MHzMurata Erie CSA8.00MT±0.5%
16.0 MHzMurata Erie CSA16.00MX±0.5%
All resonators used did not have built-in capacitors.
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
2004 Microchip Technology Inc.DS41159D-page 17
PIC18FXX8
TABLE 2-2:CAPACITOR SELECTION FOR
CRYSTAL OSCILLATOR
Osc Type
Crystal
Freq
LP32.0 kHz33 pF33 pF
200 kHz15 pF15 pF
XT200 kHz47-68 pF47-68 pF
1.0 MHz15 pF15 pF
4.0 MHz15 pF15 pF
HS4.0 MHz15 pF15 pF
8.0 MHz15-33 pF15-33 pF
20.0 MHz15-33 pF15-33 pF
25.0 MHz15-33 pF15-33 pF
These values are for design guidance only.
See notes on this page.
of the oscillator but also increases the
start-up time.
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 in HS mode, as well
as XT mode, to avoid overdrivi ng crys t als
with low drive level specification.
Cap. Range C1Cap. Range
Crystals Used
C2
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
operating temperature. In addition to this, the oscillator
frequency will vary from unit to unit due to normal
process parameter variation. Furthermore, the differ-
ence in lead frame capacit ance between package types
will also affect the oscillation frequency, especially for
EXT values. The user also needs to take into
low C
account variation due to tolerance of external R and C
components used. Figure 2-2 shows how the RC
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.
Note:If the oscillator frequency divided by 4
FIGURE 2-2:RC OSCILLATOR MODE
REXT
CEXT
VSS
Recommended values: 3 kΩ ≤ REXT ≤ 100 kΩ
The RCIO Oscillato r mode f unc tions like t he RC m ode,
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) values and the
signal is not required in the application, it
is recommended to use RCIO mode to
save current.
VDD
PIC18FXX8
OSC1
F
OSC/4
OSC2/CLKO
C
EXT > 20 pF
Internal
Clock
DS41159D-page 18 2004 Microchip Technology Inc.
PIC18FXX8
2.4External Clock Input
The EC and ECIO Oscillator mode s require an externa l
clock source to be connected to the OSC1 pin. The
feedback device between OSC1 and OSC2 is turned
off in these modes to save current. There is no oscillator start-up time required after a Power-on Reset or
after a recovery 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-3 shows the pin connections for the EC
Oscillator mode.
FIGURE 2-3:EXTERNAL CLOCK INPUT
OPERATION (EC OSC
CONFIGURATION)
PIC18FXX8
Clock from
Ext. System
OSC/4
F
The ECIO Oscillator mode func ti ons li ke t he EC m od e,
except that the OSC2 pin becomes an additional
general purpose I/O pin. Figure 2-4 shows the pin
connections for the ECIO Osci ll ator mode.
OSC1
OSC2
FIGURE 2-4:EXTERNAL CLOCK INPUT
OPERATION (ECIO
CONFIGURATION)
PIC18FXX8
Clock from
Ext. System
OSC1
I/O (OSC2)
2.5HS4 (PLL)
A Phase Locked Loop circuit is pro vided as a programmable option for users that want to multiply the
frequency of the incoming cry sta l oscil lator sig nal by 4.
For an input clock frequency of 10 MHz, the internal
clock frequency will be multiplied to 40 MHz. This is
useful for customers who are concerned with EMI due
to high-frequency crystals.
The PLL can only be enabled when the oscillator
configuration bi ts are pro grammed for HS mod e. If the y
are programmed for any other mode, the PLL is not
enabled and the system clock will come directly from
OSC1.
The PLL is one of the modes of the FOSC2:FOSC0
configuration bits. 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 referred to as T
PLL.
FIGURE 2-5:PLL BLOCK DIAGRAM
OSC2
Crystal
Osc
OSC1
Phase
Comparator
F
IN
FOUT
FOSC2:FOSC0 = 110
Loop
Filter
Divide by 4
VCO
SYSCLK
MUX
2004 Microchip Technology Inc.DS41159D-page 19
PIC18FXX8
2.6Oscillator Switching Feature
The PIC18FXX8 devices include a featu re that allows
the system clock source to be switc hed from the mai n
oscillator to an alternate low-frequency clock source.
For the PIC18FXX8 devices, this alternate clock source
is the Timer1 oscillator. If a low-frequency crystal
(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-6 shows a block diagram of the
system clock sources. The clock switching feature is
enabled by programming the Oscillator Switching
Enable (OSCSEN
CONFIG1H, to a ‘0’. Clock switching is disabled in an
erased device. See Section 1 2.2 “Timer 1 Oscillat or”
for further details of the Timer1 oscillator and
Section 24.1 “Configuration Bits” for Configuration
register details.
FIGURE 2-6:DEVICE CLOCK SOURCES
) bit in Configuration register,
PIC18FXX8
OSC2
OSC1
T1OSO
T1OSI
Main Oscillator
Sleep
Timer 1 Oscillator
T1OSCEN
Enable
Oscillator
2.6.1SYSTEM CLOCK SWITCH BIT
The system clock source switching is performed under
software control. The system clock switch bit, SCS
(OSCCON register), controls the clock switching. When
the SCS bit is ‘0’, the system clock source comes from
the main oscillator selected by the FOSC2:FOSC0
configuration bits. When the SCS bit is set, the system
clock source comes from the Timer1 oscilla tor . The SCS
bit is cleared on all forms of Reset.
Note:The Timer1 oscillator must be enabled 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, any write to the SCS bit will be
ignored (SCS bit forced cleared) and the
main oscillator con t in ues to be t he s ys tem
clock source.
4 x PLL
TOSC
TT1P
Clock Source Option
for Other Modules
TOSC/4
MUX
Clock
Source
TSCLK
Note:I/O pins have diode protection to VDD and VSS.
REGISTER 2-1:OSCCON: OSCILLATOR CONTROL REGISTER
U-0U-0U-0U-0U-0U-0U-0R/W-1
———————SCS
bit 7bit 0
bit 7-1Unimplemented: Read as ‘0’
bit 0SCS: System Clock Switch bit
When
OSCSEN configuration bit = 0 and T1OSCEN bit is set:
1 = Switch to Timer1 oscillator/clock pin
0 = Use primary oscillator/clock input pin
OSCSEN is clear or T1OSCEN is clear:
When
Bit is force d clear.
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
DS41159D-page 20 2004 Microchip Technology Inc.
PIC18FXX8
2.6.2OSCILLATOR TRANSITIONS
The PIC18FXX8 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 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.
Figure 2-7 shows a timing diagram indicating the transition from the main oscillator to the Timer1 oscillator.
The Timer1 oscillator is assumed to be running all the
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), the transition will take place after
an oscillator st art-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-8.
time. After the SCS bit is set, th e proce ssor is frozen at
the next occurring Q1 cycle . After eight synchroniz ation
cycles are counted from the Timer1 oscillator,
operation resumes. No additional delays are required
after the synchronization cy cle s.
FIGURE 2-7:TIMING DIAGRAM FOR TRANSITION FROM OSC1 TO TIMER1 OSCILLATOR
Q1
T1OSI
OSC1
Internal
System
Clock
SCS
(OSCCON<0>)
Program
Counter
TOSC
Q4
Q3Q2
Q1
TDLY
TT1P
21345678
Tscs
PC + 2PC
Q3Q2Q1
Q4Q1
Q2Q3Q4 Q1
PC + 4
Note 1: Delay on internal system clock is eight oscillator cycles for synchronization.
FIGURE 2-8:TIMING DIAGRAM FOR TRANSITION BETWEEN TIMER1 AND OSC1 (HS, XT , LP)
T1OSI
OSC1
OSC2
Internal System
Clock
(OSCCON<0>)
Note 1: T
SCS
Program
Counter
OST = 1024 TOSC (drawing not to scale).
Q3Q4
PCPC + 2
Q1
TOST
TOSC
TT1P
12345678
TSCS
Q1 Q2 Q3 Q4 Q1 Q2
Q3
PC + 4
2004 Microchip Technology Inc.DS41159D-page 21
PIC18FXX8
If the main oscillator is configured for HS4 (PLL) mode,
an oscillator start-up time (T
time-out (T
PLL) will occur. The PLL time-out is typically
OST) plus an additional PLL
2 ms and allows the PLL to lock to the main oscillator
frequency. A timing diagram indicating the transition
from the Timer 1 oscilla tor to the mai n oscillator f or HS4
mode is shown in Figure 2-9.
If the main oscillato r is co nfigure d in th e RC, R CIO, EC
or ECIO modes, the re is no oscillator start-u p t im e-ou t.
Operation will resume after eight cycles of the main
oscillator have been counted. A ti ming diag ram indicating the transition from the Timer1 oscillator to the main
oscillator for RC, RC IO, EC and EC IO mo des is sho wn
in Figure 2-10.
FIGURE 2-9:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (HS WITH PLL)
Q3
PC + 4
T1OSI
OSC1
OSC2
PLL Clock
Input
Internal System
Note 1: T
Clock
(OSCCON<0>)
SCS
Program
Counter
OST = 1024 TOSC (drawing not to scale).
Q4Q1
TOST
PCPC + 2
TPLL
TOSC
TT1P
TSCS
123456
Q1 Q2 Q3 Q4 Q1 Q2
8
7
Q4
FIGURE 2-10:TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (RC, EC)
Q3Q4
T1OSI
OSC1
OSC2
Internal System
Note 1: RC Oscillator mode assumed.
Clock
(OSCCON<0>)
SCS
Program
Counter
Q1
PCPC + 2
TT1P
TOSC
12345 678
TSCS
Q1 Q2 Q3 Q4 Q1 Q2 Q3
Q4
PC + 4
DS41159D-page 22 2004 Microchip Technology Inc.
PIC18FXX8
2.7Effects of Sleep Mode on the
On-Chip Oscillator
When the device executes a SLEEP instruction, the
on-chip clocks and oscillator are turned off and the
device is held at the beginning of an instruction cycle
(Q1 state). With the os ci lla tor o f f, the OSC1 and OSC2
signals will stop oscillating. Since all the transistor
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.
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 until the device power 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 provides a fixed delay of T
#D033) on power-up only (POR and BOR). The second
timer is the Oscillator S t art-up T imer (OST), inten ded to
keep the chip in Reset until the crystal oscillator is
stable.
With the PLL enabled ( HS4 Osc ill ato r mo de), the timeout sequence following a Power-on Reset is different
from other oscillator modes. The time-out sequence is
as follows: the PWRT time-out 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 a mount of ti me to allow the PLL to l ock at hig h
frequencies. The PWRT timer is used to provide an
additional fixed 2ms (nominal) to allow the PLL ample
time to lock to the incoming clock frequency.
TABLE 2-3:OSC1 AND OSC2 PIN STATES IN SLEEP MODE
OSC ModeOSC1 PinOSC2 Pin
RCFloating, external resistor should pull high At logic low
RCIOFloating, external resistor should pull high Configured 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 inverter disabled at quiescent
voltage level
Reset.
PWRT (parameter
2004 Microchip Technology Inc.DS41159D-page 23
PIC18FXX8
NOTES:
DS41159D-page 24 2004 Microchip Technology Inc.
PIC18FXX8
3.0RESET
The PIC18FXX8 differentiates between various kinds
of RESET:
a) Power-on Reset (POR)
b) MCLR
c)MCLR Rese t during Sleep
d) Watchdog Timer (WDT) Reset during normal
Most registers are unaffected by a Reset. Their status
is unknown on POR and unchanged by all other
Resets. The other registers are forced to a “Reset”
Reset during normal operation
operation
state on Power-on Reset, MCLR
out Reset, MCLR
Reset during Sleep and by the
RESET instruction.
Most registers are not affected by a WDT wake-up,
since this is viewed as the resumption of normal operation. Status bits from the RCON register, RI
POR
and BOR are set or cleared differently in different
Reset situations, as indicated in Table 3-2. These bits
are used in software to determine the nature of the
Reset. See Table 3-3 for a full description of the Reset
states of all registers.
A simplified block di agram of the On-Chip Reset Circu it
is shown in Figure 3-1.
The Enhanced MCU devices have a MCLR
in the MCLR
Reset path. The filter will detect and
ignore small pulses.
A WDT Reset does not drive MCLR
, WDT Reset, Brown-
FIGURE 3-1:SIMPLIFIED BLOCK DIAGRAM OF ON-CHIP RESET CIRCUIT
RESET
Instruction
Stack
Pointer
Stack Full/Underflow Reset
External Reset
, TO, PD,
noise filter
pin low.
MCLR
WDT
Module
V
DD Rise
Detect
VDD
OSC1
Note 1: This is a separate oscillator from the RC oscillator of the CLKI pin.
Brown-out
Reset
OST/PWRT
OST
On-chip
RC OSC
2: See Table 3-1 for time-out situations.
PWRT
(1)
Sleep
WDT
Time-out
Reset
Power-on Reset
BOREN
10-bit Ripple Counter
10-bit Ripple Counter
S
R
Enable PWRT
Enable OST
Chip_Reset
Q
(2)
2004 Microchip Technology Inc.DS41159D-page 25
PIC18FXX8
.
t
l
3.1Power-on Reset (POR)
A Power-on Reset pulse is generated on-chip when a
DD rise is detected. To take advantage of the POR
V
circuitry, connect the MCLR
resistor) to V
DD. This eliminates external RC compo-
pin directly (or through a
nents usually needed to create a Power-on Reset
delay. A minimum rise rate for V
DD is specified (refer to
parameter D004). For a slow rise time, see Figure 3-2.
When the device starts normal operation (exits the
Reset condition), device operating parameters
(voltage, frequency, temperature, etc.) must be met to
ensure operation. If these conditions are not met, the
device must be held in Reset until the operating conditions are met. Brown-out Reset may be used to meet
the voltage start-up condition.
3.2MCLR
PIC18FXX8 devices have a noise filter in the MCLR
Reset path. The filter will detect and ignore small
pulses.
It should be noted that a WDT Reset does not drive
pin low.
MCLR
The behavior of the ESD protection on the MCLR
differs from previous devices of this family. Voltages
applied to the pin that exceed its specification can
result in both Resets and current draws outside of
device specification during the Reset event. For this
reason, Microchip recommends that the MCLR
longer be tied directly to V
DD. The use of an RC
network, as shown in Figure 3-2, is suggested.
pin
pin no
3.3Power-up Timer (PWRT)
The Power-up Timer provides a fixed nominal time-out
(parameter #33), only on power-up from the POR. The
Power-up Timer operates on an internal RC oscillator.
The chip is kept in R eset as long a s the PWRT is active.
The PWRT’s ti me delay allows V
able level. A configuration bit (PWRTEN
DD to rise to an accept-
in CONFIG2L
register) is provided to enable/disable the PWRT.
The power-up time dela y will vary f rom chip to chip due
DD, temperature and process variation. See DC
to V
parameter #33 for details.
3.4Oscillator Start-up Timer (OST)
The Oscillator Start-up Timer (OST) provides a 1024
oscillator cycle (from OSC1 input) delay after the
PWRT delay is over (parameter #32). This additional
delay ensures that the crystal oscillator or resonator
has started and stabilized.
The OST time-out is invoked only for XT, LP, HS and
HS4 modes and only on Power-on Reset or wake-up
from Sleep.
3.5PLL Lock Time-out
With the PLL enabled, the time-ou t sequen ce foll owin g
a Power-on Reset is different from other oscillator
modes. A portion of the Po wer-up Timer is used to provide a fixed time-out th at is suff icient for the PLL to lock
to the main oscillator fre quenc y. This PLL lock time-out
PLL) is typically 2 ms and follows the oscillator
(T
start-up time-out (OST).
FIGURE 3-2:EXTERNAL POWER-ON
RESET CIRCUIT (FOR
SLOW V
V
DD
D
R
C
Note 1: External Power-on Reset circuit is required
only if the V
The diode D helps discharge the capacitor
quickly when V
2: R < 40 kΩ is recommended to make sure tha
the voltage drop across R does not violate
the device’s electrical specification.
3: R1 = 100Ω to 1 kΩ will limit any current flow-
ing into MCLR
the event of MCLR/
Electrostatic Discharge (ESD) or Electrica
Overstress (EOS).
DD power-up slope is too slow
DD POWER-UP)
R1
MCLR
PIC18FXXX
DD powers down.
from external capacitor C, in
VPP pin breakdown due to
3.6Brown-out Reset (BOR)
A configuration bit, BOREN, can disable (if clear/
programmed), or enable (if set), the Brown-out Reset
circuitry. If VDD falls below parameter D005 for greater
than parameter #35, the brown-out situation resets the
chip. A Reset may not occur if VDD falls below parameter D005 for less than parameter #35. The chip will
remain in Brown-out Reset unt il V
The Power-up T im er wil l th en be invoked and will keep
the chip in Reset an additional time delay (parameter
#33). If V
DD drops below BVDD while the Power-up
Timer is ru nni ng, the chip will go back in to a Bro wn-out
Reset and the Power-up Timer will be initialized. Once
DD rises above BVDD, the Power-up Timer will
V
execute the additional time delay.
DD rises above BVDD.
DS41159D-page 26 2004 Microchip Technology Inc.
PIC18FXX8
3.7Time-out Sequence
On power-up, the time-out sequence is as follows:
First, PWRT time-out is invoked after the POR time
delay has expired, then OST is activated. The total
time-out will vary based on oscillator configuration and
the status o f th e PW RT . Fo r e xa mple, in RC mode with
the PWRT disabled, there will be no time-out at all.
Figure 3-3, Figure 3-4, Figure 3-5, Figure 3-6 and
Figure 3-7 depict time-out sequences on power-up.
Since the time-outs occur from the POR pulse, if MC LR
is kept low long enough, the time-outs will expire.
Bringing MCLR
(Figure 3-5). This is useful for testing purposes or to
synchronize more than one PIC18FXX8 device
operating in parallel.
Table 3-2 shows the Reset condi tions f or some Spec ial
Function Registers, while Table 3-3 shows the Reset
conditions for all registers.
high will begin execution immediately
TABLE 3-1:TIME-OUT IN VARIOUS SITUATIONS
Oscillator
Configuration
HS with PLL enabled
HS, XT, LP72 ms + 1024 TOSC1024 TOSC72 ms + 1024 TOSC1024 TOSC
EC72 ms—72 ms—
External RC72 ms—72 ms—
Note 1:2 ms = Nominal time required for the 4x PLL to lock.
2: 72 ms is the nominal Power-up Timer delay.
(1)
PWRTEN
72 ms + 1024 TOSC + 2 ms 1024 TOSC + 2 ms 72 ms + 10 24 TOSC + 2 m s 1024 TOSC + 2 ms
Power-up
= 0PWRTEN = 1
(2)
Brown-out
(2)
REGISTER 3-1:RCON REGISTER BITS AND POSITIONS
R/W-0U-0U-0R/W-1R/W-1R/W-1R/W-0R/W-1
IPEN
bit 7bit 0
——RITOPDPORBOR
Wake-up from
Sleep or
Oscillator Switch
TABLE 3-2:STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION FOR
RCON REGISTER
Condition
Power-on Reset0000h0--1 110q11100uu
MCLR Reset during normal
Legend: u = unchanged, x = unknown,- = unimplemented bit, read as ‘0’
Note 1: When the wake-up is due to an interrupt and the GIEH or GIEL bits are set, the PC is loaded with the
interrupt vector (000008h or 0000 18h ).
Program
Counter
0000h0--0 011quuuuuuu
0000h0--0 011q0uuuuuu
0000h0--0 011quuu11u1
0000h0--0 011quuu111u
(1)
RCON
Register
0--1 101qu10uuuu
TO PDPORBORSTKFULSTKUNF
RI
2004 Microchip Technology Inc.DS41159D-page 27
PIC18FXX8
FIGURE 3-3:TIME-OUT SEQUENCE ON POWER-UP (MCLR TIED TO VDD )
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
OST TIME-OUT
INTERNAL RESET
TOST
FIGURE 3-4:TIME-OUT SEQUENCE ON POWER-UP (MCLR
VDD
MCLR
INTERNAL POR
PWRT TI ME-OUT
OST TIME-OUT
INTERNAL RESET
TPWRT
NOT TIED TO VDD): CASE 1
TOST
FIGURE 3-5:TIME-OUT SEQUENCE ON POWER-UP (MCLR
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
OST TIME-OUT
INTERNAL RESET
DS41159D-page 28 2004 Microchip Technology Inc.
NOT TIED TO VDD): CASE 2
TOST
Loading...
+ 372 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.