Professional Documents
Culture Documents
PIC18F45K20
PIC18F45K20
43K20/44K20/45K20/46K20
Data Sheet
28/40/44-Pin Flash Microcontrollers
with nanoWatt XLP Technology
• 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.
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.
PIC18F23K20
PIC18F24K20
PIC18F25K20
PIC18F26K20
RA3/AN3/VREF+/C1IN+ 5 24 RB3/AN9/C12IN2-/CCP2(1)
RA4/T0CKI/C1OUT 6 23 RB2/INT2/AN8/P1B
RA5/AN4/SS/HLVDIN/C2OUT 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
RC0/T1OSO/T13CKI 11 18 RC7/RX/DT
RC1/T1OSI/CCP2(1) 12 17 RC6/TX/CK
RC2/CCP1/P1A 13 16 RC5/SDO
RC3/SCK/SCL 14 15 RC4/SDI/SDA
40-pin PDIP
MCLR/VPP/RE3 1 40 RB7/KBI3/PGD
RA0/AN0/C12IN0- 2 39 RB6/KBI2/PGC
RA1/AN1/C12IN1- 3 38 RB5/KBI1/PGM
RA2/AN2/VREF-/CVREF/C2IN+ 4 37 RB4/KBI0/AN11
RA3/AN3/VREF+/C1IN+ 5 36 RB3/AN9/C12IN2-/CCP2(1)
RA4/T0CKI/C1OUT 6 35 RB2/INT2/AN8
RA5/AN4/SS/HLVDIN/C2OUT 7 34 RB1/INT1/AN10/C12IN3-
RE0/RD/AN5 8 33 RB0/INT0/FLT0/AN12
PIC18F43K20
PIC18F44K20
PIC18F45K20
RE1/WR/AN6 9 PIC18F46K20 32 VDD
RE2/CS/AN7 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
RC0/T1OSO/T13CKI 15 26 RC7/RX/DT
RC1/T1OSI/CCP2(1) 16 25 RC6/TX/CK
RC2/CCP1/P1A 17 24 RC5/SDO
RC3/SCK/SCL 18 23 RC4/SDI/SDA
RD0/PSP0 19 22 RD3/PSP3
RD1/PSP1 20 21 RD2/PSP2
RB4/KBI0/AN11/P1D
RA1/AN1/C12IN1-
RA0/AN0/C12IN0-
MCLR/VPP/RE3
RB5/KBI1/PGM
RB7/KBI3/PGD
RB6/KBI2/PGC
28-pin QFN/UQFN(2)
28 27 26 25 24 23 22
RA2/AN2/VREF-/CVREF/C2IN+ 1 21 RB3/AN9/C12IN2-/CCP2(1)
RA3/AN3/VREF+/C1IN+ 2 PIC18F23K20 20 RB2/INT2/AN8/P1B
RA4/T0CKI/C1OUT 3 PIC18F24K20 19 RB1/INT1/AN10/C12IN3-/P1C
RA5/AN4/SS/HLVDIN/C2OUT 4 18 RB0/INT0/FLT0/AN12
VSS 5
PIC18F25K20 VDD
17
OSC1/CLKIN/RA7 6 PIC18F26K20 16 VSS
OSC2/CLKOUT/RA6 7 15 RC7/RX/DT
8 9 10 11 12 13 14
RC0/T1OSO/T13CKI
RC5/SDO
RC1/T1OSI/CCP2(1)
RC2/CCP1/P1A
RC4/SDI/SDA
RC3/SCK/SCL
RC6/TX/CK
RC1/T1OSI/CCP2(1)
44-pin TQFP
RC2/CCP1/P1A
RC3/SCK/SCL
RC4/SDI/SDA
RC6/TX/CK
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC5/SDO
NC
44
43
42
41
40
39
38
37
36
35
34
RC7/RX/DT 1 33 NC
RD4/PSP4 2 32 RC0/T1OSO/T13CKI
RD5/PSP5/P1B 3 31 OSC2/CLKOUT/RA6
RD6/PSP6/P1C 4 PIC18F43K20 30 OSC1/CLKIN/RA7
RD7/PSP7/P1D 5 PIC18F44K20 29 VSS
VSS 6 28 VDD
VDD 7
PIC18F45K20 27 RE2/CS/AN7
RB0/INT0/FLT0/AN12 8 PIC18F46K20 26 RE1/WR/AN6
RB1/INT1/AN10/C12IN3- 9 25 RE0/RD/AN5
RB2/INT2/AN8 10 24 RA5/AN4/SS/HLVDIN/C2OUT
RB3/AN9/C12IN2-/CCP2(1) 11 23 RA4/T0CKI/C1OUT
12
13
14
15
16
17
18
19
20
21
22
RA2/AN2/VREF-/CVREF/C2IN+
NC
NC
RB6/KBI2/PGC
RB7/KBI3/PGD
RA3/AN3/VREF+/C1IN+
RB4/KBI0/AN11
RB5/KBI1/PGM
MCLR/VPP/RE3
RA0/AN0/C12IN0-
RA1/AN1/C12IN1-
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-pin QFN
44
43
42
41
40
39
38
37
36
35
34
RC7/RX/DT 1 33 OSC2/CLKOUT/RA6
RD4/PSP4 2 32 OSC1/CLKIN/RA7
RD5/PSP5/P1B 3 31 VSS
RD6/PSP6/P1C 4 PIC18F43K20 30 VSS
RD7/PSP7/P1D 5 PIC18F44K20 29 VDD
VSS 6 28 VDD
VDD PIC18F45K20 27 RE2/CS/AN7
7
VDD 8 PIC18F46K20 26 RE1/WR/AN6
RB0/INT0/FLT0/AN12 9 25 RE0/RD/AN5
RB1/INT1/AN10/C12IN3- 10 24 RA5/AN4/SS/HLVDIN/C2OUT
RB2/INT2/AN8 11 23 RA4/T0CKI/C1OUT
12
13
14
15
16
17
18
19
20
21
22
RA2/AN2/VREF-/CVREF/C2IN+
RB3/AN9/C12IN2-/CCP2(1)
RB5/KBI1/PGM
RB4/KBI0/AN11
MCLR/VPP/RE3
RA0/AN0/C12IN0-
RA1/AN1/C12IN1-
NC
RB6/KBI2/PGC
RB7/KBI3/PGD
RA3/AN3/VREF+/C1IN+
Comparator
Reference
Interrupts
TQFP Pin
EUSART
QFN Pin
DIL Pin
Analog
Pull-up
Timers
MSSP
ECCP
Basic
Slave
I/O
2 19 19 RA0 AN0 C12IN0- — — — — — — — — —
3 20 20 RA1 AN1 C12IN1- — — — — — — — — —
4 21 21 RA2 AN2 C2IN+ VREF-/ — — — — — — — —
CVREF
5 22 22 RA3 AN3 C1IN+ VREF+ — — — — — — — —
6 23 23 RA4 C1OUT — — — — T0CKI — — — —
7 24 24 RA5 AN4 C2OUT HLVDIN — — SS — — — — —
14 31 33 RA6 — — — — — — — — — — OSC2/
CLKOUT
13 30 32 RA7 — — — — — — — — — — OSC1/CLKIN
33 8 9 RB0 AN12 — — FLT0 — — — — INT0 Yes —
34 9 10 RB1 AN10 C12IN3- — — — — — — INT1 Yes —
35 10 11 RB2 AN8 — — — — — — — INT2 Yes —
36 11 12 RB3 AN9 C12IN2- — CCP2(1) — — — — — Yes —
37 14 14 RB4 AN11 — — — — — — — KBI0 Yes —
38 15 15 RB5 — — — — — — — — KBI1 Yes PGM
39 16 16 RB6 — — — — — — — — KBI2 Yes PGC
40 17 17 RB7 — — — — — — — — KBI3 Yes PGD
15 32 34 RC0 — — — — — — T1OSO/ — — — —
T13CKI
16 35 35 RC1 — — — CCP2(2) — — T1OSI — — — —
17 36 36 RC2 — — — CCP1/ — — — — — — —
P1A
18 37 37 RC3 — — — — — SCK/ — — — — —
SCL
23 42 42 RC4 — — — — — SDI/ — — — — —
SDA
24 43 43 RC5 — — — — — SDO — — — — —
25 44 44 RC6 — — — — TX/CK — — — — — —
26 1 1 RC7 — — — — RX/DT — — — — — —
19 38 38 RD0 — — — — — — — PSP0 — — —
20 39 39 RD1 — — — — — — — PSP1 — — —
21 40 40 RD2 — — — — — — — PSP2 — — —
22 41 41 RD3 — — — — — — — PSP3 — — —
27 2 2 RD4 — — — — — — — PSP4 — — —
28 3 3 RD5 — — — P1B — — — PSP5 — — —
29 4 4 RD6 — — — P1C — — — PSP6 — — —
30 5 5 RD7 — — — P1D — — — PSP7 — — —
8 25 25 RE0 AN5 — — — — — — RD — — —
9 26 26 RE1 AN6 — — — — — — WR — — —
10 27 27 RE2 AN7 — — — — — — CS — — —
1 18 18 RE3(3) — — — — — — — — — — MCLR/VPP
11 7 7 — — — — — — — — — — — VDD
32 28 28 — — — — — — — — — — — VDD
12 6 6 — — — — — — — — — — — VSS
31 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.
Comparator
Reference
Pin QUAD
Interrupts
EUSART
Pin DIL
Analog
Pull-up
Timers
MSSP
ECCP
Basic
Slave
I/O
2 27 RA0 AN0 C12IN0-
3 28 RA1 AN1 C12IN1-
4 1 RA2 AN2 C2IN+ VREF-/
CVREF
5 2 RA3 AN3 C1IN+ VREF+
6 3 RA4 C1OUT T0CKI
7 4 RA5 AN4 C2OUT HLVDIN SS
10 7 RA6 OSC2/
CLKOUT
9 6 RA7 OSC1/
CLKIN
21 18 RB0 AN12 FLT0 INT0 Yes
22 19 RB1 AN10 C12IN3- P1C INT1 Yes
23 20 RB2 AN8 P1B INT2 Yes
24 21 RB3 AN9 C12IN2- CCP2(1) Yes
25 22 RB4 AN11 P1D KBI0 Yes
26 23 RB5 KBI1 Yes PGM
27 24 RB6 KBI2 Yes PGC
28 25 RB7 KBI3 Yes PGD
11 8 RC0 T1OSO/
T13CKI
12 9 RC1 CCP2(2) T1OSI
13 10 RC2 CCP1/
P1A
14 11 RC3 SCK/
SCL
15 12 RC4 SDI/
SDA
16 13 RC5 SDO
17 14 RC6 TX/CK
18 15 RC7 RX/DT
1 26 RE3(3) MCLR/
VPP
8 5 VSS
19 16 VSS
20 17 VDD
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)
• The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, 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 Underflow
(PWRT, OST), (PWRT, OST), MCLR (PWRT, OST), (PWRT, OST), MCLR (PWRT, OST), (PWRT, OST), (PWRT, OST), (PWRT, OST), MCLR
MCLR (optional), (optional), WDT MCLR (optional), (optional), WDT MCLR (optional), MCLR (optional), MCLR (optional), (optional), WDT
WDT WDT WDT WDT 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
28-pin QFN 28-pin QFN 28-pin QFN 28-pin QFN 44-pin TQFP 44-pin TQFP 44-pin TQFP 44-pin TQFP
DS41303G-page 13
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 USART
INTSRC bit of the OSCTUNE register = 0
An adjustment may be required when the USART
• 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’ and 2.5.5.3 Compensating with the CCP Module
the frequency selection is set to 1 MHz. in Capture Mode
The user can modify the IRCF bits to A CCP module can use free running Timer1 (or Timer3),
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 61, 241
SPBRG EUSART Baud Rate Generator Register, Low Byte 0000 0000 61, 241
RCREG EUSART Receive Register 0000 0000 61, 238
TXREG EUSART Transmit Register 0000 0000 61, 237
TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 61, 246
RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 61, 247
EEADR EEADR7 EEADR6 EEADR5 EEADR4 EEADR3 EEADR2 EEADR1 EEADR0 0000 0000 61, 90, 99
EEADRH(7) — — — — — — EEADR9 EEADR8 ---- --00 61, 90, 99
EEDATA EEPROM Data Register 0000 0000 61, 90, 99
EECON2 EEPROM Control Register 2 (not a physical register) 0000 0000 61, 90, 99
EECON1 EEPGD CFGS — FREE WRERR WREN WR RD xx-0 x000 61, 91, 99
IPR2 OSCFIP C1IP C2IP EEIP BCLIP HLVDIP TMR3IP CCP2IP 1111 1111 62, 117
PIR2 OSCFIF C1IF C2IF EEIF BCLIF HLVDIF TMR3IF CCP2IF 0000 0000 62, 113
PIE2 OSCFIE C1IE C2IE EEIE BCLIE HLVDIE TMR3IE CCP2IE 0000 0000 62, 115
IPR1 PSPIP(2) ADIP RCIP TXIP SSPIP CCP1IP TMR2IP TMR1IP 1111 1111 62, 116
PIR1 PSPIF(2) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 62, 112
PIE1 PSPIE(2) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 62, 114
OSCTUNE INTSRC PLLEN(3) TUN5 TUN4 TUN3 TUN2 TUN1 TUN0 0q00 0000 33, 62
TRISE(2) IBF OBF IBOV PSPMODE — TRISE2 TRISE1 TRISE0 0000 -111 62, 134
TRISD(2) PORTD Data Direction Control Register 1111 1111 62, 130
TRISC PORTC Data Direction Control Register 1111 1111 62, 127
TRISB PORTB Data Direction Control Register 1111 1111 62, 124
TRISA TRISA7(5) TRISA6(5) Data Direction Control Register for PORTA 1111 1111 62, 121
LATE(2) — — — — — PORTE Data Latch Register ---- -xxx 62, 133
(Read and Write to Data Latch)
LATD(2) PORTD Data Latch Register (Read and Write to Data Latch) xxxx xxxx 62, 130
LATC PORTC Data Latch Register (Read and Write to Data Latch) xxxx xxxx 62, 127
LATB PORTB Data Latch Register (Read and Write to Data Latch) xxxx xxxx 62, 124
LATA LATA7(5) LATA6(5) PORTA Data Latch Register (Read and Write to Data Latch) xxxx xxxx 62, 121
PORTE — — — — RE3(4) RE2(2) RE1(2) RE0(2) ---- x000 62, 133
PORTD(2) RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 xxxx xxxx 62, 130
PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx 62, 127
PORTB RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 xxx0 0000 62, 124
PORTA RA7(5) RA6(5) RA5 RA4 RA3 RA2 RA1 RA0 xx0x 0000 62, 121
ANSELH(6) — — — ANS12 ANS11 ANS10 ANS9 ANS8 ---1 1111 62, 137
ANSEL ANS7(2) ANS6(2) ANS5(2) ANS4 ANS3 ANS2 ANS1 ANS0 1111 1111 62, 136
IOCB IOCB7 IOCB6 IOCB5 IOCB4 — — — — 0000 ---- 62, 124
WPUB WPUB7 WPUB6 WPUB5 WPUB4 WPUB3 WPUB2 WPUB1 WPUB0 1111 1111 62, 124
CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1R C1CH1 C1CH0 0000 0000 62, 284
CM2CON0 C2ON C2OUT C2OE C2POL C2SP C2R C2CH1 C2CH0 0000 0000 62, 285
CM2CON1 MC1OUT MC2OUT C1RSEL C2RSEL — — — — 0000 ---- 63, 287
SLRCON — — — SLRE(2) SLRD(2) SLRC SLRB SLRA ---1 1111 63, 138
SSPMSK MSK7 MSK6 MSK5 MSK4 MSK3 MSK2 MSK1 MSK0 1111 1111 63, 213
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 oper-
ation. When FREE is set, an erase operation is initiated
Several control registers are used in conjunction with on the next WR command. When FREE is clear, only
the TBLRD and TBLWT instructions. These include the: 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.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 regis- also be set. As previously noted, this also configures
ter. This provides the user with the ability to accurately Timer3 to increment on every rising edge of the
read 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
SSPBUF Reg
When the SSP is configured in Master mode, the lower
SCK/SCL seven bits of SSPADD act as the Baud Rate Generator
Shift
reload value. When the SSP is configured for I2C slave
Clock mode the SSPADD register holds the slave device
address. The SSP can be configured to respond to a
SSPSR Reg
range of addresses by qualifying selected bits of the
SDI/SDA MSb LSb
address register with the SSPMSK register.
SSPMSK Reg In receive operations, SSPSR and SSPBUF together
create a double-buffered receiver. When SSPSR
Match Detect Addr Match receives a complete byte, it is transferred to SSPBUF
and the SSPIF interrupt is set.
SSPADD Reg During transmission, the SSPBUF is not
double-buffered. A write to SSPBUF will write to both
Start and Set, Reset SSPBUF and SSPSR.
Stop bit Detect S, P bits
(SSPSTAT Reg)
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.
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.
DS41303G-page 209
PIC18F2XK20/4XK20
FIGURE 17-9:
DS41303G-page 210
Receiving Address R/W = 0 Transmitting Data Transmitting Data
ACK 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
Data in SCL held low P
sampled while CPU
responds to SSPIF
SSPIF (PIR1<3>)
PIC18F2XK20/4XK20
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
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
Bus master
terminates
SSPIF transfer
(PIR1<3>)
Cleared by software Cleared by software Cleared by software
Cleared by software
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
DS41303G-page 211
PIC18F2XK20/4XK20
FIGURE 17-11:
DS41303G-page 212
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
Receive First Byte of Address Receive Second Byte of Address Receive First Byte of Address R/W=1 Transmitting Data Byte ACK
SDA 1 1 1 1 0 A9 A8 ACK A7 A6 A5 A4 A3 A2 A1 A0 ACK 1 1 1 1 0 A9 A8 ACK 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 Sr P
PIC18F2XK20/4XK20
SSPIF
(PIR1<3>)
Cleared by software Cleared by software Cleared by software
BF (SSPSTAT<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: 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
DS41303G-page 216
Clock is not held low
because buffer full bit is
clear prior to falling edge Clock is held low until Clock is not held low
of 9th clock CKP is set to ‘1’ because ACK = 1
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.
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)
SSPIF
Bus master
(PIR1<3>) terminates
Cleared by software Cleared by software Cleared by software transfer
Cleared by software
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
DS41303G-page 217
PIC18F2XK20/4XK20
PIC18F2XK20/4XK20
17.4.5 GENERAL CALL ADDRESS If the general call address matches, the SSPSR is
SUPPORT transferred to the SSPBUF, the BF flag bit is set (eighth
bit) and on the falling edge of the ninth bit (ACK bit), the
The addressing procedure for the I2C bus is such that
SSPIF interrupt flag bit is set.
the first byte after the Start condition usually
determines which device will be the slave addressed by When the interrupt is serviced, the source for the
the master. The exception is the general call address interrupt can be checked by reading the contents of the
which can address all devices. When this address is SSPBUF. The value can be used to determine if the
used, all devices should, in theory, respond with an address was device specific or a general call address.
Acknowledge. In 10-bit mode, the SSPADD is required to be updated
The general call address is one of eight addresses for the second half of the address to match and the UA
reserved for specific purposes by the I2C protocol. It bit of the SSPSTAT register is set. If the general call
consists of all ‘0’s with R/W = 0. address is sampled when the GCEN bit is set, while the
slave is configured in 10-bit Address mode, then the
The general call address is recognized when the
second half of the address is not necessary, the UA bit
GCEN bit of the SSPCON2 is set. Following a Start bit
will not be set and the slave will begin receiving data
detect, 8 bits are shifted into the SSPSR and the
after the Acknowledge (Figure 17-15).
address is compared against the SSPADD. It is also
compared to the general call address and fixed in hard-
ware.
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
DS41303G-page 226
Write SSPCON2<0> SEN = 1 ACKSTAT in
Start condition begins SSPCON2 = 1
From slave, clear ACKSTAT bit SSPCON2<6>
SEN = 0
Transmitting Data or Second Half
Transmit Address to Slave R/W = 0 ACK
of 10-bit Address
SDA A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
SSPIF
Cleared by software service routine
Cleared by software from SSP interrupt
Cleared by software
BF (SSPSTAT<0>)
PEN
R/W
I 2C™ MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
Write to SSPCON2<4>
to start Acknowledge sequence
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)
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
of receive Set SSPIF interrupt
Set SSPIF interrupt at end of Acknow-
Set SSPIF interrupt ledge sequence
at end of receive
at end of Acknowledge
SSPIF sequence
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)
DS41303G-page 227
PIC18F2XK20/4XK20
PIC18F2XK20/4XK20
17.4.12 ACKNOWLEDGE SEQUENCE 17.4.13 STOP CONDITION TIMING
TIMING A Stop bit is asserted on the SDA pin at the end of a
An Acknowledge sequence is enabled by setting the receive/transmit by setting the Stop Sequence Enable
Acknowledge Sequence Enable bit, ACKEN bit of the bit, PEN bit of the SSPCON2 register. At the end of a
SSPCON2 register. When this bit is set, the SCL pin is receive/transmit, the SCL line is held low after the
pulled low and the contents of the Acknowledge data bit falling edge of the ninth clock. When the PEN bit is set,
are presented on the SDA pin. If the user wishes to gen- the master will assert the SDA line low. When the SDA
erate an Acknowledge, then the ACKDT bit should be line is sampled low, the Baud Rate Generator is
cleared. If not, the user should set the ACKDT bit before reloaded and counts down to ‘0’. When the Baud Rate
starting an Acknowledge sequence. The Baud Rate Generator times out, the SCL pin will be brought high
Generator then counts for one rollover period (TBRG) and one TBRG (Baud Rate Generator rollover count)
and the SCL pin is deasserted (pulled high). When the later, the SDA pin will be deasserted. When the SDA
SCL pin is sampled high (clock arbitration), the Baud pin is sampled high while SCL is high, the P bit of the
Rate Generator counts for TBRG. The SCL pin is then SSPSTAT register is set. A TBRG later, the PEN bit is
pulled low. Following this, the ACKEN bit is automatically cleared and the SSPIF bit is set (Figure 17-24).
cleared, the Baud Rate Generator is turned off and the
MSSP module then goes into Idle mode (Figure 17-23). 17.4.13.1 WCOL Status Flag
If the user writes the SSPBUF when a Stop sequence
17.4.12.1 WCOL Status Flag is in progress, then the WCOL bit is set and the
If the user writes the SSPBUF when an Acknowledge contents of the buffer are unchanged (the write doesn’t
sequence is in progress, then WCOL is set and the occur).
contents of the buffer are unchanged (the write doesn’t
occur).
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 Asyn-
chronous 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 10 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 Characteristics”.
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.
The CxCH<1:0> bits of the CMxCON0 register direct CxVIN- > CxVIN+ 1 1
one of four analog input pins to the comparator CxVIN- < CxVIN+ 1 0
inverting input.
20.2.6 COMPARATOR SPEED SELECTION
Note: To use CxIN+ and C12INx- pins as analog
inputs, the appropriate bits must be set in The trade-off between speed or power can be opti-
the ANSEL register and the corresponding mized during program execution with the CxSP control
TRIS bits must also be set to disable the bit. The default state for this bit is ‘1’ which selects the
output drivers. normal speed mode. Device power consumption can
be optimized at the cost of slower comparator propaga-
20.2.3 COMPARATOR REFERENCE tion delay by clearing the CxSP bit to ‘0’.
SELECTION
20.3 Comparator Response Time
Setting the CxR bit of the CMxCON0 register directs an
internal voltage reference or an analog input pin to the The comparator output is indeterminate for a period of
non-inverting input of the comparator. See time after the change of an input source or the selection
Section 21.0 “VOLTAGE REFERENCES” for more of a new reference voltage. This period is referred to as
information on the Internal Voltage Reference module. the response time. The response time of the
comparator differs from the settling time of the voltage
20.2.4 COMPARATOR OUTPUT reference. Therefore, both of these times must be
SELECTION considered when determining the total response time
The output of the comparator can be monitored by to a comparator input change. See the Comparator and
reading either the CxOUT bit of the CMxCON0 register Voltage Reference Specifications in Section 26.0
or the MCxOUT bit of the CM2CON1 register. In order “Electrical Characteristics” for more details.
to make the output available for an external connection,
the following conditions must be true:
• CxOE bit of the CMxCON0 register must be set
• Corresponding TRIS bit must be cleared
• CxON bit of the CMxCON0 register must 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
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
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
All bit-oriented instructions have three operands: The Instruction Set Summary, shown in Table 24-2,
lists the standard instructions recognized by the
1. The file register (specified by ‘f’) Microchip Assembler (MPASMTM).
2. The bit in the file register (specified by ‘b’)
Section 24.1.1 “Standard Instruction Set” provides
3. The accessed memory (specified by ‘a’) a description of each instruction.
The bit field designator ‘b’ selects the number of the bit
affected by the operation, while the file register
designator ‘f’ represents the number of the file in which
the bit is located.
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 01da0 ffff ffff C, DC, Z, OV, N 1, 2
ADDWFC f, d, a Add WREG and CARRY bit to f 1 0010 0da 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 memory
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 memory
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 memory
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 two-cycle instruction. this a two-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
two-cycle instruction.
two-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
† 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 to 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 details
to ensure internal
Power-on Reset signal
D004 SVDD VDD Rise Rate 0.05 — — V/ms See section on Power-on Reset for details
to ensure internal
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
Symbol Characteristic Min Typ† Max Units Conditions
No.
IPU Weak Pull-up Current
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 exter-
nal 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.
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
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-10: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET REQUIREMENTS
Param.
Symbol Characteristic Min Typ Max Units Conditions
No.
30 TmcL MCLR Pulse Width (low) 2 — — s
31 TWDT Watchdog Timer Time-out Period 3.5 4.1 4.7 ms 1:1 prescaler
(no postscaler)
32 TOST Oscillation Start-up Timer Period 1024 TOSC — 1024 TOSC — TOSC = OSC1 period
33 TPWRT Power-up Timer Period 54.8 64.4 74.1 ms
34 TIOZ I/O High-Impedance from MCLR — 2 — s
Low or Watchdog Timer Reset
35 TBOR Brown-out Reset Pulse Width 200 — — s VDD BVDD (see D005)
36 TIVRST Internal Reference Voltage Stable — 25 35 s
37 THLVD High/Low-Voltage Detect Pulse Width 200 — — s VDD VHLVD
38 TCSD CPU Start-up Time 5 — 10 s
39 TIOBST Time for HF-INTOSC to Stabilize — 0.25 1 ms
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-16: 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 Brownout 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)
XXXXXXXXXXXXXXXXX PIC18F25K20-E/SP
XXXXXXXXXXXXXXXXX e3
YYWWNNN 0810017
XXXXXXXXXXXXXXXXXXXX PIC18F25K20-E/SO e3
XXXXXXXXXXXXXXXXXXXX 0810017
XXXXXXXXXXXXXXXXXXXX
YYWWNNN
XXXXXXXXXXXXXXXXXX PIC18F45K20-E/P e3
XXXXXXXXXXXXXXXXXX 0810017
XXXXXXXXXXXXXXXXXX
YYWWNNN
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.
XXXXXXXXXXXXXXX PIC18F25K20-E/SS
XXXXXXXXXXXXXXX e3
XXXXXXXXXXXXXXX
YYWWNNN 0810017
XXXXXXXX 18F24K20
XXXXXXXX -E/ML e3
YYWWNNN 0810017
XXXXXXXXXX PIC18F45K20
XXXXXXXXXX -E/ML e3
XXXXXXXXXX 0810017
YYWWNNN
XXXXXXXXXX PIC18F44K20
XXXXXXXXXX -E/PT e3
XXXXXXXXXX 0810017
YYWWNNN
XXXXX PIC18
XXXXXX F23K20
XXXXXX -E/MV e3
YWWNNN 810017
/HDG6NLQQ\3ODVWLF'XDO,Q/LQH63±PLO%RG\>63',3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
NOTE 1
E1
1 2 3
A A2
L c
A1 b1
b e eB
8QLWV ,1&+(6
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI3LQV 1
3LWFK H %6&
7RSWR6HDWLQJ3ODQH $ ± ±
0ROGHG3DFNDJH7KLFNQHVV $
%DVHWR6HDWLQJ3ODQH $ ± ±
6KRXOGHUWR6KRXOGHU:LGWK (
0ROGHG3DFNDJH:LGWK (
2YHUDOO/HQJWK '
7LSWR6HDWLQJ3ODQH /
/HDG7KLFNQHVV F
8SSHU/HDG:LGWK E
/RZHU/HDG:LGWK E
2YHUDOO5RZ6SDFLQJ H% ± ±
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
6LJQLILFDQW&KDUDFWHULVWLF
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
/HDG3ODVWLF6PDOO2XWOLQH62±:LGHPP%RG\>62,&@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D
N
E
E1
NOTE 1
1 2 3
e
b
h
α
h
φ c
A A2
L
A1 L1 β
8QLWV 0,//,0(7(56
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI3LQV 1
3LWFK H %6&
2YHUDOO+HLJKW $ ± ±
0ROGHG3DFNDJH7KLFNQHVV $ ± ±
6WDQGRII $ ±
2YHUDOO:LGWK ( %6&
0ROGHG3DFNDJH:LGWK ( %6&
2YHUDOO/HQJWK ' %6&
&KDPIHURSWLRQDO K ±
)RRW/HQJWK / ±
)RRWSULQW / 5()
)RRW$QJOH7RS ±
/HDG7KLFNQHVV F ±
/HDG:LGWK E ±
0ROG'UDIW$QJOH7RS ±
0ROG'UDIW$QJOH%RWWRP ±
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
6LJQLILFDQW&KDUDFWHULVWLF
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGPPSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
/HDG3ODVWLF'XDO,Q/LQH3±PLO%RG\>3',3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
NOTE 1
E1
1 2 3
A A2
L c
b1
A1
b e eB
8QLWV ,1&+(6
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI3LQV 1
3LWFK H %6&
7RSWR6HDWLQJ3ODQH $ ± ±
0ROGHG3DFNDJH7KLFNQHVV $ ±
%DVHWR6HDWLQJ3ODQH $ ± ±
6KRXOGHUWR6KRXOGHU:LGWK ( ±
0ROGHG3DFNDJH:LGWK ( ±
2YHUDOO/HQJWK ' ±
7LSWR6HDWLQJ3ODQH / ±
/HDG7KLFNQHVV F ±
8SSHU/HDG:LGWK E ±
/RZHU/HDG:LGWK E ±
2YHUDOO5RZ6SDFLQJ H% ± ±
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
6LJQLILFDQW&KDUDFWHULVWLF
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
/HDG3ODVWLF6KULQN6PDOO2XWOLQH66±PP%RG\>6623@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D
N
E
E1
1 2
b
NOTE 1
e
c
A A2
φ
A1
L1 L
8QLWV 0,//,0(7(56
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI3LQV 1
3LWFK H %6&
2YHUDOO+HLJKW $ ± ±
0ROGHG3DFNDJH7KLFNQHVV $
6WDQGRII $ ± ±
2YHUDOO:LGWK (
0ROGHG3DFNDJH:LGWK (
2YHUDOO/HQJWK '
)RRW/HQJWK /
)RRWSULQW / 5()
/HDG7KLFNQHVV F ±
)RRW$QJOH
/HDG:LGWK E ±
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGPPSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
/HDG3ODVWLF4XDG)ODW1R/HDG3DFNDJH0/±[PP%RG\>4)1@
ZLWKPP&RQWDFW/HQJWK
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D D2
EXPOSED
PAD
E
b
E2
2 2
1 1 K
N N
NOTE 1 L
TOP VIEW BOTTOM VIEW
A3 A1
8QLWV 0,//,0(7(56
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI3LQV 1
3LWFK H %6&
2YHUDOO+HLJKW $
6WDQGRII $
&RQWDFW7KLFNQHVV $ 5()
2YHUDOO:LGWK ( %6&
([SRVHG3DG:LGWK (
2YHUDOO/HQJWK ' %6&
([SRVHG3DG/HQJWK '
&RQWDFW:LGWK E
&RQWDFW/HQJWK /
&RQWDFWWR([SRVHG3DG . ± ±
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
3DFNDJHLVVDZVLQJXODWHG
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
/HDG3ODVWLF4XDG)ODW1R/HDG3DFNDJH0/±[PP%RG\>4)1@
ZLWKPP&RQWDFW/HQJWK
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
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
/HDG3ODVWLF4XDG)ODW1R/HDG3DFNDJH0/±[PP%RG\>4)1@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D D2
EXPOSED
PAD
E2
b
2 2
1 1
N N K
NOTE 1 L
A3 A1
8QLWV 0,//,0(7(56
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI3LQV 1
3LWFK H %6&
2YHUDOO+HLJKW $
6WDQGRII $
&RQWDFW7KLFNQHVV $ 5()
2YHUDOO:LGWK ( %6&
([SRVHG3DG:LGWK (
2YHUDOO/HQJWK ' %6&
([SRVHG3DG/HQJWK '
&RQWDFW:LGWK E
&RQWDFW/HQJWK /
&RQWDFWWR([SRVHG3DG . ± ±
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
3DFNDJHLVVDZVLQJXODWHG
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
/HDG3ODVWLF4XDG)ODW1R/HDG3DFNDJH0/±[PP%RG\>4)1@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
/HDG3ODVWLF7KLQ4XDG)ODWSDFN37±[[PP%RG\PP>74)3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D
D1
E
e
E1
N
b
NOTE 1 1 2 3
NOTE 2
A α
c φ
β A1 A2
L L1
8QLWV 0,//,0(7(56
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI/HDGV 1
/HDG3LWFK H %6&
2YHUDOO+HLJKW $ ± ±
0ROGHG3DFNDJH7KLFNQHVV $
6WDQGRII $ ±
)RRW/HQJWK /
)RRWSULQW / 5()
)RRW$QJOH
2YHUDOO:LGWK ( %6&
2YHUDOO/HQJWK ' %6&
0ROGHG3DFNDJH:LGWK ( %6&
0ROGHG3DFNDJH/HQJWK ' %6&
/HDG7KLFNQHVV F ±
/HDG:LGWK E
0ROG'UDIW$QJOH7RS
0ROG'UDIW$QJOH%RWWRP
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
&KDPIHUVDWFRUQHUVDUHRSWLRQDOVL]HPD\YDU\
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGPPSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
/HDG3ODVWLF7KLQ4XDG)ODWSDFN37±[[PP%RG\PP>74)3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
Revision D (08/2008)
Update to Peripheral Highlights (USART module);
Deleted Section 2.2.6 (Oscillator Transitions); Revised
Sections 2.5.3, 2.9; Added Section 2.9.3 (Clock Switch
Timing); Deleted Section 2.10.4 (Clock Switching Tim-
ing); Replaced BAUDCTL with BAUDCON throughout;
Revised Table 5-2 (PLUSW0, PLUSW1, PLUSW2);
Add Note 1 to Table 7-1 (EEADRH); Revised Section
6.4.4 and Register 16-2 (FLT0 pin); Revised Registers
17-2 and 17-5 (SSPEN); Revised Register 17-6
(SEN); Added new paragraph after Figure 18-2;
Revised Note, Section 18.1.1; Deleted Note, Section
18.1.2; Added new Note 2, Sections 18.1.2.9 and
18.1.2.10; Revised Note 1, Section 18.3.1; Added
Section 18.3.2; Revised Section 18.3.5; Added new
Note 2, Sections 18.4.1.5, 18.4.1.10, 18.4.2.2,
18.4.2.4; Revised Register 21-1 (CVR); Revised Note
1, Registers 23-6, 23.8, 23-10, Table 23-3; Added new
Figure 26-1; Revised 26.2, 26.6, 26.7 (Note 3), 26.8,
26.9, 26.10; Revised Tables 26-1, 26-2, 26-3, 26-6, 26-
7, 26-8, 26-25; Updated Package Drawings.
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/Compare/PWM 1 1 1 1 1 1 1 1
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-Digital 11 input 11 input 11 input 11 input 14 input 14 input 14 input 14 input
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
28-pin UQFN
V
Voltage Reference (VR)
Specifications ........................................................... 381
Voltage Reference. See Comparator Voltage
Reference (CVREF)
Voltage References
Fixed Voltage Reference (FVR) ............................... 290
VR Stabilization ........................................................ 290
VREF. SEE ADC Reference Voltage
W
Wake-up on Break ........................................................... 254
Watchdog Timer (WDT) ........................................... 299, 308
Associated Registers ............................................... 309
Control Register ....................................................... 309
Programming Considerations .................................. 308
WCOL ...................................................... 223, 224, 225, 228
WCOL Status Flag ................................... 223, 224, 225, 228
WDTCON Register ........................................................... 309
WWW Address ................................................................. 453
WWW, On-Line Support ..................................................... 10
X
XORLW ............................................................................ 355
XORWF ............................................................................ 356
From: Name
Company
Address
City / State / ZIP / Country
Telephone: (_______) _________ - _________ FAX: (______) _________ - _________
Application (optional):
Would you like a reply? Y N
Questions:
2. How does this document meet your hardware and software development needs?
3. Do you find the organization of this document easy to follow? If not, why?
4. What additions to the document do you think would enhance the structure and subject?
5. What deletions from the document could be made without affecting the overall usefulness?
Package: ML = QFN
MV = UQFN
P = PDIP
PT = TQFP (Thin Quad Flatpack)
SO = SOIC
SP = Skinny Plastic DIP Note 1: T = Part number appended with T
SS = SSOP indicates tape and reel. P and SP
package options not available in tape
and reel.
Pattern: QTP, SQTP, Code or Special Requirements
(blank otherwise)
01/05/10