Professional Documents
Culture Documents
EUSART
Program Memory Data Memory 10-bit CCP/ MSSP
(1) Timers
Device Flash # Single-Word SRAM EEPROM I/O A/D ECCP Master Comp.
SPI 8/16-bit
(bytes) Instructions (bytes) (bytes) (ch)(2) (PWM) I2C™
PIC18F23K20 8K 4096 512 256 25 11 1/1 Y Y 1 2 1/3
PIC18F24K20 16K 8192 768 256 25 11 1/1 Y Y 1 2 1/3
PIC18F25K20 32K 16384 1536 256 25 11 1/1 Y Y 1 2 1/3
PIC18F26K20 64k 32768 3936 1024 25 11 1/1 Y Y 1 2 1/3
PIC18F43K20 8K 4096 512 256 36 14 1/1 Y Y 1 2 1/3
PIC18F44K20 16K 8192 768 256 36 14 1/1 Y Y 1 2 1/3
PIC18F45K20 32K 16384 1536 256 36 14 1/1 Y Y 1 2 1/3
PIC18F46K20 64k 32768 3936 1024 36 14 1/1 Y Y 1 2 1/3
Note 1: One pin is input-only.
2: Channel count includes internal Fixed Voltage Reference channel.
Note: For other small form-factor package availability and marking information, please visit
http://www.microchip.com/packaging or contact your local sales office.
PIC18F23K20
PIC18F24K20
PIC18F25K20
PIC18F26K20
T0CKI/C1OUT/RA4 6 23 RB2/INT2/AN8/P1B
AN4/SS/HLVDIN/C2OUT/RA5 7 22 RB1/INT1/AN10/C12IN3-/P1C
VSS 8 21 RB0/INT0/FLT0/AN12
OSC1/CLKIN/RA7 9 20 VDD
OSC2/CLKOUT/RA6 10 19 VSS
T1OSO/T13CKI/RC0 11 18 RC7/RX/DT
T1OSI/CCP2(1)/RC1 12 17 RC6/TX/CK
CCP1/P1A/RC2 13 16 RC5/SDO
SCK/SCL/RC3 14 15 RC4/SDI/SDA
RB4/KBI0/AN11/P1D
RA1/AN1/C12IN1-
RA0/AN0/C12IN0-
RE3/MCLR/VPP
RB5/KBI1/PGM
RB7/KBI3/PGD
RB6/KBI2/PGC
28 27 26 25 24 23 22
AN2/VREF-/CVREF/C2IN+/RA2 1 21 RB3/AN9/C12IN2-/CCP2(1)
AN3/VREF+/C1IN+/RA3 2 PIC18F23K20 20 RB2/INT2/AN8/P1B
T0CKI/C1OUT/RA4 3 PIC18F24K20 19 RB1/INT1/AN10/C12IN3-/P1C
AN4/SS/HLVDIN/C2OUT/RA5 4 PIC18F25K20 18 RB0/INT0/FLT0/AN12
VSS 5 PIC18F26K20 17 VDD
OSC1/CLKIN/RA7 6 16 VSS
OSC2/CLKOUT/RA6 7 15 RC7/RX/DT
8 9 10 11 12 13 14
T1OSO/T13CKI/RC0
SDO/RC5
T1OSI/CCP2(1)/RC1
CCP1/P1A/RC2
SDI/SDA/RC4
SCK/SCL/RC3
TX/CK/RC6
MCLR/VPP/RE3 1 40 RB7/KBI3/PGD
AN0/C12IN0-/RA0 2 39 RB6/KBI2/PGC
AN1/C12IN1-/RA1 3 38 RB5/KBI1/PGM
AN2/VREF-/CVREF/C2IN+/RA2 4 37 RB4/KBI0/AN11
AN3/VREF+/C1IN+/RA3 5 36 RB3/AN9/C12IN2-/CCP2(1)
T0CKI/C1OUT/RA4 6 35 RB2/INT2/AN8
AN4/SS/HLVDIN/C2OUT/RA5 7 34 RB1/INT1/AN10/C12IN3-
RD/AN5/RE0 8 33 RB0/INT0/FLT0/AN12
PIC18F43K20
PIC18F44K20
PIC18F45K20
PIC18F46K20
WR/AN6/RE1 9 32 VDD
CS/AN7/RE2 10 31 VSS
VDD 11 30 RD7/PSP7/P1D
VSS 12 29 RD6/PSP6/P1C
OSC1/CLKIN/RA7 13 28 RD5/PSP5/P1B
OSC2/CLKOUT/RA6 14 27 RD4/PSP4
T1OSO/T13CKI/RC0 15 26 RC7/RX/DT
T1OSI/CCP2(1)/RC1 16 25 RC6/TX/CK
CCP1/P1A/RC2 17 24 RC5/SDO
SCK/SCL/RC3 18 23 RC4/SDI/SDA
PSP0/RD0 19 22 RD3/PSP3
PSP1/RD1 20 21 RD2/PSP2
RC1/T1OSI/CCP2
RC2/CCP1/P1A
RC3/SCK/SCL
RC4/SDI/SDA
RC6/TX/Ck
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC5/SDO
40 39 38 37 36 35 34 33 32 31
RX/DT/RC7 1
RD4/PSP4/RD4 2 30 RC0/T1OSO/T13CKI
PSP5/P1B/RD5 3 29 RA6/OSC2/CLKOUT
RD6/PSP6/P1C/RD6 4 28 RA7/OSC1/CLKIN
PSP7/P1D/RD7 5 27 VSS
VSS 6 PIC18F4XK20 26 VDD
VDD 7 25 RE2/CS/AN7
INT0/FLT0/AN12/RB0 8 24 RE1/WR/AN6
INT1/AN10/C12IN3-/RB1 9 23 RE0/RD/AN5
INT2/AN8/RB2 10 22 RA5/AN4/SS/HLVDIN/C2OUT
21 RA4/T0CKI/C1OUT
11 12 13 14 15 16 17 18 19 20
KBI0/AN11/RB4
KBI3/PGD/RB7
KBI2/PGC/RB6
AN9/C12IN2-/CCP/RB3
KBI1/PGM/RB5
MCLR/VPP/RE3
AN0/C12IN0-/RA0
AN2/VREF-/CVREF/C2IN+/RA2
AN3/VREF+/C1IN+/RA3
AN1/C12/IN1-/RA1
RC1/T1OSI/CCP2(1)
RC0/T1OSO/T13CKI
RC2/CCP1/P1A
RC3/SCK/SCL
RC4/SDI/SDA
RC6/TX/CK
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC5/SDO
44
43
42
41
40
39
38
37
36
35
34
RX/DT/RC7 1 33 RA6/OSC2/CLKOUT
RD4/PSP4/RD4 2 32 RA7/OSC1/CLKIN
PSP5/P1B/RD5 3 31 VSS
PSP6/P1C/RD6 4 PIC18F43K20 30 VSS
PSP7/P1D/RD7 5 PIC18F44K20 29 VDD
VSS 6 PIC18F45K20 28 VDD
VDD 7 PIC18F46K20 27 RE2/CS/AN7
VDD 8 26 RE1/WR/AN6
INT0/FLT0/AN12/RB0 9 25 RE0/RD/AN5
INT1/AN10/C12IN3-/RB1 10 24 RA5/AN4/SS/HLVDIN/C2OUT
INT2/AN8/RB2 11 23 RA4/T0CKI/C1OUT
12
13
14
15
16
17
18
19
20
21
22
AN2/VREF-/CVREF/C2IN+/RA2
AN9/C12IN2-/CCP2(1)/RB3
KBI0/AN11/RB4
AN3/VREF+/C1IN+/RA3
KBI1/PGM/RB5
KBI2/PGC/RB6
KBI3/PGD/RB7
MCLR/VPP/RE3
AN0/C12IN0-/RA0
AN1/C12IN1-/RA1
NC
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC5/SDO
NC
44
43
42
41
40
39
38
37
36
35
34
RX/DT/RC7 1 33 NC
PSP4/RD4 2 32 RC0/T1OSO/T13CKI
PSP5/P1B/RD5 3 31 RA6/OSC2/CLKOUT
PSP6/P1C/RD6 4 PIC18F43K20 30 RA7/OSC1/CLKIN
PSP7/P1D/RD7 5 PIC18F44K20 29 VSS
VSS 6 PIC18F45K20 28 VDD
VDD 7 PIC18F46K20 27 RE2/CS/AN7
INT0/FLT0/AN12/RB0 8 26 RE1/WR/AN6
INT1/AN10/C12IN3-/RB1 9 25 RE0/RD/AN5
INT2/AN8/RB2 10 24 RA5/AN4/SS/HLVDIN/C2OUT
AN9/C12IN2-/CCP2(1)/RB3 11 23 RA4/T0CKI/C1OUT
12
13
14
15
16
17
18
19
20
21
22
KBI0/AN11/RB4
AN3/VREF+/C1IN+/RA3
KBI1/PGM/RB5
KBI2/PGC/RB6
KBI3/PGD/RB7
MCLR/VPP/RE3
AN0/C12IN0-/RA0
AN1/C12IN1-/RA1
NC
NC
AN2/VREF-/CVREF/C2IN+/RA2
28-Pin QFN/UQFN
Comparator
Reference
Interrupts
EUSART
Analog
Pull-up
Timers
MSSP
ECCP
Basic
Slave
I/O
40-Pin UQFN
44-Pin TQFP
40-Pin PDIP
44-Pin QFN
Reference
Interrupts
EUSART
Analog
Pull-up
Timers
Comp.
MSSP
ECCP
Basic
Slave
I/O
40-Pin UQFN
44-Pin TQFP
40-Pin PDIP
44-Pin QFN
Reference
Interrupts
EUSART
Analog
Pull-up
Timers
Comp.
MSSP
ECCP
Basic
Slave
I/O
RE1 9 24 26 26 AN6 — — — — — — WR — — —
RE2 10 25 27 27 AN7 — — — — — — CS — — —
RE3(3) 1 16 18 18 — — — — — — — — — — MCLR/VPP
— 11 7 7 7 — — — — — — — — — — VDD
— 32 26 28 28 — — — — — — — — — — VDD
— 12 6 6 6 — — — — — — — — — — VSS
— 31 27 29 30 — — — — — — — — — — VSS
— – — NC 8 — — — — — — — — — — VDD
— – — NC 29 — — — — — — — — — — VDD
— –- — NC 31 — — — — — — — — — — VSS
Note 1: CCP2 multiplexed with RB3 when CONFIG3H<0> = 0
2: CCP2 multiplexed with RC1 when CONFIG3H<0> = 1
3: Input-only.
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.
PIC18F2XK20/4XK20
Instruction, Stack Instruction, Stack Instruction, Stack Instruction, Stack Instruction, Stack Instruction, Stack Instruction, Stack Instruction, Stack
Full, Stack Underflow Full, Stack Underflow Full, Stack Underflow Full, Stack Underflow Full, Stack Underflow Full, Stack Underflow Full, Stack Underflow Full, Stack
(PWRT, OST), (PWRT, OST), MCLR (PWRT, OST), (PWRT, OST), MCLR (PWRT, OST), (PWRT, OST), (PWRT, OST), Underflow (PWRT,
MCLR (optional), (optional), WDT MCLR (optional), (optional), WDT MCLR (optional), MCLR (optional), MCLR (optional), OST), MCLR
WDT WDT WDT WDT WDT (optional), WDT
Programmable High/ Yes Yes Yes Yes Yes Yes Yes Yes
Low-Voltage Detect
Programmable Brown- Yes Yes Yes Yes Yes Yes Yes Yes
out Reset
Instruction Set 75 Instructions; 83 75 Instructions; 83 75 Instructions; 83 75 Instructions; 83 75 Instructions; 83 75 Instructions; 83 75 Instructions; 83 75 Instructions; 83
with Extended with Extended with Extended with Extended with Extended with Extended with Extended with Extended
Instruction Set Instruction Set Instruction Set Instruction Set Instruction Set Instruction Set Instruction Set Instruction Set
enabled enabled enabled enabled enabled enabled enabled enabled
Packages 28-pin PDIP 28-pin PDIP 28-pin PDIP 28-pin PDIP 40-pin PDIP 40-pin PDIP 40-pin PDIP 40-pin PDIP
28-pin SOIC 28-pin SOIC 28-pin SOIC 28-pin SOIC 44-pin QFN 44-pin QFN 44-pin QFN 44-pin QFN
DS40001303H-page 13
28-pin QFN 28-pin QFN 28-pin QFN 28-pin QFN 44-pin TQFP 44-pin TQFP 44-pin TQFP 44-pin TQFP
28-pin SSOP 28-pin SSOP 28-pin SSOP 28-pin SSOP 40-pin UQFN 40-pin UQFN 40-pin UQFN 40-pin UQFN
28-pin UQFN
Note 1: PORTE contains the single RE3 read-only bit. The LATE and TRISE registers are not implemented.
2: Frequency range shown applies to industrial range devices only. Maximum frequency for extended range devices is 48 MHz.
PIC18F2XK20/4XK20
FIGURE 1-1: PIC18F2XK20 (28-PIN) BLOCK DIAGRAM
Data Bus<8>
Table Pointer<21>
8
Instruction State machine
Decode and control signals
Control
PRODH PRODL
PORTC
8 x 8 Multiply RC0/T1OSO/T13CKI
3 8 RC1/T1OSI/CCP2(1)
RC2/CCP1
BITOP W RC3/SCK/SCL
8 8 8
RC4/SDI/SDA
Internal RC5/SDO
OSC1(3) Power-up RC6/TX/CK
Oscillator 8 8
Block Timer RC7/RX/DT
(3) Oscillator
OSC2 ALU<8>
LFINTOSC Start-up Timer
T1OSI Oscillator Power-on 8
Reset
16 MHz
T1OSO Oscillator Watchdog
Timer
Precision FVR
Single-Supply Brown-out Band Gap
MCLR(2) PORTE
Programming Reset Reference
In-Circuit Fail-Safe
VDD, VSS Clock Monitor
Debugger MCLR/VPP/RE3(2)
BOR Data
EEPROM Timer0 Timer1 Timer2 Timer3
HLVD
FVR
ADC FVR
CVREF Comparator ECCP1 CCP2 MSSP EUSART 10-bit
Note 1: CCP2 is multiplexed with RC1 when Configuration bit CCP2MX is set, or RB3 when CCP2MX is not set.
2: RE3 is only available when MCLR functionality is disabled.
3: OSC1/CLKIN and OSC2/CLKOUT are only available in select oscillator modes and when these pins are not being used as digital I/O.
Refer to Section 2.0 “Oscillator Module (With Fail-Safe Clock Monitor)” for additional information.
BOR Data
EEPROM Timer0 Timer1 Timer2 Timer3
HLVD
FVR
ADC FVR
CVREF Comparator ECCP1 CCP2 MSSP EUSART PSP
10-bit
Note 1: CCP2 is multiplexed with RC1 when Configuration bit CCP2MX is set, or RB3 when CCP2MX is not set.
2: RE3 is only available when MCLR functionality is disabled.
3: OSC1/CLKIN and OSC2/CLKOUT are only available in select oscillator modes and when these pins are not being used as digital I/O.
Refer to Section 2.0 “Oscillator Module (With Fail-Safe Clock Monitor)” for additional information.
PIC18F2XK20/4XK20
Primary Oscillator LP, XT, HS, RC, EC
OSC2
IDLEN
Sleep HSPLL, HFINTOSC/PLL
4 x PLL Sleep
OSC1
OSCTUNE<6>(1)
Secondary Oscillator T1OSC Peripherals
MUX
Main
T1OSO
T1OSCEN
Enable
T1OSI Oscillator OSCCON<6:4> Internal Oscillator
2 MHz Clock
Control
MUX
16 MHz 100
Source 1 MHz
16 MHz 011
(HFINTOSC) 500 kHz
31 kHz 010 FOSC<3:0> OSCCON<1:0>
Source 250 kHz
001
1 31 kHz Clock Source Option
31 kHz (LFINTOSC) 000 for other Modules
0
OSCTUNE<7>
WDT, PWRT, FSCM
and Two-Speed Start-up
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ q = depends on condition
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Figure 2-3 and Figure 2-4 show typical circuits for FIGURE 2-4: CERAMIC RESONATOR
quartz crystal and ceramic resonators, respectively.
OPERATION
(XT OR HS MODE)
FIGURE 2-3: QUARTZ CRYSTAL
OPERATION (LP, XT OR
PIC® MCU
HS MODE)
OSC1/CLKIN
PIC® MCU
C1 To Internal
OSC1/CLKIN Logic
C2 RS(1) OSC2/CLKOUT
Note 1: A series resistor (RS) may be required for
ceramic resonators with low drive level.
Note 1: A series resistor (RS) may be required for 2: The value of RF varies with the Oscillator mode
quartz crystals with low drive level. selected (typically between 2 M to 10 M.
2: The value of RF varies with the Oscillator mode 3: An additional parallel feedback resistor (RP)
selected (typically between 2 M to 10 M. may be required for proper ceramic resonator
operation.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PLLEN bit is active only when the HFINTOSC is the primary clock source (FOSC<2:0> = 100X) and
the selected frequency is 8 MHz or 16 MHz. Otherwise, the PLLEN bit is unavailable and always reads ‘0’.
• IRCF<2:0> bits of the OSCCON register = 000 and 2.5.5.1 Compensating with the EUSART
INTSRC bit of the OSCTUNE register = 0
An adjustment may be required when the EUSART
• Power-up Timer (PWRT) begins to generate framing errors or receives data with
• Watchdog Timer (WDT) errors while in Asynchronous mode. Framing errors
• Fail-Safe Clock Monitor (FSCM) indicate that the device clock frequency is too high; to
adjust for this, decrement the value in OSCTUNE to
2.5.4 FREQUENCY SELECT BITS (IRCF) reduce the clock frequency. On the other hand, errors
The output of the 16 MHz HFINTOSC and 31 kHz in data may suggest that the clock speed is too low; to
LFINTOSC connects to a postscaler and multiplexer compensate, increment OSCTUNE to increase the
(see Figure 2-1). The Internal Oscillator Frequency clock frequency.
Select bits IRCF<2:0> of the OSCCON register select
the output frequency of the internal oscillators. One of 2.5.5.2 Compensating with the Timers
eight frequencies can be selected via software: This technique compares device clock speed to some
• 16 MHz reference clock. Two timers may be used; one timer is
clocked by the peripheral clock, while the other is
• 8 MHz
clocked by a fixed reference source, such as the
• 4 MHz Timer1 oscillator.
• 2 MHz
Both timers are cleared, but the timer clocked by the
• 1 MHz (Default after Reset) reference generates interrupts. When an interrupt
• 500 kHz occurs, the internally clocked timer is read and both
• 250 kHz timers are cleared. If the internally clocked timer value
• 31 kHz (LFINTOSC or HFINTOSC/512) is greater than expected, then the internal oscillator
block is running too fast. To adjust for this, decrement
the OSCTUNE register.
Note: Following any Reset, the IRCF<2:0> bits
of the OSCCON register are set to ‘011’ 2.5.5.3 Compensating with the CCP Module
and the frequency selection is set to in Capture Mode
1 MHz. The user can modify the IRCF bits A CCP module can use free running Timer1 (or Timer3),
to select a different frequency. clocked by the internal oscillator block and an external
event with a known period (i.e., AC power frequency).
The time of the first event is captured in the
CCPRxH:CCPRxL registers and is recorded for use later.
When the second event causes a capture, the time of the
first event is subtracted from the time of the second
event. Since the period of the external event is known,
the time difference between events can be calculated.
If the measured time is much greater than the calcu-
lated time, the internal oscillator block is running too
fast; to compensate, decrement the OSCTUNE register.
If the measured time is much less than the calculated
time, the internal oscillator block is running too slow; to
compensate, increment the OSCTUNE register.
OSC2
Phase
HS Mode FIN Comparator
OSC1 Crystal FOUT
Osc
Loop
Filter
4 VCO
SYSCLK
MUX
Old Clock
Start-up Time(1) Clock Sync Running
New Clock
System Clock
Old Clock
Start-up Time(1) Clock Sync Running
New Clock
System Clock
Note 1: Start-up time includes TOST (1024 TOSC) for external clocks, plus TPLL (approx. 2 ms) for HSPLL mode.
Sample Clock
System Oscillator
Clock Failure
Output
Note: The system clock is normally at a much higher frequency than the sample clock. The relative frequencies in
this example have been chosen for clarity.
OSC1
CPU
Clock
Peripheral
Clock
Sleep
Program
Counter PC PC + 2
OSC1
TOST(1) TPLL(1)
PLL Clock
Output
CPU Clock
Peripheral
Clock
Program PC PC + 2 PC + 4 PC + 6
Counter
Wake Event OSTS bit set
Note1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
Q1 Q2 Q3 Q4 Q1
OSC1
CPU Clock
Peripheral
Clock
Program PC PC + 2
Counter
FIGURE 3-4: TRANSITION TIMING FOR WAKE FROM IDLE TO RUN MODE
Q1 Q2 Q3 Q4
OSC1
TCSD
CPU Clock
Peripheral
Clock
Program PC
Counter
Wake Event
TABLE 3-3: EXIT DELAY ON WAKE-UP BY RESET FROM SLEEP MODE OR ANY IDLE MODE
(BY CLOCK SOURCES)
Clock Source Clock Source Clock Ready Status
Exit Delay
before Wake-up after Wake-up Bit (OSCCON)
LP, XT, HS
Primary Device Clock HSPLL OSTS
TCSD(1)
(PRI_IDLE mode) EC, RC
HFINTOSC(2) IOFS
LP, XT, HS TOST(3)
HSPLL TOST + tPLL(3) OSTS
T1OSC or LFINTOSC(1)
EC, RC TCSD(1)
HFINTOSC(1) TIOBST(4) IOFS
LP, XT, HS TOST(4)
HSPLL TOST + tPLL(3) OSTS
HFINTOSC(2)
EC, RC TCSD(1)
HFINTOSC(1) None IOFS
LP, XT, HS TOST(3)
None HSPLL TOST + tPLL(3) OSTS
(Sleep mode) EC, RC TCSD(1)
HFINTOSC(1) TIOBST(4) IOFS
Note 1: TCSD (parameter 38) is a required delay when waking from Sleep and all Idle modes and runs concurrently
with any other required delays (see Section 3.4 “Idle Modes”). On Reset, HFINTOSC defaults to 1 MHz.
2: Includes both the HFINTOSC 16 MHz source and postscaler derived frequencies.
3: TOST is the Oscillator Start-up Timer (parameter 32). tPLL is the PLL Lock-out Timer (parameter F12).
4: Execution continues during the HFINTOSC stabilization period, TIOBST (parameter 39).
External Reset
MCLRE
MCLR
( )_IDLE
Sleep
WDT
Time-out
VDD POR
Detect
VDD
Brown-out
Reset
BOREN S
OST/PWRT
OST(2) 1024 Cycles
Chip_Reset
10-bit Ripple Counter R Q
OSC1
32 s
PWRT(2) 65.5 ms
LFINTOSC 11-bit Ripple Counter
Enable PWRT
Enable OST(1)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When CONFIG2L[2:1] = 01, then the SBOREN Reset state is ‘1’; otherwise, it is ‘0’.
2: The actual Reset value of POR is determined by the type of device Reset. See the notes following this
register and Section 4.6 “Reset State of Registers” for additional information.
3: See Table 4-3.
Note 1: Brown-out Reset is indicated when BOR is ‘0’ and POR is ‘1’ (assuming that both POR and BOR were set
to ‘1’ by firmware immediately after POR).
2: It is recommended that the POR bit be set after a Power-on Reset has been detected so that subsequent
Power-on Resets may be detected.
HSPLL 66 ms(1) + 1024 TOSC + 2 ms(2) 1024 TOSC + 2 ms(2) 1024 TOSC + 2 ms(2)
HS, XT, LP 66 ms(1) + 1024 TOSC 1024 TOSC 1024 TOSC
EC, ECIO 66 ms(1) — —
RC, RCIO 66 ms(1) — —
(1)
INTIO1, INTIO2 66 ms — —
Note 1: 66 ms (65.5 ms) is the nominal Power-up Timer (PWRT) delay.
2: 2 ms is the nominal time required for the PLL to lock.
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-4: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 1
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-5: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 2
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-7: TIME-OUT SEQUENCE ON POR W/PLL ENABLED (MCLR TIED TO VDD)
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
PLL TIME-OUT
INTERNAL RESET
TABLE 4-3: STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION
FOR RCON REGISTER
Program RCON Register STKPTR Register
Condition
Counter SBOREN RI TO PD POR BOR STKFUL STKUNF
Power-on Reset 0000h 1 1 1 1 0 0 0 0
RESET Instruction 0000h u(2) 0 u u u u u u
(2)
Brown-out Reset 0000h u 1 1 1 u 0 u u
MCLR during Power-Managed 0000h u(2) u 1 u u u u u
Run Modes
MCLR during Power-Managed 0000h u(2) u 1 0 u u u u
Idle Modes and Sleep Mode
WDT Time-out during Full Power 0000h u(2) u 0 u u u u u
or Power-Managed Run Mode
MCLR during Full Power 0000h u(2) u u u u u u u
Execution
Stack Full Reset (STVREN = 1) 0000h u(2) u u u u u 1 u
Stack Underflow Reset 0000h u(2) u u u u u u 1
(STVREN = 1)
Stack Underflow Error (not an 0000h u(2) u u u u u u 1
actual Reset, STVREN = 0)
WDT Time-out during PC + 2 u(2) u 0 0 u u u u
Power-Managed Idle or Sleep
Modes
Interrupt Exit from PC + 2(1) u(2) u u 0 u u u u
Power-Managed Modes
Legend: u = unchanged
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 (008h or 0018h).
2: Reset state is ‘1’ for SBOREN and unchanged for all other Resets when software BOR is enabled
(BOREN<1:0> Configuration bits = 01). Otherwise, the Reset state is ‘0’.
FIGURE 5-1: PROGRAM MEMORY MAP AND STACK FOR PIC18F2XK20/4XK20 DEVICES
PC<20:0>
CALL,RCALL,RETURN 21
RETFIE,RETLW
Stack Level 1
Stack Level 31
PIC18F24K20/ On-Chip
Program Memory
44K20
7FFFh
8000h
PIC18F25K20/
45K20
FFFFh
10000h
Read ‘0’ Read ‘0’ Read ‘0’
PIC18F26K20/
46K20
Read ‘0’
1FFFFFh
200000h
11111
11110
Top-of-Stack Registers 11101 Stack Pointer
Legend:
R = Readable bit W = Writable bit U = Unimplemented C = Clearable only bit
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
Q1
Q2 Internal
Q3 Phase
Clock
Q4
PC PC PC + 2 PC + 4
OSC2/CLKOUT
(RC mode)
Execute INST (PC – 2)
Fetch INST (PC) Execute INST (PC)
Fetch INST (PC + 2) Execute INST (PC + 2)
Fetch INST (PC + 4)
All instructions are single cycle, except for any program branches. These take two cycles since the fetch instruction
is “flushed” from the pipeline while the new instruction is being fetched and then executed.
5.2.4 TWO-WORD INSTRUCTIONS and used by the instruction sequence. If the first word
is skipped for some reason and the second word is
The standard PIC18 instruction set has four two-word
executed by itself, a NOP is executed instead. This is
instructions: CALL, MOVFF, GOTO and LSFR. In all
necessary for cases when the two-word instruction is
cases, the second word of the instruction always has
preceded by a conditional instruction that changes the
‘1111’ as its four Most Significant bits; the other 12 bits
PC. Example 5-4 shows how this works.
are literal data, usually a data memory address.
The use of ‘1111’ in the 4 MSbs of an instruction Note: See Section 5.6 “PIC18 Instruction
specifies a special form of NOP. If the instruction is Execution and the Extended Instruc-
executed in proper sequence – immediately after the tion Set” for information on two-word
first word – the data in the second word is accessed instructions in the extended instruction set.
When ‘a’ = 0:
BSR<3:0> Data Memory Map
The BSR is ignored and the
00h 000h Access Bank is used.
= 0000 Access RAM 05Fh
Bank 0 The first 96 bytes are
GPR 060h
FFh 0FFh general purpose RAM
00h 100h (from Bank 0).
= 0001
Bank 1 GPR The second 160 bytes are
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4
FFh 4FFh
= 0101 00h 500h
Bank 5
FFh 5FFh
= 0110 00h 600h
Bank 6
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
FFh 8FFh
= 1001 00h Unused 900h
Bank 9 Read 00h
FFh 9FFh
00h A00h
= 1010
Bank 10
FFh AFFh
= 1011 00h B00h
Bank 11
FFh BFFh
= 1100 00h C00h
Bank 12
FFh CFFh
= 1101 D00h
Bank 13 00h
FFh DFFh
00h E00h
= 1110
Bank 14
FFh EFFh
00h Unused F00h
= 1111 F5Fh
Bank 15
SFR F60h
FFh FFFh
When ‘a’ = 0:
BSR<3:0> Data Memory Map
The BSR is ignored and the
00h 000h Access Bank is used.
= 0000 Access RAM 05Fh
Bank 0 The first 96 bytes are
GPR 060h
FFh 0FFh general purpose RAM
00h 100h (from Bank 0).
= 0001
Bank 1 GPR The second 160 bytes are
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2 GPR
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4
FFh 4FFh
= 0101 00h 500h
Bank 5
FFh 5FFh
= 0110 00h 600h
Bank 6
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
FFh 8FFh
= 1001 00h Unused 900h
Bank 9 Read 00h
FFh 9FFh
00h A00h
= 1010
Bank 10
FFh AFFh
= 1011 00h B00h
Bank 11
FFh BFFh
= 1100 00h C00h
Bank 12
FFh CFFh
= 1101 D00h
Bank 13 00h
FFh DFFh
00h E00h
= 1110
Bank 14
FFh EFFh
00h Unused F00h
= 1111 F5Fh
Bank 15
SFR F60h
FFh FFFh
When ‘a’ = 0:
BSR<3:0> Data Memory Map
The BSR is ignored and the
00h 000h Access Bank is used.
= 0000 Access RAM 05Fh
Bank 0 The first 96 bytes are
GPR 060h
FFh 0FFh general purpose RAM
00h 100h (from Bank 0).
= 0001
Bank 1 GPR The second 160 bytes are
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2 GPR
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
GPR
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4 GPR
FFh 4FFh
= 0101 00h 500h
Bank 5 GPR
FFh 5FFh
= 0110 00h 600h
Bank 6
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
FFh 8FFh
= 1001 00h 900h
Bank 9
FFh 9FFh
00h Unused A00h
= 1010
Bank 10 Read 00h
FFh AFFh
= 1011 00h B00h
Bank 11
FFh BFFh
= 1100 00h C00h
Bank 12
FFh CFFh
= 1101 D00h
Bank 13 00h
FFh DFFh
00h E00h
= 1110
Bank 14
FFh EFFh
00h Unused F00h
= 1111 F5Fh
Bank 15
SFR F60h
FFh FFFh
When ‘a’ = 0:
BSR<3:0> Data Memory Map
The BSR is ignored and the
00h 000h Access Bank is used.
= 0000 Access RAM 05Fh
Bank 0 The first 96 bytes are
GPR 060h
FFh 0FFh general purpose RAM
00h 100h (from Bank 0).
= 0001
Bank 1 GPR The second 160 bytes are
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2 GPR
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
GPR
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4 GPR
FFh 4FFh
= 0101 00h 500h
Bank 5 GPR
FFh 5FFh
= 0110 00h 600h
Bank 6 GPR
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 GPR Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
GPR
FFh 8FFh
= 1001 00h 900h
Bank 9 GPR
FFh 9FFh
00h A00h
= 1010
Bank 10 GPR
FFh AFFh
= 1011 00h B00h
Bank 11 GPR
FFh BFFh
= 1100 00h C00h
Bank 12 GPR
FFh CFFh
= 1101 D00h
Bank 13 00h GPR
FFh DFFh
00h E00h
= 1110
Bank 14 GPR
FFh EFFh
00h GPR F00h
= 1111 F5Fh
Bank 15
SFR F60h
FFh FFFh
Bank 3
through
Bank 13
FFh
E00h
00h
Bank 14
F00h FFh
00h
Bank 15
FFFh FFh
Note 1: The Access RAM bit of the instruction can be used to force an override of the selected bank (BSR<3:0>) to
the registers of the Access Bank.
2: The MOVFF instruction embeds the entire 12-bit address in the instruction.
SPBRGH EUSART Baud Rate Generator Register, High Byte 0000 0000 58, 226
SPBRG EUSART Baud Rate Generator Register, Low Byte 0000 0000 58, 226
RCREG EUSART Receive Register 0000 0000 58, 223
TXREG EUSART Transmit Register 0000 0000 58, 222
TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 58, 231
RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 58, 232
EEADR EEADR7 EEADR6 EEADR5 EEADR4 EEADR3 EEADR2 EEADR1 EEADR0 0000 0000 58, 85, 93
EEADRH(7) — — — — — — EEADR9 EEADR8 ---- --00 58, 85, 93
EEDATA EEPROM Data Register 0000 0000 58, 85, 93
EECON2 EEPROM Control Register 2 (not a physical register) 0000 0000 58, 85, 93
EECON1 EEPGD CFGS — FREE WRERR WREN WR RD xx-0 x000 58, 86, 93
IPR2 OSCFIP C1IP C2IP EEIP BCLIP HLVDIP TMR3IP CCP2IP 1111 1111 59, 110
PIR2 OSCFIF C1IF C2IF EEIF BCLIF HLVDIF TMR3IF CCP2IF 0000 0000 59, 106
PIE2 OSCFIE C1IE C2IE EEIE BCLIE HLVDIE TMR3IE CCP2IE 0000 0000 59, 108
IPR1 PSPIP(2) ADIP RCIP TXIP SSPIP CCP1IP TMR2IP TMR1IP 1111 1111 59, 109
PIR1 PSPIF(2) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 59, 105
PIE1 PSPIE(2) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 59, 107
OSCTUNE INTSRC PLLEN(3) TUN5 TUN4 TUN3 TUN2 TUN1 TUN0 0q00 0000 32, 59
TRISE(2) IBF OBF IBOV PSPMODE — TRISE2 TRISE1 TRISE0 0000 -111 59, 126
TRISD(2) PORTD Data Direction Control Register 1111 1111 59, 122
TRISC PORTC Data Direction Control Register 1111 1111 59, 119
TRISB PORTB Data Direction Control Register 1111 1111 59, 116
TRISA TRISA7(5) TRISA6(5) Data Direction Control Register for PORTA 1111 1111 59, 113
LATE(2) — — — — — PORTE Data Latch Register ---- -xxx 59, 125
(Read and Write to Data Latch)
LATD(2) PORTD Data Latch Register (Read and Write to Data Latch) xxxx xxxx 59, 122
LATC PORTC Data Latch Register (Read and Write to Data Latch) xxxx xxxx 59, 119
LATB PORTB Data Latch Register (Read and Write to Data Latch) xxxx xxxx 59, 116
LATA LATA7(5) LATA6(5) PORTA Data Latch Register (Read and Write to Data Latch) xxxx xxxx 59, 113
PORTE — — — — RE3(4) RE2(2) RE1(2) RE0(2) ---- x000 59, 125
PORTD(2) RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 xxxx xxxx 59, 122
PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx 59, 119
PORTB RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 xxx0 0000 59, 116
PORTA RA7(5) RA6(5) RA5 RA4 RA3 RA2 RA1 RA0 xx0x 0000 59, 113
ANSELH(6) — — — ANS12 ANS11 ANS10 ANS9 ANS8 ---1 1111 59, 129
ANSEL ANS7(2) ANS6(2) ANS5(2) ANS4 ANS3 ANS2 ANS1 ANS0 1111 1111 59, 128
IOCB IOCB7 IOCB6 IOCB5 IOCB4 — — — — 0000 ---- 59, 116
WPUB WPUB7 WPUB6 WPUB5 WPUB4 WPUB3 WPUB2 WPUB1 WPUB0 1111 1111 59, 116
CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1R C1CH1 C1CH0 0000 0000 59, 267
CM2CON0 C2ON C2OUT C2OE C2POL C2SP C2R C2CH1 C2CH0 0000 0000 59, 268
CM2CON1 MC1OUT MC2OUT C1RSEL C2RSEL — — — — 0000 ---- 60, 270
SLRCON — — — SLRE(2) SLRD(2) SLRC SLRB SLRA ---1 1111 60, 130
SSPMSK MSK7 MSK6 MSK5 MSK4 MSK3 MSK2 MSK1 MSK0 1111 1111 60, 200
Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition
Note 1: The SBOREN bit is only available when the BOREN<1:0> Configuration bits = 01; otherwise it is disabled and reads as ‘0’. See
Section 4.4 “Brown-out Reset (BOR)”.
2: These registers and/or bits are not implemented on 28-pin devices and are read as ‘0’. Reset values are shown for 40/44-pin devices;
individual unimplemented bits should be interpreted as ‘-’.
3: The PLLEN bit is only available in specific oscillator configuration; otherwise it is disabled and reads as ‘0’. See Section 2.6.2 “PLL in
HFINTOSC Modes”.
4: The RE3 bit is only available when Master Clear Reset is disabled (MCLRE Configuration bit = 0). Otherwise, RE3 reads as ‘0’. This bit is
read-only.
5: RA6/RA7 and their associated latch and direction bits are individually configured as port pins based on various primary oscillator modes.
When disabled, these bits read as ‘0’.
6: All bits of the ANSELH register initialize to ‘0’ if the PBADEN bit of CONFIG3H is ‘0’.
7: This register is only implemented in the PIC18F46K20 and PIC18F26K20 devices.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For Borrow, the polarity is reversed. A subtraction is executed by adding the two’s complement of the
second operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high-order or low-order
bit of the source register.
000h
When ‘a’ = 0 and f 60h:
060h
The instruction executes in
Direct Forced mode. ‘f’ is inter- Bank 0
BSR
When ‘a’ = 1 (all values of f): 000h 00000000
FIGURE 5-12: REMAPPING THE ACCESS BANK WITH INDEXED LITERAL OFFSET
ADDRESSING
Example Situation:
ADDWF f, d, a 000h
FSR2H:FSR2L = 120h
Bank 0
Locations in the region
from the FSR2 pointer 100h
(120h) to the pointer plus Bank 1
120h
05Fh (17Fh) are mapped Window
17Fh 00h
to the bottom of the
Bank 1
Access RAM (000h-05Fh). 200h Bank 1 “Window”
Special File Registers at 5Fh
60h
F60h through FFFh are
mapped to 60h through Bank 2
FFh, as usual. SFRs
through
Bank 0 addresses below Bank 14
5Fh can still be addressed FFh
by using the BSR. Access Bank
F00h
Bank 15
F60h
SFRs
FFFh
Data Memory
Instruction: TBLRD*
Program Memory
Table Pointer(1)
Table Latch (8-bit)
TBLPTRU TBLPTRH TBLPTRL
TABLAT
Program Memory
(TBLPTR)
Instruction: TBLWT*
Program Memory
(TBLPTR<MSBs>)
Note 1: During table writes the Table Pointer does not point directly to Program Memory. The LSBs of TBLPRTL
actually point to an address within the write block holding registers. The MSBs of the Table Pointer deter-
mine where the write block will eventually be written. The process for writing the holding registers to the
program memory array is discussed in Section 6.5 “Writing to Flash Program Memory”.
6.2 Control Registers The FREE bit allows the program memory erase
operation. When FREE is set, an erase operation is
Several control registers are used in conjunction with initiated on the next WR command. When FREE is
the TBLRD and TBLWT instructions. These include the: clear, only writes are enabled.
• EECON1 register The WREN bit, when set, will allow a write operation.
• EECON2 register The WREN bit is clear on power-up.
• TABLAT register The WRERR bit is set by hardware when the WR bit is
• TBLPTR registers set and cleared when the internal programming timer
expires and the write operation is complete.
6.2.1 EECON1 AND EECON2 REGISTERS
Note: During normal operation, the WRERR is
The EECON1 register (Register 6-1) is the control read as ‘1’. This can indicate that a write
register for memory accesses. The EECON2 register is operation was prematurely terminated by
not a physical register; it is used exclusively in the a Reset, or a write operation was
memory write and erase sequences. Reading attempted improperly.
EECON2 will read all ‘0’s.
The EEPGD control bit determines if the access will be The WR control bit initiates write operations. The WR
a program or data EEPROM memory access. When bit cannot be cleared, only set, by firmware. Then WR
EEPGD is clear, any subsequent operations will bit is cleared by hardware at the completion of the write
operate on the data EEPROM memory. When EEPGD operation.
is set, any subsequent operations will operate on the
Note: The EEIF interrupt flag bit of the PIR2
program memory.
register is set when the write is complete.
The CFGS control bit determines if the access will be The EEIF flag stays set until cleared by
to the Configuration/Calibration registers or to program firmware.
memory/data EEPROM memory. When CFGS is set,
subsequent operations will operate on Configuration
registers regardless of EEPGD (see Section 23.0
“Special Features of the CPU”). When CFGS is clear,
memory selection access is determined by EEPGD.
Legend:
R = Readable bit W = Writable bit
S = Bit can be set by software, but not cleared U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the
error condition.
TABLE 6-2: TABLE POINTER OPERATIONS WITH TBLRD AND TBLWT INSTRUCTIONS
Example Operation on Table Pointer
TBLRD*
TBLPTR is not modified
TBLWT*
TBLRD*+
TBLPTR is incremented after the read/write
TBLWT*+
TBLRD*-
TBLPTR is decremented after the read/write
TBLWT*-
TBLRD+*
TBLPTR is incremented before the read/write
TBLWT+*
Program Memory
TABLAT
Write Register
8 8 8 8
Program Memory
7.1 EEADR and EEADRH Registers Control bits, RD and WR, start read and erase/write
operations, respectively. These bits are set by firmware
The EEADR register is used to address the data and cleared by hardware at the completion of the
EEPROM for read and write operations. The 8-bit operation.
range of the register can address a memory range of The RD bit cannot be set when accessing program
256 bytes (00h to FFh). The EEADRH register expands memory (EEPGD = 1). Program memory is read using
the range to 1024 bytes by adding an additional two table read instructions. See Section 6.1 “Table Reads
address bits. and Table Writes” regarding table reads.
7.2 EECON1 and EECON2 Registers The EECON2 register is not a physical register. It is
used exclusively in the memory write and erase
Access to the data EEPROM is controlled by two sequences. Reading EECON2 will read all ‘0’s.
registers: EECON1 and EECON2. These are the same
registers which control access to the program memory
and are used in a similar manner for the data
EEPROM.
Legend:
R = Readable bit W = Writable bit
S = Bit can be set by software, but not cleared U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the
error condition.
8.2 Operation
Example 8-1 shows the instruction sequence for an 8 x 8
unsigned multiplication. Only one instruction is required
when one of the arguments is already loaded in the
WREG register.
Example 8-2 shows the sequence to do an 8 x 8 signed
multiplication. To account for the sign bits of the argu-
ments, each argument’s Most Significant bit (MSb) is
tested and the appropriate subtractions are done.
Wake-up if in
Idle or Sleep modes
TMR0IF
TMR0IE
TMR0IP
(1)
RBIF
RBIE
RBIP
INT0IF
INT0IE
Interrupt to CPU
INT1IF Vector to Location
INT1IE
INT1IP 0008h
SSPIF
SSPIE INT2IF
SSPIP INT2IE
INT2IP
ADIF GIEH/GIE
ADIE
ADIP IPEN
RCIF IPEN
RCIE
RCIP GIEL/PEIE
IPEN
Additional Peripheral Interrupts
High Priority Interrupt Generation
SSPIF
SSPIE
SSPIP
Interrupt to CPU
TMR0IF Vector to Location
TMR0IE 0018h
ADIF TMR0IP
ADIE (1)
ADIP RBIF
RBIE
RCIF RBIP GIEH/GIE
RCIE GIEL/PEIE
RCIP
INT1IF
INT1IE
INT1IP
Additional Peripheral Interrupts
INT2IF
INT2IE
INT2IP
Note 1: The RBIF interrupt also requires the individual pin IOCB enables.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: A mismatch condition will continue to set the RBIF bit. Reading PORTB will end the
mismatch condition and allow the bit to be cleared.
2: RB port change interrupts also require the individual pin IOCB enables.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PSPIF bit is unimplemented on 28-pin devices and will read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PSPIE bit is unimplemented on 28-pin devices and will read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PSPIF bit is unimplemented on 28-pin devices and will read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Actual Reset values are determined by device configuration and the nature of the device Reset.
See Register 4-1 for additional information.
FIGURE 10-1: GENERIC I/O PORT Pins RA0 through RA5 may also be used as comparator
inputs or outputs by setting the appropriate bits in the
OPERATION
CM1CON0 and CM2CON0 registers.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
RE0/RD/AN5 RE0 0 O DIG LATE<0> data output; not affected by analog input.
1 I ST PORTE<0> data input; disabled when analog input enabled.
RD 1 I TTL PSP read enable input (PSP enabled).
AN5 1 I ANA A/D input channel 5; default input configuration on POR.
RE1/WR/AN6 RE1 0 O DIG LATE<1> data output; not affected by analog input.
1 I ST PORTE<1> data input; disabled when analog input enabled.
WR 1 I TTL PSP write enable input (PSP enabled).
AN6 1 I ANA A/D input channel 6; default input configuration on POR.
RE2/CS/AN7 RE2 0 O DIG LATE<2> data output; not affected by analog input.
1 I ST PORTE<2> data input; disabled when analog input enabled.
CS 1 I TTL PSP write enable input (PSP enabled).
AN7 1 I ANA A/D input channel 7; default input configuration on POR.
MCLR/VPP/ MCLR — I ST External Master Clear input; enabled when MCLRE Configuration bit is
RE3(1,2) set.
VPP — I ANA High-voltage detection; used for ICSP™ mode entry detection. Always
available, regardless of pin mode.
RE3 —(2) I ST PORTE<3> data input; enabled when MCLRE Configuration bit is
clear.
Legend: DIG = Digital level output; TTL = TTL input buffer; ST = Schmitt Trigger input buffer; ANA = Analog level input/output;
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
Note 1: RE3 is available on both PIC18F2XK20 and PIC18F4XK20 devices. All other PORTE pins are only implemented on
PIC18F4XK20 devices.
2: RE3 does not have a corresponding TRIS bit to control data direction.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Default state is determined by the PBADEN bit of CONFIG3H. The default state is ‘0’ When
PBADEN = ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
TABLE 11-2: INTERACTIONS BETWEEN CCP1 AND CCP2 FOR TIMER RESOURCES
CCP1 Mode CCP2 Mode Interaction
Capture Capture Each module can use TMR1 or TMR3 as the time base. The time base can be different
for each CCP.
Capture Compare CCP2 can be configured for the Special Event Trigger to reset TMR1 or TMR3
(depending upon which time base is used). Automatic A/D conversions on trigger event
can also be done. Operation of CCP1 could be affected if it is using the same timer as a
time base.
Compare Capture CCP1 can be configured for the Special Event Trigger to reset TMR1 or TMR3
(depending upon which time base is used). Operation of CCP2 could be affected if it is
using the same timer as a time base.
Compare Compare Either module can be configured for the Special Event Trigger to reset the time base.
Automatic A/D conversions on CCP2 trigger event can be done. Conflicts may occur if
both modules are using the same time base.
Capture PWM None
Compare PWM None
PWM(1) Capture None
PWM(1) Compare None
(1)
PWM PWM Both PWMs will have the same frequency and update rate (TMR2 interrupt).
Note 1: Includes standard and enhanced PWM operation.
TMR3H TMR3L
Set CCP1IF
T3CCP2 TMR3
CCP1 pin Enable
Prescaler and CCPR1H CCPR1L
1, 4, 16 Edge Detect
TMR1
T3CCP2 Enable
4 TMR1H TMR1L
CCP1CON<3:0> Set CCP2IF
4
Q1:Q4
4
CCP2CON<3:0>
T3CCP1 TMR3H TMR3L
T3CCP2
TMR3
Enable
CCP2 pin
Prescaler and CCPR2H CCPR2L
1, 4, 16 Edge Detect
TMR1
Enable
T3CCP2
TMR1H TMR1L
T3CCP1
Compare Output S Q
Comparator
Match Logic
R
TRIS
4 Output Enable
CCP1CON<3:0>
0 TMR1H TMR1L 0
Compare Output S Q
Comparator
Match Logic
R
TRIS
4 Output Enable
CCPR2H CCPR2L
CCP2CON<3:0>
CCPRxL
CCPRxH(2) (Slave)
CCPx
Comparator R Q
(1) S
TMR2
TRIS
Comparator
Clear Timer2,
toggle CCPx pin and
latch duty cycle
PR2
CCPRxL:DCxB<1:0>
Duty Cycle Ratio = -----------------------------------------------------------
4 PR2 + 1
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
FOSC/4 0
0
Sync with Set
1 Internal TMR0L TMR0IF
Programmable Clocks on Overflow
T0CKI pin 1
Prescaler
T0SE (2 TCY Delay)
8
T0CS 3
T0PS<2:0>
8
PSA Internal Data Bus
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI max. prescale.
FOSC/4 0
0
Sync with Set
1 Internal TMR0
TMR0L High Byte TMR0IF
T0CKI pin Programmable 1 Clocks on Overflow
Prescaler 8
T0SE (2 TCY Delay)
T0CS 3 Read TMR0L
T0PS<2:0>
Write TMR0L
PSA
8
8
TMR0H
8
8
Internal Data Bus
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI max. prescale.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T1OSO/T13CKI 1
Prescaler Synchronize
FOSC/4 0
1, 2, 4, 8 Detect
Internal
Clock 0
T1OSI 2
Sleep Input
T1OSCEN(1) TMR1CS Timer1
On/Off
T1CKPS<1:0>
T1SYNC
TMR1ON
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
8
Read TMR1L
Write TMR1L
8
8
TMR1H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
T1CKI = 0
when TMR1
Enabled
XTAL
32.768 kHz
T1OSO
C2
27 pF
VSS
OSC1
OSC2
RC0
RC1
RC2
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
4 1:1 to 1:16
T2OUTPS<3:0> Set TMR2IF
Postscaler
2
T2CKPS<1:0> TMR2 Output
(to PWM or MSSP)
TMR2/PR2
Reset Match
1:1, 1:4, 1:16
FOSC/4 TMR2 Comparator PR2
Prescaler
8 8
8
Internal Data Bus
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Read TMR1L
Write TMR1L
8
8
TMR3H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
15.2 Timer3 16-Bit Read/Write Mode 15.3 Using the Timer1 Oscillator as the
Timer3 can be configured for 16-bit reads and writes
Timer3 Clock Source
(see Figure 15-2). When the RD16 control bit of the The Timer1 internal oscillator may be used as the clock
T3CON register is set, the address for TMR3H is source for Timer3. The Timer1 oscillator is enabled by
mapped to a buffer register for the high byte of Timer3. setting the T1OSCEN bit of the T1CON register. To use
A read from TMR3L will load the contents of the high it as the Timer3 clock source, the TMR3CS bit must
byte of Timer3 into the Timer3 High Byte Buffer register. also be set. As previously noted, this also configures
This provides the user with the ability to accurately read Timer3 to increment on every rising edge of the
all 16 bits of Timer1 without having to determine oscillator source.
whether a read of the high byte, followed by a read of
The Timer1 oscillator is described in Section 13.0
the low byte, has become invalid due to a rollover
“Timer1 Module”.
between reads.
A write to the high byte of Timer3 must also take place 15.4 Timer3 Interrupt
through the TMR3H Buffer register. The Timer3 high
byte is updated with the contents of TMR3H when a The TMR3 register pair (TMR3H:TMR3L) increments
write occurs to TMR3L. This allows a user to write all from 0000h to FFFFh and overflows to 0000h. The
16 bits to both the high and low bytes of Timer3 at once. Timer3 interrupt, if enabled, is generated on overflow
The high byte of Timer3 is not directly readable or and is latched in interrupt flag bit, TMR3IF of the PIR2
writable in this mode. All reads and writes must take register. This interrupt can be enabled or disabled by
place through the Timer3 High Byte Buffer register. setting or clearing the Timer3 Interrupt Enable bit,
TMR3IE of the PIE2 register.
Writes to TMR3H do not clear the Timer3 prescaler.
The prescaler is only cleared on writes to TMR3L.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
FIGURE 16-1: EXAMPLE SIMPLIFIED BLOCK DIAGRAM OF THE ENHANCED PWM MODE
DC1B<1:0> P1M<1:0> CCP1M<3:0>
Duty Cycle Registers
2 4
CCPR1L
CCP1/P1A CCP1/P1A
TRIS
CCPR1H (Slave)
P1B P1B
Output TRIS
Comparator R Q
Controller
P1C P1C
TMR2 (1)
S TRIS
P1D P1D
Comparator
Clear Timer2, TRIS
toggle PWM pin and
latch duty cycle
PR2 PWM1CON
Note 1: The 8-bit timer TMR2 register is concatenated with the 2-bit internal Q clock, or 2 bits of the prescaler to create the 10-bit
time base.
Note 1: The TRIS register value for each PWM output must be configured appropriately.
2: Clearing the CCPxCON register will relinquish ECCP control of all PWM output pins.
3: Any pin not used by an Enhanced PWM mode is available for alternate pin functions.
TABLE 16-1: EXAMPLE PIN ASSIGNMENTS FOR VARIOUS PWM ENHANCED MODES
ECCP Mode P1M<1:0> CCP1/P1A P1B P1C P1D
Single 00 Yes(1) Yes(1) Yes(1) Yes(1)
Half-Bridge 10 Yes Yes No No
Full-Bridge, Forward 01 Yes Yes Yes Yes
Full-Bridge, Reverse 11 Yes Yes Yes Yes
Note 1: Outputs are enabled by pulse steering in Single mode. See Register 16-4.
P1A Active
P1D Modulated
P1A Inactive
P1D Inactive
Relationships:
• Period = 4 * TOSC * (PR2 + 1) * (TMR2 Prescale Value)
• Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 Prescale Value)
• Delay = 4 * TOSC * (PWM1CON<6:0>)
Note 1: Dead-band delay is programmed using the PWM1CON register (Section 16.4.6 “Programmable Dead-Band Delay
mode”).
Pulse PR2+1
P1M<1:0> Signal 0
Width
Period
P1A Modulated
Delay(1) Delay(1)
10 (Half-Bridge) P1B Modulated
P1A Active
P1D Modulated
P1A Inactive
P1D Inactive
Relationships:
• Period = 4 * TOSC * (PR2 + 1) * (TMR2 Prescale Value)
• Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 Prescale Value)
• Delay = 4 * TOSC * (PWM1CON<6:0>)
Note 1: Dead-band delay is programmed using the PWM1CON register (Section 16.4.6 “Programmable Dead-Band Delay
mode”).
FET
Driver +
P1A
-
Load
FET
Driver
+
P1B
-
V+
FET FET
Driver Driver
P1A
Load
FET FET
Driver Driver
P1B
FET QA QC FET
Driver Driver
P1A
Load
P1B
FET FET
Driver Driver
P1C
QB QD
V-
P1D
P1B(2)
P1C(2)
P1D(2)
(1) (1)
Reverse Mode
Period
Pulse Width
P1A(2)
P1B(2)
P1C(2)
P1D(2)
(1) (1)
Note 1: At this time, the TMR2 register is equal to the PR2 register.
2: Output signal is shown as active-high.
P1A (Active-High)
P1B (Active-High)
Pulse Width
P1C (Active-High)
(2)
P1D (Active-High)
Pulse Width
Note 1: The direction bit P1M1 of the CCP1CON register is written any time during the PWM cycle.
2: When changing directions, the P1A and P1C signals switch before the end of the current PWM cycle. The
modulated P1B and P1D signals are inactive at this time. The length of this time is (1/FOSC) TMR2 prescale
value.
P1A
P1B
PW
P1C
P1D PW
TON
External Switch C
TOFF
External Switch D
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
PWM Period
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
ECCPASE
Cleared by
Start of Shutdown Shutdown Firmware PWM
PWM Period Event Occurs Event Clears Resumes
PWM Period
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
FET
Driver +
P1A V
-
Load
FET
Driver
+
P1B V
-
V-
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PWM Steering mode is available only when the CCP1CON register bits CCP1M<3:2> = 11 and
P1M<1:0> = 00.
PORT Data
0
TRIS
STRB
PORT Data 0
TRIS
STRC
1 P1C pin
CCP1M1
PORT Data 0
TRIS
STRD
PORT Data 0
TRIS
PWM Period
PWM
STRn
P1n = PWM
PWM
STRn
P1n = PWM
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Polarity of clock state is set by the CKP bit of the SSPCON1 register.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: In Master mode, the overflow bit is not set since each new reception (and transmission) is initiated by
writing to the SSPBUF register.
2: When enabled, these pins must be properly configured as input or output.
3: Bit combinations not specifically listed here are either reserved or implemented in I2C mode only.
SDO SDI
Write to
SSPBUF
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
4 Clock
SCK Modes
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Input
Sample
(SMP = 1)
SSPIF
Next Q4 Cycle
SSPSR to after Q2
SSPBUF
SS
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI bit 0
(SMP = 0) bit 7 bit 7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
SSPSR to after Q2
SSPBUF
SS
Optional
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI
(SMP = 0) bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
SSPSR to after Q2
SSPBUF
SS
Not Optional
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Write to
SSPBUF
SDI
(SMP = 0) bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
after Q2
SSPSR to
SSPBUF
REGISTER 17-3: SSPADD: MSSP ADDRESS AND BAUD RATE REGISTER (I2C MODE)
R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
ADD7 ADD6 ADD5 ADD4 ADD3 ADD2 ADD1 ADD0
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Master mode
bit 7-3 Not used: Unused for most significant address byte. Bit state of this register is a don’t care. Bit pattern
sent by master is fixed by I2C specification and must be equal to ‘11110’. However, those bits are
compared by hardware and are not affected by the value in this register.
bit 2-1 ADD<9:8>: Two Most Significant bits of 10-bit Address
bit 0 Not used: Unused in this mode. Bit state is a “don’t care”.
10-Bit Slave mode: Least significant address byte
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For bits ACKEN, RCEN, PEN, RSEN, SEN: If the I2C module is not in the Idle mode, these bits may not
be set (no spooling) and the SSPBUF may not be written (or writes to the SSPBUF are disabled).
2: Value that will be transmitted when the user initiates an Acknowledge sequence at the end of a receive.
DS40001303H-page 196
Receiving Address R/W = 0 Receiving Data ACK Receiving Data ACK
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
PIC18F2XK20/4XK20
SSPIF
Bus master
(PIR1<3>) terminates
transfer
BF (SSPSTAT<0>)
Cleared by software
SSPBUF is read
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
Cleared by software Cleared by software
From SSPIF ISR From SSPIF ISR
SSPBUF is written by software SSPBUF is written by software
CKP
DS40001303H-page 197
PIC18F2XK20/4XK20
FIGURE 17-10:
DS40001303H-page 198
taken place taken place
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
Bus master
terminates
SSPIF transfer
(PIR1<3>)
Cleared by software Cleared by software Cleared by software
Cleared by software
PIC18F2XK20/4XK20
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
Bus master
terminates
Clock is held low until Clock is held low until transfer
update of SSPADD has update of SSPADD has Clock is held low until
taken place taken place CKP is set to ‘1’
R/W = 0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S Sr P
SSPIF
(PIR1<3>)
Cleared by software Cleared by software Cleared by software
BF (SSPSTAT<0>)
DS40001303H-page 199
PIC18F2XK20/4XK20
PIC18F2XK20/4XK20
17.4.3.4 SSP Mask Register This register must be initiated prior to setting
2 SSPM<3:0> bits to select the I2C Slave mode (7-bit or
An SSP Mask (SSPMSK) register is available in I C
10-bit address).
Slave mode as a mask for the value held in the
SSPSR register during an address comparison The SSP Mask register is active during:
operation. A zero (‘0’) bit in the SSPMSK register has • 7-bit Address mode: address compare of A<7:1>.
the effect of making the corresponding bit in the
• 10-bit Address mode: address compare of A<7:0>
SSPSR register a “don’t care”.
only. The SSP mask has no effect during the
This register is reset to all ‘1’s upon any Reset reception of the first (high) byte of the address.
condition and, therefore, has no effect on standard
SSP operation until written with a mask value.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The MSK0 bit is used only in 10-bit slave mode. In all other modes, this bit has no effect.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
SDA DX DX – 1
SCL
Master device
CKP asserts clock
Master device
deasserts clock
WR
SSPCON1
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF
Bus master
(PIR1<3>) terminates
transfer
BF (SSPSTAT<0>)
Cleared by software
SSPBUF is read
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
CKP
CKP
If BF is cleared written
prior to the falling to ‘1’ in
edge of the 9th clock, software
CKP will not be reset BF is set after falling
to ‘0’ and no clock edge of the 9th clock,
stretching will occur CKP is reset to ‘0’ and
clock stretching occurs
I2C™ SLAVE MODE TIMING WITH SEN = 1 (RECEPTION, 7-BIT ADDRESS)
DS40001303H-page 203
PIC18F2XK20/4XK20
FIGURE 17-14:
DS40001303H-page 204
taken place taken place because ACK = 1
CKP is set to ‘1’
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
ACK ACK
SDA 1 1 1 1 0 A9 A8 ACK A7 A6 A5 A4 A3 A2 A1 A0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF
Bus master
(PIR1<3>) terminates
Cleared by software Cleared by software Cleared by software transfer
Cleared by software
PIC18F2XK20/4XK20
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
SCL
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
SSPIF
BF (SSPSTAT<0>)
Cleared by software
SSPBUF is read
SSPOV (SSPCON1<6>) ‘0’
GCEN (SSPCON2<7>)
‘1’
Internal SSPM<3:0>
Data Bus SSPADD<7:0>
Read Write
SSPBUF Baud
Rate
Generator
SDA Shift
Clock Arbitrate/WCOL Detect
SDA In Clock
SSPSR
(hold off clock source)
MSb LSb
Receive Enable
Acknowledge
Generate
SCL
SSPM<3:0> SSPADD<7:0>
SDA DX DX – 1
BRG decrements on
Q2 and Q4 cycles
BRG
03h 02h 01h 00h (hold off) 03h 02h
Value
SCL
TBRG
S
Sr = Repeated Start
BF (SSPSTAT<0>)
PEN
R/W
I 2C™ MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
DS40001303H-page 213
PIC18F2XK20/4XK20
FIGURE 17-22:
Write to SSPCON2<4>
to start Acknowledge sequence
DS40001303H-page 214
SDA = ACKDT (SSPCON2<5>) = 0
Write to SSPCON2<0> (SEN = 1),
begin Start condition ACK from Master Set ACKEN, start Acknowledge sequence
Master configured as a receiver SDA = ACKDT = 0 SDA = ACKDT = 1
SEN = 0 by programming SSPCON2<3> (RCEN = 1)
PEN bit = 1
Write to SSPBUF occurs here, RCEN cleared RCEN = 1, start RCEN cleared
ACK from Slave next receive automatically written here
start XMIT automatically
Transmit Address to Slave R/W = 0 Receiving Data from Slave Receiving Data from Slave
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK
Bus master
ACK is not sent terminates
transfer
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SCL S P
Data shifted in on falling edge of CLK Set SSPIF at end
PIC18F2XK20/4XK20
Set P bit
Cleared by software Cleared by software Cleared by software Cleared by software (SSPSTAT<4>)
SDA = 0, SCL = 1 Cleared in
while CPU software and SSPIF
responds to SSPIF
BF
(SSPSTAT<0>) Last bit is shifted into SSPSR and
contents are unloaded into SSPBUF
SSPOV
ACKEN
I 2C™ MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS)
SCL 8 9
SSPIF
Cleared in
SSPIF set at software
the end of receive Cleared in
software SSPIF set at the end
of Acknowledge sequence
Note: TBRG = one Baud Rate Generator period.
SDA ACK
P
TBRG TBRG TBRG
SCL brought high after TBRG
SDA asserted low before rising edge of clock
to setup Stop condition
SDA
BCLIF
SDA
SCL
Set SEN, enable Start SEN cleared automatically because of bus collision.
condition if SDA = 1, SCL = 1 SSP module reset into Idle state.
SEN
SDA sampled low before
Start condition. Set BCLIF.
S bit and SSPIF set because
BCLIF SDA = 0, SCL = 1.
SSPIF and BCLIF are
cleared by software
SSPIF
TBRG TBRG
SDA
FIGURE 17-28: BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
SDA = 0, SCL = 1
Set S Set SSPIF
Less than TBRG
TBRG
SCL S
SCL pulled low after BRG
time-out
SEN
Set SEN, enable START
sequence if SDA = 1, SCL = 1
BCLIF ‘0’
SSPIF
SDA = 0, SCL = 1, Interrupts cleared
set SSPIF by software
SDA
SCL
RSEN
BCLIF
Cleared by software
S ‘0’
SSPIF ‘0’
TBRG TBRG
SDA
SCL
S ‘0’
SSPIF
PEN
BCLIF
P ‘0’
SSPIF ‘0’
SDA
PEN
BCLIF
P ‘0’
SSPIF ‘0’
TXEN
TRMT
Baud Rate Generator FOSC
÷n
TX9
BRG16 n
+1 Multiplier x4 x16 x64
TX9D
SYNC 1 X 0 0 0
SPBRGH SPBRG BRGH X 1 1 0 0
BRG16 X 1 0 1 0
BRG16
+1 n
Multiplier x4 x16 x64
SYNC 1 X 0 0 0
SPBRGH SPBRG BRGH X 1 1 0 0 FIFO
FERR RX9D RCREG Register
BRG16 X 1 0 1 0
8
Data Bus
RCIF Interrupt
RCIE
Write to TXREG
Word 1
BRG Output
(Shift Clock)
RC4/C2OUT/TX/CK
pin Start bit bit 0 bit 1 bit 7/8 Stop bit
Word 1
TXIF bit
(Transmit Buffer 1 TCY
Reg. Empty Flag)
Word 1
TRMT bit Transmit Shift Reg
(Transmit Shift
Reg. Empty Flag)
Write to TXREG
Word 1 Word 2
BRG Output
(Shift Clock)
RC4/C2OUT/TX/CK
pin Start bit bit 0 bit 1 bit 7/8 Stop bit Start bit bit 0
TXIF bit 1 TCY Word 1 Word 2
(Interrupt Reg. Flag)
1 TCY
TRMT bit Word 1 Word 2
(Transmit Shift Transmit Shift Reg
Reg. Empty Flag) Transmit Shift Reg
• CREN = 1 Immediately after all data bits and the Stop bit have
been received, the character in the RSR is transferred
• SYNC = 0
to the EUSART receive FIFO and the RCIF interrupt
• SPEN = 1 flag bit of the PIR1 register is set. The top character in
All other EUSART control bits are assumed to be in the FIFO is transferred out of the FIFO by reading the
their default state. RCREG register.
Setting the CREN bit of the RCSTA register enables the Note: If the receive FIFO is overrun, no additional
receiver circuitry of the EUSART. Clearing the SYNC bit characters will be received until the overrun
of the TXSTA register configures the EUSART for condition is cleared. See Section 18.1.2.6
asynchronous operation. Setting the SPEN bit of the “Receive Overrun Error” for more
RCSTA register enables the EUSART. The RX/DT I/O information on overrun errors.
pin must be configured as an input by setting the
corresponding TRIS control bit. If the RX/DT pin is 18.1.2.3 Receive Data Polarity
shared with an analog peripheral the analog I/O function The polarity of the receive data can be controlled with
must be disabled by clearing the corresponding ANSEL the DTRXP bit of the BAUDCON register. The default
bit. state of this bit is ‘0’ which selects high true receive idle
and data bits. Setting the DTRXP bit to ‘1’ will invert the
receive data resulting in low true idle and data bits. The
DTRXP bit controls receive data polarity only in
Asynchronous mode. In synchronous mode the
DTRXP bit has a different function.
Read Rcv
Buffer Reg
RCREG
RCIF
(Interrupt Flag)
OERR bit
CREN
Note: This timing diagram shows three words appearing on the RX input. The RCREG (receive buffer) is read after the third word,
causing the OERR (overrun) bit to be set.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
BAUD FOSC = 64.000 MHz FOSC = 18.432 MHz FOSC = 16.000 MHz FOSC = 11.0592 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 — — — — — — — — — — — —
1200 — — — — — — — — — — — —
2400 — — — — — — — — — — — —
9600 — — — 9600 0.00 119 9615 0.16 103 9600 0.00 71
10417 — — — 10378 -0.37 110 10417 0.00 95 10473 0.53 65
19.2k 19.23k 0.16 207 19.20k 0.00 59 19.23k 0.16 51 19.20k 0.00 35
57.6k 57.97k 0.64 68 57.60k 0.00 19 58.82k 2.12 16 57.60k 0.00 11
115.2k 114.29k -0.79 34 115.2k 0.00 9 111.1k -3.55 8 115.2k 0.00 5
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 — — — — — — — — — 300 0.16 207
1200 — — — 1202 0.16 207 1200 0.00 191 1202 0.16 51
2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25
9600 9615 0.16 51 9615 0.16 25 9600 0.00 23 — — —
10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5
19.2k 19231 0.16 25 19.23k 0.16 12 19.2k 0.00 11 — — —
57.6k 55556 -3.55 8 — — — 57.60k 0.00 3 — — —
115.2k — — — — — — 115.2k 0.00 1 — — —
BAUD FOSC = 64.000 MHz FOSC = 18.432 MHz FOSC = 16.000 MHz FOSC = 11.0592 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300.0 0.00 13332 300.0 0.00 3839 300.03 0.01 3332 300.0 0.00 2303
1200 1200.1 0.01 3332 1200 0.00 959 1200.5 0.04 832 1200 0.00 575
2400 2399 -0.02 1666 2400 0.00 479 2398 -0.08 416 2400 0.00 287
9600 9592 -0.08 416 9600 0.00 119 9615 0.16 103 9600 0.00 71
10417 10417 0.00 383 10378 -0.37 110 10417 0.00 95 10473 0.53 65
19.2k 19.23k 0.16 207 19.20k 0.00 59 19.23k 0.16 51 19.20k 0.00 35
57.6k 57.97k 0.64 68 57.60k 0.00 19 58.82k 2.12 16 57.60k 0.00 11
115.2k 114.29k -0.79 34 115.2k 0.00 9 111.11k -3.55 8 115.2k 0.00 5
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 299.9 -0.02 1666 300.1 0.04 832 300.0 0.00 767 300.5 0.16 207
1200 1199 -0.08 416 1202 0.16 207 1200 0.00 191 1202 0.16 51
2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25
9600 9615 0.16 51 9615 0.16 25 9600 0.00 23 — — —
10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5
19.2k 19.23k 0.16 25 19.23k 0.16 12 19.20k 0.00 11 — — —
57.6k 55556 -3.55 8 — — — 57.60k 0.00 3 — — —
115.2k — — — — — — 115.2k 0.00 1 — — —
BAUD FOSC = 64.000 MHz FOSC = 18.432 MHz FOSC = 16.000 MHz FOSC = 11.0592 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300 0.00 53332 300.0 0.00 15359 300.0 0.00 13332 300.0 0.00 9215
1200 1200 0.00 13332 1200 0.00 3839 1200.1 0.01 3332 1200 0.00 2303
2400 2400 0.00 6666 2400 0.00 1919 2399.5 -0.02 1666 2400 0.00 1151
9600 9598.1 -0.02 1666 9600 0.00 479 9592 -0.08 416 9600 0.00 287
10417 10417 0.00 1535 10425 0.08 441 10417 0.00 383 10433 0.16 264
19.2k 19.21k 0.04 832 19.20k 0.00 239 19.23k 0.16 207 19.20k 0.00 143
57.6k 57.55k -0.08 277 57.60k 0.00 79 57.97k 0.64 68 57.60k 0.00 47
115.2k 115.11k -0.08 138 115.2k 0.00 39 114.29k -0.79 34 115.2k 0.00 23
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300.0 0.00 6666 300.0 0.01 3332 300.0 0.00 3071 300.1 0.04 832
1200 1200 -0.02 1666 1200 0.04 832 1200 0.00 767 1202 0.16 207
2400 2401 0.04 832 2398 0.08 416 2400 0.00 383 2404 0.16 103
9600 9615 0.16 207 9615 0.16 103 9600 0.00 95 9615 0.16 25
10417 10417 0.00 191 10417 0.00 95 10473 0.53 87 10417 0.00 23
19.2k 19.23k 0.16 103 19.23k 0.16 51 19.20k 0.00 47 19.23k 0.16 12
57.6k 57.14k -0.79 34 58.82k 2.12 16 57.60k 0.00 15 — — —
115.2k 117.6k 2.12 16 111.1k -3.55 8 115.2k 0.00 7 — — —
BRG Clock
RCIDL
RCIF bit
(Interrupt)
Read
RCREG
Note 1: The ABD sequence requires the EUSART module to be configured in Asynchronous mode.
To terminate the auto-baud process before the RCIF Therefore, the initial character in the transmission must
flag is set, clear the ABDEN bit then clear the ABDOVF be all ‘0’s. This must be ten or more bit times, 13-bit
bit. The ABDOVF bit will remain set if the ABDEN bit is times recommended for LIN bus, or any number of bit
not cleared first. times for standard RS-232 devices.
Oscillator Startup Time
18.3.3 AUTO-WAKE-UP ON BREAK
Oscillator start-up time must be considered, especially
During Sleep mode, all clocks to the EUSART are in applications using oscillators with longer start-up
suspended. Because of this, the Baud Rate Generator intervals (i.e., LP, XT or HS/PLL mode). The Sync
is inactive and a proper character reception cannot be Break (or wake-up signal) character must be of
performed. The Auto-Wake-up feature allows the sufficient length, and be followed by a sufficient
controller to wake-up due to activity on the RX/DT line. interval, to allow enough time for the selected oscillator
This feature is available only in Asynchronous mode. to start and provide proper initialization of the EUSART.
The Auto-Wake-up feature is enabled by setting the WUE Bit
WUE bit of the BAUDCON register. Once set, the normal
The wake-up event causes a receive interrupt by
receive sequence on RX/DT is disabled, and the
setting the RCIF bit. The WUE bit is cleared by
EUSART remains in an Idle state, monitoring for a
hardware by a rising edge on RX/DT. The interrupt
wake-up event independent of the CPU mode. A
condition is then cleared by software by reading the
wake-up event consists of a high-to-low transition on the
RCREG register and discarding its contents.
RX/DT line. (This coincides with the start of a Sync Break
or a wake-up signal character for the LIN protocol.) To ensure that no actual data is lost, check the RCIDL
bit to verify that a receive operation is not in process
The EUSART module generates an RCIF interrupt
before setting the WUE bit. If a receive operation is not
coincident with the wake-up event. The interrupt is
occurring, the WUE bit may then be set just prior to
generated synchronously to the Q clocks in normal CPU
entering the Sleep mode.
operating modes (Figure 18-7), and asynchronously if
the device is in Sleep mode (Figure 18-8). The interrupt
condition is cleared by reading the RCREG register.
The WUE bit is automatically cleared by the low-to-high
transition on the RX line at the end of the Break. This
signals to the user that the Break event is over. At this
point, the EUSART module is in Idle mode waiting to
receive the next character.
RCIF
Cleared due to User Read of RCREG
Note 1: The EUSART remains in Idle while the WUE bit is set.
Note 1: If the wake-up event requires long oscillator warm-up time, the automatic clearing of the WUE bit can occur while the stposc signal is
still active. This sequence should not depend on the presence of Q clocks.
2: The EUSART remains in Idle while the WUE bit is set.
Write to TXREG
Dummy Write
BRG Output
(Shift Clock)
TX/CK pin
(SCKP = 1)
Write to
TXREG Reg Write Word 1 Write Word 2
TXIF bit
(Interrupt Flag)
TRMT bit
‘1’ ‘1’
TXEN bit
Note: Sync Master mode, SPBRG = 0, continuous transmission of two 8-bit words.
TX/CK pin
Write to
TXREG reg
TXIF bit
TRMT bit
TXEN bit
RX/DT
pin bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
TX/CK pin
(SCKP = 0)
TX/CK pin
(SCKP = 1)
Write to
bit SREN
SREN bit
RCIF bit
(Interrupt)
Read
RXREG
Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
VCFG1 = 0
AVSS
VREF- VCFG1 = 1
AVDD
VCFG0 = 0
VREF+ VCFG0 = 1
AN0 0000
AN1 0001
AN2 0010
AN3 0011
AN4 0100
AN5 0101
AN6 0110
AN7 0111
ADC
AN8 1000
GO/DONE 10
AN9 1001
AN10 1010 0 = Left Justify
ADFM
AN11 1011 1 = Right Justify
CHS<3:0>
TABLE 19-1: ADC CLOCK PERIOD (TAD) VS. DEVICE OPERATING FREQUENCIES
ADC Clock Period (TAD) Device Frequency (FOSC)
ADRESH ADRESL
(ADFM = 0) MSB LSB
bit 7 bit 0 bit 7 bit 0
Set GO bit
On the following cycle:
ADRESH:ADRESL is loaded, GO bit is cleared,
ADIF bit is set, holding capacitor is connected to analog input.
FIGURE 19-4: A/D CONVERSION TAD CYCLES (ACQT<2:0> = 010, TACQ = 4 TAD)
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 2 TAD
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Automatic
Acquisition Conversion starts Discharge
Time (Holding capacitor is disconnected from analog input)
Set GO bit
(Holding capacitor continues On the following cycle:
acquiring input) ADRESH:ADRESL is loaded, GO bit is cleared,
ADIF bit is set, holding capacitor is connected to analog input.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T ACQ = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient
= T AMP + T C + T COFF
= 5µs + T C + Temperature - 25°C 0.05µs/°C
T C = – C HOLD R IC + R SS + R S ln(1/2047)
= – 13.5pF 1k + 700 + 10k ln(0.0004885)
= 1.20 µs
Therefore:
T ACQ = 5µs + 1.20µs + 50°C- 25°C 0.05 s/ °C
= 7.45µs
Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out.
2: The charge holding capacitor (CHOLD) is discharged after each conversion.
3: The maximum recommended impedance for analog sources is 10 k. This is required to meet the pin
leakage specification.
VDD
Sampling
Switch
Rs ANx RIC 1k SS Rss
3.5V
Legend: CPIN = Input Capacitance 3.0V
I LEAKAGE = Leakage current at the pin due to
VDD
various junctions 2.5V
RIC = Interconnect Resistance 2.0V
SS = Sampling Switch 1.5V
CHOLD = Sample/Hold Capacitance
.1 1 10 100
Rss (k)
Note 1: See Section 26.0 “Electrical Specifications”.
Full-Scale Range
3FFh
3FEh
3FDh
3FCh
ADC Output Code
Full-Scale
004h Transition
003h
002h
001h
000h Analog Input Voltage
1/2 LSB ideal
C1CH<1:0>
2 To
D Q Data Bus
Q1
C12IN0- 0 EN
RD_CM1CON0
C12IN1- 1
MUX Set C1IF
D Q
C12IN2- 2
Q3*RD_CM1CON0
EN
C12IN3- 3 To PWM Logic
CL
Reset
C1ON(1)
C1R C1OE
C1VIN- -
C1IN+ 0 C1OUT
MUX C1VIN+ C1
+
FVR 1 C1OUT pin(2)
0 C1SP
MUX C1POL
CVREF 1 C1VREF
C1RSEL Note 1: When C1ON = 0, the C1 comparator will produce a ‘0’ output to the XOR Gate.
2: Output shown for reference only. See I/O port pin block diagram for more detail.
3: Q1 and Q3 are phases of the four-phase system clock (FOSC).
4: Q1 is held high during Sleep mode.
To
D Q
Data Bus
Q1
EN
RD_CM2CON0
C2CH<1:0>
Set C2IF
2 D Q
Q3*RD_CM2CON0
EN To PWM Logic
C12IN0- 0 C2ON(1)
CL
C2OE
C12IN1- 1 NRESET
MUX C2VIN-
C12IN2- 2 C2 C2OUT
C2VIN+
C12IN3- C2OUT pin(2)
3 C2SP
C2POL
C2R
C2IN+ 0
MUX
FVR 1
0
MUX
CVREF 1 C2VREF
Note 1: When C2ON = 0, the C2 comparator will produce a ‘0’ output to the XOR Gate.
C2RSEL 2: Output shown for reference only. See I/O port pin block diagram for more detail.
3: Q1 and Q3 are phases of the four-phase system clock (FOSC).
4: Q1 is held high during Sleep mode.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Comparator output requires the following three conditions: C1OE = 1, C1ON = 1 and corresponding port
TRIS bit = 0.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Comparator output requires the following three conditions: C2OE = 1, C2ON = 1 and corresponding port
TRIS bit = 0.
AIN
CPIN ILEAKAGE(1)
VA
5 pF
Vss
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
CVRSS = 1
VREF+
VDD
CVRSS = 0 8R
CVR<3:0>
CVREN R
16-to-1 MUX
R
16 Steps
CVREF
R
R
R
CVRR
8R
CVRSS = 1
VREF-
CVRSS = 0
PIC18F2XK20/4XK20
CVREF
R(1)
Module
+
Voltage CVREF Buffered CVREF Output
–
Reference
Output
Impedance
Note 1: R is dependent upon the voltage reference Configuration bits, CVR<3:0> and CVRR.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented C = Clearable only bit
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Set
HLVDIF
HLVDEN
Internal Voltage
BOREN Reference
VDD
VHLVD
HLVDIF
Enable HLVD
TIVRST
IRVST
HLVDIF cleared by software
Internal Reference is stable
CASE 2:
VDD
VHLVD
HLVDIF
Enable HLVD
TIVRST
IRVST
Internal Reference is stable
HLVDIF cleared by software
VHLVD
VDD
HLVDIF
Enable HLVD
IRVST TIVRST
CASE 2:
VHLVD
VDD
HLVDIF
Enable HLVD
IRVST TIVRST
Voltage
detach. This feature could save a design a few extra
components and an attach signal (input pin).
For general battery applications, Figure 22-4 shows a
possible voltage curve. Over time, the device voltage
decreases. When the device voltage reaches voltage
VA, the HLVD logic generates an interrupt at time TA.
The interrupt could cause the execution of an ISR, TA TB
Time
which would allow the application to perform
“housekeeping tasks” and perform a controlled Legend: VA = HLVD trip point
shutdown before the device voltage exits the valid VB = Minimum valid device
operating range at TB. The HLVD, thus, would give the operating voltage
application a time window, represented by the
difference between TA and TB, to safely exit.
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed x = Bit is unknown
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed x = Bit is unknown
Note 1: See Section 26.1 “DC Characteristics: Supply Voltage” for specifications.
2: The Power-up Timer is decoupled from Brown-out Reset, allowing these features to be independently controlled.
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed x = Bit is unknown
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed x = Bit is unknown
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed x = Bit is unknown
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Note 1: This bit is read-only in Normal Execution mode; it can be written only in Program mode.
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Note 1: These values for DEV<10:3> may be shared with other devices. The specific device is always identified
by using the entire DEV<10:0> bit sequence.
WDTPS<3:0> 4
Sleep
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit has no effect if the Configuration bit, WDTEN, is enabled.
Unimplemented Unimplemented
Read ‘0’s Read ‘0’s
(2000h-1FFFFFh) (4000h-1FFFFFh)
Unimplemented Unimplemented (Unimplemented
Read ‘0’s Read ‘0’s Memory Space)
(8000h-1FFFFFh) (10000h-1FFFFFh)
TBLPTR = 0008FFh
WRT0, EBTR0 = 01
007FFFh
000000h
WRTB, EBTRB = 11
0007FFh
000800h
TBLPTR = 0008FFh
WRT0, EBTR0 = 10
001FFFh
002000h
PC = 003FFEh TBLRD* WRT1, EBTR1 = 11
003FFFh
004000h
WRT2, EBTR2 = 11
005FFFh
006000h
WRT3, EBTR3 = 11
007FFFh
Results: All table reads from external blocks to Blockn are disabled whenever EBTRn = 0.
TABLAT register returns a value of ‘0’.
007FFFh
Literal operations
15 8 7 0
OPCODE k (literal) MOVLW 7Fh
Control operations
CALL, GOTO and Branch operations
15 8 7 0
OPCODE n<7:0> (literal) GOTO Label
15 12 11 0
1111 n<19:8> (literal)
15 8 7 0
OPCODE S n<7:0> (literal) CALL MYFUNC
15 12 11 0
1111 n<19:8> (literal)
S = Fast bit
15 11 10 0
OPCODE n<10:0> (literal) BRA MYFUNC
15 8 7 0
OPCODE n<7:0> (literal) BC MYFUNC
BYTE-ORIENTED OPERATIONS
ADDWF f, d, a Add WREG and f 1 0010 01da ffff ffff C, DC, Z, OV, N 1, 2
ADDWFC f, d, a Add WREG and CARRY bit to f 1 0010 00da ffff ffff C, DC, Z, OV, N 1, 2
ANDWF f, d, a AND WREG with f 1 0001 01da ffff ffff Z, N 1,2
CLRF f, a Clear f 1 0110 101a ffff ffff Z 2
COMF f, d, a Complement f 1 0001 11da ffff ffff Z, N 1, 2
CPFSEQ f, a Compare f with WREG, skip = 1 (2 or 3) 0110 001a ffff ffff None 4
CPFSGT f, a Compare f with WREG, skip > 1 (2 or 3) 0110 010a ffff ffff None 4
CPFSLT f, a Compare f with WREG, skip < 1 (2 or 3) 0110 000a ffff ffff None 1, 2
DECF f, d, a Decrement f 1 0000 01da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
DECFSZ f, d, a Decrement f, Skip if 0 1 (2 or 3) 0010 11da ffff ffff None 1, 2, 3, 4
DCFSNZ f, d, a Decrement f, Skip if Not 0 1 (2 or 3) 0100 11da ffff ffff None 1, 2
INCF f, d, a Increment f 1 0010 10da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
INCFSZ f, d, a Increment f, Skip if 0 1 (2 or 3) 0011 11da ffff ffff None 4
INFSNZ f, d, a Increment f, Skip if Not 0 1 (2 or 3) 0100 10da ffff ffff None 1, 2
IORWF f, d, a Inclusive OR WREG with f 1 0001 00da ffff ffff Z, N 1, 2
MOVF f, d, a Move f 1 0101 00da ffff ffff Z, N 1
MOVFF fs, fd Move fs (source) to 1st word 2 1100 ffff ffff ffff None
fd (destination) 2nd word 1111 ffff ffff ffff
MOVWF f, a Move WREG to f 1 0110 111a ffff ffff None
MULWF f, a Multiply WREG with f 1 0000 001a ffff ffff None 1, 2
NEGF f, a Negate f 1 0110 110a ffff ffff C, DC, Z, OV, N
RLCF f, d, a Rotate Left f through Carry 1 0011 01da ffff ffff C, Z, N 1, 2
RLNCF f, d, a Rotate Left f (No Carry) 1 0100 01da ffff ffff Z, N
RRCF f, d, a Rotate Right f through Carry 1 0011 00da ffff ffff C, Z, N
RRNCF f, d, a Rotate Right f (No Carry) 1 0100 00da ffff ffff Z, N
SETF f, a Set f 1 0110 100a ffff ffff None 1, 2
SUBFWB f, d, a Subtract f from WREG with 1 0101 01da ffff ffff C, DC, Z, OV, N
borrow
SUBWF f, d, a Subtract WREG from f 1 0101 11da ffff ffff C, DC, Z, OV, N 1, 2
SUBWFB f, d, a Subtract WREG from f with 1 0101 10da ffff ffff C, DC, Z, OV, N
borrow
SWAPF f, d, a Swap nibbles in f 1 0011 10da ffff ffff None 4
TSTFSZ f, a Test f, skip if 0 1 (2 or 3) 0110 011a ffff ffff None 1, 2
XORWF f, d, a Exclusive OR WREG with f 1 0001 10da ffff ffff Z, N
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless
the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program mem-
ory locations have a valid instruction.
BIT-ORIENTED OPERATIONS
BCF f, b, a Bit Clear f 1 1001 bbba ffff ffff None 1, 2
BSF f, b, a Bit Set f 1 1000 bbba ffff ffff None 1, 2
BTFSC f, b, a Bit Test f, Skip if Clear 1 (2 or 3) 1011 bbba ffff ffff None 3, 4
BTFSS f, b, a Bit Test f, Skip if Set 1 (2 or 3) 1010 bbba ffff ffff None 3, 4
BTG f, d, a Bit Toggle f 1 0111 bbba ffff ffff None 1, 2
CONTROL OPERATIONS
BC n Branch if Carry 1 (2) 1110 0010 nnnn nnnn None
BN n Branch if Negative 1 (2) 1110 0110 nnnn nnnn None
BNC n Branch if Not Carry 1 (2) 1110 0011 nnnn nnnn None
BNN n Branch if Not Negative 1 (2) 1110 0111 nnnn nnnn None
BNOV n Branch if Not Overflow 1 (2) 1110 0101 nnnn nnnn None
BNZ n Branch if Not Zero 1 (2) 1110 0001 nnnn nnnn None
BOV n Branch if Overflow 1 (2) 1110 0100 nnnn nnnn None
BRA n Branch Unconditionally 2 1101 0nnn nnnn nnnn None
BZ n Branch if Zero 1 (2) 1110 0000 nnnn nnnn None
CALL n, s Call subroutine 1st word 2 1110 110s kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
CLRWDT — Clear Watchdog Timer 1 0000 0000 0000 0100 TO, PD
DAW — Decimal Adjust WREG 1 0000 0000 0000 0111 C
GOTO n Go to address 1st word 2 1110 1111 kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
NOP — No Operation 1 0000 0000 0000 0000 None
NOP — No Operation 1 1111 xxxx xxxx xxxx None 4
POP — Pop top of return stack (TOS) 1 0000 0000 0000 0110 None
PUSH — Push top of return stack (TOS) 1 0000 0000 0000 0101 None
RCALL n Relative Call 2 1101 1nnn nnnn nnnn None
RESET Software device Reset 1 0000 0000 1111 1111 All
RETFIE s Return from interrupt enable 2 0000 0000 0001 000s GIE/GIEH,
PEIE/GIEL
RETLW k Return with literal in WREG 2 0000 1100 kkkk kkkk None
RETURN s Return from Subroutine 2 0000 0000 0001 001s None
SLEEP — Go into Standby mode 1 0000 0000 0000 0011 TO, PD
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless
the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program mem-
ory locations have a valid instruction.
LITERAL OPERATIONS
ADDLW k Add literal and WREG 1 0000 1111 kkkk kkkk C, DC, Z, OV, N
ANDLW k AND literal with WREG 1 0000 1011 kkkk kkkk Z, N
IORLW k Inclusive OR literal with WREG 1 0000 1001 kkkk kkkk Z, N
LFSR f, k Move literal (12-bit) 2nd word 2 1110 1110 00ff kkkk None
to FSR(f) 1st word 1111 0000 kkkk kkkk
MOVLB k Move literal to BSR<3:0> 1 0000 0001 0000 kkkk None
MOVLW k Move literal to WREG 1 0000 1110 kkkk kkkk None
MULLW k Multiply literal with WREG 1 0000 1101 kkkk kkkk None
RETLW k Return with literal in WREG 2 0000 1100 kkkk kkkk None
SUBLW k Subtract WREG from literal 1 0000 1000 kkkk kkkk C, DC, Z, OV, N
XORLW k Exclusive OR literal with WREG 1 0000 1010 kkkk kkkk Z, N
DATA MEMORY PROGRAM MEMORY OPERATIONS
TBLRD* Table Read 2 0000 0000 0000 1000 None
TBLRD*+ Table Read with post-increment 0000 0000 0000 1001 None
TBLRD*- Table Read with post-decrement 0000 0000 0000 1010 None
TBLRD+* Table Read with pre-increment 0000 0000 0000 1011 None
TBLWT* Table Write 2 0000 0000 0000 1100 None
TBLWT*+ Table Write with post-increment 0000 0000 0000 1101 None
TBLWT*- Table Write with post-decrement 0000 0000 0000 1110 None
TBLWT+* Table Write with pre-increment 0000 0000 0000 1111 None
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless
the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program mem-
ory locations have a valid instruction.
Q Cycle Activity:
Q1 Q2 Q3 Q4
Decode Read Process Write to
register ‘f’ Data destination
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction format then becomes: {label} instruction argument(s).
BTFSC Bit Test File, Skip if Clear BTFSS Bit Test File, Skip if Set
Syntax: BTFSC f, b {,a} Syntax: BTFSS f, b {,a}
Operands: 0 f 255 Operands: 0 f 255
0b7 0b<7
a [0,1] a [0,1]
Operation: skip if (f<b>) = 0 Operation: skip if (f<b>) = 1
Status Affected: None Status Affected: None
Encoding: 1011 bbba ffff ffff Encoding: 1010 bbba ffff ffff
Description: If bit ‘b’ in register ‘f’ is ‘0’, then the next Description: If bit ‘b’ in register ‘f’ is ‘1’, then the next
instruction is skipped. If bit ‘b’ is ‘0’, then instruction is skipped. If bit ‘b’ is ‘1’, then
the next instruction fetched during the the next instruction fetched during the
current instruction execution is discarded current instruction execution is discarded
and a NOP is executed instead, making and a NOP is executed instead, making
this a 2-cycle instruction. this a 2-cycle instruction.
If ‘a’ is ‘0’, the Access Bank is selected. If If ‘a’ is ‘0’, the Access Bank is selected. If
‘a’ is ‘1’, the BSR is used to select the ‘a’ is ‘1’, the BSR is used to select the
GPR bank. GPR bank.
If ‘a’ is ‘0’ and the extended instruction If ‘a’ is ‘0’ and the extended instruction
set is enabled, this instruction operates in set is enabled, this instruction operates
Indexed Literal Offset Addressing in Indexed Literal Offset Addressing
mode whenever f 95 (5Fh). mode whenever f 95 (5Fh).
See Section 24.2.3 “Byte-Oriented and See Section 24.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed Bit-Oriented Instructions in Indexed
Literal Offset Mode” for details. Literal Offset Mode” for details.
Words: 1 Words: 1
Cycles: 1(2) Cycles: 1(2)
Note: 3 cycles if skip and followed Note: 3 cycles if skip and followed
by a 2-word instruction. by a 2-word instruction.
Q Cycle Activity: Q Cycle Activity:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Decode Read Process No Decode Read Process No
register ‘f’ Data operation register ‘f’ Data operation
If skip: If skip:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
If skip and followed by 2-word instruction: If skip and followed by 2-word instruction:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
No No No No No No No No
operation operation operation operation operation operation operation operation
CPFSGT Compare f with W, skip if f > W CPFSLT Compare f with W, skip if f < W
Syntax: CPFSGT f {,a} Syntax: CPFSLT f {,a}
Operands: 0 f 255 Operands: 0 f 255
a [0,1] a [0,1]
Operation: (f) –W), Operation: (f) –W),
skip if (f) > (W) skip if (f) < (W)
(unsigned comparison) (unsigned comparison)
Status Affected: None Status Affected: None
Encoding: 0110 010a ffff ffff
Encoding: 0110 000a ffff ffff
Description: Compares the contents of data memory
Description: Compares the contents of data memory
location ‘f’ to the contents of the W by
location ‘f’ to the contents of W by
performing an unsigned subtraction.
performing an unsigned subtraction.
If the contents of ‘f’ are greater than the
If the contents of ‘f’ are less than the
contents of WREG, then the fetched
contents of W, then the fetched
instruction is discarded and a NOP is
instruction is discarded and a NOP is
executed instead, making this a
executed instead, making this a
2-cycle instruction.
2-cycle instruction.
If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘1’, the BSR is used to select the
If ‘a’ is ‘1’, the BSR is used to select the
GPR bank.
GPR bank.
If ‘a’ is ‘0’ and the extended instruction
set is enabled, this instruction operates Words: 1
in Indexed Literal Offset Addressing Cycles: 1(2)
mode whenever f 95 (5Fh). See
Note: 3 cycles if skip and followed
Section 24.2.3 “Byte-Oriented and by a 2-word instruction.
Bit-Oriented Instructions in Indexed
Literal Offset Mode” for details. Q Cycle Activity:
Words: 1 Q1 Q2 Q3 Q4
Cycles: 1(2) Decode Read Process No
Note: 3 cycles if skip and followed register ‘f’ Data operation
by a 2-word instruction. If skip:
Q Cycle Activity: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 No No No No
Decode Read Process No operation operation operation operation
register ‘f’ Data operation If skip and followed by 2-word instruction:
If skip: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 No No No No
No No No No operation operation operation operation
operation operation operation operation No No No No
If skip and followed by 2-word instruction: operation operation operation operation
Q1 Q2 Q3 Q4
No No No No
Example: HERE CPFSLT REG, 1
operation operation operation operation NLESS :
No No No No LESS :
operation operation operation operation
Before Instruction
PC = Address (HERE)
Example: HERE CPFSGT REG, 0 W = ?
NGREATER : After Instruction
GREATER :
If REG < W;
Before Instruction PC = Address (LESS)
PC = Address (HERE) If REG W;
W = ? PC = Address (NLESS)
After Instruction
If REG W;
PC = Address (GREATER)
If REG W;
PC = Address (NGREATER)
Q1 Q2 Q3 Q4 Q Cycle Activity:
Decode Read Process Write to Q1 Q2 Q3 Q4
register ‘f’ Data destination Decode Read Process Write to
If skip: register ‘f’ Data destination
Q1 Q2 Q3 Q4 If skip:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
If skip and followed by 2-word instruction: operation operation operation operation
Q1 Q2 Q3 Q4 If skip and followed by 2-word instruction:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
No No No No operation operation operation operation
operation operation operation operation No No No No
operation operation operation operation
Example: HERE DECFSZ CNT, 1, 1
GOTO LOOP Example: HERE DCFSNZ TEMP, 1, 0
CONTINUE ZERO :
NZERO :
Before Instruction
PC = Address (HERE) Before Instruction
After Instruction TEMP = ?
CNT = CNT - 1 After Instruction
If CNT = 0; TEMP = TEMP – 1,
PC = Address (CONTINUE) If TEMP = 0;
If CNT 0; PC = Address (ZERO)
PC = Address (HERE + 2) If TEMP 0;
PC = Address (NZERO)
POP Pop Top of Return Stack PUSH Push Top of Return Stack
Syntax: POP Syntax: PUSH
Operands: None Operands: None
Operation: (TOS) bit bucket Operation: (PC + 2) TOS
Status Affected: None Status Affected: None
Encoding: 0000 0000 0000 0110 Encoding: 0000 0000 0000 0101
Description: The TOS value is pulled off the return Description: The PC + 2 is pushed onto the top of
stack and is discarded. The TOS value the return stack. The previous TOS
then becomes the previous value that value is pushed down on the stack.
was pushed onto the return stack. This instruction allows implementing a
This instruction is provided to enable software stack by modifying TOS and
the user to properly manage the return then pushing it onto the return stack.
stack to incorporate a software stack.
Words: 1
Words: 1
Cycles: 1
Cycles: 1 Q Cycle Activity:
Q Cycle Activity: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 Decode PUSH No No
Decode No POP TOS No PC + 2 onto operation operation
operation value operation return stack
RLNCF Rotate Left f (No Carry) RRCF Rotate Right f through Carry
Syntax: RLNCF f {,d {,a}} Syntax: RRCF f {,d {,a}}
Operands: 0 f 255 Operands: 0 f 255
d [0,1] d [0,1]
a [0,1] a [0,1]
Operation: (f<n>) dest<n + 1>, Operation: (f<n>) dest<n – 1>,
(f<7>) dest<0> (f<0>) C,
Status Affected: N, Z (C) dest<7>
Status Affected: C, N, Z
Encoding: 0100 01da ffff ffff
Encoding: 0011 00da ffff ffff
Description: The contents of register ‘f’ are rotated
one bit to the left. If ‘d’ is ‘0’, the result Description: The contents of register ‘f’ are rotated
is placed in W. If ‘d’ is ‘1’, the result is one bit to the right through the CARRY
stored back in register ‘f’ (default). flag. If ‘d’ is ‘0’, the result is placed in W.
If ‘a’ is ‘0’, the Access Bank is selected. If ‘d’ is ‘1’, the result is placed back in
If ‘a’ is ‘1’, the BSR is used to select the register ‘f’ (default).
GPR bank. If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘0’ and the extended instruction If ‘a’ is ‘1’, the BSR is used to select the
set is enabled, this instruction operates GPR bank.
in Indexed Literal Offset Addressing If ‘a’ is ‘0’ and the extended instruction
mode whenever f 95 (5Fh). See set is enabled, this instruction operates
Section 24.2.3 “Byte-Oriented and in Indexed Literal Offset Addressing
Bit-Oriented Instructions in Indexed mode whenever f 95 (5Fh). See
Literal Offset Mode” for details. Section 24.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed
register f
Literal Offset Mode” for details.
Words: 1 C register f
Cycles: 1
Words: 1
Q Cycle Activity:
Cycles: 1
Q1 Q2 Q3 Q4
Decode Read Process Write to Q Cycle Activity:
register ‘f’ Data destination Q1 Q2 Q3 Q4
Decode Read Process Write to
Example: RLNCF REG, 1, 0 register ‘f’ Data destination
Before Instruction
REG = 1010 1011 Example: RRCF REG, 0, 0
After Instruction Before Instruction
REG = 0101 0111 REG = 1110 0110
C = 0
After Instruction
REG = 1110 0110
W = 0111 0011
C = 0
ADDFSR Add Literal to FSR ADDULNK Add Literal to FSR2 and Return
Syntax: ADDFSR f, k Syntax: ADDULNK k
Operands: 0 k 63 Operands: 0 k 63
f [ 0, 1, 2 ] Operation: FSR2 + k FSR2,
Operation: FSR(f) + k FSR(f) (TOS) PC
Status Affected: None Status Affected: None
Encoding: 1110 1000 ffkk kkkk Encoding: 1110 1000 11kk kkkk
Description: The 6-bit literal ‘k’ is added to the Description: The 6-bit literal ‘k’ is added to the
contents of the FSR specified by ‘f’. contents of FSR2. A RETURN is then
Words: 1 executed by loading the PC with the
Cycles: 1 TOS.
The instruction takes two cycles to
Q Cycle Activity:
execute; a NOP is performed during
Q1 Q2 Q3 Q4 the second cycle.
Decode Read Process Write to This may be thought of as a special
literal ‘k’ Data FSR case of the ADDFSR instruction,
where f = 3 (binary ‘11’); it operates
only on FSR2.
Example: ADDFSR 2, 23h Words: 1
Before Instruction Cycles: 2
FSR2 = 03FFh
After Instruction
Q Cycle Activity:
FSR2 = 0422h
Q1 Q2 Q3 Q4
Decode Read Process Write to
literal ‘k’ Data FSR
No No No No
Operation Operation Operation Operation
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction syntax then becomes: {label} instruction argument(s).
MOVSS Move Indexed to Indexed PUSHL Store Literal at FSR2, Decrement FSR2
Syntax: MOVSS [zs], [zd] Syntax: PUSHL k
Operands: 0 zs 127 Operands: 0k 255
0 zd 127
Operation: k (FSR2),
Operation: ((FSR2) + zs) ((FSR2) + zd) FSR2 – 1 FSR2
Status Affected: None
Status Affected: None
Encoding:
Encoding: 1111 1010 kkkk kkkk
1st word (source) 1110 1011 1zzz zzzzs
2nd word (dest.) 1111 xxxx xzzz zzzzd Description: The 8-bit literal ‘k’ is written to the data
memory address specified by FSR2. FSR2
Description The contents of the source register are
is decremented by 1 after the operation.
moved to the destination register. The
This instruction allows users to push values
addresses of the source and destination
onto a software stack.
registers are determined by adding the
7-bit literal offsets ‘zs’ or ‘zd’, Words: 1
respectively, to the value of FSR2. Both
Cycles: 1
registers can be located anywhere in
the 4096-byte data memory space Q Cycle Activity:
(000h to FFFh). Q1 Q2 Q3 Q4
The MOVSS instruction cannot use the Decode Read ‘k’ Process Write to
PCL, TOSU, TOSH or TOSL as the data destination
destination register.
If the resultant source address points to
an indirect addressing register, the Example: PUSHL 08h
value returned will be 00h. If the
resultant destination address points to Before Instruction
an indirect addressing register, the FSR2H:FSR2L = 01ECh
Memory (01ECh) = 00h
instruction will execute as a NOP.
Words: 2 After Instruction
Cycles: 2 FSR2H:FSR2L = 01EBh
Memory (01ECh) = 08h
Q Cycle Activity:
Q1 Q2 Q3 Q4
Decode Determine Determine Read
source addr source addr source reg
Decode Determine Determine Write
dest addr dest addr to dest reg
SUBFSR Subtract Literal from FSR SUBULNK Subtract Literal from FSR2 and Return
Syntax: SUBFSR f, k Syntax: SUBULNK k
Operands: 0 k 63 Operands: 0 k 63
f [ 0, 1, 2 ] Operation: FSR2 – k FSR2
Operation: FSR(f) – k FSRf (TOS) PC
Status Affected: None Status Affected: None
Encoding: 1110 1001 ffkk kkkk Encoding: 1110 1001 11kk kkkk
Description: The 6-bit literal ‘k’ is subtracted from Description: The 6-bit literal ‘k’ is subtracted from the
the contents of the FSR specified by contents of the FSR2. A RETURN is then
‘f’. executed by loading the PC with the TOS.
Words: 1 The instruction takes two cycles to
execute; a NOP is performed during the
Cycles: 1
second cycle.
Q Cycle Activity: This may be thought of as a special case of
Q1 Q2 Q3 Q4 the SUBFSR instruction, where f = 3 (binary
Decode Read Process Write to ‘11’); it operates only on FSR2.
register ‘f’ Data destination Words: 1
Cycles: 2
Q Cycle Activity:
Example: SUBFSR 2, 23h
Before Instruction Q1 Q2 Q3 Q4
FSR2 = 03FFh Decode Read Process Write to
register ‘f’ Data destination
After Instruction
FSR2 = 03DCh No No No No
Operation Operation Operation Operation
The MPASM Assembler generates relocatable object • Support for the entire device instruction set
files for the MPLINK Object Linker, Intel® standard HEX • Support for fixed-point and floating-point data
files, MAP files to detail memory usage and symbol • Command-line interface
reference, absolute LST files that contain source lines • Rich directive set
and generated machine code, and COFF files for • Flexible macro language
debugging.
• MPLAB X IDE compatibility
The MPASM Assembler features include:
• Integration into MPLAB X IDE projects
• User-defined macros to streamline
assembly code
• Conditional assembly for multipurpose
source files
• Directives that allow complete control over the
assembly process
Note 1: Power dissipation is calculated as follows: PDIS = VDD x {IDD – IOH} + {(VDD – VOH) x IOH} + (VOL x IOL).
2: Voltage spikes below VSS at the MCLR/VPP/RE3 pin, inducing currents greater than 80 mA, may cause
latch-up. Thus, a series resistor of 50-100 should be used when applying a “low” level to the
MCLR/VPP/RE3 pin, rather than pulling this pin directly to VSS.
3: Maximum current rating requires even load distribution across I/O pins. Maximum current rating may be
limited by the device package power dissipation characterizations. See Table 26-15 to calculate device
specifications.
† NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure above maximum rating conditions for
extended periods may affect device reliability.
3.5V
3.0V
2.7V
Voltage
2.0V
1.8V
10 16 20 30 32 40 48 50 60 64
Frequency (MHz)
3.5V
3.0V
2.7V
Voltage
2.0V
1.8V
10 16 20 30 32 40 50 60 64
Frequency (MHz)
Param.
Symbol Characteristic Min. Typ. Max. Units Conditions
No.
D001 VDD Supply Voltage 1.8 — 3.6 V
D002 VDR RAM Data Retention 1.5 — — V
Voltage(1)
D003 VPOR VDD Start Voltage — — 0.7 V See section on Power-on Reset for
to ensure internal details
Power-on Reset signal
D004 SVDD VDD Rise Rate 0.05 — — V/ms See section on Power-on Reset for
to ensure internal details
Power-on Reset signal
D005 VBOR Brown-out Reset Voltage
BORV<1:0> = 11(2) 1.72 1.82 1.95 V
BORV<1:0> = 10 2.15 2.27 2.40 V
BORV<1:0> = 01 2.65 2.75 2.90 V
BORV<1:0> = 00(3) 2.98 3.08 3.25 V
Note 1: This is the limit to which VDD can be lowered in Sleep mode, or during a device Reset, without losing RAM
data.
2: With BOR enabled, operation is supported until a BOR occurs. This is valid although VDD may be below
the minimum rated supply voltage.
3: With BOR enabled, full-speed operation (FOSC = 64 MHZ) is supported until a BOR occurs. This is valid
although VDD may be below the minimum voltage for this frequency.
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D006 Power-down Current (IPD)(1) 0.05 1.0 A -40°C
0.05 1.0 A +25°C
VDD = 1.8V, (Sleep mode)
0.6 3.0 A +85°C
4 20 A +125°C
D007 0.1 1.0 A -40°C
0.1 1.0 A +25°C
VDD = 3.0V, (Sleep mode)
0.7 3.0 A +85°C
5 20 A +125°C
Note 1: The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is
measured with the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD or VSS and
all features that add delta current disabled (such as WDT, Timer1 Oscillator, BOR, etc.).
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D008 Supply Current (IDD)(1, 2) 5.5 9 A -40°C
6.0 10 A +25°C
VDD = 1.8V
6.5 14 A +85°C
9.0 30 A +125°C FOSC = 31 kHz
(RC_RUN mode,
D008A 10.0 15 A -40°C LFINTOSC source)
10.5 16 A +25°C
VDD = 3.0V
11.0 20 A +85°C
14.0 40 A +125°C
D009 0.40 0.50 mA -40°C TO +125°C VDD = 1.8V FOSC = 1 MHz
(RC_RUN mode,
D009A 0.60 0.80 mA -40°C TO +125°C VDD = 3.0V HF-INTOSC source)
D010 2.2 3.0 mA -40°C TO +125°C VDD = 1.8V FOSC = 16 MHz
(RC_RUN mode,
D010A 3.8 4.4 mA -40°C TO +125°C VDD = 3.0V HF-INTOSC source)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and
temperature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to Vss;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D011 Supply Current (IDD)(1, 2) 2.0 5 A -40°C
2.0 5 A +25°C
VDD = 1.8V
2.5 9 A +85°C
5.0 25 A +125°C FOSC = 31 kHz
(RC_IDLE mode,
D011A 3.5 8 A -40°C LFINTOSC source)
3.5 8 A +25°C
VDD = 3.0V
4.0 12 A +85°C
7.0 30 A +125°C
D012 0.30 0.40 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
(RC_IDLE mode,
D012A 0.40 0.60 mA -40°C to +125°C VDD = 3.0V HF-INTOSC source)
D013 1.0 1.2 mA -40°C to +125°C VDD = 1.8V FOSC = 16 MHz
(RC_IDLE mode,
D013A 1.6 2.0 mA -40°C to +125°C VDD = 3.0V HF-INTOSC source)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and
temperature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to Vss;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D014 Supply Current (IDD)(1, 2) 0.25 0.45 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D014A (PRI_RUN,
0.50 0.75 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D015 2.7 3.2 mA -40°C to +125°C VDD = 2V FOSC = 20 MHz
D015A (PRI_RUN,
4.3 5.0 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D016 FOSC = 64 MHz
12.2 14.0 mA -40°C to +85°C VDD = 3.0V (PRI_RUN,
EC oscillator)
D017 2.1 2.9 mA -40°C to +125°C VDD = 1.8V FOSC = 4 MHz
D017A 16 MHz Internal
4.2 5.0 mA -40°C to +125°C VDD = 3.0V (PRI_RUN HS+PLL)
D018 FOSC = 16 MHz
12.2 15.0 mA -40°C to +85°C VDD = 3.0V 64 MHz Internal
(PRI_RUN HS+PLL)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and
temperature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to Vss;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D019 Supply Current (IDD)(1, 2) 0.05 0.07 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D019A (PRI_IDLE mode,
0.09 0.15 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D020 1.2 1.6 mA -40°C to +125°C VDD = 2.0V FOSC = 20 MHz
D020A (PRI_IDLEmode,
1.8 2.5 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D021 FOSC = 64 MHz
5.6 7.0 mA -40°C to +85°C VDD = 3.0V (PRI_IDLEmode,
EC oscillator)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and
temperature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to Vss;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D022 Supply Current (IDD)(1, 2) 5.5 9 A -40°C
5.5 10 A +25°C VDD = 1.8V
6.5 14 A +85°C FOSC = 32 kHz(3)
(SEC_RUN mode,
D022A 10.0 15 A -40°C Timer1 as clock)
10.0 16 A +25°C VDD = 3.0V
11.0 20 A +85°C
D023 2.0 5 A -40°C
2.0 5 A +25°C VDD = 1.8V
2.5 9 A +85°C FOSC = 32 kHz(3)
(SEC_IDLE mode,
D023A 3.5 8 A -40°C Timer1 as clock)
3.5 8 A +25°C VDD = 3.0V
4.0 12 A +85°C
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and
temperature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to Vss;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
3: Low-Power mode on T1 osc. Low-Power mode is limited to 85°C.
Param.
Device Characteristics Typ. Max. Units Conditions
No.
Module Differential Currents
D024 Watchdog Timer 0.7 2.0 A -40°C to +125°C VDD = 1.8V
(IWDT) 1.1 3.0 A -40°C to +125°C VDD = 3.0V
D024A Brown-out Reset(2) 21 50 A -40C to +125C VDD = 2.0V
(IBOR) 25 60 A -40C to +125C VDD = 3.3V
— Sleep mode,
0 A -40C to +125C VDD = 3.3V
BOREN<1:0> = 10
D024B High/Low-Voltage Detect(2)
13 30 A -40C to +125C VDD = 1.8-3.0V
(IHLVD)
D025 Timer1 Oscillator 0.5 2.0 A -40C
(IOSCB) 0.5 2.0 A +25C VDD = 1.8V 32 kHz on Timer1(1)
LP
0.7 2.0 A +85C
0.7 3.0 A -40C
0.7 3.0 A +25C VDD = 3.0V 32 kHz on Timer1(1)
0.9 3.0 A +85C
D025A Timer1 Oscillator 11 30 A -40C
(IOSCB) 13 33 A +25C VDD = 1.8V 32 kHz on Timer1(3)
HP
15 35 A +85C
14 33 A -40C
17 37 A +25C VDD = 3.0V 32 kHz on Timer1(3)
19 40 A +85C
D026 A/D Converter(4) 200 360 A -40C to +125C VDD = 1.8V
(IAD) A/D on, not converting
260 500 A -40C to +125C VDD = 3.0V
IFRC 2 5 A -40C to +125C VDD = 1.8V Adder for FRC
11 18 A -40C to +125C VDD = 3.0V
Note 1: Low-Power mode on T1 osc. Low-Power mode is limited to 85°C.
2: BOR and HLVD enable internal band gap reference. With both modules enabled, current consumption will be
less than the sum of both specifications.
3: High-Power mode in T1 osc.
4: A/D converter differential currents apply only in Run mode. In Sleep or Idle mode both the ADC and the FRC turn
off as soon as conversion (if any) is complete.
Param.
Symbol Characteristic Min. Typ.† Max. Units Conditions
No.
VIL Input Low Voltage
I/O ports:
D030 with TTL buffer VSS — 0.15 VDD V
D031 with Schmitt Trigger VSS — 0.2 VDD V
D032 MCLR VSS — 0.2 VDD V
D033 OSC1 VSS — 0.3 VDD V HS, HSPLL modes
D033A OSC1 VSS — 0.2 VDD V RC, EC modes(1)
D033B OSC1 VSS — 0.3 VDD V XT, LP modes
D034 T13CKI VSS — 0.3 VDD V
VIH Input High Voltage
I/O ports:
D040 with TTL buffer 0.25 VDD + — VDD V
0.8V
D041 VIH with Schmitt Trigger: 0.8 VDD — VDD V 2.4V < VDD < 3.6V
0.9 VDD — VDD V VDD < 2.4V
D042 VIH MCLR 0.8 VDD — VDD V 2.4V < VDD < 3.6V
0.9 VDD — VDD V VDD < 2.4V
D043 OSC1 0.7 VDD — VDD V HS, HSPLL modes
D043A OSC1 0.8 VDD — VDD V EC mode
D043B OSC1 0.9 VDD — VDD V RC mode(1)
D043C OSC1 1.6 — VDD V XT, LP modes
D044 T13CKI 1.6 — VDD V
IIL Input Leakage I/O and VSS VPIN VDD,
MCLR(2,3) Pin at
high-impedance
D060 I/O ports — 5 50 nA +25°C
— 10 100 nA +60°C
— 30 200 nA +85°C
— 100 1000 nA +125°C
Input Leakage RA2
D061 IIL — 10 100 nA +25°C
— 35 250 nA +60°C
— 200 750 nA +85°C
— 400 2000 nA +125°C
Input Leakage RA3
D062 IIL — 10 80 nA +25°C
— 25 200 nA +60°C
— 70 500 nA +85°C
— 300 1500 nA +125°C
IPU Weak Pull-up Current
Note 1: In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that
the PIC® device be driven with an external clock while in RC mode.
2: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified
levels represent normal operating conditions. Higher leakage current may be measured at different input
voltages.
3: Negative current is defined as current sourced by the pin.
4: Parameter is characterized but not tested.
Param.
Symbol Characteristic Min. Typ.† Max. Units Conditions
No.
D070 IPURB PORTB weak pull-up 50 90 400 A VDD = 3.0V, VPIN =
current VSS
Note 1: In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that
the PIC® device be driven with an external clock while in RC mode.
2: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified
levels represent normal operating conditions. Higher leakage current may be measured at different input
voltages.
3: Negative current is defined as current sourced by the pin.
4: Parameter is characterized but not tested.
Param.
Symbol Characteristic Min. Typ.† Max. Units Conditions
No.
VOL Output Low Voltage
D080 I/O ports — — 0.6 V IOL = 8.5 mA, VDD
= 3.0V,
-40C to +85C
D083 OSC2/CLKOUT — — 0.6 V IOL = 1.6 mA, VDD
(RC, RCIO, EC, ECIO = 3.0V,
modes) -40C to +85C
VOH Output High Voltage(3)
D090 I/O ports VDD – 0.7 — — V IOH = -3.0 mA, VDD
= 3.0V,
-40C to +85C
D092 OSC2/CLKOUT VDD – 0.7 — — V IOH = -1.3 mA, VDD
(RC, RCIO, EC, ECIO = 3.0V,
modes) -40C to +85C
Capacitive Loading
Specs
on Output Pins
D100(4) COSC2 OSC2 pin — — 15 pF In XT, HS and LP
modes when
external clock is
used to drive
OSC1
D101 CIO All I/O pins and OSC2 — — 50 pF To meet the AC
(in RC mode) Timing
Specifications
D102 CB SCL, SDA — — 400 pF I2C™ Specification
Note 1: In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that
the PIC® device be driven with an external clock while in RC mode.
2: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified
levels represent normal operating conditions. Higher leakage current may be measured at different input
voltages.
3: Negative current is defined as current sourced by the pin.
4: Parameter is characterized but not tested.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
CM01 VIOFF Input Offset Voltage — 10 50 mV VREF = VDD/2,
High-Power mode
— 12 80 mV VREF = VDD/2,
Low-Power mode
CM02 VICM Input Common-mode Voltage VSS — VDD V
CM04 TRESP Response Time — 200 400 ns High-Power mode
— 300 600 ns Low-Power mode
CM05 TMC2OV Comparator Mode Change to — — 10 s
Output Valid*
* These parameters are characterized but not tested.
Note 1: Response time measured with one comparator input at VDD/2, while the other input transitions
from VSS to VDD.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
CV01* CLSB Step Size(2) — VDD/24 — V Low Range (VRR = 1)
— VDD/32 — V High Range (VRR = 0)
CV02* CACC Absolute Accuracy — — 1/2 LSb
CV03* CR Unit Resistor Value (R) — 3k —
CV04* CST Settling Time(1) — 7.5 10 s
* These parameters are characterized but not tested.
Note 1: Settling time measured while CVRR = 1 and CVR3:CVR0 transitions from ‘0000’ to ‘1111’.
2: See Section 21.1 “Comparator Voltage Reference” for more information.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
VR01 VROUT VR voltage output 1.15 1.20 1.25 V -40°C to +85°C
1.10 1.20 1.30 V +85°C to +125°C
VR02* TCVOUT Voltage drift temperature — <50 — ppm/C -40°C to +40°C (See
coefficient Figure 27-34)
VR03* VROUT/ Voltage drift with respect to — <2000 — V/V 25°C, 2.0 to 3.3V (See
VDD VDD regulation Figure 27-33)
VR04* TSTABLE Settling Time — 25 100 s 0 to 125°C
* These parameters are characterized but not tested.
VDD
(HLVDIF can be
VHLVD cleared by software)
(HLVDIF set by hardware)
HLVDIF
Param.
Symbol Characteristic Min. Typ.† Max. Units Conditions
No.
D420 HLVD Voltage on HLVDL<3:0> = 0000 1.70 1.85 2.00 V
VDD Transition HLVDL<3:0> = 0001 1.80 1.95 2.10 V
High-to-Low
HLVDL<3:0> = 0010 1.91 2.06 2.21 V
HLVDL<3:0> = 0011 2.02 2.17 2.32 V
HLVDL<3:0> = 0100 2.15 2.30 2.45 V
HLVDL<3:0> = 0101 2.22 2.37 2.52 V
HLVDL<3:0> = 0110 2.38 2.53 2.68 V
HLVDL<3:0> = 0111 2.46 2.61 2.76 V
HLVDL<3:0> = 1000 2.55 2.70 2.85 V
HLVDL<3:0> = 1001 2.65 2.80 2.95 V
HLVDL<3:0> = 1010 2.75 2.90 3.05 V
HLVDL<3:0> = 1011 2.87 3.02 3.17 V
HLVDL<3:0> = 1100 2.98 3.13 3.28 V
HLVDL<3:0> = 1101 3.26 3.41 3.56 V
HLVDL<3:0> = 1110 3.42 3.57 3.72 V
† Production tested at TAMB = 25°C. Specifications over temperature limits ensured by characterization.
Param.
Sym. Characteristic Typ. Units Conditions
No.
TH01 JA Thermal Resistance Junction to 60.0 C/W 28-pin SPDIP package
Ambient
80.3 C/W 28-pin SOIC package
90.0 C/W 28-pin SSOP package
36.0 C/W 28-pin QFN 6x6 mm package
48.0 C/W 28-pin UQFN 4x4 mm package
47.2 C/W 40-pin PDIP package
46.0 C/W 44-pin TQFP package
24.4 C/W 44-pin QFN package
41.0 C/W 40-pin UQFN 5x5 mm package
TH02 JC Thermal Resistance Junction to 31.4 C/W 28-pin SPDIP package
Case
24.0 C/W 28-pin SOIC package
24.0 C/W 28-pin SSOP package
6.0 C/W 28-pin QFN 6x6 mm package
12.0 C/W 28-pin UQFN 4x4 mm package
24.7 C/W 40-pin PDIP package
14.5 C/W 44-pin TQFP package
20.0 C/W 44-pin QFN package
50.5 C/W 40-pin UQFN 5x5 mm package
TH03 TJMAX Maximum Junction Temperature 150 C —
TH04 PD Power Dissipation — W PD = PINTERNAL + PI/O
TH05 PINTERNAL Internal Power Dissipation — W PINTERNAL = IDD X VDD(1)
TH06 PI/O I/O Power Dissipation — W PI/O =(IOL * VOL) + (IOH * (VDD - VOH))
TH07 PDER Derated Power — W PDER = PDMAX (TJ - TA)/JA(2)
Note 1: IDD is current to run the chip alone without driving any load on the output pins.
2: TA = Ambient Temperature, TJ = Junction Temperature
VDD/2
RL Pin CL
VSS
CL
Pin
RL = 464
VSS CL = 50 pF for all pins except OSC2/CLKOUT
and including D and E outputs as ports
OSC1
1 3 3 4 4
2
CLKOUT
Param.
Characteristic Min. Typ. Max. Units Conditions
No.
OA1 HFINTOSC Accuracy @ Freq = 16 MHz, 8 MHz, 4 MHz, 2 MHz, 1 MHz, 500 kHz, 250 kHz(1)
-2 0 +2 % +0°C to +70°C VDD = 1.8-3.6V
-3 — +2 % +70°C to +85°C VDD = 1.8-3.6V
-5 — +5 % -40°C to 0°C and VDD = 1.8-3.6V
+85°C to 125°C
OA2 LFINTOSC Accuracy @ Freq = 31.25 kHz
-15 — +15 % -40°C to +125°C VDD = 1.8-3.6V
Note 1: Frequency calibrated at 25°C. OSCTUNE register can be used to compensate for temperature drift.
OSC1
10 11
CLKOUT
13 12
14 19 18
16
I/O pin
(Input)
17 15
20, 21
Note: Refer to Figure 26-4 for load conditions.
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
OSC
Time-out
Internal
Reset
Watchdog
Timer
Reset 31
34 34
I/O pins
VDD BVDD
35
VBGAP = 1.2V
VIVRST
Enable Internal
Reference Voltage
Internal Reference
Voltage Stable 36
TABLE 26-21: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET REQUIREMENTS
Param.
Symbol Characteristic Min. Typ. Max. Units Conditions
No.
T0CKI
40 41
42
T1OSO/T13CKI
45 46
47 48
TMR0 or
TMR1
Note: Refer to Figure 26-4 for load conditions.
CCPx
(Capture Mode)
50 51
52
CCPx
(Compare or PWM Mode)
53 54
RE2/CS
RE0/RD
RE1/WR
65
RD7:RD0
62
64
63
Note: Refer to Figure 26-4 for load conditions.
SS
70
SCK
(CKP = 0)
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76
SS
81
SCK
(CKP = 0)
71 72
79
73
SCK
(CKP = 1)
80
78
75, 76
74
Note: Refer to Figure 26-4 for load conditions.
SS
70
SCK
(CKP = 0) 83
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76 77
TABLE 26-27: EXAMPLE SPI MODE REQUIREMENTS (SLAVE MODE TIMING, CKE = 0)
Param.
Symbol Characteristic Min. Max. Units Conditions
No.
70
SCK 83
(CKP = 0)
71 72
SCK
(CKP = 1)
80
75, 76 77
SDI
MSb In bit 6 - - - -1 LSb In
74
Note: Refer to Figure 26-4 for load conditions.
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
91 92
SDA
In
110
109 109
SDA
Out
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
SDA
Out
RC6/TX/CK
pin 121 121
RC7/RX/DT
pin
120
122
Note: Refer to Figure 26-4 for load conditions.
RC6/TX/CK
pin 125
RC7/RX/DT
pin
126
BSF ADCON0, GO
(Note 2)
131
Q4
130
A/D CLK 132
ADIF TCY
GO DONE
SAMPLING STOPPED
SAMPLE
Note 1: If the A/D clock source is selected as RC, a time of TCY is added before the A/D clock starts.
This allows the SLEEP instruction to be executed.
2: This is a minimal RC delay (typically 100 ns), which also disconnects the holding capacitor from the analog input.
10
125°C
85°C
IPD (uA)
0.1
40°C
Limited Accuracy 25°C
-40°C
0.01
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
100
125°C
IPD (uA)
10
85°C
40°C
1 25°C
VDD (V)
16
14 125°C
12
85°C
25°C
IDD (uA)
10 -40°C
4
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
45
125°C
40
35
30
IDD (uA)
25
20 85°C
25°C
15 -40°C
10
5
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
5.0
4.5
4.0 16 MHz
3.5
3.0
IDD (mA)
2.5
8 MHz
2.0
1.5
4 M Hz
1.0
1 MHz
0.5
0.0
VDD (V)
16 MHz
4
IDD (mA)
3 8 MHz
4 MHz
1
1 MHz
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
125°C
5
IDD (uA)
4 85°C
25°C
-40°C
3
1
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
35
125°C
30
25
20
IDD (uA)
15
85°C
10
25°C
-40°C
5
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
2.5
2.0
16 MHz
1.5
IDD (mA)
8 MHz
1.0
4 MHz
0.5
1 MHz
0.0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
3.0
2.5
16 MHz
2.0
IDD (mA)
1.5
8 MHz
1.0
4 MHz
1 MHz
0.5
0.0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
16
14
64 MHz
12
10
40 MHz
IDD (mA)
20 MHz
4
16 MHz
10 MHz
2
4 MHz
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
18
16
64 MHz
14
12
10 40 MHz
IDD (mA)
6
20 MHz
16 MHz
4
10 MHz
2
4 MHz
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
16
14
64 MHz
12 (16 MHz Input)
10
40 MHz
IDD (mA)
4
16 MHz
(4 MHz Input)
2
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
20
18
16 64 MHz
(16 MHz Input)
14
12
40 MHz
IDD (mA)
6
16 MHz
4 (4 MHz Input)
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
6
64 MHz
4
40 MHz
IDD (mA)
2 20 MHz
16 MHz
1 10 MHz
4 MHz
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
64 MHz
7
5
IDD (mA)
40 MHz
4
3
20 MHz
2 16 MHz
10 MHz
1
4 MHz
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
4.0
3.5
Max.
3.0
2.5
IPD (uA)
2.0
1.5
Typ.
1.0
0.5
0.0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
FIGURE 27-18: PIC18F4XK20/PIC18F2XK20 IBOR and IHLVD – Delta IPD for Brown-out Reset
and High/Low Voltage Detect, -40°C to +125°C
70
60 Max. BOR
50
40
IPD (uA)
30 Max. HLVD
Typ. BOR
20
Typ. HLVD
10
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
3.5
3.0 Max.
-40°C to +85°C
2.5
2.0
IPD (uA)
1.5
1.0
Typ. 85°C
Typ. 25°C
0.5
0.0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
FIGURE 27-20: PIC18F4XK20/PIC18F2XK20 IOCSB – Typical Delta IPD for High-Power Timer1
Oscillator
20
85°C
18
25°C
16
IPD (uA)
14 -40°C
12
10
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
42
40 85°C
38
25°C
36
IPD (uA)
34
-40°C
32
30
28
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
80
70
Max.
60
50
(uA)
40
IPD
Typ.
30
20
10
0
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
340
320 125°C
300 85°C
280
(uA)
25°C
260
IDD
240
220
200
180
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
FIGURE 27-24: PIC18F4XK20/PIC18F2XK20 IAD – Maximum Delta IDD for ADC, 25°C to +125°C
(Run Mode, ADC on, but not converting)
440
125°C
420
85°C
400
380
25°C
360
340
IDD (uA)
320
300
280
260
240
220
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
7.0
125°C
6.5
85°C
6.0
5.5
IPD (uA)
25°C
5.0
4.5
-40°C
4.0
3.5
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
16
125°C
15
85°C
14
IPD (uA)
25°C
13
12
-40°C
11
10
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
55
50 125°C
85°C
45
IPD (uA)
25°C
40
35 -40°C
30
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
95
125°C
90
85 85°C
80
IPD (uA)
25°C
75
70
-40°C
65
60
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
70
60
-40°C 3 sigma
50
25°C 3 sigma
Abs. Offset (mV)
85°C 3 sigma
40
a
sigm
° C3
30 125
Typical
20
10
0
0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8
VREF (V)
70
-40°C 3 sigma
60
a
igm
3s
°C
50 25
Abs. Offset (mV)
a
m
sig
40
3
°C
a
m
85
sig
3
C
30
5°
12
Typical
20
10
0
0.0 0.4 0.8 1.2 1.6 2.0 2.4 2.8 3.2 3.6
VREF (V)
45
40
35 -40°C 3 sigma
25°C 3 sigma
30
ma
Abs. Offset (mV)
3 sig igma
85°C C3s
25 125°
20
Typical
15
10
0
0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8
VREF (V)
45
-40°C 3 sigma
40
35 25°C 3 sigma
a
sigm
30 C3
85°
Abs. Offset (mV)
a
igm
25 3s
5°C
12
20
Typical
15
10
0.0 0.4 0.8 1.2 1.6 2.0 2.4 2.8 3.2 3.6
VREF (V)
1.205
1.200 25°C
-40°C
85°C
1.195
FVR (V)
1.190
1.185
125°C
1.180
1.175
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
1.205
1.200 3.6V
2.0V
1.195
FVR (V)
1.190
1.8V
1.185
1.180
1.175
-40 -20 0 20 40 60 80 100 120
Temp. (°C)
1.8
Min.
1.6
1.4
1.2
VIH (V)
-40°C
25°C
1.0
85°C
125°C
0.8
0.6
0.4
1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6
VDD (V)
3.0
2.8
Min.
2.6
2.4
2.2
-40°C
VIH (V)
2.0 25°C
125°C
85°C
1.8
1.6
1.4
1.2
1.0
1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6
VDD (V)
1.2
-40°C
1.0 25°C
85°C
125°C
0.8
VIL (V)
0.6
Max.
0.4
0.2
0.0
1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6
VDD (V)
1.6
1.4 -40°C
25°C
85°C 125°C
1.2
1.0
VIL (V)
0.8
Max.
0.6
0.4
0.2
1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6
VDD (V)
3.6
2.4
Typ. 3.0V
VOH (V)
1.8
Typ. 3.6V
Min. 3.0V
1.2
Typ. 1.8V
0.6
Min. 3.6V
Min. 1.8V
0
0 5 10 15 20 25
IOH (mA)
1.8
Max. 1.8V
Max. 3.0V
1.5
Max. 3.6V
1.2
VOL (V)
0.9
0.6 1.8V
3.0V
3.6V
0.3
0
0 5 10 15 20 25
IOL (mA)
1000
RA2 Max.
RA3 Max.
100
Input Leakage (nA)
RA2 Typ.
RA3 Typ.
10
1
25 30 35 40 45 50 55 60 65 70 75 80 85
Temp. (°C)
16.08
16.00 25°C
Frequency (MHz)
15.92
85°C
15.84 -40°C
15.76
125°C
15.68
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
16.80
16.64
16.48
16.32 Max
Frequency (MHz)
16.16
16.00 3.0V
15.84
15.68 Min
15.52
15.36
15.20
-40 -20 0 20 40 60 80 100 120
Temp. (°C)
33.25
32.25
Frequency (kHz)
31.25
25°C
-40°C
30.25 85°C
29.25
125°C
28.25
1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.6
VDD (V)
33.25
32.25
1.8V
Frequency (kHz)
31.25
2.5V
3.6V 3.0V
30.25
29.25
28.25
-40 -20 0 20 40 60 80 100 120
Temp. (°C)
PIC18F25K20
-E/SP e3
1519017
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX PIC18F25K20
XXXXXXXXXXXXXXXXXXXX -E/SO e3
YYWWNNN 1519017
PIC18F25K20
-E/SS e3
1519017
Note: In the event the full Microchip part number cannot be marked on one line, it will
be carried over to the next line, thus limiting the number of available
characters for customer-specific information.
PIN 1 PIN 1
XXXXXXXX 18F24K20
XXXXXXXX -E/ML e3
YYWWNNN 1519017
519017
XXXXXXXXXXXXXXXXXX PIC18F45K20
XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX -E/P e3
YYWWNNN 1519017
Note: In the event the full Microchip part number cannot be marked on one line, it will
be carried over to the next line, thus limiting the number of available
characters for customer-specific information.
PIN 1 PIN 1
PIC18F
45K20
-I/MV e3
1519017
PIN 1 PIN 1
XXXXXXXXXXX PIC18F45K20
XXXXXXXXXXX -E/ML
XXXXXXXXXXX
1519017
YYWWNNN
XXXXXXXXXX
XXXXXXXXXX PIC18F44K20
XXXXXXXXXX -E/PT
YYWWNNN 1519017
Note: In the event the full Microchip part number cannot be marked on one line, it will
be carried over to the next line, thus limiting the number of available
characters for customer-specific information.
!" 3
&'
!&" &4# *!(!!&
4%&
&#&
&&255***'
'54
NOTE 1
E1
1 2 3
A A2
L c
A1 b1
b e eB
6&! 7,8.
'!
9'&! 7 7: ;
7"')
%! 7 <
& 1,
&
& = =
##4
4!! -
1!&
& = =
"# &
"# >#& . - --
##4>#& . <
: 9& - -?
&
& 9 -
9#
4!! <
6 9#>#& )
9
* 9#>#& ) <
:
*+ 1 = = -
!"
!"#$%&" ' ()"&'"!&)
&#*&&&#
+%&, & !&
- '!
!#.#
&"#'
#%!
& "!
!
#%!
& "!
!!
&$#/ !#
'!
#&
.0
1,2 1!'!
&$& "!
**&
"&&
!
* ,1
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
#$
%
&'
%
!" 3
&'
!&" &4# *!(!!&
4%&
&#&
&&255***'
'54
D
N
E
E1
1 2
b
NOTE 1
e
c
A A2
φ
A1
L1 L
& @ @ <@
9#>#& ) = -<
!"
!"#$%&" ' ()"&'"!&)
&#*&&&#
'!
!#.#
&"#'
#%!
& "!
!
#%!
& "!
!!
&$#'' !#
- '!
#&
.0
1,2 1!'!
&$& "!
**&
"&&
!
.32 % '!
("!"*&
"&&
(%
%
'&
"
!!
* ,-1
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
( )* ! + , -.- ()!
/# '&& 0
+#
!" 3
&'
!&" &4# *!(!!&
4%&
&#&
&&255***'
'54
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
NOTE 1
E1
1 2 3
A A2
L c
b1
A1
b e eB
6&! 7,8.
'!
9'&! 7 7: ;
7"')
%! 7
& 1,
&
& = =
##4
4!! =
1!&
& = =
"# &
"# >#& . = ?
##4>#& . < = <
: 9& < =
&
& 9 =
9#
4!! < =
6 9#>#& ) - =
9
* 9#>#& ) = -
:
*+ 1 = =
!"
!"#$%&" ' ()"&'"!&)
&#*&&&#
+%&, & !&
- '!
!#.#
&"#'
#%!
& "!
!
#%!
& "!
!!
&$#/ !#
'!
#&
.0
1,2 1!'!
&$& "!
**&
"&&
!
* ,?1
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
D A
D1 B
NOTE 2
(DATUM A)
(DATUM B)
E1 E
NOTE 1 A A
2X
N
0.20 H A B
2X 1 2 3
0.20 H A B 4X 11 TIPS
TOP VIEW
0.20 C A B
A A2
C
SEATING PLANE
0.10 C A1
SIDE VIEW
1 2 3
NOTE 1
44 X b
e 0.20 C A B
BOTTOM VIEW
Microchip Technology Drawing C04-076C Sheet 1 of 2
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
L θ
(L1)
SECTION A-A
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Number of Leads N 44
Lead Pitch e 0.80 BSC
Overall Height A - - 1.20
Standoff A1 0.05 - 0.15
Molded Package Thickness A2 0.95 1.00 1.05
Overall Width E 12.00 BSC
Molded Package Width E1 10.00 BSC
Overall Length D 12.00 BSC
Molded Package Length D1 10.00 BSC
Lead Width b 0.30 0.37 0.45
Lead Thickness c 0.09 - 0.20
Lead Length L 0.45 0.60 0.75
Footprint L1 1.00 REF
Foot Angle θ 0° 3.5° 7°
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Exact shape of each corner is optional.
3. Dimensioning and tolerancing per ASME Y14.5M
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
44-Lead Plastic Thin Quad Flatpack (PT) - 10X10X1 mm Body, 2.00 mm Footprint [TQFP]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
C1
44
1
2
G
C2
Y1
X1 E
SILK SCREEN
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Contact Pitch E 0.80 BSC
Contact Pad Spacing C1 11.40
Contact Pad Spacing C2 11.40
Contact Pad Width (X44) X1 0.55
Contact Pad Length (X44) Y1 1.50
Distance Between Pads G 0.25
Notes:
1. Dimensioning and tolerancing per ASME Y14.5M
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
Microchip Technology Drawing No. C04-2076B
Program Memory 8192 16384 32768 65536 8192 16384 32768 65536
(Bytes)
Program Memory 4096 8192 16384 32768 4096 8192 16384 32768
(Instructions)
Interrupt Sources 19 19 19 19 20 20 20 20
I/O Ports Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C,
(E) (E) (E) (E) D, E D, E D, E D, E
Capture/ 1 1 1 1 1 1 1 1
Compare/PWM
Modules
Enhanced 1 1 1 1 1 1 1 1
Capture/
Compare/PWM
Modules
Parallel No No No No Yes Yes Yes Yes
Communications
(PSP)
10-bit Analog-to- 11 input 11 input 11 input 11 input 14 input 14 input 14 input 14 input
Digital Module channels channels channels channels channels channels channels channels
Packages 28-pin PDIP 28-pin PDIP 28-pin PDIP 28-pin PDIP 40-pin PDIP 40-pin PDIP 40-pin PDIP 40-pin PDIP
28-pin SOIC 28-pin SOIC 28-pin SOIC 28-pin SOIC 44-pin TQFP 44-pin TQFP 44-pin TQFP 44-pin TQFP
28-pin SSOP 28-pin SSOP 28-pin SSOP 28-pin SSOP 44-pin QFN 44-pin QFN 44-pin QFN 44-pin QFN
28-pin QFN 28-pin QFN 28-pin QFN 28-pin QFN 40-pin UQFN 40-pin UQFN 40-pin UQFN 40-pin UQFN
28-pin UQFN
• 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.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
CERTIFIED BY DNV Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
== ISO/TS 16949 ==
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
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.
01/27/15