6.08 X 8 Hardware Multiplier...........................................................................................................................................................61
14.0 Master Synchronous Serial Port (MSSP) Module ....................................................................................................................117
17.0 Low Voltage Detect ..................................................................................................................................................................175
18.0 Special Features of the CPU.................................................................................................................................................... 181
19.0 Instruction Set Summary..........................................................................................................................................................191
20.0 Development Support. .............................................................................................................................................................. 235
22.0 DC and AC Characteristics Graphs and Tables.......................................................................................................................273
Appendix D:Migration from Baseline to Enhanced Devices................................................... ....... .... .. .... .. ....................................284
Appendix E:Migration from Midrange to Enhanced Devices........................................................... .. .. .... .. .................................... 285
Appendix F:Migration from High-end to Enhanced Devices ......................................................................................................... 285
PIC18CXX2 Product Identification System ........................................................................................................................................ 295
To Our Valued Customers
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.
New Customer Notification System
Register on our web site (www.microchip.com/cn) to receive the most current information on our products.
Errata
An errata sheet may exist for current devices, describing minor operational differences (from the data sheet) and recommended
workarounds. As device/documentation issues become known to us, w e will pub lish an errata sheet. The errata will specify the re vision 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: (602) 786-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.
Corrections to this Data Sheet
We constantly strive to improve the quality of all our products and documentation. We have spent a great deal of time to ensure
that this document is correct. However , w e realize that we ma y ha v e missed a f ew things . If y ou find any inf ormation that is missi n g
or appears in error, please:
• Fill out and mail in the reader response form in the back of this data sheet.
• E-mail us at webmaster@microchip.com.
We appreciate your assistance in making this a better document.
DS39026B-page 4Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
1.0DEVICE OVERVIEW
This document contains device-specific information for
the following four devices:
1.PIC18C242
2.PIC18C252
3.PIC18C442
4.PIC18C452
These devices come in 28 and 40-pin packages. The
28-pin devices do not have a Parallel Slave Port (PSP)
implemented and the numb er of Analog-to-Digital (A/D)
converter input channels is reduced to 5. An overview
of features is shown in Table 1-1.
The following two figures are device block diagrams
sorted by pin count; 28-pin f or Figur e 1-1 and 40-pin f or
Figure 1-2. The 28-pin and 40-pin pinouts are listed in
Table 1-2 and Table 1-3 respectively.
Note1: Optional multiplexing of CCP2 input/output with RB3 is enabled by selection of configuration bit.
2: The high order bits of the Direc t Address f or the RAM are from the BSR registe r (e xce pt f or the M O VF F
instruction).
3: Many of the general purpose I/O pins are multiplexed with one or more peripheral module functions.
The multiplexing combinations are device dependent.
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 7
PIC18CXX2
TABLE 1-2:PIC18C2X2 PINOUT I/O DESCRIPTIONS
Pin Name
MCLR
/VPP
MCLR
VPP
NC————These pins should be left unconnected.
OSC1/CLKI
OSC1
CLKI
OSC2/CLKO/RA6
OSC2
CLKO
RA6
RA0/AN0
RA0
AN0
RA1/AN1
RA1
AN1
RA2/AN2/V
RA3/AN3/V
RA4/T0CKI
RA5/AN4/SS
RA6See the OSC2/CLKO/RA6 pin.
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output
REF-
RA2
AN2
REF-
V
REF+
RA3
AN3
REF+
V
RA4
T0CKI
/LVDIN
RA5
AN4
SS
LVDIN
ST = Schmitt Trigger input with CMOS levels
I = Input O = Output
P = Power OD = Open Drain (no P diode to V
Pin Number
DIPSOICDescription
11
99
1010
22
33
44
55
66
77
Pin
Type
Buffer
Type
I
P
I
I
O
O
I/O
I/O
I
I/O
I
I/O
I
I
I/O
I
I
I/OIST/OD
I/O
I
I
I
STMaster clear (reset) input. This pin is an active low reset
ST
CMOS
—
—
TTL
TTL
Analog
TTL
Analog
TTL
Analog
Analog
TTL
Analog
Analog
ST
TTL
Analog
ST
Analog
to the device.
Programming voltage input.
Oscillator crystal input or external clock source input.
ST buffer when configured in RC mode. CMOS otherwise.
External clock source input. Always associated with
pin function OSC1. (See related OSC1/CLKIN,
OSC2/CLKOUT pins).
Oscillator crystal output. Connects to crystal or
resonator in crystal oscillator mode.
In RC mode, OSC2 pin outputs CLKOUT which has 1/4
the frequency of OSC1, and denotes the instruction
cycle rate.
General Purpose I/O pin.
PORTA is a bi-directional I/O port.
Digital I/O.
Analog input 0.
Digital I/O.
Analog input 1.
Digital I/O.
Analog input 2.
A/D Reference Voltage (Low) input.
Digital I/O.
Analog input 3.
A/D Reference Voltage (High) input.
Digital I/O. Open drain when configured as output.
Timer0 external cloc k input .
Digital I/O.
Analog input 4.
SPI Slave Select input.
Low Voltage Detect Input.
Digital I/O.
Capture1 input/Compare1 output/PWM1 output.
Digital I/O.
Synchronous serial clock input/output for SPI mode.
Synchronous serial clock input/output for I
Digital I/O.
SPI Data In.
2
C Data I/O.
I
Digital I/O.
SPI Data Out.
Digital I/O.
USART Asynchronous Transmit.
USART Synchronous Clock.
(See related RX/DT)
Digital I/O.
USART Asynchronous Receive.
USART Synchronous Data.
(See related TX/CK)
DD)
2
C mode
DS39026B-page 10Preliminary
7/99 Microchip Technology Inc.
TABLE 1-3:PIC18C4X2 PINOUT I/O DESCRIPTIONS
PIC18CXX2
Pin Name
MCLR
/VPP
MCLR
VPP
NC———These pins should be left unconnected.
OSC1/CLKI
OSC1
CLKI
OSC2/CLKO/RA6
OSC2
CLKO
RA6
RA0/AN0
RA0
AN0
RA1/AN1
RA1
AN1
RA2/AN2/V
RA3/AN3/V
RA4/T0CKI
RA5/AN4/SS
RA6See the OSC2/CLKO/RA6 pin.
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output
REF-
RA2
AN2
REF-
V
REF+
RA3
AN3
REF+
V
RA4
T0CKI
/LVDIN
RA5
AN4
SS
LVDIN
ST = Schmitt Trigger input with CMOS levels
I = Input O = Output
P = Power OD = Open Drain (no P diode to V
Pin Number
DIPPLCC TQFPDescription
1218
131430
141531
2319
3420
4521
5622
6723
7824
Pin
Type
I/O
I/O
I/O
I/O
I/O
I/OIST/OD
I/O
Buffer
Type
I
P
I
I
O
O
I
I
I
I
I
I
I
I
I
STMaster clear (reset) input. This pin is an active
ST
CMOS
—
—
TTL
TTL
Analog
TTL
Analog
TTL
Analog
Analog
TTL
Analog
Analog
ST
TTL
Analog
ST
Analog
low reset to the device.
Programming voltage input.
Oscillator crystal input or external clock
source input. ST buffer when configured in
RC mode. CMOS otherwise.
External clock source input. Always
associated with pin function OSC1. (See
related OSC1/CLKIN, OSC2/CLKOUT pins).
Oscillator crystal output. Connects to crystal
or resonator in crystal oscillator mode.
In RC mode, OSC2 pin outputs CLKOUT,
which has 1/4 the frequency of OSC1 and
denotes the instruction cycle rate.
General Purpose I/O pin.
PORTA is a bi-directional I/O port.
Digital I/O.
Analog input 0.
Digital I/O.
Analog input 1.
Digital I/O.
Analog input 2.
A/D Reference Voltage (Low) input.
Digital I/O.
Analog input 3.
A/D Reference Voltage (High) input.
Digital I/O . Open dr ain when config ured as outpu t.
Timer0 external clock input.
Digital I/O.
Analog input 4.
SPI Slave Select input.
Low Voltage Detect Input.
SS12, 31 13, 34 6, 29P—Ground reference for logic and I/O pins.
ST = Schmitt Trigger input with CMOS levels
I = Input O = Output
P = Power OD = Open Drain (no P diode to V
Pin Number
DIPPLCC TQFPDescription
8925I/O
91026I/O
101127I/O
Pin
Type
Buffer
Type
TTL
TTL
TTL
TTL
TTL
TTL
TTL
TTL
ST
TTL
Analog
ST
TTL
Analog
ST
TTL
Analog
PORTD is a bi-directional I/O port.
Parallel Slave Po rt (PSP) for interfacing to a microprocessor port. These pins have TTL input buffers when
PSP module is enabled.
Digital I/O.
Parallel Slave Port Data.
Digital I/O.
Parallel Slave Port Data.
Digital I/O.
Parallel Slave Port Data.
Digital I/O.
Parallel Slave Port Data.
Digital I/O.
Parallel Slave Port Data.
Digital I/O.
Parallel Slave Port Data.
Digital I/O.
Parallel Slave Port Data.
Digital I/O.
Parallel Slave Port Data.
PORTE is a bi-directional I/O port.
Digital I/O.
Read control for parallel slave port.
(See also WR
Analog input 5.
Digital I/O.
Write control for parallel slave port.
(See CS
Analog input 6.
Digital I/O.
Chip Select control for parallel slave port.
(See related RD
Analog input 7.
and CS pins)
and RD pins)
and WR)
DD)
DS39026B-page 14Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
2.0OSCILLATOR
CONFIGURATIONS
2.1Oscillator Types
The PIC18CXX2 can be operated in eight different
oscillator modes. The user can program three configuration bits (FOSC 2, FOSC 1, an d FOSC0 ) to s elect one
of these eight modes:
1.LPLow Power Crystal
2.XTCrystal/Resonator
3.HSHigh Speed Crystal/Resonator
4.HS + PLL High Speed Crystal/Resonator with
PLL enabled
5.RCExternal Resistor/Capacitor
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 HS-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 connec tions. An ex ternal clock source ma y als o
be connected to the OSC1 pin in these modes, as
shown in Figure2-2.
The PIC18CXX2 oscillat or desi gn requ ires th e use o f a
parallel cut crystal.
Note:Use of a series cut crystal may give a fre-
quency out of the crystal manufacturers
specifications.
FIGURE 2-1:CRYSTAL/CERAMIC
RESONATOR OPERATION
(HS, XT OR LP
OSC CONFIGURATION)
(1)
C1
(1)
C2
Note 1: See Table 2-1 and Table 2-2 for recom-
Note 2: A series resistor (RS) may be required
Note 3: R
OSC1
XTAL
(2)
RS
OSC2
mended values of C1 and C2.
for AT strip cut crystals.
F varies with the crystal chosen.
RF
(3)
SLEEP
PIC18CXXX
To
internal
logic
FIGURE 2-2:EXTERNAL CLOCK INPUT
OPERATION (HS, XT OR LP
OSC CONFIGURATION)
Clock from
ext. system
Open
OSC1
PIC18CXXX
OSC2
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 15
PIC18CXX2
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 at bottom of page.
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
Resonators Used:
455 kHzPanasonic EFO-A455K04B
2.0 MHzMurata Erie CSA2.00MG
4.0 MHzMurata Erie CSA4.00MG
8.0 MHzMurata Erie CSA8.00MT
16.0 MHzMurata Erie CSA16.00MX
All resonators used did not have built-in capacitors.
0.3%
±
0.5%
±
0.5%
±
0.5%
±
0.5%
±
TABLE 2-2:CAPACITOR SELECTION FOR
CRYSTAL OSCILLATOR
Osc Type
LP32.0 kHz33 pF33 pF
XT200 kHz47-68 pF47-68 pF
HS4.0 MHz15 pF15 pF
32.0 kHzEpson C-001R32.768K-A± 20 PPM
200 kHzSTD XTL 200.000KHz± 20 PPM
1.0 MHzECS ECS-10-13-1± 50 PPM
4.0 MHzECS ECS-40-20-1± 50 PPM
8.0 MHzEPSON CA-301 8.000M-C± 30 PPM
20.0 MHzE PS ON CA-301 20.000M-C± 30 PPM
Crystal
Freq
200 kHz15 pF15 pF
1.0 MHz15 pF15 pF
4.0 MHz15 pF15 pF
8.0 MHz15-33 pF15-33 pF
20.0 MHz15-33 pF15-33 pF
25.0 MHzTBDTBD
These values are for design guidance only. See
notes at bottom of page.
Cap. Range
C1
Crystals Used
Cap.
Range
C2
Note1: Recommended values of C1 and C2 are
identical to the ranges tested (Table 2-1).
2: Higher capacitance increases the stability
of the oscillator, but also increases the st artup time.
3: Since each r esonator/crystal has its own
characteristics, the user should consult the
resonator/crystal manufacturer for app ropri ate values of external components.
4: Rs may be required in HS mode, as well as
XT mode, to avoid overdriving crystals with
low drive level specification.
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
EXT) and capacitor ( CEXT) val-
ues 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
EXT values. The user also needs to
take into account variation due to tolerance of external
R and C components used. Figure 2-3 shows how the
R/C combination is connected.
In the RC oscillator mode, the oscillator frequency
divided by 4 is available on the OSC2 pin. This signal
may be used for test purposes or to synchronize other
logic.
FIGURE 2-3:RC OSCILLATOR MODE
VDD
REXT
OSC1
CEXT
VSS
F
Recommended values: 3 kΩ ≤ REXT ≤ 100 k
OSC/4
OSC2/CLKO
EXT > 20pF
C
Internal
clock
PIC18CXXX
Ω
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).
2.4External Clock Input
The EC and ECIO oscillator mode s require an e xternal
clock source to be connected to the OSC1 pi n. The
feedback device between OSC1 and OSC2 is turned
off in these modes to sa v e current. There is no osc illator startup 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 for test purposes or to synchronize other
logic. Figure 2-4 shows the pin conne cti ons for the EC
oscillator mode.
DS39026B-page 16Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
FIGURE 2-4:E XTERN AL CLOCK INPUT
OPERATION
(EC OSC CONFIGURATION)
Clock from
ext. system
OSC/4
F
The ECIO oscillator mode functions like the EC mode,
except that the OSC 2 pin be comes a n addit ional 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.
OSC1
PIC18CXXX
OSC2
FIGURE 2-5:E XTERN AL CLOCK INPUT
OPERATION
(ECIO CONFIGURATION)
Clock from
ext. system
RA6
OSC1
PIC18CXXX
I/O (OSC2)
2.5HS/PLL
A Phase Locked Loop circuit is provided as a programmable option for users that want to multiply the frequency of the incoming crystal oscillator signal 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 bits are programmed for HS mode. If they
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 FOSC<2:0> 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 that is called T
PLL.
FIGURE 2-6:PLL BLOCK DIAGRAM
(from configuration
HS Osc
bit register)
PLL Enable
OSC2
Phase
Comparator
IN
F
Crystal
Osc
FOUT
OSC1
Loop
Filter
Divide by 4
VCO
SYSCLK
MUX
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 17
PIC18CXX2
2.6Oscillator Switching Feature
The PIC18CXX2 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 PIC18CXX2 devices, this alternate clock
source is the Timer1 oscilla tor . If a low-freque ncy crystal (32 KHz, for example) has been attached to the
Timer1 oscillator pins and the Timer1 oscillator has
FIGURE 2-7:DEVICE CLOCK SOURCES
PIC18CXXX
OSC2
OSC1
T1OSO
T1OSI
Main Oscillator
Sleep
Timer1 Oscillator
T1OSCEN
Enable
Oscillator
been enabled, the device can switch to a low power
execution mode. Figure2-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 Configuration R eg ist er1 H to a
’0’. Clock switching is disabled in an erased device.
See Section 9 f or further details of the T imer1 oscillator .
See Section 18.0 for Configuration Register details.
4 x PLL
TOSC
TT1P
Clock Source option
for other modules
Tosc/4
MUX
Clock
Source
TSCLK
2.6.1SYSTEM CLOCK SWITCH BIT
The system clock source switching is performed under
software control. The system clock switch bit, SCS
(OSCCON<0>) controls the cloc k s wi tching . Whe n the
SCS bit is ’0’, the system clock source comes from the
main oscillator that is sel ect ed by the FOSC configur ation bits in Configuration Register1H. When the SCS
bit is set, th e system clock sour ce will come from the
Timer1 oscillator. The SCS bit is cleared on all forms
of reset.
Register 2-1:OSCCON Register
U-0U-0U-0U-0U-0U-0U-0R/W-1
———————
bit 7bit 0
bit 7-1Unim plemented: Read as '0'
bit 0SCS: System Clock Switch bit
OSCSEN configuration bit = ’0’ and T1OSCEN bit is set:
when
1 = Switch to Timer1 Oscillator/Clock pin
0 = Use primary Oscillator/Clock input pin
OSCSEN and T1OSCEN are in other states:
when
bit is forced clear
Note:The Timer1 oscillator must be enabled to
switch the system clock source. The
Timer1 osci llator i s enabled by setting t he
T1OSCEN bit in the Time r1 control register
(T1CON). If the Timer1 oscillator is not
enabled, then any write to the SCS bit will
be ignored (SCS bit forced cleared) and
the main oscillator will continue to be the
system clock source.
SCS
Legend
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR reset’1’ = Bit is set’0’ = Bit is clearedx = Bit is unknown
DS39026B-page 18Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
2.6.2OSCILLATOR TRANSITIONS
A timing diagram indicating the transition from the
main oscillator to the Timer1 oscillator is shown in
The PIC18CXX2 devices contain circuitry to prevent
"glitches" when switching between oscillator sources.
Essential ly, the circuitry waits for eigh t ri sing ed ges of
the clock s ource t hat the pro cessor is s wi tching to . This
ensures that the new clock source is stable and that its
pulse width will not be less than the shortest pulse
Figure 2-8. The Timer1 oscillator is assumed to be
running all the time. After the SCS bit is set, the processor is 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.
width of the two clock sources.
FIGURE 2-8:TIMING DIAGRAM FOR TRANSITION FROM OSC1 TO TIMER1 OSCILLATOR
Q1
T1OSI
OSC1
Internal
System
Clock
SCS
(OSCCON<0>)
Program
Counter
TOSC
Q1
TDLY
TT1P
21345678
Tscs
PC + 2PC
Note1: Delay on internal system clock is eight oscillator cycles for synchronization.
Q3Q2Q1Q4Q3Q2
Q4Q1
Q2Q3Q4Q1
PC + 4
The sequence of events that takes place when switching from the Timer1 oscillator to the main oscillator will
depend on the mode of the main oscillator. In addition
to eight clock cycles of the main oscillator, additional
delays may take place.
If the main oscillator is configured for an external crystal (HS, XT, LP), then the transition will take place after
an oscillator startup 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
OSC2
Internal System
Clock
SCS
(OSCCON<0>)
Program Counter
Q3Q4
PCPC + 2
Q1
TOST
Note1: TOST = 1024TOSC (drawing not to scale).
TT1P
12345678
TSCS
TOSC
Q3
PC + 6
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 19
PIC18CXX2
If the main oscillator is configured f or HS-PLL mode , an
oscillator startup time (T
timeout (T
PLL) will occur . The PL L timeout is typic ally 2
OST) plus an additional PLL
quency. A timing diagram indicating the tran sitio n from
the Timer1 oscillator to the main oscillator for HS-PLL
mode is shown in Figure 2 -10.
ms and allows the PLL to lock to the main o scillato r fre-
FIGURE 2-10: TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (HS WITH PLL)
Q4Q1
T1OSI
OSC1
OSC2
PLL Clock
Input
Internal System
Program Counter
Clock
SCS
(OSCCON<0>)
TOST
PCPC + 2
TPLL
Note 1: TOST = 1024TOSC (drawing not to scale).
TT1P
TOSC
1 234 5678
TSCS
Q1 Q2 Q3 Q4 Q1 Q2
PC + 4
Q3
Q4
If the main os ci lla tor is c on fig ured in the RC, RCIO, EC
or ECIO modes, there is no oscillator startup timeout.
Operation will resume after eight cycles of the main
ing the transition from the Timer1 oscillator to the main
oscillator for R C, RCIO , EC and EC IO modes is shown
in Figure 2-11.
oscillator ha ve been count ed. A timing diagram indicat-
FIGURE 2-11: TIMING FOR TRANSITION BETWEEN TIMER1 AND OSC1 (RC, EC)
Q3Q4
T1OSI
OSC1
OSC2
Internal System
Clock
SCS
(OSCCON<0>)
Program Counter
PCPC + 2
Note 1: RC oscillator mode assumed.
Q1
TOSC
1
TT1P
23
45678
TSCS
Q1 Q2 Q3 Q4 Q1 Q2 Q3
Q4
PC + 4
DS39026B-page 20Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
2.7Effects of Sleep Mode on the On-chip
Oscillator
When the device e xec utes a SLEEP instruction, the onchip clocks and oscillator are turned off and the device
is held at the beginning of an instruction cycle (Q1
state). With the oscill ato r off, the OSC1 and OSC2 si gnals will stop oscillating. Since all the transistor switch-
ing currents have been rem o ved, sleep mode achiev e s
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.
TABLE 2-3:OSC1 AND OSC2 PIN STATES IN SLEEP MODE
OSC ModeOSC1 PinOSC2 Pin
RCFloating, external resistor should pull
high
RCIOFloating, external resistor should pull
high
ECIOFloatingConfigured as Port A, bit 6
ECFloatingAt logic low
LP, XT, and HSFeedback inverter disabled, at quies-
cent voltage level
See Table 3-1, in the “Reset” section, for time-outs due to Sleep and MCLR
2.8Power-up Delays
Pow er up dela ys are control led by two timers, so that n o
external reset circuitry is required f or most applic ations.
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 the
“Reset” section.
The first timer is the Power-up Timer (PWRT), which
optionally provides a fixed delay of 72 ms (nominal) on
power-up only (POR and BOR). The second timer is
the Oscillator Start-up Timer OS T, intended to keep th e
chip in RESET until the crystal oscillator is stable.
With the PLL enabled (HS/PLL oscillator mode), the
time-out sequence following a power-on reset is different from other oscilla tor modes. Th e time-out seque nce
is as follows : First the PWR T time-o ut is inv ok ed after a
POR time delay has expired. Then the Oscillator Startup Timer (OST) is invoked. However, this is still not a
sufficient amount o f time to al low the PL L to loc k at high
frequencies. The PWRT timer is used to provide an
additional fix ed 2ms (nominal) ti me-out to a llow the PLL
ample time to lock to the incoming clock frequency.
At logic low
Configured as P o rt A, bit 6
Feedback inverter disabled, at quiescent voltage level
reset.
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 21
PIC18CXX2
NOTES:
DS39026B-page 22Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
3.0RESET
The PIC18CXXX differentiates between various kinds
of reset:
e)Programmable Brown-out Reset (BOR)
f)Reset Instruction
g)Stack Full rese t
h)Stack Underflow reset
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 state” on
reset during normal operation
reset during SLEEP
operation)
Power-on Reset, MCLR
CLR reset during SLEEP and by the RESET instruc-
M
tion.
Most registers are not affected by a WDT wake-up,
since this is viewed as the resumption of normal operation. Stat us bit s from th e RCON r egiste r, RI
and BOR, are set or clea red diff er ently in diff ere nt
POR
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 descripti on of the rese t
states of all registers.
A simplified bl ock diag ram of the on-ch ip res et circui t is
shown in Figure 3-1.
The Enhanced MCU devices have a MCLR
in the MCLR
reset path. The filter wi ll detect a nd ignore
small pulses.
, WDT reset, Brown-out Reset,
A WDT reset does not drive MCLR pin low.
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
MCLR
SLEEP
WDT
Time-out
Reset
Power-on Reset
BOREN
OST
10-bit Ripple counter
PWRT
10-bit Ripple counter
Enable PWRT
Enable OST
(2)
VDD
OSC1
Module
V
Brown-out
OST/PWRT
On-chip
RC OSC
WDT
DD rise
detect
Reset
(1)
Note1: This is a separate oscillator from the RC oscillator of the CLKIN pin.
2: See Table 3-1 for time-out situations.
S
Chip_Reset
R
Q
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 23
PIC18CXX2
3.1Power-On Reset (POR)
A Power-on Reset pulse is generated on-chip when
V
DD rise is detected. To take advantag e of the P OR cir-
cuitry , ju st tie the MC LR
tor) to V
DD. This will elimi nate e xternal R C compon ents
pin directly (or th rough a resi s-
usually needed to create a Power-on Reset delay. A
maximum rise time for VDD is specified (parameter
D004). For a slow rise time, see Figure 3-2.
When the device starts normal operation (exits the
reset condition), d evice operating p arameters (vol tage,
frequency , temperature ,...) must be m et 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.
FIGURE 3-2:EXTERN AL POWER-ON
RESET CIRCUIT (FOR SLOW
DD POWER-UP)
V
V
DD
D
R
R1
MCLR
C
Note1: External Po wer-on Reset cir cuit is required
only if the V
DD power-up s lop e i s too s low .
The diode D hel ps d isch arge th e ca pacito r
quickly when V
DD powers down.
2: R < 40 kΩ is recommended to make sure
that the voltage drop across R does not
violate the device’s electrical specification.
3: R1 = 100Ω to 1 kΩ will limit any current
flowing into MCLR
C in the event of MCLR/
down due to Electrostatic Discharge
(ESD) or Electrical Overstress (EOS).
PIC18CXXX
from external capacitor
VPP pin break-
3.2Power-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 ke pt in reset a s lon g as the PW R T i s act iv e .
The PWRT’s time delay allows VDD to rise to an acceptable level. A configuration bit is provided to enable/disable the PWRT.
The power-up ti me dela y will v ary from chip-to-chi p due
DD, temperature and process variation. See DC
to V
parameter #33 for details.
3.3Oscillator Start-up Timer (OST)
The Oscillator Start-up Timer (OST) provides 1024
oscillator cycle (from OSC1 input) delay after the
PWRT dela y is ov er (parameter #3 2). This ensures th at
the crystal oscillator or reso nator has started and stabilized.
The OST time-out is invoked only for XT, LP and HS
modes and only on Power-on Reset or wake-up from
SLEEP.
3.4PLL Lock Timeout
With the PLL enabled, the timeout sequence following
a power-on reset is different from other oscillator
modes. A portion of the P ow er-up Timer is use d to provide a fixed timeout that is sufficient for the PLL to lock
to the main oscillator fre que nc y. This PLL lock timeout
PLL) is typically 2 ms and follows the oscillator startup
(T
timeout (OST).
3.5Brown-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 will reset
the chip. A reset may not occur if V
parameter D005 for less than parameter #35. The chip
will remain in Brown-out Reset until VDD rises above
DD. The Po wer-up Tim er will then be in vok ed and will
BV
keep the chip in RESET an additional time delay
(parameter #33). If VDD drops below BVDD while the
Power-up Timer is running, the chip will go back into a
Brown-out Reset and the Power-up Timer will be initialized. Once V
DD rises abo v e BV DD, the Power-up Timer
will execute the additional time delay.
DD falls below
DS39026B-page 24Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
3.6Time-out Sequence
On power-up , the time-out sequence is as f ollows: 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 oscillat or config urati on and the s tatu s of
the PWRT. For example, 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 oc cur from the POR p ulse, 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 PIC18CXXX device ope rating in parallel.
Table 3-2 shows the re set condi tio ns for som e Spe cial
Function Registers, while Table 3-3 shows the reset
conditions for all the registers.
high will begin execution immediately
TABLE 3-1:TIME-OUT IN VARIOUS SITUATIONS
Oscillator
Configuration
HS with PLL enabled
HS, XT, LP72 ms + 1024Tosc1024Tosc72 ms + 1024Tosc1024Tosc
EC72 ms—72 ms—
External RC72 ms—72 ms—
Note1: 2 ms = Nominal time required for the 4x PLL to lock.
2: 72 ms is the nominal power-up timer delay
Power-up
(1)
72 ms + 1024Tosc + 2ms 1024Tosc + 2 ms 72 ms + 1024To sc + 2ms 1024Tosc + 2 ms
(2)
Brown-out
(2)
Wake-up from
SLEEP or
Oscillator SwitchPWRTE = 0PWRTE = 1
Register 3-1:RCON Register Bits and Positions
R/W-0R/W-0U-0R/W-1R/W-1R/W-1R/W-1R/W-1
IPENLWRT
bit 7bit 0
—RITOPDPORBOR
TABLE 3-2:STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION FOR
RCON REGISTER
Program
Condition
Power-on Reset0000h00-1 110011100uu
Reset during normal
MCLR
operation
Software Reset during normal
operation
Stack Full Reset during normal
operation
Stack Underflow Reset during
normal operation
MCLR Reset during SLEEP0000h00-u 10uuu10uuuu
WDT Reset0000h0u-u 01uu101uuuu
WDT Wake-upPC + 2uu-u 00uuu00uuuu
Brown-out Reset0000h0u-1 11u011110uu
Interrupt wake-up from SLEEP
Legend: u = unchanged, x = unknown, — = unimplemented bit read as '0'.
Note1: 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 (0x000008h or 0x000018h).
Counter
0000h00-u uuuuuuuuuuu
0000h0u-0 uuuu0uuuuuu
0000h0u-u uu11uuuuuu1
0000h0u-u uu11uuuuu1u
PC + 2
RCON
RegisterRITOPDPORBORSTKFULSTKUNF
(1)
uu-u 00uuu10uuuu
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 25
PIC18CXX2
TABLE 3-3:INITIALIZATION CONDITIONS FOR ALL REGISTERS
POSTINC0242442252452N/AN/AN/A
POSTDEC0 242442252452N/AN/AN/A
PREINC0242442252452N/AN/AN/A
PLUSW0242442252452N/AN/AN/A
FSR0H242442252452---- 0000---- 0000---- uuuu
FSR0L242442252452xxxx xxxxuuuu uuuuuuuu uuuu
WREG242442252452xxxx xxxxuuuu uuuuuuuu uuuu
INDF1242442252452N/AN/AN/A
POSTINC1242442252452N/AN/AN/A
POSTDEC1 242442252452N/AN/AN/A
PREINC1242442252452N/AN/AN/A
PLUSW1242442252452N/AN/AN/A
Legend: u = unchanged, x = unknown, - = unimplemented bit, read as ’0’, q = value depends on condition
Note1: One or more bits in the INTCONx or PIRx registers will be affected (to cause wake-up).
2: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the PC is loaded with the interrupt
vector (0008h or 0018h).
3: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the TOSU, TO SH and TOSL are
updated with the current value of the PC. The STKPTR is modified to point to the next location in the hardware stack.
4: See Table 3-2 for reset value for specific condition.
5: Bit 6 of PORTA, LATA, and TRISA are enabled in ECIO and RCIO oscillator modes only. In all other
oscillator modes, they are disabled and read ’0’.
6: The long write enable is only reset on a POR or MCLR
7: Bit 6 of PORTA, LATA and TRISA are not available on all devices. When unimplemented, they are read ’0’.
Reset Instruction
Stack Resets
reset.
Wake-up via WDT
or Interrupt
---0 uuuu
uuuu uuuu
uuuu uuuu
uu-u uuuu
PC + 2
uuuu uuuu
uuuu -u-u
uu-u u-uu
(3)
(3)
(3)
(3)
(2)
(1)
(1)
(1)
DS39026B-page 26Preliminary
7/99 Microchip Technology Inc.
PIC18CXX2
TABLE 3-3:INITIALIZATION CONDITIONS FOR ALL REGISTERS (Cont.’d)
Note1: One or more bits in the INTCONx or PIRx registers will be affected (to cause wake-up).
2: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the PC is loaded with the interrupt
3: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the TOSU, TO SH and TOSL are
4: See Table 3-2 for reset value for specific condition.
5: Bit 6 of PORTA, LATA, and TRISA are enabled in ECIO and RCIO oscillator modes only. In all other
6: The long write enable is only reset on a POR or MCLR
7: Bit 6 of PORTA, LATA and TRISA are not available on all devices. When unimplemented, they are read ’0’.
24244225245200-1 11q000-1 qquuuu-u qquu
vector (0008h or 0018h).
updated with the current value of the PC. The STKPTR is modified to point to the next location in the hard-
ware stack.
oscillator modes, they are disabled and read ’0’.
Brown-out Reset
Reset Instruction
Stack Resets
reset.
Wake-up via WDT
or Interrupt
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 27
PIC18CXX2
TABLE 3-3:INITIALIZATION CONDITIONS FOR ALL REGISTERS (Cont.’d)
Legend: u = unchanged, x = unknown, - = unimplemented bit, read as ’0’, q = value depends on condition
Note1: One or more bits in the INTCONx or PIRx registers will be affected (to cause wake-up).
2: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the PC is loaded with the interrupt
3: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the TOSU, TO SH and TOSL are
4: See Table 3-2 for reset value for specific condition.
5: Bit 6 of PORTA, LATA, and TRISA are enabled in ECIO and RCIO oscillator modes only. In all other
6: The long write enable is only reset on a POR or MCLR
7: Bit 6 of PORTA, LATA and TRISA are not available on all devices. When unimplemented, they are read ’0’.
Legend: u = unchanged, x = unknown, - = unimplemented bit, read as ’0’, q = value depends on condition
Note1: One or more bits in the INTCONx or PIRx registers will be affected (to cause wake-up).
2: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the PC is loaded with the interrupt
vector (0008h or 0018h).
3: When the wake-up is due to an interrupt and the GIEL or GIEH bit is set, the TOSU, TO SH and TOSL are
updated with the current value of the PC. The STKPTR is modified to point to the next location in the hardware stack.
4: See Table 3-2 for reset value for specific condition.
5: Bit 6 of PORTA, LATA, and TRISA are enabled in ECIO and RCIO oscillator modes only. In all other
oscillator modes, they are disabled and read ’0’.
6: The long write enable is only reset on a POR or MCLR
7: Bit 6 of PORTA, LATA and TRISA are not available on all devices. When unimplemented, they are read ’0’.
Reset Instruction
Stack Resets
-111 1111
-uuu uuuu
-u0u 0000
reset.
(5)
(5)
(5)
Wake-up via WDT
or Interrupt
-uuu uuuu
-uuu uuuu
-uuu uuuu
(5)
(5)
(5)
7/99 Microchip Technology Inc.
PreliminaryDS39026B-page 29
PIC18CXX2
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
TPWRT
PWRT TIME-OUT
OST TIME-OUT
INTERNAL RESET
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
DS39026B-page 30Preliminary
NOT TIED TO VDD ): CASE 2
TOST
7/99 Microchip Technology Inc.
Loading...
+ 266 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.