Datasheet PDF
Datasheet PDF
Datasheet PDF
Data Sheet
28/40/44-Pin, Low-Power,
High-Performance 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.
ISBN: 978-1-60932-175-8
Microchip received ISO/TS-16949:2002 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
Program
Data Memory MSSP
A/D Channels(2)
Memory
(Half-Bridge)
(Full-Bridge)
Comparator
16-bit Timer
8-bit Timer
BOR/LVD
SR Latch
EUSART
# Single-Word
CTMU
ECCP
ECCP
10-bit
Instructions
I/O(1)
CCP
EEPROM
Device
(Bytes)
(Bytes)
(Bytes)
SRAM
Flash
I2C™
SPI
PIC18(L)F23K22 8K 4096 512 256 25 19 2 1 2 2 2 2 2 Y Y Y 3 4
PIC18(L)F24K22 16K 8192 768 256 25 19 2 1 2 2 2 2 2 Y Y Y 3 4
PIC18(L)F25K22 32K 16384 1536 256 25 19 2 1 2 2 2 2 2 Y Y Y 3 4
PIC18(L)F26K22 64k 32768 3896 1024 25 19 2 1 2 2 2 2 2 Y Y Y 3 4
PIC18(L)F43K22 8K 4096 512 256 36 30 2 2 1 2 2 2 2 Y Y Y 3 4
PIC18(L)F44K22 16K 8192 768 256 36 30 2 2 1 2 2 2 2 Y Y Y 3 4
PIC18(L)F45K22 32K 16384 1536 256 36 30 2 2 1 2 2 2 2 Y Y Y 3 4
PIC18(L)F46K22 64k 32768 3896 1024 36 30 2 2 1 2 2 2 2 Y Y Y 3 4
Note 1: One pin is input only.
2: Channel count includes internal FVR and DAC channels.
MCLR/VPP/RE3 1 28 RB7
RA0 2 27 RB6
RA1 3 26 RB5
RA2 4 25 RB4
PIC18(L)F2XK22
RA3 5 24 RB3
RA4 6 23 RB2
RA5 7 22 RB1
VSS 8 21 RB0
RA7 9 20 VDD
RA6 10 19 VSS
RC0 11 18 RC7
RC1 12 17 RC6
RC2 13 16 RC5
RC3 14 15 RC4
RB7
RB6
RB5
RB4
28 27 26 25 24 23 22
RA2 1 21 RB3
RA3 2 20 RB2
RA4 3 19 RB1
RA5/ 4 PIC18(L)F2XK22 18 RB0
VSS 5 17 VDD
RA7 6 16 VSS
RA6 7 15 RC7
8 9 10 11 12 13 14
RC6
RC3
RC4
RC5
RC0
RC1
RC2
Note 1: The 28-pin UQFN package is available only for PIC18(L)F23K22 and PIC18(L)F24K22.
PIC18(L)F4XK22
RE0 8 33 RB0
RE1 9 32 VDD
RE2/ 10 31 VSS
VDD 11 30 RD7
VSS 12 29 RD6
RA7 13 28 RD5
RA6 14 27 RD4
RC0 15 26 RC7
RC1 16 25 RC6
RC2 17 24 RC5
RC3 18 23 RC4
RD0 19 22 RD3
RD1 20 21 RD2
44-pin TQFP
RC6/TX1/CK1
RC5/SDO1
RC4
RD3
RD2
RD1
RD0
RC3
RC2
RC1
NC
41
40
39
37
36
35
34
42
44
43
38
RC7 1 33 NC
RD4 2 32 RC0
RD5 3 31 RA6
RD6 4 30 RA7
RD7 5 29 VSS
VSS 6 PIC18(L)F4XK22 28 VDD
VDD 7 27 RE2
RB0 8 26 RE1
RB1 9 25 RE0
RB2 10 24 RA5
RB3 11 23 RA4
12
13
14
15
16
17
18
19
20
21
22
RB6
RB7
RA3
RA0
RA1
RA2
RB5
MCLR/VPP/RE3
RB4
NC
NC
44-pin QFN
RD3
RD1
RD0
RC2
RC1
RC0
RC6
RC5
RC4
RD2
RC3
44
43
42
41
40
39
37
36
35
34
38
RC7 1 33 RA6
RD4 2 32 RA7
RD5 3 31 VSS
RD6 4 30 VSS
RD7 5 29 VDD
VSS 6 PIC18(L)F4XK22 28 VDD
VDD 7 27 RE2
VDD 8 26 RE1
RB0 9 25 RE0
RB1 10 24 RA5
RB2 11 23 RA4
22
12
13
14
15
16
17
18
19
20
21
RB5
RB6
RB7
RA2
RA0
RA1
RB4
RA3
NC
MCLR/VPP/RE3
RB3
28-QFN, UQFN
Comparator
Reference
Interrupts
28-SPDIP
SR Latch
EUSART
(E)CCP
Analog
Pull-up
Timers
CTMU
MSSP
Basic
I/O
Comparator
Reference
Interrupts
SR Latch
44-TQFP
EUSART
40-PDIP
44-QFN
(E)CCP
Analog
Pull-up
Timers
CTMU
MSSP
Basic
I/O
2 19 19 RA0 AN0 C12IN0-
3 20 20 RA1 AN1 C12IN1-
4 21 21 RA2 AN2 C2IN+ VREF-
DACOUT
5 22 22 RA3 AN3 C1IN+ VREF+
6 23 23 RA4 C1OUT SRQ T0CKI
7 24 24 RA5 AN4 C2OUT SRNQ HLVDIN SS1
14 31 33 RA6 OSC2/
CLKO
13 30 32 RA7 OSC1/
CLKI
33 8 9 RB0 AN12 SRI FLT0 INT0 Y
34 9 10 RB1 AN10 C12IN3- INT1 Y
35 10 11 RB2 AN8 CTED1 INT2 Y
36 11 12 RB3 AN9 C12IN2- CTED2 CCP2/ Y
P2A(1)
37 14 14 RB4 AN11 T5G IOC Y
38 15 15 RB5 AN13 CCP3/ T1G IOC Y
P3A(4) T3CKI(2)
39 16 16 RB6 IOC Y PGC
40 17 17 RB7 IOC Y PGD
15 32 34 RC0 P2B(5) SOSCO/
T1CKI
T3CKI(2)
T3G
16 35 35 RC1 CCP2(1) SOSCI
P2A
17 36 36 RC2 AN14 CTPLS CCP1/ T5CKI
P1A
18 37 37 RC3 AN15 SCK1/
SCL1
23 42 42 RC4 AN16 SDI1/
SDA1
24 43 43 RC5 AN17 SDO1
25 44 44 RC6 AN18 TX1/
CK1
26 1 1 RC7 AN19 RX1/
DT1
19 38 38 RD0 AN20 SCK2/
SCL2
20 39 39 RD1 AN21 CCP4 SDI2/
SDA2
21 40 40 RD2 AN22 P2B(5)
22 41 41 RD3 AN23 P2C SS2
27 2 2 RD4 AN24 P2D SD02
28 3 3 RD5 AN25 P1B
29 4 4 RD6 AN26 P1C TX2
CK2
30 5 5 RD7 AN27 P1D RX2/
DT2
8 25 25 RE0 AN5 CCP3/
P3A(4)
Note 1: CCP2 multiplexed in fuses.
2: T3CKI multiplexed in fuses.
3: Pins are enabled on -ICE derivative only, otherwise they are No Connects.
4: CCP3/P3A multiplexed in fuses.
5: P2B multiplexed in fuses.
Comparator
Reference
Interrupts
SR Latch
44-TQFP
EUSART
40-PDIP
44-QFN
(E)CCP
Analog
Pull-up
Timers
CTMU
MSSP
Basic
I/O
9 26 26 RE1 AN6 P3B
1 18 18 RE3 Y MCLR/
VPP
11 7 7,8 VDD
32 28 28, 29 VDD
12 6 6 VSS
31 29 30, 31 VSS
— 12(3) —
(3)
— 13 —
— 33(3) —
— 34 13 NC
Note 1: CCP2 multiplexed in fuses.
2: T3CKI multiplexed in fuses.
3: Pins are enabled on -ICE derivative only, otherwise they are No Connects.
4: CCP3/P3A multiplexed in fuses.
5: P2B multiplexed in fuses.
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.
(Instructions)
Data Memory (Bytes) 512 768 1536 3896 512 768 1536 3896
Data EEPROM Memory (Bytes) 256 256 256 1024 256 256 256 1024
I/O Ports A, B, C, E(1) A, B, C, E(1) A, B, C, E(1) A, B, C, E(1) A, B, C, D, E A, B, C, D, E A, B, C, D, E A, B, C, D, E
Capture/Compare/PWM Mod- 2 2 2 2 2 2 2 2
ules (CCP)
Preliminary
SR Latch Yes
Charge Time Measurement Unit Yes
Module (CTMU)
Programmable Yes
High/Low-Voltage Detect (HLVD)
Programmable Brown-out Reset Yes
(BOR)
Resets (and Delays) POR, BOR,
RESET Instruction,
Stack Overflow,
Stack Underflow
(PWRT, OST),
MCLR, WDT
Instruction Set 75 Instructions;
83 with Extended Instruction Set enabled
Operating Frequency DC - 64 MHz
Note 1: PORTE contains the single RE3 read-only bit.
DS41412B-page 15
PIC18(L)F2X/4XK22
PIC18(L)F2X/4XK22
FIGURE 1-1: PIC18(L)F2X/4XK22 FAMILY BLOCK DIAGRAM
Data Bus<8>
Table Pointer<21>
8 8 Data Latch
inc/dec logic
Data Memory
21 PCLATU PCLATH
20 Address Latch PORTA
PCU PCH PCL RA0:RA7
Program Counter 12
Data Address<12>
31-Level Stack
Address Latch 4 12 4
BSR FSR0 Access
Program Memory STKPTR Bank
(8/16/32/64 Kbytes) FSR1
PORTB
FSR2 12
Data Latch RB0:RB7
inc/dec
8 logic
Table Latch
8
Instruction State machine
Decode and control signals
Control
PRODH PRODL
PORTD
8 x 8 Multiply RD0:RD7
3 8
BITOP W
8 8 8
OSC1(2) Internal
Oscillator Power-up
Timer 8 8
Block PORTE
(2) Oscillator
OSC2 ALU<8>
LFINTOSC Start-up Timer RE0:RE2
SOSCI Oscillator Power-on 8 RE3(1)
Reset
16 MHz
SOSCO Oscillator Watchdog
Timer
Precision FVR
Single-Supply Brown-out Band Gap
MCLR(1) Reset
Programming Reference
In-Circuit Fail-Safe
Debugger Clock Monitor
2 19 19 RA0/C12IN0-/AN0
RA0 I/O TTL Digital I/O.
C12IN0- I Analog Comparators C1 and C2 inverting input.
AN0 I Analog Analog input 0.
3 20 20 RA1/C12IN1-/AN1
RA1 I/O TTL Digital I/O.
C12IN1- I Analog Comparators C1 and C2 inverting input.
AN1 I Analog Analog input 1.
4 21 21 RA2/C2IN+/AN2/DACOUT/VREF-
RA2 I/O TTL Digital I/O.
C2IN+ I Analog Comparator C2 non-inverting input.
AN2 I Analog Analog input 2.
DACOUT O Analog DAC Reference output.
VREF- I Analog A/D reference voltage (low) input.
5 22 22 RA3/C1IN+/AN3/VREF+
RA3 I/O TTL Digital I/O.
C1IN+ I Analog Comparator C1 non-inverting input.
AN3 I Analog Analog input 3.
VREF+ I Analog A/D reference voltage (high) input.
6 23 23 RA4/C1OUT/SRQ/T0CKI
RA4 I/O TTL Digital I/O.
C1OUT O CMOS Comparator C1 output.
SRQ O TTL SR Latch Q output.
T0CKI I ST Timer0 external clock input.
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output; ST = Schmitt Trigger input with CMOS levels;
I = Input; O = Output; P = Power.
Note 1: Default pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX, CCP3MX
and CCP2MX are set.
2: Alternate pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX,
CCP3MX and CCP2MX are clear.
7 24 24 RA5/C2OUT/SRNQ/SS1/HLVDIN/AN4
RA5 I/O TTL Digital I/O.
C2OUT O CMOS Comparator C2 output.
SRNQ O TTL SR Latch Q output.
SS1 I TTL SPI slave select input (MSSP1).
HLVDIN I Analog High/Low-Voltage Detect input.
AN4 I Analog Analog input 4.
14 31 33 RA6/CLKO/OSC2
RA6 I/O TTL Digital I/O.
CLKO O — In RC mode, OSC2 pin outputs CLKOUT which
has 1/4 the frequency of OSC1 and denotes the
instruction cycle rate.
OSC2 O — Oscillator crystal output. Connects to crystal or
resonator in Crystal Oscillator mode.
13 30 32 RA7/CLKI/OSC1
RA7 I/O TTL Digital I/O.
CLKI I CMOS External clock source input. Always associated
with pin function OSC1.
OSC1 I ST Oscillator crystal input or external clock source
input ST buffer when configured in RC mode;
CMOS otherwise.
33 8 9 RB0/INT0/FLT0/SRI/AN12
RB0 I/O TTL Digital I/O.
INT0 I ST External interrupt 0.
FLT0 I ST PWM Fault input for ECCP Auto-Shutdown.
SRI I ST SR Latch input.
AN12 I Analog Analog input 12.
34 9 10 RB1/INT1/C12IN3-/AN10
RB1 I/O TTL Digital I/O.
INT1 I ST External interrupt 1.
C12IN3- I Analog Comparators C1 and C2 inverting input.
AN10 I Analog Analog input 10.
35 10 11 RB2/INT2/CTED1/AN8
RB2 I/O TTL Digital I/O.
INT2 I ST External interrupt 2.
CTED1 I ST CTMU Edge 1 input.
AN8 I Analog Analog input 8.
36 11 12 RB3/CTED2/P2A/CCP2/C12IN2-/AN9
RB3 I/O TTL Digital I/O.
CTED2 I ST CTMU Edge 2 input.
P2A(2) O CMOS Enhanced CCP2 PWM output.
CCP2(2) I/O ST Capture 2 input/Compare 2 output/PWM 2 output.
C12IN2- I Analog Comparators C1 and C2 inverting input.
AN9 I Analog Analog input 9.
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output; ST = Schmitt Trigger input with CMOS levels;
I = Input; O = Output; P = Power.
Note 1: Default pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX, CCP3MX
and CCP2MX are set.
2: Alternate pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX,
CCP3MX and CCP2MX are clear.
37 14 14 RB4/IOC0/T5G/AN11
RB4 I/O TTL Digital I/O.
IOC0 I TTL Interrupt-on-change pin.
T5G I ST Timer5 external clock gate input.
AN11 I Analog Analog input 11.
38 15 15 RB5/IOC1/P3A/CCP3/T3CKI/T1G/AN13
RB5 I/O TTL Digital I/O.
IOC1 I TTL Interrupt-on-change pin.
P3A(1) O CMOS Enhanced CCP3 PWM output.
CCP3(1) I/O ST Capture 3 input/Compare 3 output/PWM 3 output.
(2)
T3CKI I ST Timer3 clock input.
T1G I ST Timer1 external clock gate input.
AN13 I Analog Analog input 13.
39 16 16 RB6/IOC2/PGC
RB6 I/O TTL Digital I/O.
IOC2 I TTL Interrupt-on-change pin.
PGC I/O ST In-Circuit Debugger and ICSP™ programming
clock pin.
40 17 17 RB7/IOC3/PGD
RB7 I/O TTL Digital I/O.
IOC3 I TTL Interrupt-on-change pin.
PGD I/O ST In-Circuit Debugger and ICSP™ programming
data pin.
15 32 34 RC0/P2B/T3CKI/T3G/T1CKI/SOSCO
RC0 I/O TTL Digital I/O.
P2B(2) O CMOS Enhanced CCP1 PWM output.
T3CKI(1) I ST Timer3 clock input.
T3G I ST Timer3 external clock gate input.
T1CKI I ST Timer1 clock input.
SOSCO O — Secondary oscillator output.
16 35 35 RC1/P2A/CCP2/SOSCI
RC1 I/O TTL Digital I/O.
P2A(1) O CMOS Enhanced CCP2 PWM output.
CCP2(1) I/O ST Capture 2 input/Compare 2 output/PWM 2 output.
SOSCI I Analog Secondary oscillator input.
17 36 36 RC2/CTPLS/P1A/CCP1/T5CKI/AN14
RC2 I/O TTL Digital I/O.
CTPLS O — CTMU pulse generator output.
P1A O CMOS Enhanced CCP1 PWM output.
CCP1 I/O ST Capture 1 input/Compare 1 output/PWM 1 output.
T5CKI I ST Timer5 clock input.
AN14 I Analog Analog input 14.
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output; ST = Schmitt Trigger input with CMOS levels;
I = Input; O = Output; P = Power.
Note 1: Default pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX, CCP3MX
and CCP2MX are set.
2: Alternate pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX,
CCP3MX and CCP2MX are clear.
18 37 37 RC3/SCK1/SCL1/AN15
RC3 I/O TTL Digital I/O.
SCK1 I/O ST Synchronous serial clock input/output for SPI
mode (MSSP2).
SCL1 I/O ST Synchronous serial clock input/output for I2C™
mode (MSSP2).
AN15 I Analog Analog input 15.
23 42 42 RC4/SDI1/SDA1/AN16
RC4 I/O TTL Digital I/O.
SDI1 I ST SPI data in (MSSP1).
SDA1 I/O ST I2C™ data I/O (MSSP1).
AN16 I Analog Analog input 16.
24 43 43 RC5/SDO1/AN17
RC5 I/O TTL Digital I/O.
SDO1 O — SPI data out (MSSP1).
AN17 I Analog Analog input 17.
25 44 44 RC6/TX1/CK1/AN18
RC6 I/O TTL Digital I/O.
TX1 O — EUSART 1 asynchronous transmit.
CK1 I/O ST EUSART 1 synchronous clock (see related RXx/
DTx).
AN18 I Analog Analog input 18.
26 1 1 RC7/RX1/DT1/AN19
RC7 I/O TTL Digital I/O.
RX1 I ST EUSART 1 asynchronous receive.
DT1 I/O ST EUSART 1 synchronous data (see related TXx/
CKx).
AN19 I Analog Analog input 19.
19 38 38 RD0/SCK2/SCL2/AN20
RD0 I/O TTL Digital I/O.
SCK2 I/O ST Synchronous serial clock input/output for SPI
mode (MSSP2).
SCL2 I/O ST Synchronous serial clock input/output for I2C™
mode (MSSP2).
AN20 I Analog Analog input 20.
20 39 39 RD1/CCP4/SDI2/SDA2/AN21
RD1 I/O TTL Digital I/O.
CCP4 I/O ST Capture 4 input/Compare 4 output/PWM 4 output.
SDI2 I ST SPI data in (MSSP2).
SDA2 I/O ST I2C™ data I/O (MSSP2).
AN21 I Analog Analog input 21.
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output; ST = Schmitt Trigger input with CMOS levels;
I = Input; O = Output; P = Power.
Note 1: Default pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX, CCP3MX
and CCP2MX are set.
2: Alternate pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX,
CCP3MX and CCP2MX are clear.
21 40 40 RD2/P2B/AN22
RD2 I/O TTL Digital I/O
P2B(1) O CMOS Enhanced CCP2 PWM output.
AN22 I Analog Analog input 22.
22 41 41 RD3/P2C/SS2/AN23
RD3 I/O TTL Digital I/O.
P2C O CMOS Enhanced CCP2 PWM output.
SS2 I TTL SPI slave select input (MSSP2).
AN23 I Analog Analog input 23.
27 2 2 RD4/P2D/SDO2/AN24
RD4 I/O TTL Digital I/O.
P2D O CMOS Enhanced CCP2 PWM output.
SDO2 O — SPI data out (MSSP2).
AN24 I Analog Analog input 24.
28 3 3 RD5/P1B/AN25
RD5 I/O TTL Digital I/O.
P1B O CMOS Enhanced CCP1 PWM output.
AN25 I Analog Analog input 25.
29 4 4 RD6/P1C/TX2/CK2/AN26
RD6 I/O TTL Digital I/O.
P1C O CMOS Enhanced CCP1 PWM output.
TX2 O — EUSART 2 asynchronous transmit.
CK2 I/O ST EUSART 2 synchronous clock (see related RXx/
DTx).
AN26 I Analog Analog input 26.
30 5 5 RD7/P1D/RX2/DT2/AN27
RD7 I/O TTL Digital I/O.
P1D O CMOS Enhanced CCP1 PWM output.
RX2 I ST EUSART 2 asynchronous receive.
DT2 I/O ST EUSART 2 synchronous data (see related TXx/
CKx).
AN27 I Analog Analog input 27.
8 25 25 RE0/P3A/CCP3/AN5
RE0 I/O TTL Digital I/O.
P3A(2) O CMOS Enhanced CCP3 PWM output.
CCP3(2) I/O ST Capture 3 input/Compare 3 output/PWM 3 output.
AN5 I Analog Analog input 5.
9 26 26 RE1/P3B/AN6
RE1 I/O TTL Digital I/O.
P3B O CMOS Enhanced CCP3 PWM output.
AN6 I Analog Analog input 6.
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output; ST = Schmitt Trigger input with CMOS levels;
I = Input; O = Output; P = Power.
Note 1: Default pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX, CCP3MX
and CCP2MX are set.
2: Alternate pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX,
CCP3MX and CCP2MX are clear.
10 27 27 RE2/CCP5/AN7
RE2 I/O TTL Digital I/O.
CCP5 I/O ST Capture 5 input/Compare 5 output/PWM 5 output
AN7 I Analog Analog input 7.
1 18 18 RE3/VPP/MCLR
RE3 I ST Digital input.
VPP P Programming voltage input.
MCLR I ST Active-low Master Clear (device Reset) input.
11,32 7,28 7,8, VDD P — Positive supply for logic and I/O pins.
28,29
12,31 6,29 6,30,31 VSS P — Ground reference for logic and I/O pins.
12,13, 13 NC
33,34
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output; ST = Schmitt Trigger input with CMOS levels;
I = Input; O = Output; P = Power.
Note 1: Default pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX, CCP3MX
and CCP2MX are set.
2: Alternate pin assignment for P2B, T3CKI, CCP3/P3A and CCP2/P2A when Configuration bits PB2MX, T3CMX,
CCP3MX and CCP2MX are clear.
Low-Power Mode
SOSCO
Secondary SOSCOUT Event Switch
Oscillator (SCS<1:0>)
(SOSC)
SOSCI
INTOSC
1x
Internal Oscillator
IRCF<2:0>
MFIOSEL
INTSRC
3 3
HF-16 MHZ
HFINTOSC HF-8 MHZ
(16 MHz) HF-4 MHZ
Internal Oscillator MUX(3)
HF-2 MHZ
HF-1 MHZ
INTOSC HF-500 kHZ
Divide HF-250 kHZ
HF-31.25 kHZ INTOSC
Circuit
MFINTOSC
(500 kHz)
MF-500 kHZ
MF-250 kHZ
MF-31.25 kHZ
MF-500 KHZ
1 500 kHZ 010 INTOSC
HF-500 KHZ
0
MF-250 KHZ
1
250 kHZ 001
HF-250 KHZ
0
HF-31.25 KHZ 11
MF-31.25 KHZ 10 31.25 kHZ
000
LF-31.25 KHZ
0X
SOSCEN SOSCGO
T1SOSCEN
T3SOSCEN
T5SOSCEN
To Clock Switch Module
EN
SOSCI
Secondary SOSCOUT
Oscillator
SOSCO
1
T1CKI
T3G SOSCEN T1CLK_EXT_SRC
T3CKI 0
SOSCEN T1SOSCEN
T3G
SOSCEN
1
0 T3CLK_EXT_SRC
0
T3CKI 1
T3SOSCEN
T1G
T3CMX
T1G 1
T5CLK_EXT_SRC
T5CKI 0
T5SOSCEN
T5G T5G
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
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ q = depends on condition
‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
-n/n = Value at POR and BOR/Value at all other Resets
C1 To Internal
PIC® MCU Logic
C1 To Internal
Logic
C2 Ceramic RS(1) OSC2/CLKOUT
Quartz
RF(2) Sleep Resonator
Crystal
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 (IRCF<2:0> = 11x). Otherwise, the PLLEN bit is unavailable
and always reads ‘0’.
2.9 Clock Switching After a Reset, the SCS<1:0> bits of the OSCCON
register are always cleared.
The system clock source can be switched between
external and internal clock sources via software using Note: Any automatic clock switch, which may
the System Clock Select (SCS<1:0>) bits of the occur from Two-Speed Start-up or Fail-Safe
OSCCON register. Clock Monitor, does not update the
SCS<1:0> bits of the OSCCON register.
PIC18(L)F2X/4XK22 devices contain circuitry to pre-
The user can monitor the SOSCRUN,
vent clock “glitches” when switching between clock
MFIOFS and LFIOFS bits of the
sources. A short pause in the device clock occurs dur-
OSCCON2 register, and the HFIOFS and
ing the clock switch. The length of this pause is the sum
OSTS bits of the OSCCON register to
of two cycles of the old clock source and three to four
determine the current system clock source.
cycles of the new clock source. This formula assumes
that the new clock source is stable.
2.9.2 OSCILLATOR START-UP TIME-OUT
Clock transitions are discussed in greater detail in STATUS (OSTS) BIT
Section 3.1.2 “Entering Power-Managed Modes”.
The Oscillator Start-up Time-out Status (OSTS) bit of
2.9.1 SYSTEM CLOCK SELECT the OSCCON register indicates whether the system
(SCS<1:0>) BITS clock is running from the external clock source, as
defined by the FOSC<3:0> bits in the CONFIG1H
The System Clock Select (SCS<1:0>) bits of the Configuration register, or from the internal clock
OSCCON register select the system clock source that source. In particular, when the primary oscillator is the
is used for the CPU and peripherals. source of the primary clock, OSTS indicates that the
• When SCS<1:0> = 00, the system clock source is Oscillator Start-up Timer (OST) has timed out for LP,
determined by configuration of the FOSC<3:0> XT or HS modes.
bits in the CONFIG1H Configuration register.
• When SCS<1:0> = 10, the system clock source is
chosen by the internal oscillator frequency
selected by the INTSRC bit of the OSCTUNE
register, the MFIOSEL bit of the OSCCON2
register and the IRCF<2:0> bits of the OSCCON
register.
• When SCS<1:0> = 01, the system clock source is
the 32.768 kHz secondary oscillator shared with
Timer1, Timer3 and Timer5.
Start-up delay specifications are located in • Two-Speed Start-up mode is enabled when the
Section 27.0 “Electrical Characteristics”, under AC IESO of the CONFIG1H Configuration register is
Specifications (Oscillator Module). set.
• SCS<1:0> (of the OSCCON register) = 00.
• FOSC<2:0> bits of the CONFIG1H Configuration
register are configured for LP, XT or HS mode.
Two-Speed Start-up mode becomes active after:
• Power-on Reset (POR) and, if enabled, after
Power-up Timer (PWRT) has expired, or
• Wake-up from Sleep.
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.
SOSCI 1 2 3 n-1 n
CPU
Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
FIGURE 3-2: TRANSITION TIMING FROM SEC_RUN MODE TO PRI_RUN MODE (HSPLL)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
SOSC
OSC1
TOST(1) TPLL(1)
1 2 n-1 n
PLL Clock
Output
Clock
Transition(2)
CPU Clock
Peripheral
Clock
Program PC PC + 2 PC + 4
Counter
Note1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
2: Clock transition typically occurs within 2-4 TOSC.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
INTOSC
Multiplexer
OSC1
TOST(1) TPLL(1)
1 2 n-1 n
PLL Clock
Output
Clock
Transition(2)
CPU Clock
Peripheral
Clock
Program PC PC + 2 PC + 4
Counter
Note1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
2: Clock transition typically occurs within 2-4 TOSC.
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
Q1 Q2 Q3 Q4
OSC1
TCSD
CPU Clock
Peripheral
Clock
Program PC
Counter
Wake Event
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
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’
‘1’ = Bit is set ‘0’ = Bit is cleared -n/n = Value at POR and BOR/Value at all other Resets
x = Bit is unknown u = unchanged q = depends on condition
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 .
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.
(1)
HSPLL 66 ms + 1024 TOSC + 2 1024 TOSC + 2 ms(2) 1024 TOSC + 2 ms(2)
ms(2)
HS, XT, LP 66 ms(1) + 1024 TOSC 1024 TOSC 1024 TOSC
(1)
EC, ECIO 66 ms — —
RC, RCIO 66 ms(1) — —
INTIO1, INTIO2 66 ms(1) — —
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.
FIGURE 4-3: TIME-OUT SEQUENCE ON POWER-UP (MCLR TIED TO VDD, VDD RISE < TPWRT)
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
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-6: SLOW RISE TIME (MCLR TIED TO VDD, VDD RISE > TPWRT)
5V
VDD 0V
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
PLL TIME-OUT
INTERNAL RESET
Stack Level 31
PIC18(L)F25K22
PIC18(L)F45K22
FFFFh
10000h
Read ‘0’ Read ‘0’ Read ‘0’
PIC18(L)F26K22
PIC18(L)F46K22
Read ‘0’
1FFFFFh
200000h
5.1.1 PROGRAM COUNTER The CALL, RCALL, GOTO and program branch
instructions write to the program counter directly. For
The Program Counter (PC) specifies the address of the
these instructions, the contents of PCLATH and
instruction to fetch for execution. The PC is 21 bits wide
PCLATU are not transferred to the program counter.
and is contained in three separate 8-bit registers. The
low byte, known as the PCL register, is both readable
5.1.2 RETURN ADDRESS STACK
and writable. The high byte, or PCH register, contains
the PC<15:8> bits; it is not directly readable or writable. The return address stack allows any combination of up
Updates to the PCH register are performed through the to 31 program calls and interrupts to occur. The PC is
PCLATH register. The upper byte is called PCU. This pushed onto the stack when a CALL or RCALL
register contains the PC<20:16> bits; it is also not instruction is executed or an interrupt is Acknowledged.
directly readable or writable. Updates to the PCU The PC value is pulled off the stack on a RETURN,
register are performed through the PCLATU register. RETLW or a RETFIE instruction. PCLATU and PCLATH
are not affected by any of the RETURN or CALL
The contents of PCLATH and PCLATU are transferred
instructions.
to the program counter by any operation that writes
PCL. Similarly, the upper two bytes of the program The stack operates as a 31-word by 21-bit RAM and a
counter are transferred to PCLATH and PCLATU by an 5-bit Stack Pointer, STKPTR. The stack space is not
operation that reads PCL. This is useful for computed part of either program or data space. The Stack Pointer
offsets to the PC (see Section 5.1.4.1 “Computed is readable and writable and the address on the top of
GOTO”). the stack is readable and writable through the Top-of-
Stack (TOS) Special File Registers. Data can also be
The PC addresses bytes in the program memory. To
pushed to, or popped from the stack, using these
prevent the PC from becoming misaligned with word
registers.
instructions, the Least Significant bit of PCL is fixed to
a value of ‘0’. The PC increments by 2 to address
sequential instructions in the program memory.
11111
11110
Top-of-Stack Registers 11101 Stack Pointer
5.1.2.2 Return Stack Pointer (STKPTR) If STVREN is cleared, the STKFUL bit will be set on the
31st push and the Stack Pointer will increment to 31.
The STKPTR register (Register 5-1) contains the Stack
Any additional pushes will not overwrite the 31st push
Pointer value, the STKFUL (stack full) Status bit and
and STKPTR will remain at 31.
the STKUNF (Stack Underflow) Status bits. The value
of the Stack Pointer can be 0 through 31. The Stack When the stack has been popped enough times to
Pointer increments before values are pushed onto the unload the stack, the next pop will return a value of zero
stack and decrements after values are popped off the to the PC and sets the STKUNF bit, while the Stack
stack. On Reset, the Stack Pointer value will be zero. Pointer remains at zero. The STKUNF bit will remain
The user may read and write the Stack Pointer value. set until cleared by software or until a POR occurs.
This feature can be used by a Real-Time Operating
Note: Returning a value of zero to the PC on an
System (RTOS) for return stack maintenance.
underflow has the effect of vectoring the
After the PC is pushed onto the stack 31 times (without program to the Reset vector, where the
popping any values off the stack), the STKFUL bit is stack conditions can be verified and
set. The STKFUL bit is cleared by software or by a appropriate actions can be taken. This is
POR. not the same as a Reset, as the contents
The action that takes place when the stack becomes of the SFRs are not affected.
full depends on the state of the STVREN (Stack Over-
flow Reset Enable) Configuration bit. (Refer to
Section 24.1 “Configuration Bits” for a description of
the device Configuration bits.) If STVREN is set
(default), the 31st push will push the (PC + 2) value
onto the stack, set the STKFUL bit and reset the
device. The STKFUL bit will remain set and the Stack
Pointer will be set to zero.
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
5.1.2.4 Stack Full and Underflow Resets while servicing a low priority interrupt, the stack register
values stored by the low priority interrupt will be
Device Resets on Stack Overflow and Stack Underflow
overwritten. In these cases, users must save the key
conditions are enabled by setting the STVREN bit in
registers by software during a low priority interrupt.
Configuration Register 4L. When STVREN is set, a full
or underflow will set the appropriate STKFUL or If interrupt priority is not used, all interrupts may use the
STKUNF bit and then cause a device Reset. When fast register stack for returns from interrupt. If no
STVREN is cleared, a full or underflow condition will set interrupts are used, the fast register stack can be used
the appropriate STKFUL or STKUNF bit but not cause to restore the Status, WREG and BSR registers at the
a device Reset. The STKFUL or STKUNF bits are end of a subroutine call. To use the fast register stack
cleared by the user software or a Power-on Reset. for a subroutine call, a CALL label, FAST instruction
must be executed to save the Status, WREG and BSR
5.1.3 FAST REGISTER STACK registers to the fast register stack. A RETURN, FAST
A fast register stack is provided for the Status, WREG instruction is then executed to restore these registers
and BSR registers, to provide a “fast return” option for from the fast register stack.
interrupts. The stack for each register is only one level Example 5-1 shows a source code example that uses
deep and is neither readable nor writable. It is loaded the fast register stack during a subroutine call and
with the current value of the corresponding register return.
when the processor vectors for an interrupt. All inter-
rupt sources will push values into the stack registers.
The values in the registers are then loaded back into
their associated registers if the RETFIE, FAST
instruction is used to return from the interrupt.
If both low and high priority interrupts are enabled, the
stack registers cannot be used reliably to return from
low priority interrupts. If a high priority interrupt occurs
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.
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 F00h
= 1111 Unused
Bank 15 F37h
F38h
SFR(1) F5Fh Note 1: Addresses F38h through F5Fh are
also used by SFRs, but are not
F60h
part of the Access RAM. Users
must always use the complete
SFR
address or load the proper BSR
FFh FFFh value to access these registers.
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 F37h
Bank 15
F38h
SFR(1) Note 1: Addresses F38h through F5Fh are
F5Fh
also used by SFRs, but are not
F60h
part of the Access RAM. Users
must always use the complete
SFR address or load the proper BSR
FFh value to access these registers.
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 F00h
= 1111 Unused
Bank 15 F37h
SFR(1)
F38h Note 1: Addresses F38h through F5Fh are
F5Fh also used by SFRs, but are not
F60h part of the Access RAM. Users
must always use the complete
SFR address or load the proper BSR
value to access these registers.
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
00h F00h
= 1111 GPR F37h
Bank 15 F38h
SFR(1) Note 1: Addresses F38h through F5Fh are
F5Fh
F60h also used by SFRs, but are not
part of the Access RAM. Users
SFR must always use the complete
address or load the proper BSR
value to access these registers.
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.
FA2h IPR2 OSCFIP C1IP C2IP EEIP BCL1IP HLVDIP TMR3IP CCP2IP 1111 1111
FA1h PIR2 OSCFIF C1IF C2IF EEIF BCL1IF HLVDIF TMR3IF CCP2IF 0000 0000
FA0h PIE2 OSCFIE C1IE C2IE EEIE BCL1IE HLVDIE TMR3IE CCP2IE 0000 0000
F9Fh IPR1 — ADIP RC1IP TX1IP SSP1IP CCP1IP TMR2IP TMR1IP -111 1111
F9Eh PIR1 — ADIF RC1IF TX1IF SSP1IF CCP1IF TMR2IF TMR1IF -000 0000
F9Dh PIE1 — ADIE RC1IE TX1IE SSP1IE CCP1IE TMR2IE TMR1IE -000 0000
F9Ch HLVDCON VDIRMAG BGVST IRVST HLVDEN HLVDL<3:0> 0000 0000
F9Bh OSCTUNE INTSRC PLLEN TUN<5:0> 00xx xxxx
F96h TRISE WPUE3 — — — — TRISE2(1) TRISE1(1) TRISE0(1) 1--- -111
F95h TRISD(1) TRISD7 TRISD6 TRISD5 TRISD4 TRISD3 TRISD2 TRISD1 TRISD0 1111 1111
F94h TRISC TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 1111 1111
F93h TRISB TRISB7 TRISB6 TRISB5 TRISB4 TRISB3 TRISB2 TRISB1 TRISB0 1111 1111
F92h TRISA TRISA7 TRISA6 TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 1111 1111
F8Dh LATE(1) — — — — — LATE2 LATE1 LATE0 ---- -xxx
F8Ch LATD(1) LATD7 LATD6 LATD5 LATD4 LATD3 LATD2 LATD1 LATD0 xxxx xxxx
F8Bh LATC LATC7 LATC6 LATC5 LATC4 LATC3 LATC2 LATC1 LATC0 xxxx xxxx
F8Ah LATB LATB7 LATB6 LATB5 LATB4 LATB3 LATB2 LATB1 LATB0 xxxx xxxx
F89h LATA LATA7 LATA6 LATA5 LATA4 LATA3 LATA2 LATA1 LATA0 xxxx xxxx
PORTE(2) — — — — RE3 — — — ---- x---
F84h
PORTE(1) — — — — RE3 RE2 RE1 RE0 ---- x000
F83h PORTD(1) RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 0000 0000
F82h PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 0000 00xx
F81h PORTB RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 xxx0 0000
F80h PORTA RA7 RA6 RA5 RA4 RA3 RA2 RA1 RA0 xx0x 0000
F7Fh IPR5 — — — — — TMR6IP TMR5IP TMR4IP ---- -111
F7Eh PIR5 — — — — — TMR6IF TMR5IF TMR4IF ---- -111
F7Dh PIE5 — — — — — TMR6IE TMR5IE TMR4IE ---- -000
F7Ch IPR4 — — — — — CCP5IP CCP4IP CCP3IP ---- -000
F7Bh PIR4 — — — — — CCP5IF CCP4IF CCP3IF ---- -000
F7Ah PIE4 — — — — — CCP5IE CCP4IE CCP3IE ---- -000
F79h CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1R C1CH<1:0> 0000 1000
F78h CM2CON0 C2ON C2OUT C2OE C2POL C2SP C2R C2CH<1:0> 0000 1000
F77h CM2CON1 MC1OUT MC2OUT C1RSEL C2RSEL C1HYS C2HYS C1SYNC C2SYNC 0000 0000
F76h SPBRGH2 EUSART2 Baud Rate Generator, High Byte 0000 0000
F75h SPBRG2 EUSART2 Baud Rate Generator, Low Byte 0000 0000
F74h RCREG2 EUSART2 Receive Register 0000 0000
F73h TXREG2 EUSART2 Transmit Register 0000 0000
F72h TXSTA2 CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010
F71h RCSTA2 SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x
F70h BAUDCON2 ABDOVF RCIDL DTRXP CKTXP BRG16 — WUE ABDEN 01x0 0-00
F6Fh SSP2BUF SSP2 Receive Buffer/Transmit Register xxxx xxxx
F6Eh SSP2ADD SSP2 Address Register in I2C Slave Mode. SSP2 Baud Rate Reload Register in I2C Master Mode 0000 0000
F6Dh SSP2STAT SMP CKE D/A P S R/W UA BF 0000 0000
F6Ch SSP2CON1 WCOL SSPOV SSPEN CKP SSPM<3:0> 0000 0000
F6Bh SSP2CON2 GCEN ACKSTAT ACKDT ACKEN RCEN PEN RSEN SEN 0000 0000
F6Ah SSP2MSK SSP1 MASK Register bits 1111 1111
F69h SSP2CON3 ACKTIM PCIE SCIE BOEN SDAHT SBCDE AHEN DHEN 0000 0000
Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition
Note 1: PIC18(L)F4XK22 devices only.
2: PIC18(L)F2XK22 devices only.
3: PIC18(L)F23/24K22 and PIC18(L)F43/44K22 devices only.
4: PIC18(L)F26K22 and PIC18(L)F46K22 devices only.
F3Ah ANSELC ANSC7 ANSC6 ANSC5 ANSC4 ANSC3 ANSC2 — — 1111 11--
F39h ANSELB — — ANSB5 ANSB4 ANSB3 ANSB2 ANSB1 ANSB0 --11 1111
F38h ANSELA — — ANSA5 — ANSA3 ANSA2 ANSA1 ANSA0 --1- 1111
Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition
Note 1: PIC18(L)F4XK22 devices only.
2: PIC18(L)F2XK22 devices only.
3: PIC18(L)F23/24K22 and PIC18(L)F43/44K22 devices only.
4: PIC18(L)F26K22 and PIC18(L)F46K22 devices only.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For Borrow, the polarity is reversed. A subtraction is executed by adding the two’s complement of the
second operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high-order or low-order
bit of the source register.
000h
When ‘a’ = 0 and f 60h:
060h
The instruction executes in
Direct Forced mode. ‘f’ is inter- Bank 0
BSR
When ‘a’ = 1 (all values of f): 000h 00000000
FIGURE 5-12: REMAPPING THE ACCESS BANK WITH INDEXED LITERAL OFFSET
ADDRESSING
Example Situation:
ADDWF f, d, a 000h
FSR2H:FSR2L = 120h
Bank 0
Locations in the region
from the FSR2 pointer 100h
(120h) to the pointer plus Bank 1
120h
05Fh (17Fh) are mapped Window
17Fh 00h
to the bottom of the
Bank 1
Access RAM (000h-05Fh). 200h Bank 1 “Window”
Special File Registers at 5Fh
60h
F60h through FFFh are
mapped to 60h through Bank 2
FFh, as usual. SFRs
through
Bank 0 addresses below Bank 14
5Fh can still be addressed FFh
by using the BSR. Access Bank
F00h
Bank 15
F60h
SFRs
FFFh
Data Memory
Instruction: TBLRD*
Program Memory
Table Pointer(1)
Table Latch (8-bit)
TBLPTRU TBLPTRH TBLPTRL
TABLAT
Program Memory
(TBLPTR)
Instruction: TBLWT*
Program Memory
(TBLPTR<MSBs>)
Note 1: During table writes the Table Pointer does not point directly to Program Memory. The LSBs of TBLPRTL
actually point to an address within the write block holding registers. The MSBs of the Table Pointer deter-
mine where the write block will eventually be written. The process for writing the holding registers to the
program memory array is discussed in Section 6.5 “Writing to Flash Program Memory”.
6.2 Control Registers The FREE bit allows the program memory erase
operation. When FREE is set, an erase operation is
Several control registers are used in conjunction with initiated on the next WR command. When FREE is
the TBLRD and TBLWT instructions. These include the: clear, only writes are enabled.
• EECON1 register The WREN bit, when set, will allow a write operation.
• EECON2 register The WREN bit is clear on power-up.
• TABLAT register The WRERR bit is set by hardware when the WR bit is
• TBLPTR registers set and cleared when the internal programming timer
expires and the write operation is complete.
6.2.1 EECON1 AND EECON2 REGISTERS
Note: During normal operation, the WRERR is
The EECON1 register (Register 6-1) is the control read as ‘1’. This can indicate that a write
register for memory accesses. The EECON2 register is operation was prematurely terminated by
not a physical register; it is used exclusively in the a Reset, or a write operation was
memory write and erase sequences. Reading attempted improperly.
EECON2 will read all ‘0’s.
The EEPGD control bit determines if the access will be The WR control bit initiates write operations. The WR
a program or data EEPROM memory access. When bit cannot be cleared, only set, by firmware. Then WR
EEPGD is clear, any subsequent operations will bit is cleared by hardware at the completion of the write
operate on the data EEPROM memory. When EEPGD operation.
is set, any subsequent operations will operate on the Note: The EEIF interrupt flag bit of the PIR2
program memory. register is set when the write is complete.
The CFGS control bit determines if the access will be The EEIF flag stays set until cleared by
to the Configuration/Calibration registers or to program firmware.
memory/data EEPROM memory. When CFGS is set,
subsequent operations will operate on Configuration
registers regardless of EEPGD (see Section 24.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-1: 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
arguments, each argument’s Most Significant bit (MSb)
is tested and the appropriate subtractions are done.
Wake-up if in
INT0IF Idle or Sleep modes
INT0IE
TMR0IF
TMR0IE
TMR0IP
(1)
RBIF
RBIE
RBIP
INT1IF Interrupt to CPU
PIR1<6:0> INT1IE Vector to Location
PIE1<6:0> INT1IP 0008h
IPR1<6:0>
INT2IF
PIR2<7:0> INT2IE
PIE2<7:0> INT2IP
IPR2<7:0>
GIEH/GIE
PIR3<7:0>
PIE3<7:0>
IPR3<7:0> IPEN
PIR4<2:0>
PIE4<2:0> IPEN
IPR4<2:0> GIEL/PEIE
PIR5<2:0> IPEN
PIE5<2:0>
IPR5<2:0>
High Priority Interrupt Generation
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
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
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
RE0/P3A/CCP3/AN5 RE0 0 1 O DIG LATE<0> data output; not affected by analog input.
1 0 I ST PORTE<0> data input; disabled when analog input
enabled.
P3A(1) 0 1 O DIG Enhanced CCP3 PWM output.
CCP3(1) 0 1 O DIG Compare 3 output/PWM 3 output.
1 0 I ST Capture 3 input.
AN5 1 1 I AN Analog input 5.
RE1/P3B/AN6 RE1 0 1 O DIG LATE<1> data output; not affected by analog input.
1 0 I ST PORTE<1> data input; disabled when analog input
enabled.
P3B 0 x O DIG Enhanced CCP3 PWM output.
AN6 1 1 I AN Analog input 6.
RE2/CCP5/AN7 RE2 0 1 O DIG LATE<2> data output; not affected by analog input.
1 0 I ST PORTE<2> data input; disabled when analog input
enabled.
CCP5 0 1 O DIG Compare 5 output/PWM 5 output.
1 0 I ST Capture 5 input.
AN7 1 1 I AN Analog input 7.
RE3/VPP/MCLR RE3 — — I ST PORTE<3> data input; enabled when Configuration bit
MCLRE = 0.
VPP — — P AN Programming voltage input; always available
MCLR — — I ST Active-low Master Clear (device Reset) input; enabled
when configuration bit MCLRE = 1.
Legend: AN = Analog input or output; TTL = TTL compatible input; HV = High Voltage; OD = Open Drain; XTAL = Crystal; CMOS
= CMOS compatible input or output; ST = Schmitt Trigger input with CMOS levels; I2CTM = Schmitt Trigger input with I2C.
Note 1: Alternate pin assignment for P3A/CCP3 when Configuration bit CCP3MX is clear..
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
-n/n = Value at POR and BOR/Value at all other Resets
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
-n/n = Value at POR and BOR/Value at all other Resets
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
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
FOSC/4 0
1
Sync with Set
1 Internal TMR0L TMR0IF
Programmable Clocks on Overflow
T0CKI pin 0
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
1
Sync with Set
1 Internal TMR0
TMR0L High Byte TMR0IF
T0CKI pin Programmable 0 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.
TxGSS<1:0>
TxG 00 TxGSPM
Timer2/4/6 Match 01 0
TxG_IN Data Bus
PR2/4/6 0 TxGVAL
D Q
Comparator 1 10 Single Pulse RD
SYNCC1OUT(7) 1 TXGCON
Acq. Control Q1 EN
D Q 1
Comparator 2 11
SYNCC2OUT(7) Interrupt Set
CK Q TxGGO/DONE
TMRxON det TMRxGIF
R
TxGPOL TxGTM
TMRxGE
Set flag bit TMRxON
TMRxIF on To Comparator Module
Overflow TMRx(2),(4)
EN Synchronized
0 clock input
TMRxH TMRxL TxCLK
Q D
1
Secondary TMRxCS<1:0>
SOSCOUT TxSYNC
Oscillator
Module
See Figure 2-4 Reserved 11
Prescaler Synchronize(3),(7)
1 1, 2, 4, 8
TxCLK_EXT_SRC det
(5) ,(6) (1) 10
2
TxCKI 0
FOSC TxCKPS<1:0>
Internal 01
Clock FOSC/2
TxSOSCEN Internal Sleep input
FOSC/4 Clock
Internal 00
Clock
Timer1/3/5 is enabled by configuring the TMRxON and The following asynchronous sources may be used:
TMRxGE bits in the TxCON and TxGCON registers, • Asynchronous event on the TxG pin to Timer1/3/5
respectively. Table 12-1 displays the Timer1/3/5 enable Gate
selections. • C1 or C2 comparator input to Timer1/3/5 Gate
12.7.3 TIMER1/3/5 GATE TOGGLE MODE Enabling the Toggle mode and the Single-Pulse mode
simultaneously will permit both sections to work
When Timer1/3/5 Gate Toggle mode is enabled, it is together. This allows the cycle times on the Timer1/3/5
possible to measure the full-cycle length of a Gate source to be measured. See Figure 12-7 for
Timer1/3/5 gate signal, as opposed to the duration of a timing details.
single level pulse.
The Timer1/3/5 Gate source is routed through a flip-flop 12.7.5 TIMER1/3/5 GATE VALUE STATUS
that changes state on every incrementing edge of the When Timer1/3/5 Gate Value Status is utilized, it is
signal. See Figure 12-5 for timing details. possible to read the most current level of the gate
Timer1/3/5 Gate Toggle mode is enabled by setting the control value. The value is stored in the TxGVAL bit in
TxGTM bit of the TxGCON register. When the TxGTM the TxGCON register. The TxGVAL bit is valid even
bit is cleared, the flip-flop is cleared and held clear. This when the Timer1/3/5 Gate is not enabled (TMRxGE bit
is necessary in order to control which edge is is cleared).
measured.
12.7.6 TIMER1/3/5 GATE EVENT
Note: Enabling Toggle mode at the same time as INTERRUPT
changing the gate polarity may result in
indeterminate operation. When Timer1/3/5 Gate Event Interrupt is enabled, it is
possible to generate an interrupt upon the completion
of a gate event. When the falling edge of TxGVAL
occurs, the TMRxGIF flag bit in the PIR3 register will be
set. If the TMRxGIE bit in the PIE3 register is set, then
an interrupt will be recognized.
The TMRxGIF flag bit operates even when the
Timer1/3/5 Gate is not enabled (TMRxGE bit is
cleared).
For more information on selecting high or low priority
status for the Timer1/3/5 Gate Event Interrupt see
Section 9.0 “Interrupts”.
For more information on selecting high or low priority For more information, see Section 14.0
status for the Timer1/3/5 Overflow Interrupt, see “Capture/Compare/PWM Modules”.
Section 9.0 “Interrupts”.
12.11 ECCP/CCP Special Event Trigger
Note: The TMRxH:TMRxL register pair and the
TMRxIF bit should be cleared before When any of the CCP’s are configured to trigger a
enabling interrupts. special event, the trigger will clear the TMRxH:TMRxL
register pair. This special event does not cause a
12.9 Timer1/3/5 Operation During Sleep Timer1/3/5 interrupt. The CCP module may still be
configured to generate a CCP interrupt.
Timer1/3/5 can only operate during Sleep when setup In this mode of operation, the CCPRxH:CCPRxL
in Asynchronous Counter mode. In this mode, an register pair becomes the period register for
external crystal or clock source can be used to Timer1/3/5.
increment the counter. To set up the timer to wake the
device: Timer1/3/5 should be synchronized and FOSC/4 should
be selected as the clock source in order to utilize the
• TMRxON bit of the TxCON register must be set Special Event Trigger. Asynchronous operation of
• TMRxIE bit of the PIE1/2/5 register must be set Timer1/3/5 can cause a Special Event Trigger to be
• PEIE/GIEL bit of the INTCON register must be set missed.
• TxSYNC bit of the TxCON register must be set In the event that a write to TMRxH or TMRxL coincides
• TMRxCS bits of the TxCON register must be with a Special Event Trigger from the CCP, the write will
configured take precedence.
• TxSOSCEN bit of the TxCON register must be For more information, see Section 17.2.8 “Special
configured Event Trigger”.
The device will wake-up on an overflow and execute
the next instruction. If the GIE/GIEH bit of the INTCON
register is set, the device will call the Interrupt Service
Routine.
The secondary oscillator will continue to operate in
Sleep regardless of the TxSYNC bit setting.
TXCKI = 1
when TMRx
Enabled
TXCKI = 0
when TMRX
Enabled
TMRxGE
TxGPOL
TxG_IN
TxCKI
TxGVAL
TMRxGE
TxGPOL
TxGTM
TxTxG_IN
TxCKI
TxGVAL
TMRxGE
TxGPOL
TxGSPM
Cleared by hardware on
TxGGO/ Set by software falling edge of TxGVAL
DONE
Counting enabled on
rising edge of TxG
TxG_IN
TxCKI
TxGVAL
Cleared by
TMRxGIF Cleared by software Set by hardware on software
falling edge of TxGVAL
TMRxGE
TxGPOL
TxGSPM
TxGTM
Cleared by hardware on
TxGGO/ Set by software falling edge of TxGVAL
DONE Counting enabled on
rising edge of TxG
TxG_IN
TxCKI
TxGVAL
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
TMRxCS<1:0> = 0X
This bit is ignored. Timer1/3/5 uses the internal clock when TMRxCS<1:0> = 1X.
bit 1 TxRD16: 16-Bit Read/Write Mode Enable bit
1 = Enables register read/write of Timer1/3/5 in one 16-bit operation
0 = Enables register read/write of Timer1/3/5 in two 8-bit operation
bit 0 TMRxON: Timer1/3/5 On bit
1 = Enables Timer1/3/5
0 = Stops Timer1/3/5
Clears Timer1/3/5 Gate flip-flop
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared HC = Bit is cleared by hardware
Sets Flag
TMRx
bit TMRxIF
Output
Prescaler Reset
FOSC/4 TMRx
1:1, 1:4, 1:16, 1:64
2 Postscaler
Comparator
EQ 1:1 to 1:16
TxCKPS<1:0>
PRx 4
TxOUTPS<3:0>
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
TMRxH TMRxL
TRIS
Output Enable
• PRx registers Table 14-12 shows the pin assignments for various
Enhanced PWM modes.
• TxCON registers
• CCPRxL registers Note 1: The corresponding TRIS bit must be
• CCPxCON registers cleared to enable the PWM output on the
CCPx pin.
The ECCP modules have the following additional PWM
registers which control Auto-shutdown, Auto-restart, 2: Clearing the CCPxCON register will
Dead-band Delay and PWM Steering modes: relinquish control of the CCPx pin.
FIGURE 14-5: EXAMPLE SIMPLIFIED BLOCK DIAGRAM OF THE ENHANCED PWM MODE
DCxB<1:0> PxM<1:0> CCPxM<3:0>
Duty Cycle Registers
2 4
CCPRxL
CCPx/PxA CCPx/PxA
TRISx
CCPRxH (Slave)
PxB PxB
Output TRISx
Comparator R Q
Controller
PxC PxC(2)
TMRx (1)
S TRISx
PxD PxD(2)
Comparator
Clear Timer, TRISx
toggle PWM pin and
latch duty cycle
PRx PWMxCON
Note 1: The 8-bit timer TMRx register is concatenated with the 2-bit internal Q clock, or 2 bits of the prescaler to create the 10-bit time
base.
2: PxC and PxD are not available on Half-Bridge ECCP Modules.
TABLE 14-12: EXAMPLE PIN ASSIGNMENTS FOR VARIOUS PWM ENHANCED MODES
ECCP Mode PxM<1:0> CCPx/PxA PxB PxC PxD
(1) (1) (1)
Single 00 Yes Yes Yes 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: PWM Steering enables outputs in Single mode.
PxA Active
PxD Modulated
PxA Inactive
PxD Inactive
Relationships:
• Period = 4 * TOSC * (PRx + 1) * (TMRx Prescale Value)
• Pulse Width = TOSC * (CCPRxL<7:0>:CCPxCON<5:4>) * (TMRx Prescale Value)
• Delay = 4 * TOSC * (PWMxCON<6:0>)
Note 1: Dead-band delay is programmed using the PWMxCON register (Section 14.4.5 “Programmable Dead-Band Delay
Mode”).
Pulse PRx+1
PxM<1:0> Signal 0
Width
Period
PxA Modulated
Delay(1) Delay(1)
10 (Half-Bridge) PxB Modulated
PxA Active
PxD Modulated
PxA Inactive
PxD Inactive
Relationships:
• Period = 4 * TOSC * (PRx + 1) * (TMRx Prescale Value)
• Pulse Width = TOSC * (CCPRxL<7:0>:CCPxCON<5:4>) * (TMRx Prescale Value)
• Delay = 4 * TOSC * (PWMxCON<6:0>)
Note 1: Dead-band delay is programmed using the PWMxCON register (Section 14.4.5 “Programmable Dead-Band Delay
Mode”).
FET
Driver +
PxA
-
Load
FET
Driver
+
PxB
-
V+
FET FET
Driver Driver
PxA
Load
FET FET
Driver Driver
PxB
FET QA QC FET
Driver Driver
PxA
Load
PxB
FET FET
Driver Driver
PxC
QB QD
V-
PxD
PxB(2)
PxC(2)
PxD(2)
(1) (1)
Reverse Mode
Period
Pulse Width
PxA(2)
PxB(2)
PxC(2)
PxD(2)
(1) (1)
Note 1: At this time, the TMRx register is equal to the PRx register.
2: Output signal is shown as active-high.
PxA (Active-High)
PxB (Active-High)
Pulse Width
PxC (Active-High)
(2)
PxD (Active-High)
Pulse Width
Note 1: The direction bit PxM1 of the CCPxCON register is written any time during the PWM cycle.
2: When changing directions, the PxA and PxC signals switch before the end of the current PWM cycle. The
modulated PxB and PxD signals are inactive at this time. The length of this time is (TimerX Prescale)/FOSC,
where TimerX is Timer2, Timer4 or Timer6.
PxA
PxB
PW
PxC
PxD PW
TON
External Switch C
TOFF
External Switch D
14.4.3 ENHANCED PWM AUTO- of each pin pair is determined by the PSSxAC<1:0> and
SHUTDOWN MODE PSSxBD<1:0> bits of the ECCPxAS register. Each pin
pair may be placed into one of three states:
The PWM mode supports an Auto-Shutdown mode that
will disable the PWM outputs when an external • Drive logic ‘1’
shutdown event occurs. Auto-Shutdown mode places • Drive logic ‘0’
the PWM output pins into a predetermined state. This • Tri-state (high-impedance)
mode is used to help prevent the PWM from damaging
the application.
The auto-shutdown sources are selected using the Note 1: The auto-shutdown condition is a level-
CCPxAS<2:0> bits of the ECCPxAS register. A based signal, not an edge-based signal.
shutdown event may be generated by: As long as the level is present, the auto-
shutdown will persist.
• A logic ‘0’ on the INT pin
2: Writing to the CCPxASE bit is disabled
• Comparator Cx
while an auto-shutdown condition
• Setting the CCPxASE bit in firmware persists.
A shutdown condition is indicated by the CCPxASE 3: Once the auto-shutdown condition has
(Auto-Shutdown Event Status) bit of the ECCPxAS been removed and the PWM restarted
register. If the bit is a ‘0’, the PWM pins are operating (either through firmware or auto-restart),
normally. If the bit is a ‘1’, the PWM outputs are in the the PWM signal will always restart at the
shutdown state. beginning of the next PWM period.
When a shutdown event occurs, two things happen:
The CCPxASE bit is set to ‘1’. The CCPxASE will
remain set until cleared in firmware or an auto-restart
occurs (see Section 14.4.4 “Auto-Restart Mode”).
The enabled PWM pins are asynchronously placed in
their shutdown states. The PWM output pins are
grouped into pairs [PxA/PxC] and [PxB/PxD]. The state
PWM Period
PWM Activity
Start of
PWM Period
Shutdown Event
CCPxASE bit
PWM
Shutdown Shutdown Resumes
Event Occurs Event Clears CCPxASE
Cleared by
Firmware
14.4.4 AUTO-RESTART MODE If auto-restart is enabled, the CCPxASE bit will remain
set as long as the auto-shutdown condition is active.
The Enhanced PWM can be configured to
When the auto-shutdown condition is removed, the
automatically restart the PWM signal once the auto-
CCPxASE bit will be cleared via hardware and normal
shutdown condition has been removed. Auto-restart is
operation will resume.
enabled by setting the PxRSEN bit in the PWMxCON
register.
PWM Period
PWM Activity
Start of
PWM Period
Shutdown Event
CCPxASE bit
PWM
Shutdown Resumes
Event Occurs
Shutdown CCPxASE
Event Clears Cleared by
Hardware
FET
Driver +
PxA V
-
Load
FET
Driver
+
PxB V
-
V-
The PxA, PxB, PxC and PxD output latches may not be
in the proper states when the PWM module is
initialized. Enabling the PWM pin output drivers at the
same time as the Enhanced PWM modes may cause
damage to the application circuit. The Enhanced PWM
PWM Period
PWM
STRx
P1n = PWM
PWM
STRx
P1n = PWM
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Reset
‘1’ = Bit is set ‘0’ = Bit is cleared
1000 = Compare mode: set output on compare match (CCPx pin is set, CCPxIF is set)
1001 = Compare mode: clear output on compare match (CCPx pin is cleared, CCPxIF is set)
1010 = Compare mode: generate software interrupt on compare match (CCPx pin is unaffected,
CCPxIF is set)
1011 = Compare mode: Special Event Trigger (CCPx pin is unaffected, CCPxIF is set)
TimerX (selected by CxTSEL bits) is reset
ADON is set, starting A/D conversion if A/D module is enabled(1)
11xx =: PWM mode
Note 1: This feature is available on CCP5 only.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Reset
‘1’ = Bit is set ‘0’ = Bit is cleared
1000 = Compare mode: set output on compare match (CCPx pin is set, CCPxIF is set)
1001 = Compare mode: clear output on compare match (CCPx pin is cleared, CCPxIF is set)
1010 = Compare mode: generate software interrupt on compare match (CCPx pin is unaffected,
CCPxIF is set)
1011 = Compare mode: Special Event Trigger (CCPx pin is unaffected, CCPxIF is set)
TimerX is reset
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Note 1: If C1SYNC or C2SYNC bits in the CM2CON1 register are enabled, the shutdown will be delayed by
Timer1.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Note 1: The PWM Steering mode is available only when the CCPxCON register bits CCPxM<3:2> = 11 and
PxM<1:0> = 00.
Data Bus
Read Write
SSPxBUF Reg
SDIx
SSPxSR Reg
SDOx bit 0 Shift
Clock
Edge
Select
SSPxM<3:0>
4
( TMR22Output )
SCKx
Edge Prescaler TOSC
Select 4, 16, 64
Baud Rate
Generator
TRIS bit (SSPxADD)
Internal
Data Bus [SSPxM 3:0]
Read Write
SSPxSR
Clock Cntl
MSb LSb
Receive Enable (RCEN)
Internal
Data Bus
Read Write
Shift
Clock
SSPxSR Reg
SDAx MSb LSb
SSPxMSK Reg
SSPxADD Reg
SCLK SCLK
SPI Master
SDOx SDIx SPI Slave
SDIx SDOx #1
General I/O SSx
General I/O
General I/O SCLK
SDIx SPI Slave
SDOx #2
SSx
SCLK
SDIx SPI Slave
SDOx #3
SSx
Slave Select
General I/O SSx
Processor 1 (optional) Processor 2
Write to
SSPxBUF
SCKx
(CKP = 0
CKE = 0)
SCKx
(CKP = 1
CKE = 0)
4 Clock
SCKx Modes
(CKP = 0
CKE = 1)
SCKx
(CKP = 1
CKE = 1)
Input
Sample
(SMP = 1)
SSPxIF
SSPxSR to
SSPxBUF
SCLK SCLK
SPI Master
SDOx SDIx SPI Slave
SDIx SDOx #1
General I/O SSx
SCLK
SDIx SPI Slave
SDOx #2
SSx
SCLK
SDIx SPI Slave
SDOx #3
SSx
SSx
SCKx
(CKP = 0
CKE = 0)
SCKx
(CKP = 1
CKE = 0)
Write to
SSPxBUF
Shift register SSPxSR
and bit count are reset
SSPxBUF to
SSPxSR
SDIx bit 0
bit 7 bit 7
Input
Sample
SSPxIF
Interrupt
Flag
SSPxSR to
SSPxBUF
SSx
Optional
SCKx
(CKP = 0
CKE = 0)
SCKx
(CKP = 1
CKE = 0)
Write to
SSPxBUF
Valid
SDOx bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
SDIx
bit 7 bit 0
Input
Sample
SSPxIF
Interrupt
Flag
SSPxSR to
SSPxBUF
Write Collision
detection active
SSx
Not Optional
SCKx
(CKP = 0
CKE = 1)
SCKx
(CKP = 1
CKE = 1)
Write to
SSPxBUF
Valid
SDOx bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
SDIx
bit 7 bit 0
Input
Sample
SSPxIF
Interrupt
Flag
SSPxSR to
SSPxBUF
Write Collision
detection active
The I2C specification defines a Start condition as a A Restart is valid any time that a Stop would be valid.
transition of SDAx from a high-to -low state while SCLx A master can issue a Restart if it wishes to hold the
line is high. A Start condition is always generated by bus after terminating the current transfer. A Restart
the master and signifies the transition of the bus from has the same effect on the slave that a Start would,
an Idle to an active state. Figure 15-10 shows wave resetting all slave logic and preparing it to clock in an
forms for Start and Stop conditions. address. The master may want to address the same or
A bus collision can occur on a Start condition if the another slave.
module samples the SDAx line low before asserting it In 10-bit Addressing Slave mode a Restart is required
low. This does not conform to the I2C specification that for the master to clock data out of the addressed slave.
states no bus collision can occur on a Start. Once a slave has been fully addressed, matching both
high and low address bytes, the master can issue a
15.4.6 STOP CONDITION Restart and the high address byte with the R/W bit set.
A Stop condition is a transition of the SDAx line from a The slave logic will then hold the clock and prepare to
low-to-high state while the SCLx line is high. clock out data.
After a full match with R/W clear in 10-bit mode, a prior
Note: At least one SCLx low time must appear
match flag is set and maintained. Until a Stop
before a Stop is valid, therefore, if the SDAx
condition, a high address with R/W clear, or high
line goes low then high again while the SCLx
address match fails.
line stays high, only the Start condition is
detected. 15.4.8 START/STOP CONDITION INTERRUPT
MASKING
SDAx
SCLx
S P
Change of Change of
Data Allowed Data Allowed
Start Stop
Condition Condition
Sr
Change of Change of
Data Allowed Data Allowed
Restart
Condition
When the SEN bit of the SSPxCON2 register is set, 1. S bit of SSPxSTAT is set; SSPxIF is set if
SCLx will be held low (clock stretch) following each interrupt on Start detect is enabled.
received byte. The clock must be released by setting 2. Matching address with R/W bit clear is clocked
the CKP bit of the SSPxCON1 register, except in. SSPxIF is set and CKP cleared after the 8th
sometimes in 10-bit mode. See Section 15.2.3 “SPI falling edge of SCLx.
Master Mode” for more detail. 3. Slave clears the SSPxIF.
4. Slave can look at the ACKTIM bit of the
15.5.2.1 7-bit Addressing Reception
SSPxCON3 register to determine if the SSPxIF
This section describes a standard sequence of events was after or before the ACK.
for the MSSPx module configured as an I2C slave in 5. Slave reads the address value from SSPxBUF,
7-bit Addressing mode. All decisions made by hard- clearing the BF flag.
ware or software and their effect on reception. 6. Slave sets ACK value clocked out to the master
Figure 15-13 and Figure 15-14 is used as a visual by setting ACKDT.
reference for this description.
7. Slave releases the clock by setting CKP.
This is a step by step process of what typically must 8. SSPxIF is set after an ACK, not after a NACK.
be done to accomplish I2C communication.
9. If SEN = 1 the slave hardware will stretch the
1. Start bit detected. clock after the ACK.
2. S bit of SSPxSTAT is set; SSPxIF is set if 10. Slave clears SSPxIF.
interrupt on Start detect is enabled.
Note: SSPxIF is still set after the 9th falling edge of
3. Matching address with R/W bit clear is received. SCLx even if there is no clock stretching and
4. The slave pulls SDAx low sending an ACK to the BF has been cleared. Only if NACK is sent to
master, and sets SSPxIF bit. master is SSPxIF not set.
5. Software clears the SSPxIF bit. 11. SSPxIF set and CKP cleared after 8th falling
6. Software reads received address from edge of SCLx for a received data byte.
SSPxBUF clearing the BF flag. 12. Slave looks at ACKTIM bit of SSPxCON3 to
7. If SEN = 1; Slave software sets CKP bit to determine the source of the interrupt.
release the SCLx line. 13. Slave reads the received data from SSPxBUF
8. The master clocks out a data byte. clearing BF.
9. Slave drives SDAx low sending an ACK to the 14. Steps 7-14 are the same for each received data
master, and sets SSPxIF bit. byte.
10. Software clears SSPxIF. 15. Communication is ended by either the slave
11. Software reads the received byte from sending an ACK = 1, or the master sending a
SSPxBUF clearing BF. Stop condition. If a Stop is sent and Interrupt on
12. Steps 8-12 are repeated for all received bytes Stop detect is disabled, the slave will only know
from the master. by polling the P bit of the SSTSTAT register.
13. Master sends Stop condition, setting P bit of
SSPxSTAT, and the bus goes Idle.
DS41412B-page 224
Bus Master sends
Stop condition
From Slave to Master
SCLx
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
PIC18(L)F2X/4XK22
SSPxIF
SSPxIF set on 9th
Preliminary
Cleared by software Cleared by software falling edge of
SCLx
BF
First byte
SSPxBUF is read of data is
available
in SSPxBUF
SSPxOV
SSPxIF
Preliminary
BF
First byte
of data is
SSPxBUF is read available
in SSPxBUF
SSPxOV
DS41412B-page 225
PIC18(L)F2X/4XK22
Master Releases SDAx Master sends
to slave for ACK sequence Stop condition
FIGURE 15-16:
DS41412B-page 226
A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCLx
S 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 P
SSPxIF
If AHEN = 1: SSPxIF is set on
SSPxIF is set 9th falling edge of Cleared by software No interrupt
SCLx, after ACK after not ACK
BF from Slave
Address is
read from Data is read from SSPxBUF
PIC18(L)F2X/4XK22
ACKDT SSBUF
Slave software
clears ACKDT to Slave software
ACK the received sets ACKDT to
CKP byte not ACK
Preliminary
When AHEN=1:
When DHEN=1: CKP set by software,
CKP is cleared by hardware
CKP is cleared by SCLx is released
and SCLx is stretched hardware on 8th falling
edge of SCLx
ACKTIM
P
I2C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 0, AHEN = 1, DHEN = 1)
Stop condition
Master releases
R/W = 0 SDAx to slave for ACK sequence
Receiving Address Receive Data Receive Data ACK
SDAx ACK
A7 A6 A5 A4 A3 A2 A1 D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0
SSPxIF
Cleared by software No interrupt after
if not ACK
from Slave
BF
Received
address is loaded into Received data is SSPxBUF can be
SSPxBUF available on SSPxBUF read any time before
next byte is loaded
ACKDT
Preliminary
ACKDT to ACK not ACK
the received byte
CKP
When AHEN = 1; When DHEN = 1; CKP is not cleared
on the 8th falling edge on the 8th falling edge Set by software, if not ACK
of SCLx of an address of SCLx of a received release SCLx
byte, CKP is cleared data byte, CKP is cleared
ACKTIM
P
I2C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 1, AHEN = 1, DHEN = 1)
DS41412B-page 227
PIC18(L)F2X/4XK22
PIC18(L)F2X/4XK22
15.5.3 SLAVE TRANSMISSION 15.5.3.2 7-bit Transmission
When the R/W bit of the incoming address byte is set A master device can transmit a read request to a
and an address match occurs, the R/W bit of the slave, and then clock data out of the slave. The list
SSPxSTAT register is set. The received address is below outlines what software for a slave will need to do
loaded into the SSPxBUF register, and an ACK pulse is to accomplish a standard transmission. Figure 15-17
sent by the slave on the ninth bit. can be used as a reference to this list.
Following the ACK, slave hardware clears the CKP bit 1. Master sends a Start condition on SDAx and
and the SCLx pin is held low (see Section 15.5.6 SCLx.
“Clock Stretching” for more detail). By stretching the 2. S bit of SSPxSTAT is set; SSPxIF is set if inter-
clock, the master will be unable to assert another clock rupt on Start detect is enabled.
pulse until the slave is done preparing the transmit 3. Matching address with R/W bit set is received by
data. the slave setting SSPxIF bit.
The transmit data must be loaded into the SSPxBUF 4. Slave hardware generates an ACK and sets
register which also loads the SSPxSR register. Then SSPxIF.
the SCLx pin should be released by setting the CKP bit 5. SSPxIF bit is cleared by user.
of the SSPxCON1 register. The eight data bits are
6. Software reads the received address from
shifted out on the falling edge of the SCLx input. This
SSPxBUF, clearing BF.
ensures that the SDAx signal is valid during the SCLx
high time. 7. R/W is set so CKP was automatically cleared
after the ACK.
The ACK pulse from the master-receiver is latched on
8. The slave software loads the transmit data into
the rising edge of the ninth SCLx input pulse. This ACK
SSPxBUF.
value is copied to the ACKSTAT bit of the SSPxCON2
register. If ACKSTAT is set (not ACK), then the data 9. CKP bit is set releasing SCLx, allowing the mas-
transfer is complete. In this case, when the not ACK is ter to clock the data out of the slave.
latched by the slave, the slave goes Idle and waits for 10. SSPxIF is set after the ACK response from the
another occurrence of the Start bit. If the SDAx line was master is loaded into the ACKSTAT register.
low (ACK), the next transmit data must be loaded into 11. SSPxIF bit is cleared.
the SSPxBUF register. Again, the SCLx pin must be 12. The slave software checks the ACKSTAT bit to
released by setting bit CKP. see if the master wants to clock out more data.
An MSSPx interrupt is generated for each data transfer Note 1: If the master ACKs the clock will be
byte. The SSPxIF bit must be cleared by software and stretched.
the SSPxSTAT register is used to determine the status
of the byte. The SSPxIF bit is set on the falling edge of 2: ACKSTAT is the only bit updated on the
the ninth clock pulse. rising edge of SCLx (9th) rather than the
falling.
15.5.3.1 Slave Mode Bus Collision 13. Steps 9-13 are repeated for each transmitted
A slave receives a Read request and begins shifting byte.
data out on the SDAx line. If a bus collision is detected 14. If the master sends a not ACK; the clock is not
and the SBCDE bit of the SSPxCON3 register is set, held, but SSPxIF is still set.
the BCLxIF bit of the PIRx register is set. Once a bus 15. The master sends a Restart condition or a Stop.
collision is detected, the slave goes Idle and waits to be 16. The slave is no longer addressed.
addressed again. User software can use the BCLxIF bit
to handle a slave bus collision.
SCLx
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
Cleared by software
BF
BF is automatically
Received address Data to transmit is cleared after 8th falling
is read from SSPxBUF loaded into SSPxBUF edge of SCLx
CKP
When R/W is set CKP is not
SCLx is always held for not
held low after 9th SCLx Set by software ACK
falling edge
ACKSTAT
Preliminary
Masters not ACK
is copied to
ACKSTAT
R/W
R/W is copied from the
matching address byte
D/A
I2C SLAVE, 7-BIT ADDRESS, TRANSMISSION (AHEN = 0)
Indicates an address
has been received
DS41412B-page 229
PIC18(L)F2X/4XK22
PIC18(L)F2X/4XK22
15.5.3.3 7-bit Transmission with Address
Hold Enabled
Setting the AHEN bit of the SSPxCON3 register
enables additional clock stretching and interrupt
generation after the 8th falling edge of a received
matching address. Once a matching address has
been clocked in, CKP is cleared and the SSPxIF
interrupt is set.
Figure 15-18 displays a standard waveform of a 7-bit
Address Slave Transmission with AHEN enabled.
1. Bus starts Idle.
2. Master sends Start condition; the S bit of
SSPxSTAT is set; SSPxIF is set if interrupt on
Start detect is enabled.
3. Master sends matching address with R/W bit
set. After the 8th falling edge of the SCLx line the
CKP bit is cleared and SSPxIF interrupt is
generated.
4. Slave software clears SSPxIF.
5. Slave software reads ACKTIM bit of SSPxCON3
register, and R/W and D/A of the SSPxSTAT
register to determine the source of the interrupt.
6. Slave reads the address value from the SSPxBUF
register clearing the BF bit.
7. Slave software decides from this information if it
wishes to ACK or not ACK and sets ACKDT bit
of the SSPxCON2 register accordingly.
8. Slave sets the CKP bit releasing SCLx.
9. Master clocks in the ACK value from the slave.
10. Slave hardware automatically clears the CKP bit
and sets SSPxIF after the ACK if the R/W bit is
set.
11. Slave software clears SSPxIF.
12. Slave loads value to transmit to the master into
SSPxBUF setting the BF bit.
Note: SSPxBUF cannot be loaded until after the
ACK.
13. Slave sets CKP bit releasing the clock.
14. Master clocks out the data from the slave and
sends an ACK value on the 9th SCLx pulse.
15. Slave hardware copies the ACK value into the
ACKSTAT bit of the SSPxCON2 register.
16. Steps 10-15 are repeated for each byte
transmitted to the master from the slave.
17. If the master sends a not ACK the slave
releases the bus allowing the master to send a
Stop and end the communication.
Note: Master must send a not ACK on the last byte
to ensure that the slave releases the SCLx
line to receive a Stop.
SCLx
S 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
SSPxIF
Cleared by software
BF BF is automatically
Received address Data to transmit is cleared after 8th falling
is read from SSPxBUF loaded into SSPxBUF edge of SCLx
ACKDT
Slave clears
ACKDT to ACK
address
Preliminary
ACKSTAT
Master’s ACK
response is copied
to SSPxSTAT
CKP
When AHEN = 1; CKP not cleared
CKP is cleared by hardware When R/W = 1; Set by software, after not ACK
after receiving matching CKP is always releases SCLx
address. cleared after ACK
ACKTIM
I2C SLAVE, 7-BIT ADDRESS, TRANSMISSION (AHEN = 1)
R/W
D/A
DS41412B-page 231
PIC18(L)F2X/4XK22
PIC18(L)F2X/4XK22
15.5.4 SLAVE MODE 10-BIT ADDRESS 15.5.5 10-BIT ADDRESSING WITH ADDRESS OR
RECEPTION DATA HOLD
This section describes a standard sequence of events Reception using 10-bit addressing with AHEN or
for the MSSPx module configured as an I2C slave in DHEN set is the same as with 7-bit modes. The only
10-bit Addressing mode. difference is the need to update the SSPxADD register
Figure 15-19 and is used as a visual reference for this using the UA bit. All functionality, specifically when the
description. CKP bit is cleared and SCLx line is held low are the
same. Figure 15-20 can be used as a reference of a
This is a step by step process of what must be done by slave in 10-bit addressing with AHEN set.
slave software to accomplish I2C communication.
Figure 15-21 shows a standard waveform for a slave
1. Bus starts Idle. transmitter in 10-bit Addressing mode.
2. Master sends Start condition; S bit of SSPxSTAT
is set; SSPxIF is set if interrupt on Start detect is
enabled.
3. Master sends matching high address with R/W
bit clear; UA bit of the SSPxSTAT register is set.
4. Slave sends ACK and SSPxIF is set.
5. Software clears the SSPxIF bit.
6. Software reads received address from SSPxBUF
clearing the BF flag.
7. Slave loads low address into SSPxADD,
releasing SCLx.
8. Master sends matching low address byte to the
slave; UA bit is set.
Note: Updates to the SSPxADD register are not
allowed until after the ACK sequence.
Master sends
Stop condition
Receive First Address Byte Receive Second Address Byte Receive Data Receive Data
SCLx
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 P
S
SCLx is held low
while CKP = 0
SSPxIF
Set by hardware Cleared by software
on 9th falling edge
BF
Data is read
Preliminary
If address matches Receive address is
SSPxADD it is loaded into read from SSPxBUF from SSPxBUF
SSPxBUF
UA
When UA = 1; Software updates SSPxADD
SCLx is held low and releases SCLx
CKP
DS41412B-page 233
PIC18(L)F2X/4XK22
Receive First Address Byte R/W = 0 Receive Second Address Byte Receive Data Receive Data
FIGURE 15-21:
DS41412B-page 234
SCLx S 1 2 3 4 5 6 7 8 9 UA 1 2 3 4 5 6 7 8 9 UA 1 2 3 4 5 6 7 8 9 1 2
SSPxIF
Set by hardware Cleared by software Cleared by software
on 9th falling edge
PIC18(L)F2X/4XK22
BF
Preliminary
Slave software clears
ACKDT to ACK
the received byte
UA
Master sends
Master sends Stop condition
Restart event Master sends
not ACK
SCLx 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 P
S
Sr
SSPxIF
BF
Preliminary
UA
High address is loaded
UA indicates SSPxADD After SSPxADD is back into SSPxADD
must be updated updated, UA is cleared
CKP and SCLx is released
Indicates an address
has been received
I2C SLAVE, 10-BIT ADDRESS, TRANSMISSION (SEN = 0, AHEN = 0, DHEN = 0)
DS41412B-page 235
PIC18(L)F2X/4XK22
PIC18(L)F2X/4XK22
15.5.6 CLOCK STRETCHING 15.5.6.2 10-bit Addressing Mode
Clock stretching occurs when a device on the bus In 10-bit Addressing mode, when the UA bit is set, the
holds the SCLx line low effectively pausing communi- clock is always stretched. This is the only time the
cation. The slave may stretch the clock to allow more SCLx is stretched without CKP being cleared. SCLx is
time to handle data or prepare a response for the mas- released immediately after a write to SSPxADD.
ter device. A master device is not concerned with
Note: Previous versions of the module did not
stretching as anytime it is active on the bus and not
stretch the clock if the second address byte
transferring data it is stretching. Any stretching done
did not match.
by a slave is invisible to the master software and han-
dled by the hardware that generates SCLx. 15.5.6.3 Byte NACKing
The CKP bit of the SSPxCON1 register is used to
When the AHEN bit of SSPxCON3 is set; CKP is
control stretching in software. Any time the CKP bit is
cleared by hardware after the 8th falling edge of SCLx
cleared, the module will wait for the SCLx line to go
for a received matching address byte. When the
low and then hold it. Setting CKP will release SCLx
DHEN bit of SSPxCON3 is set; CKP is cleared after
and allow more communication.
the 8th falling edge of SCLx for received data.
15.5.6.1 Normal Clock Stretching Stretching after the 8th falling edge of SCLx allows the
Following an ACK if the R/W bit of SSPxSTAT is set, a slave to look at the received address or data and
read request, the slave hardware will clear CKP. This decide if it wants to ACK the received data.
allows the slave time to update SSPxBUF with data to 15.5.7 CLOCK SYNCHRONIZATION AND
transfer to the master. If the SEN bit of SSPxCON2 is THE CKP BIT
set, the slave hardware will always stretch the clock
after the ACK sequence. Once the slave is ready; CKP Any time the CKP bit is cleared, the module will wait
is set by software and communication resumes. for the SCLx line to go low and then hold it. However,
clearing the CKP bit will not assert the SCLx output
Note 1: The BF bit has no effect on whether the low until the SCLx output is already sampled low.
clock will be stretched or not. This is Therefore, the CKP bit will not assert the SCLx line
different than previous versions of the until an external I2C master device has already
module that would not stretch the clock, asserted the SCLx line. The SCLx output will remain
clear CKP, if SSPxBUF was read before low until the CKP bit is set and all other devices on the
the 9th falling edge of SCLx. I2C bus have released SCLx. This ensures that a write
2: Previous versions of the module did not to the CKP bit will not violate the minimum high time
stretch the clock for a transmission if requirement for SCLx (see Figure 15-22).
SSPxBUF was loaded before the 9th fall-
ing edge of SCLx. It is now always cleared
for read requests.
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
SDAx DX DX ‚ – 1
SCLx
Master device
CKP asserts clock
Master device
releases clock
WR
SSPxCON1
SCLx
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
SSPxIF
BF (SSPxSTAT<0>)
Cleared by software
SSPxBUF is read
GCEN (SSPxCON2<7>)
’1’
Master mode is enabled by setting and clearing the The master device generates all of the serial clock
appropriate SSPxM bits in the SSPxCON1 register and pulses and the Start and Stop conditions. A transfer is
by setting the SSPxEN bit. In Master mode, the SCLx ended with a Stop condition or with a Repeated Start
and SDAx lines are set as inputs and are manipulated condition. Since the Repeated Start condition is also
by the MSSPx hardware. the beginning of the next serial transfer, the I2C bus will
not be released.
Master mode of operation is supported by interrupt
generation on the detection of the Start and Stop con- In Master Transmitter mode, serial data is output
ditions. The Stop (P) and Start (S) bits are cleared from through SDAx, while SCLx outputs the serial clock. The
a Reset or when the MSSPx module is disabled. Con- first byte transmitted contains the slave address of the
trol of the I 2C bus may be taken when the P bit is set, receiving device (7 bits) and the Read/Write (R/W) bit.
or the bus is Idle. In this case, the R/W bit will be logic ‘0’. Serial data is
transmitted 8 bits at a time. After each byte is transmit-
In Firmware Controlled Master mode, user code ted, an Acknowledge bit is received. Start and Stop
conducts all I 2C bus operations based on Start and conditions are output to indicate the beginning and the
Stop bit condition detection. Start and Stop condition end of a serial transfer.
detection is the only active circuitry in this mode. All
other communication is done by the user software In Master Receive mode, the first byte transmitted con-
directly manipulating the SDAx and SCLx lines. tains the slave address of the transmitting device
(7 bits) and the R/W bit. In this case, the R/W bit will be
The following events will cause the SSPx Interrupt Flag logic ‘1’. Thus, the first byte transmitted is a 7-bit slave
bit, SSPxIF, to be set (SSPx interrupt, if enabled): address followed by a ‘1’ to indicate the receive bit.
• Start condition detected Serial data is received via SDAx, while SCLx outputs
the serial clock. Serial data is received 8 bits at a time.
• Stop condition detected
After each byte is received, an Acknowledge bit is
• Data transfer byte transmitted/received transmitted. Start and Stop conditions indicate the
• Acknowledge transmitted/received beginning and end of transmission.
• Repeated Start generated A Baud Rate Generator is used to set the clock
Note 1: The MSSPx module, when configured in frequency output on SCLx. See Section 15.7 “Baud
I2C Master mode, does not allow queue- Rate Generator” for more detail.
ing of events. For instance, the user is not
allowed to initiate a Start condition and
immediately write the SSPxBUF register
to initiate transmission before the Start
condition is complete. In this case, the
SSPxBUF will not be written to and the
WCOL bit will be set, indicating that a write
to the SSPxBUF did not occur
2: When in Master mode, Start/Stop
detection is masked and an interrupt is
generated when the SEN/PEN bit is
cleared and the generation is complete.
SDAx DX DX ‚ – 1
BRG decrements on
Q2 and Q4 cycles
BRG
03h 02h 01h 00h (hold off) 03h 02h
Value
TBRG
SCLx
S
TBRG
SDAx A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
Preliminary
BF (SSPxSTAT<0>)
PEN
R/W
I2C MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
DS41412B-page 243
PIC18(L)F2X/4XK22
PIC18(L)F2X/4XK22
15.6.7 I2C MASTER MODE RECEPTION 15.6.7.4 Typical Receive Sequence:
Master mode reception is enabled by programming the 1. The user generates a Start condition by setting
Receive Enable bit, RCEN, of the SSPxCON2 register. the SEN bit of the SSPxCON2 register.
Note: The MSSPx module must be in an Idle 2. SSPxIF is set by hardware on completion of the
state before the RCEN bit is set or the Start.
RCEN bit will be disregarded. 3. SSPxIF is cleared by software.
The Baud Rate Generator begins counting and on each 4. User writes SSPxBUF with the slave address to
rollover, the state of the SCLx pin changes (high-to-low/ transmit and the R/W bit set.
low-to-high) and data is shifted into the SSPxSR. After 5. Address is shifted out the SDAx pin until all 8 bits
the falling edge of the eighth clock, the receive enable are transmitted. Transmission begins as soon
flag is automatically cleared, the contents of the as SSPxBUF is written to.
SSPxSR are loaded into the SSPxBUF, the BF flag bit 6. The MSSPx module shifts in the ACK bit from
is set, the SSPxIF flag bit is set and the Baud Rate the slave device and writes its value into the
Generator is suspended from counting, holding SCLx ACKSTAT bit of the SSPxCON2 register.
low. The MSSPx is now in Idle state awaiting the next 7. The MSSPx module generates an interrupt at
command. When the buffer is read by the CPU, the BF the end of the ninth clock cycle by setting the
flag bit is automatically cleared. The user can then SSPxIF bit.
send an Acknowledge bit at the end of reception by set-
8. User sets the RCEN bit of the SSPxCON2 regis-
ting the Acknowledge Sequence Enable bit, ACKEN, of
ter and the Master clocks in a byte from the slave.
the SSPxCON2 register.
9. After the 8th falling edge of SCLx, SSPxIF and
15.6.7.1 BF Status Flag BF are set.
10. Master clears SSPxIF and reads the received
In receive operation, the BF bit is set when an address
byte from SSPxUF, clears BF.
or data byte is loaded into SSPxBUF from SSPxSR. It
is cleared when the SSPxBUF register is read. 11. Master sets ACK value sent to slave in ACKDT
bit of the SSPxCON2 register and initiates the
15.6.7.2 SSPxOV Status Flag ACK by setting the ACKEN bit.
In receive operation, the SSPxOV bit is set when 8 bits 12. Masters ACK is clocked out to the slave and
are received into the SSPxSR and the BF flag bit is SSPxIF is set.
already set from a previous reception. 13. User clears SSPxIF.
14. Steps 8-13 are repeated for each received byte
15.6.7.3 WCOL Status Flag from the slave.
If the user writes the SSPxBUF when a receive is 15. Master sends a not ACK or Stop to end
already in progress (i.e., SSPxSR is still shifting in a communication.
data byte), the WCOL bit is set and the contents of the
buffer are unchanged (the write does not occur).
begin Start condition ACK from Master Set ACKEN, start Acknowledge sequence
Master configured as a receiver SDAx = ACKDT = 0 SDAx = ACKDT = 1
SEN = 0 by programming SSPxCON2<3> (RCEN = 1)
PEN bit = 1
Write to SSPxBUF occurs here, RCEN cleared RCEN = 1, start RCEN cleared
ACK from Slave next receive automatically written here
start XMIT automatically
Transmit Address to Slave R/W = 0 Receiving Data from Slave Receiving Data from Slave
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
SCLx S P
Data shifted in on falling edge of CLK Set SSPxIF at end
of receive Set SSPxIF interrupt
Set SSPxIF interrupt at end of Acknow-
Set SSPxIF interrupt ledge sequence
at end of receive at end of Acknowledge
SSPxIF sequence
Set P bit
Cleared by software Cleared by software Cleared by software Cleared by software (SSPxSTAT<4>)
SDAx = 0, SCLx = 1 Cleared in
while CPU software and SSPxIF
responds to SSPxIF
BF
Preliminary
(SSPxSTAT<0>) Last bit is shifted into SSPxSR and
contents are unloaded into SSPxBUF
SSPxOV
ACKEN
RCEN
I2C™ MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS)
Master configured as a receiver RCEN cleared ACK from Master RCEN cleared
by programming SSPxCON2<3> (RCEN = 1) automatically SDAx = ACKDT = 0 automatically
DS41412B-page 245
PIC18(L)F2X/4XK22
PIC18(L)F2X/4XK22
15.6.8 ACKNOWLEDGE SEQUENCE 15.6.9 STOP CONDITION TIMING
TIMING A Stop bit is asserted on the SDAx 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, of the bit, PEN, of the SSPxCON2 register. At the end of a
SSPxCON2 register. When this bit is set, the SCLx pin is receive/transmit, the SCLx 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 SDAx pin. If the user wishes to the master will assert the SDAx line low. When the
generate an Acknowledge, then the ACKDT bit should SDAx line is sampled low, the Baud Rate Generator is
be cleared. If not, the user should set the ACKDT bit reloaded and counts down to ‘0’. When the Baud Rate
before starting an Acknowledge sequence. The Baud Generator times out, the SCLx pin will be brought high
Rate Generator then counts for one rollover period and one TBRG (Baud Rate Generator rollover count)
(TBRG) and the SCLx pin is deasserted (pulled high). later, the SDAx pin will be deasserted. When the SDAx
When the SCLx pin is sampled high (clock arbitration), pin is sampled high while SCLx is high, the P bit of the
the Baud Rate Generator counts for TBRG. The SCLx pin SSPxSTAT register is set. A TBRG later, the PEN bit is
is then pulled low. Following this, the ACKEN bit is auto- cleared and the SSPxIF bit is set (Figure 15-30).
matically cleared, the Baud Rate Generator is turned off
and the MSSPx module then goes into Idle mode 15.6.9.1 WCOL Status Flag
(Figure 15-29). If the user writes the SSPxBUF when a Stop sequence
is in progress, then the WCOL bit is set and the
15.6.8.1 WCOL Status Flag contents of the buffer are unchanged (the write does
If the user writes the SSPxBUF when an Acknowledge not occur).
sequence is in progress, then WCOL is set and the
contents of the buffer are unchanged (the write does
not occur).
SCLx 8 9
SSPxIF
Cleared in
SSPxIF set at software
the end of receive Cleared in
software SSPxIF set at the end
of Acknowledge sequence
Note: TBRG = one Baud Rate Generator period.
SDAx ACK
P
TBRG TBRG TBRG
SCLx brought high after TBRG
SDAx asserted low before rising edge of clock
to setup Stop condition
SDAx
BCLxIF
SDAx
SCLx
Set SEN, enable Start SEN cleared automatically because of bus collision.
condition if SDAx = 1, SCLx = 1 SSPx module reset into Idle state.
SEN
SDAx sampled low before
Start condition. Set BCLxIF.
S bit and SSPxIF set because
BCLxIF SDAx = 0, SCLx = 1.
SSPxIF and BCLxIF are
cleared by software
SSPxIF
TBRG TBRG
SDAx
FIGURE 15-35: BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
SDAx = 0, SCLx = 1
Set S Set SSPxIF
Less than TBRG
TBRG
SCLx S
SCLx pulled low after BRG
time-out
SEN
Set SEN, enable Start
sequence if SDAx = 1, SCLx = 1
BCLxIF ’0’
SSPxIF
SDAx = 0, SCLx = 1, Interrupts cleared
set SSPxIF by software
SDAx
SCLx
RSEN
BCLxIF
Cleared by software
S ’0’
SSPxIF ’0’
TBRG TBRG
SDAx
SCLx
S ’0’
SSPxIF
PEN
BCLxIF
P ’0’
SSPxIF ’0’
SDAx
PEN
BCLxIF
P ’0’
SSPxIF ’0’
SSPxM<3:0> SSPxADD<7:0>
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared HS = Bit is set by hardware C = User cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared HC = Cleared by hardware S = User set
bit 7 GCEN: General Call Enable bit (in I2C Slave mode only)
1 = Enable interrupt when a general call address (0x00 or 00h) is received in the SSPxSR
0 = General call address disabled
bit 6 ACKSTAT: Acknowledge Status bit (in I2C mode only)
1 = Acknowledge was not received
0 = Acknowledge was received
bit 5 ACKDT: Acknowledge Data bit (in I2C mode only)
In Receive mode:
Value transmitted when the user initiates an Acknowledge sequence at the end of a receive
1 = Not Acknowledge
0 = Acknowledge
bit 4 ACKEN(1): Acknowledge Sequence Enable bit (in I2C Master mode only)
In Master Receive mode:
1 = Initiate Acknowledge sequence on SDAx and SCLx pins, and transmit ACKDT data bit.
Automatically cleared by hardware.
0 = Acknowledge sequence idle
bit 3 RCEN(1): Receive Enable bit (in I2C Master mode only)
1 = Enables Receive mode for I2C
0 = Receive idle
bit 2 PEN(1): Stop Condition Enable bit (in I2C Master mode only)
SCKx Release Control:
1 = Initiate Stop condition on SDAx and SCLx pins. Automatically cleared by hardware.
0 = Stop condition Idle
bit 1 RSEN(1): Repeated Start Condition Enabled bit (in I2C Master mode only)
1 = Initiate Repeated Start condition on SDAx and SCLx pins. Automatically cleared by hardware.
0 = Repeated Start condition Idle
bit 0 SEN(1): Start Condition Enabled bit (in I2C Master mode only)
In Master mode:
1 = Initiate Start condition on SDAx and SCLx pins. Automatically cleared by hardware.
0 = Start condition Idle
In Slave mode:
1 = Clock stretching is enabled for both slave transmit and slave receive (stretch enabled)
0 = Clock stretching is disabled
Note 1: For bits ACKEN, RCEN, PEN, RSEN, SEN: If the I2C module is not in the Idle mode, this bit may not be
set (no spooling) and the SSPxBUF may not be written (or writes to the SSPxBUF are disabled).
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
REGISTER 15-6: SSPXADD: MSSPx 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
ADD<7:0>
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
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<2:1>: 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:
TXEN
TRMT
Baud Rate Generator FOSC
÷n
TX9
BRG16 n
+1 Multiplier x4 x16 x64
TX9D
SYNC 1 X 0 0 0
SPBRGHx SPBRGx 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
SPBRGHx SPBRGx BRGH X 1 1 0 0 FIFO
FERR RX9D RCREGx Register
BRG16 X 1 0 1 0
8
Data Bus
RCxIF Interrupt
RCxIE
Write to TXREGx
Word 1
BRG Output
(Shift Clock)
TXx/CKx pin
Start bit bit 0 bit 1 bit 7/8 Stop bit
Word 1
TXxIF bit
(Transmit Buffer 1 TCY
Reg. Empty Flag)
Word 1
TRMT bit
Transmit Shift Reg
(Transmit Shift
Reg. Empty Flag)
Write to TXREGx
Word 1 Word 2
BRG Output
(Shift Clock)
Read Rcv
Buffer Reg
RCREGx
RCxIF
(Interrupt Flag)
OERR bit
CREN
Note: This timing diagram shows three words appearing on the RXx/DTx input. The RCREGx (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 = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRGx SPBRGx SPBRGx SPBRGx
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 300 0.00 191 300 0.16 51
1200 1202 0.16 103 1202 0.16 51 1200 0.00 47 1202 0.16 12
2400 2404 0.16 51 2404 0.16 25 2400 0.00 23 — — —
9600 9615 0.16 12 — — — 9600 0.00 5 — — —
10417 10417 0.00 11 10417 0.00 5 — — — — — —
19.2k — — — — — — 19.20k 0.00 2 — — —
57.6k — — — — — — 57.60k 0.00 0 — — —
115.2k — — — — — — — — — — — —
BAUD FOSC = 64.000 MHz FOSC = 18.432 MHz FOSC = 16.000 MHz FOSC = 11.0592 MHz
RATE SPBRGx SPBRGx SPBRGx SPBRGx
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 SPBRGx SPBRGx SxBRGx SPBRGx
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 SPBRGHx: SPBRGHx: SPBRGHx SPBRGHx:
Actual % Actual % Actual % Actual %
SPBRGx SPBRGx :SPBRGx SPBRGx
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 SPBRGHx: SPBRGHx: SPBRGHx SPBRGHx:
Actual % Actual % Actual % Actual %
SPBRGx SPBRGx :SPBRGx SPBRGx
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 SPBRGHx: SPBRGHx: SPBRGHx SPBRGHx:
Actual % Actual % Actual % Actual %
SPBRGx SPBRGx :SPBRGx SPBRGx
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 SPBRGHx: SPBRGHx: SPBRGHx SPBRGHx:
Actual % Actual % Actual % Actual %
SPBRGx SPBRGx :SPBRGx SPBRGx
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
RCxIF bit
(Interrupt)
Read
RCREGx
Note 1: The ABD sequence requires the EUSART module to be configured in Asynchronous mode.
RXx/DTx Line
RCxIF
Cleared due to User Read of RCREGx
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 TXREGx
Dummy Write
BRG Output
(Shift Clock)
Write to
TXREGx Reg Write Word 1 Write Word 2
TXxIF bit
(Interrupt Flag)
TRMT bit
‘1’ ‘1’
TXEN bit
Note: Sync Master mode, SPBRGx = 0, continuous transmission of two 8-bit words.
TXx/CKx pin
Write to
TXREGx reg
TXxIF bit
TRMT bit
TXEN bit
RXx/DTx
pin bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
TXx/CKx pin
(SCKP = 0)
TXx/CKx pin
(SCKP = 1)
Write to
bit SREN
SREN bit
RCxIF bit
(Interrupt)
Read
RCREGx
Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
11111
FVR BUF2
11110
CTMU
11101
Reserved
11100
AN28(1)
11011
AN27(1)
ADCMD
00101 ADON
AN5(1)
10-Bit ADC GO/DONE
00100
AN4
10
00011
AN3
00010
AN2 0 = Left Justify
ADFM
00001 1 = Right Justify
AN1
00000
AN0 10
2
PVCFG<1:0>
ADRESH ADRESL
AVDD 00
01
VREF+/AN3
10
FVR BUF2
Reserved 11
2
NVCFG<1:0>
AVSS 00
01
VREF-/AN2
10
Reserved
Reserved 11
Note: Additional ADC channels AN5-AN7 and AN20-AN27 are only available on PIC18(L)F4XK22 devices.
TABLE 17-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 17-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
1
V AP PLIE D 1 – ------------ = V CHOLD ;[1] VCHOLD charged to within 1/2 lsb
2047
–TC
----------
RC ;[2] VCHOLD charge response to VAPPLIED
V AP P LI ED 1 – e = V CHOLD
– Tc
---------
1
V AP P LIED 1 – e = V A P PLIE D 1 – ------------
RC
;combining [1] and [2]
2047
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 27.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
CxCH<1:0>
2 CxON(1)
To CMxCON0 (CxOUT)
CxSP CM2CON1 (MCxOUT)
C12IN0- 0
D Q
C12IN1- 1 CxVIN- Q1 (2),(3)
EN
-
C12IN2- 2 Cx
CxVIN+
C12IN3- +
3
D Q
To Interrupts
Q3(2)
EN (CxIF)
CxR
CL
Read or Write
of CMxCON0
CxIN+ 0 Reset
Cx Output
DAC 1 CxPOL
0 to PWM Logic
CxSYNC
FVR BUF1 1 CxOE TRIS bit
CXVREF
0
CXRSEL
D Q 1 CxOUT
Timer1 Clock
SYNCCxOUT
- to SR Latch
- to TxG MUX(4)
Note 1: When C1ON = 0, the C1 comparator will produce a ‘0’ output to the XOR Gate.
2: Q1 and Q3 are phases of the four-phase system clock (FOSC).
3: Q1 is held high during Sleep mode.
4: Synchronized comparator output should not be used to gate Timer1 in conjunction with synchronized T1CKI.
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.
18.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
the ANSEL register and the corresponding optimized during program execution with the CxSP
TRIS bits must also be set to disable the control bit. The default state for this bit is ‘1’ which
output drivers. selects the normal speed mode. Device power
consumption can be optimized at the cost of slower
18.2.3 COMPARATOR REFERENCE comparator propagation delay by clearing the CxSP bit
SELECTION to ‘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: 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.
VT 0.6V RIC
Rs < 10K
To Comparator
AIN
CPIN ILEAKAGE(1)
VA VT 0.6V
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
CTMUCONH/CTMUCONL
EDGEN CTMUICON
EDGSEQEN
ITRIM<5:0> TGEN
EDG1SELx
EDG1POL IRNG<1:0> IDISSEN
EDG2SELx EDG1STAT CTTRIG
EDG2POL EDG2STAT Current Source
CTED1 Edge
CTMU
Control Control
CTED2 Logic Current Logic
Control
ECCP2
Pulse CTPLS
ECCP1 Generator
A/D Converter Comparator 2
Input
Comparator 2 Output
/**************************************************************************/
//Setup AD converter;
/**************************************************************************/
// ADCON2
ADCON2bits.ADFM=1; // Results format 1= Right justified
ADCON2bits.ACQT=1; // Acquition time 7 = 20TAD 2 = 4TAD 1=2TAD
ADCON2bits.ADCS=2; // Clock conversion bits 6= FOSC/64 2=FOSC/32
// ADCON1
ADCON1bits.PVCFG0 =0; // Vref+ = AVdd
ADCON1bits.NVCFG1 =0; // Vref- = AVss
// ADCON0
ADCON0bits.CHS=2; // Select ADC channel
int main(void)
{
int i;
int j = 0; //index for loop
unsigned int Vread = 0;
double VTot = 0;
float Vavg=0, Vcal=0, CTMUISrc = 0; //float values stored for calcs
(4 pF + 11 pF) • 2.31V/0.55 A
or 63 s.
See Example 19-3 for a typical routine for CTMU
capacitance calibration.
int main(void)
{
int i;
int j = 0; //index for loop
unsigned int Vread = 0;
float CTMUISrc, CTMUCap, Vavg, VTot, Vcal;
int main(void)
{
unsigned int Vread; //storage for reading
unsigned int switchState;
int i;
PIC18(L)FXXK22 Device
CTMU
CTED1 EDG1
Current Source
CTED2 EDG2
Output Pulse
A/D Converter
ANX
CAD
RPR
PIC18(L)FXXK22 Device
CTMU
CTED1 EDG1 CTPLS
Current Source
Comparator
C12IN1-
C2
CPULSE CVREF
19.7 Operation During Sleep/Idle module is performing an operation when Idle mode is
Modes invoked, in this case, the results will be similar to those
with Sleep mode.
19.7.1 SLEEP MODE AND DEEP SLEEP
MODES 19.8 CTMU Peripheral Module Disable
When the device enters any Sleep mode, the CTMU (PMD)
module current source is always disabled. If the CTMU When this peripheral is not used, the Peripheral
is performing an operation that depends on the current Module Disable bit can be set to disconnect all clock
source when Sleep mode is invoked, the operation may sources to the module, reducing power consumption to
not terminate correctly. Capacitance and time an absolute minimum. See Section 3.6 “Selective
measurements may return erroneous values. Peripheral Module Control”.
19.7.2 IDLE MODE
The behavior of the CTMU in Idle mode is determined
by the CTMUSIDL bit (CTMUCONH<5>). If CTMUSIDL
is cleared, the module will continue to operate in Idle
mode. If CTMUSIDL is set, the module’s current source
is disabled when the device enters Idle mode. If the
If the CTMU is in the process of taking a measurement at The CTMUCONH and CTMUCONL registers
the time of Reset, the measurement will be lost. A partial (Register 19-1 and Register 19-2) contain control bits
charge may exist on the circuit that was being measured, for configuring the CTMU module edge source selec-
and should be properly discharged before the CTMU tion, edge source polarity selection, edge sequencing,
makes subsequent attempts to make a measurement. A/D trigger, analog circuit capacitor discharge and
The circuit is discharged by setting and then clearing the enables. The CTMUICON register (Register 19-3) has
IDISSEN bit (CTMUCONH<1>) while the A/D Converter bits for selecting the current source range and current
is connected to the appropriate channel. source trim.
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
The latch is a Set-Reset Latch that does not depend on 20.4 Effects of a Reset
a clock source. Each of the Set and Reset inputs are
active-high. The latch can be set or reset by: Upon any device Reset, the SR Latch is not initialized,
and the SRQ and SRNQ outputs are unknown. The
• Software control (SRPS and SRPR bits)
user’s firmware is responsible to initialize the latch
• Comparator C1 output (SYNCC1OUT) output before enabling it to the output pins.
• Comparator C2 output (SYNCC2OUT)
• SRI Pin
• Programmable clock (DIVSRCLK)
The SRPS and the SRPR bits of the SRCON0 register
may be used to set or reset the SR Latch, respectively.
The latch is Reset-dominant. Therefore, if both Set and
Reset inputs are high, the latch will go to the Reset
state. Both the SRPS and SRPR bits are self resetting
which means that a single write to either of the bits is all
that is necessary to complete a latch Set or Reset
operation.
The output from Comparator C1 or C2 can be used as
the Set or Reset inputs of the SR Latch. The output of
either Comparator can be synchronized to the Timer1
clock source. See Section 18.0 “Comparator
Module” and Section 12.0 “Timer1/3/5 Module with
Gate Control” for more information.
An external source on the SRI pin can be used as the
Set or Reset inputs of the SR Latch.
An internal clock source, DIVSRCLK, is available and it
can periodically set or reset the SR Latch. The
SRCLK<2:0> bits in the SRCON0 register are used to
select the clock source period. The SRSCKE and
SRRCKE bits of the SRCON1 register enable the clock
source to set or reset the SR Latch, respectively.
3
SRCLK<2:0>
Programmable
SRCLK divider
Peripheral 1:4 to 1:512 DIVSRCLK
Clock 4-512 cycles
...
t0 t0+4 t0+8 t0+12
Tosc
SRCLK<2:0> = "001"
1:8
SRLEN
SRPS Pulse SRQEN
Gen(2)
SRI
SRSPE S Q
DIVSRCLK SRQ
SRSCKE
SYNCC2OUT(3)
SRSC2E
SYNCC1OUT(3)
SR
SRSC1E
Latch(1)
SRPR Pulse
Gen(2)
SRI
SRRPE R Q
DIVSRCLK SRNQ
SRRCKE SRLEN
SYNCC2OUT(3) SRNQEN
SRRC2E
SYNCC1OUT(3)
SRRC1E
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
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
• ADC input channel The FVRS<1:0> bits of the VREFCON0 register are
used to enable and configure the gain amplifier settings
• ADC positive reference
for the reference supplied to the DAC and Comparator
• Comparator positive input modules. When the ADC module is configured to use
• Digital-to-Analog Converter (DAC) the FVR output, (FVR BUF2) the reference is buffered
The FVR can be enabled by setting the FVREN bit of through an additional unity gain amplifier. This buffer is
the VREFCON0 register. disabled if the ADC is not configured to use the FVR.
For specific use of the FVR, refer to the specific module
sections: Section 17.0 “Analog-to-Digital Converter
(ADC) Module”, Section 22.0 “Digital-to-Analog
Converter (DAC) Module” and Section 18.0 “Com-
parator Module”.
X1 FVR BUF2
(To ADC Module)
FVRS<1:0> 2
X1
X2 FVR BUF1
X4 (To Comparators, DAC)
FVREN +
1.024V Fixed
FVRST _ Reference
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
22.2 Ratiometric Output Level This allows the comparator to detect a zero-crossing
while not consuming additional current through the DAC
The DAC output value is derived using a resistor ladder module.
with each end of the ladder tied to a positive and
negative voltage reference input source. If the voltage 22.6 DAC Voltage Reference Output
of either input source fluctuates, a similar fluctuation will
result in the DAC output value. The DAC can be output to the DACOUT pin by setting
the DACOE bit of the VREFCON1 register to ‘1’.
The value of the individual resistors within the ladder
Selecting the DAC reference voltage for output on the
can be found in Section 27.0 “Electrical
DACOUT pin automatically overrides the digital output
Characteristics”.
buffer and digital input threshold detector functions of
that pin. Reading the DACOUT pin when it has been
22.3 Low-Power Voltage State configured for DAC reference voltage output will always
In order for the DAC module to consume the least return a ‘0’.
amount of power, one of the two voltage reference input Due to the limited current drive capability, a buffer must
sources to the resistor ladder must be disconnected. be used on the DAC voltage reference output for
Either the positive voltage source, (VSRC+), or the external connections to DACOUT. Figure 22-2 shows
negative voltage source, (VSRC-) can be disabled. an example buffering technique.
Reserved 11
FVR BUF1 10 VSRC+
VREF+ 01
DACR<4:0>
5
VDD 00
R
2
11111
R
DACPSS<1:0>
11110
R
DACEN
DACLPS R
32-to-1 MUX
32
Steps DAC
(To Comparator, CSM and
ADC Modules)
R
R
00001 DACOUT
R
00000
DACOE
DACNSS
VREF- 1 VSRC-
VSS 0
PIC® MCU
DAC
R
Module
+
Voltage DACOUT Buffered DAC Output
–
Reference
Output
Impedance
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set ‘0’ = Bit is cleared
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
HLVDEN VDIRMAG
HLVDIN
Set
16-to-1 MUX
HLVDIF
HLVDEN
Internal Voltage
BOREN Reference
1.024V Typical
VHLVD
HLVDIF
Enable HLVD
TIRVST
IRVST
HLVDIF cleared in software
Internal Reference is stable
CASE 2:
VDD
VHLVD
HLVDIF
Enable HLVD
IRVST TIRVST
HLVDIF cleared in software
Internal Reference is stable
HLVDIF cleared in software,
HLVDIF remains set since HLVD condition still exists
VHLVD
VDD
HLVDIF
Enable HLVD
IRVST TIRVST
CASE 2:
VHLVD
VDD
HLVDIF
Enable HLVD
IRVST TIRVST
• Oscillator Selection The user will note that address 300000h is beyond the
user program memory space. In fact, it belongs to the
• Resets: configuration memory space (300000h-3FFFFFh), which
- Power-on Reset (POR) can only be accessed using table reads and table writes.
- Power-up Timer (PWRT)
Programming the Configuration registers is done in a
- Oscillator Start-up Timer (OST) manner similar to programming the Flash memory. The
- Brown-out Reset (BOR) WR bit in the EECON1 register starts a self-timed write
• Interrupts to the Configuration register. In normal operation mode,
• Watchdog Timer (WDT) a TBLWT instruction with the TBLPTR pointing to the
Configuration register sets up the address and the data
• Code Protection
for the Configuration register write. Setting the WR bit
• ID Locations starts a long write to the Configuration register. The
• In-Circuit Serial Programming™ Configuration registers are written a byte at a time. To
The oscillator can be configured for the application write or erase a configuration cell, a TBLWT instruction
depending on frequency, power, accuracy and cost. All can write a ‘1’ or a ‘0’ into the cell. For additional details
of the options are discussed in detail in Section 2.0 on Flash programming, refer to Section 6.5 “Writing
“Oscillator Module (With Fail-Safe Clock Monitor)”. to Flash Program Memory”.
A complete discussion of device Resets and interrupts
is available in previous sections of this data sheet.
In addition to their Power-up and Oscillator Start-up
Timers provided for Resets, PIC18(L)F2X/4XK22
devices have a Watchdog Timer, which is either
permanently enabled via the Configuration bits or
software controlled (if configured as disabled).
The inclusion of an internal RC oscillator also provides
the additional benefits of a Fail-Safe Clock Monitor
(FSCM) and Two-Speed Start-up. FSCM provides for
background monitoring of the peripheral clock and
automatic switchover in the event of its failure. Two-
Speed Start-up enables code to be executed almost
immediately on start-up, while the primary clock source
completes its start-up delays.
All of these features are enabled and configured by
setting the appropriate Configuration register bits.
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 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
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
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
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 25-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 25.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 01da ffff ffff C, DC, Z, OV, N 1, 2
ADDWFC f, d, a Add WREG and CARRY bit to f 1 0010 00da ffff ffff C, DC, Z, OV, N 1, 2
ANDWF f, d, a AND WREG with f 1 0001 01da ffff ffff Z, N 1,2
CLRF f, a Clear f 1 0110 101a ffff ffff Z 2
COMF f, d, a Complement f 1 0001 11da ffff ffff Z, N 1, 2
CPFSEQ f, a Compare f with WREG, skip = 1 (2 or 3) 0110 001a ffff ffff None 4
CPFSGT f, a Compare f with WREG, skip > 1 (2 or 3) 0110 010a ffff ffff None 4
CPFSLT f, a Compare f with WREG, skip < 1 (2 or 3) 0110 000a ffff ffff None 1, 2
DECF f, d, a Decrement f 1 0000 01da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
DECFSZ f, d, a Decrement f, Skip if 0 1 (2 or 3) 0010 11da ffff ffff None 1, 2, 3, 4
DCFSNZ f, d, a Decrement f, Skip if Not 0 1 (2 or 3) 0100 11da ffff ffff None 1, 2
INCF f, d, a Increment f 1 0010 10da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
INCFSZ f, d, a Increment f, Skip if 0 1 (2 or 3) 0011 11da ffff ffff None 4
INFSNZ f, d, a Increment f, Skip if Not 0 1 (2 or 3) 0100 10da ffff ffff None 1, 2
IORWF f, d, a Inclusive OR WREG with f 1 0001 00da ffff ffff Z, N 1, 2
MOVF f, d, a Move f 1 0101 00da ffff ffff Z, N 1
MOVFF fs, fd Move fs (source) to 1st word 2 1100 ffff ffff ffff None
fd (destination) 2nd word 1111 ffff ffff ffff
MOVWF f, a Move WREG to f 1 0110 111a ffff ffff None
MULWF f, a Multiply WREG with f 1 0000 001a ffff ffff None 1, 2
NEGF f, a Negate f 1 0110 110a ffff ffff C, DC, Z, OV, N
RLCF f, d, a Rotate Left f through Carry 1 0011 01da ffff ffff C, Z, N 1, 2
RLNCF f, d, a Rotate Left f (No Carry) 1 0100 01da ffff ffff Z, N
RRCF f, d, a Rotate Right f through Carry 1 0011 00da ffff ffff C, Z, N
RRNCF f, d, a Rotate Right f (No Carry) 1 0100 00da ffff ffff Z, N
SETF f, a Set f 1 0110 100a ffff ffff None 1, 2
SUBFWB f, d, a Subtract f from WREG with 1 0101 01da ffff ffff C, DC, Z, OV, N
borrow
SUBWF f, d, a Subtract WREG from f 1 0101 11da ffff ffff C, DC, Z, OV, N 1, 2
SUBWFB f, d, a Subtract WREG from f with 1 0101 10da ffff ffff C, DC, Z, OV, N
borrow
SWAPF f, d, a Swap nibbles in f 1 0011 10da ffff ffff None 4
TSTFSZ f, a Test f, skip if 0 1 (2 or 3) 0110 011a ffff ffff None 1, 2
XORWF f, d, a Exclusive OR WREG with f 1 0001 10da ffff ffff Z, N
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the
first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program 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 25.2.3 “Byte-Oriented and See Section 25.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 25.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 25.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 25.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.
5.5V
3.6V
3.5V
3.0V
2.7V
Voltage
2.2V
1.8V
10 20 30 32 40 50 60 64
Frequency (MHz)
Param
Device Characteristics Typ Max Units Conditions
No.
D020 Supply Current (IDD)(1),(2) 5.0 14 A -40°C
4.0 14 A +25°C
4.0 — A +60°C VDD = 1.8V
4.5 18 A +85°C
7.0 30 A 125°C FOSC = 31 kHz
(RC_RUN mode,
D021 8.0 20 A -40°C LFINTOSC source)
7.0 20 A +25°C
7.0 — A +60°C VDD = 3.0V
7.5 22 A +85°C
10.0 35 A +125°C
D022 12 50 A -40°C
15 50 A +25°C
VDD = 1.8V
17 50 A +85°C
20 60 A +125°C
D023 16 50 A -40°C
19 50 A +25°C FOSC = 31 kHz
VDD = 3.0V (RC_RUN mode,
23 50 A +85°C LFINTOSC source)
25 60 A +125°C
17 50 A -40°C
21 50 A +25°C
D024 VDD = 5.0V
24 50 A +85°C
28 60 A +125°C
D025 0.12 0.25 mA -40°C to +125°C VDD = 1.8V FOSC = 500 KHz
(RC_RUN mode,
D026 0.15 0.30 mA -40°C to +125°C VDD = 3.0V MFINTOSC source)
D027 0.16 0.30 mA -40°C to +125°C VDD = 1.8V
FOSC = 500 KHz
D028 0.20 0.40 mA -40°C to +125°C VDD = 3.0V (RC_RUN mode,
D029 0.50 -40°C to +125°C VDD = 5.0V MFINTOSC source)
0.25 mA
D030 0.30 0.50 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
(RC_RUN mode,
D031 0.40 0.70 mA -40°C to +125°C VDD = 3.0V HFINTOSC source)
D032 0.35 0.60 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D033 0.45 0.80 mA -40°C to +125°C VDD = 3.0V (RC_RUN mode,
HFINTOSC source)
D034 0.55 0.90 mA -40°C to +125°C VDD = 5.0V
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin
loading and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an
impact on the current consumption.
Test condition: All Peripheral Module Control bits in PMD0, PMD1 and PMD2 set to ‘1’.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to Vss;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
Param
Device Characteristics Typ Max Units Conditions
No.
D035 1.0 1.7 mA -40°C to +125°C VDD = 1.8V FOSC = 16 MHz
1.7 (RC_RUN mode,
D036 2.8 mA -40°C to +125°C VDD = 3.0V
HFINTOSC source)
D037 1.2 1.9 mA -40°C to +125°C VDD = 1.8V FOSC = 16 MHz
D038 2.0 3.2 mA -40°C to +125°C VDD = 3.0V (RC_RUN mode,
HFINTOSC source)
D039 2.3 3.6 mA -40°C to +125°C VDD = 5.0V
FOSC = 64 MHz
(RC_RUN mode,
D041 6.5 10 mA -40°C to +125°C VDD = 3.0V
HFINTOSC + PLL
source)
D043 7.0 11.0 mA -40°C to +125°C VDD = 3.0V FOSC = 64 MHz
7.9 (RC_RUN mode,
D044 12.0 mA -40°C to +125°C VDD = 5.0V HFINTOSC + PLL
source)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as I/O pin
loading and switching rate, oscillator type and circuit, internal code execution pattern and temperature, also have an
impact on the current consumption.
Test condition: All Peripheral Module Control bits in PMD0, PMD1 and PMD2 set to ‘1’.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to Vss;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
Param
Device Characteristics Typ Max Units Conditions
No.
D045 Supply Current (IDD)(1),(2) 2.5 8 A -40°C
1.5 8 A +25°C
1.5 — A +60°C VDD = 1.8V
2.0 10 A +85°C
4.0 25 A +125°C FOSC = 31 kHz
(RC_IDLE mode,
D046 3.0 10 A -40°C LFINTOSC source)
2.0 10 A +25°C
2.0 — A +60°C VDD = 3.0V
2.5 12 A +85°C
5.0 30 A +125°C
D047 10 50 A -40°C
13 50 A +25°C
VDD = 1.8V
15 50 A +85°C
18 60 A +125°C
D048 12 50 A -40°C
14 50 A +25°C FOSC = 31 kHz
VDD = 3.0V (RC_IDLE mode,
17 50 A +85°C LFINTOSC source)
20 60 A +125°C
D049 13 50 A -40°C
16 50 A +25°C
VDD = 5.0V
18 50 A +85°C
23 60 A +125°C
D050 0.10 0.20 mA -40°C to +125°C VDD = 1.8V FOSC = 500 KHz
(RC_IDLE mode,
D051 0.12 0.25 mA -40°C to +125°C VDD = 3.0V MFINTOSC source)
D052 0.13 0.25 mA -40°C to +125°C VDD = 1.8V FOSC = 500 KHz
D053 0.15 0.30 mA -40°C to +125°C VDD = 3.0V (RC_IDLE mode,
D054 0.20 0.40 mA -40°C to +125°C VDD = 5.0V MFINTOSC source)
Param
Device Characteristics Typ Max Units Conditions
No.
D057 0.3 0.50 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D058 0.4 0.70 mA -40°C to +125°C VDD = 3.0V (RC_IDLE mode,
HFINTOSC source)
D059 0.45 0.80 mA -40°C to +125°C VDD = 5.0V
D060 0.5 0.9 mA -40°C to +125°C VDD = 1.8V FOSC = 16 MHz
0.8 (RC_IDLE mode,
D061 1.4 mA -40°C to +125°C VDD = 3.0V HFINTOSC source)
D062 0.6 1.0 mA -40°C to +125°C VDD = 1.8V FOSC = 16 MHz
0.9 (RC_IDLE mode,
D063 1.4 mA -40°C to +125°C VDD = 3.0V
HFINTOSC source)
D064 1.1 1.7 mA -40°C to +125°C VDD = 5.0V
FOSC = 64 MHz
(RC_IDLE mode,
D066 2.5 4 mA -40°C to +125°C VDD = 3.0V
HFINTOSC + PLL
source)
D068 3.0 5.0 mA -40°C to +125°C VDD = 3.0V FOSC = 64 MHz
(RC_IDLE mode,
D069 3.5 6.0 mA -40°C to +125°C VDD = 5.0V HFINTOSC + PLL
source)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and temper-
ature, also have an impact on the current consumption.
The test conditions for all IDD measurements in active operation mode are:
OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
MCLR = VDD; WDT enabled/disabled as specified.
2: For RC oscillator configurations, current through REXT is not included. The current through the resistor can
be estimated by the formula Ir = VDD/2REXT (mA) with REXT in k.
Param
Device Characteristics Typ Max Units Conditions
No.
D070 Supply Current (IDD)(1),(2) 0.07 0.14 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D071 (PRI_RUN,
0.12 0.25 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D072 0.08 0.20 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D073 0.13 0.25 mA -40°C to +125°C VDD = 3.0V (PRI_RUN,
EC oscillator)
D074 0.15 0.30 mA -40°C to +125°C VDD = 5.0V
D075 1.2 2.0 mA -40°C to +125°C VDD = 1.8V FOSC = 20 MHz
D076 (PRI_RUN,
2.2 3.8 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D077 1.4 2.5 mA -40°C to +125°C VDD = 1.8V FOSC = 20 MHz
D078 2.4 4.0 mA -40°C to +125°C VDD = 3.0V (PRI_RUN,
EC oscillator)
D079 2.7 4.5 mA -40°C to +125°C VDD = 5.0V
D080 FOSC = 64 MHz
6.5 11 mA -40°C to +125°C VDD = 3.0V (PRI_RUN,
EC oscillator)
D081 6.8 11 mA -40°C to +125°C VDD = 3.0V FOSC = 64 MHz
D082 (PRI_RUN,
7.5 13 mA -40°C to +125°C VDD = 5.0V EC oscillator)
D083 1.0 1.7 mA -40°C to +125°C VDD = 1.8V FOSC = 4 MHz
D084 16 MHz Internal
1.8 3.2 mA -40°C to +125°C VDD = 3.0V (PRI_RUN, EC +
PLL)
D085 1.0 1.8 mA -40°C to +125°C VDD = 1.8V FOSC = 4 MHz
D086 1.9 3.5 mA -40°C to +125°C VDD = 3.0V 16 MHz Internal
(PRI_RUN, EC +
D087 2.2 4.0 mA -40°C to +125°C VDD = 5.0V PLL)
D088 FOSC = 16 MHz
64 MHz Internal
6.5 10 mA -40°C to +125°C VDD = 3.0V
(PRI_RUN, EC +
PLL)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and temper-
ature, also have an impact on the current consumption.
The test conditions for all IDD measurements in active operation mode are:
OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
MCLR = VDD; WDT enabled/disabled as specified.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to VSS;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI-IDLE only).
Param
Device Characteristics Typ Max Units Conditions
No.
D089 6.8 11 mA -40°C to +125°C VDD = 3.0V FOSC = 16 MHz
D090 64 MHz Internal
7.5 13 mA -40°C to +125°C VDD = 5.0V (PRI_RUN, EC +
PLL)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and temper-
ature, also have an impact on the current consumption.
The test conditions for all IDD measurements in active operation mode are:
OSC1 = external square wave, from rail-to-rail; all I/O pins tri-stated, pulled to VDD;
MCLR = VDD; WDT enabled/disabled as specified.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to VSS;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI-IDLE only).
Param
Device Characteristics Typ Max Units Conditions
No.
D100 Supply Current (IDD)(1),(2) 0.025 0.07 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D101 (PRI_IDLE mode,
0.045 0.10 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D102 0.04 0.12 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D103 0.06 0.15 mA -40°C to +125°C VDD = 3.0V (PRI_IDLE mode,
EC oscillator)
D104 0.07 0.17 mA -40°C to +125°C VDD = 5.0V
D105 0.45 0.65 mA -40°C to +125°C VDD = 1.8V FOSC = 20 MHz
D106 (PRI_IDLEmode,
0.75 1.10 mA -40°C to +125°C VDD = 3.0V EC oscillator)
D107 0.5 0.8 mA -40°C to +125°C VDD = 1.8V FOSC = 20 MHz
D108 0.9 1.5 mA -40°C to +125°C VDD = 3.0V (PRI_IDLEmode,
EC oscillator)
D109 1.1 1.8 mA -40°C to +125°C VDD = 5.0V
D110 FOSC = 64 MHz
2.5 4 mA -40°C to +125°C VDD = 3.0V (PRI_IDLEmode,
EC oscillator)
D111 2.7 4.2 mA -40°C to +125°C VDD = 3.0V FOSC = 64 MHz
D112 (PRI_IDLEmode,
3.3 5.0 mA -40°C to +125°C VDD = 5.0V EC oscillator)
D113 0.40 0.70 mA -40°C to +125°C VDD = 1.8V FOSC = 4 MHz
D114 16 MHz Internal
0.65 1.10 mA -40°C to +125°C VDD = 3.0V (PRI_IDLE, EC +
PLL)
D115 0.4 0.7 mA -40°C to +125°C VDD = 1.8V FOSC = 4 MHz
D116 0.7 1.2 mA -40°C to +125°C VDD = 3.0V 16 MHz Internal
(PRI_IDLE, EC +
D117 0.9 1.5 mA -40°C to +125°C VDD = 5.0V PLL)
D118 FOSC = 16 MHz
64 MHz Internal
2.5 4 mA -40°C to +125°C VDD = 3.0V
(PRI_IDLE, EC +
PLL)
D119 2.7 5.0 mA -40°C to +125°C VDD = 3.0V FOSC = 16 MHz
D120 64 MHz Internal
3.3 6.0 mA -40°C to +125°C VDD = 5.0V (PRI_IDLE, EC +
PLL)
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and temper-
ature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to VSS;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI-IDLE only).
Param
Device Characteristics Typ Max Units Conditions
No.
D130 Supply Current (IDD)(1),(2) 4.0 14 A -40°C
4.5 14 A +25°C
5.0 — A +60°C VDD = 1.8V
5.5 18 A +85°C
9.0 30 A +125°C FOSC = 32 kHz
(SEC_RUN mode,
D131 7.0 20 A -40°C SOSC source)
7.5 20 A +25°C
8.0 — A +60°C VDD = 3.0V
8.5 22 A +85°C
11.0 35 A +125°C
D132 12 50 A -40°C
16 50 A +25°C
VDD = 1.8V
19 50 A +85°C
22 60 A +125°C
D133 16 50 A -40°C
20 50 A +25°C FOSC = 32 kHz
VDD = 3.0V (SEC_RUN mode,
23 50 A +85°C SOSC source)
27 60 A +125°C
D134 18 50 A -40°C
22 50 A +25°C
VDD = 5.0V
25 50 A +85°C
30 60 A +125°C
D135 1.5 8 A -40°C
2.0 8 A +25°C
2.5 — A +60°C VDD = 1.8V
3.0 10 A +85°C
6.0 25 A +125°C FOSC = 32 kHz
(SEC_IDLE mode,
D136 2.0 10 A -40°C SOSC source)
2.5 10 A +25°C
3.0 — A +60°C VDD = 3.0V
3.5 12 A +85°C
7.0 30 A +125°C
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and temper-
ature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to VSS;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
Param
Device Characteristics Typ Max Units Conditions
No.
D137 10 50 A -40°C
13 50 A +25°C
VDD = 1.8V
16 50 A +85°C
19 60 A +125°C
D138 11 50 A -40°C
15 50 A +25°C FOSC = 32 kHz
VDD = 3.0V (SEC_IDLE mode,
18 50 A +85°C SOSC source)
22 60 A +125°C
D139 13 50 A -40°C
17 50 A +25°C
VDD = 5.0V
20 50 A +85°C
24 60 A +125°C
Note 1: The supply current is mainly a function of operating voltage, frequency and mode. Other factors, such as
I/O pin loading and switching rate, oscillator type and circuit, internal code execution pattern and temper-
ature, also have an impact on the current consumption.
2: The test conditions for all IDD measurements in active operation mode are:
All I/O pins set as outputs driven to VSS;
MCLR = VDD;
OSC1 = external square wave, from rail-to-rail (PRI_RUN and PRI_IDLE only).
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 — 12 mV High-Power mode
— 18 mV Low-Power mode
CM02 VICM Input Common-mode Voltage — VDD V
CM03 CMRR Common-mode Rejection Ratio — — dB
CM04 TRESP Response Time — 200 ns High-Power mode(1)
— 300 ns Low-Power mode
CM05 TMC2OV Comparator Mode Change to — — 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/32 — V
CV02* CACC Absolute Accuracy — — 1/2 LSb
CV03* CR Unit Resistor Value (R) — 5k —
CV04* CST Settling Time(1) — — 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 22.0 “Digital-to-Analog Converter (DAC) Module” for more information.
VDD
(HLVDIF can be
VHLVD cleared by software)
(HLVDIF set by hardware)
HLVDIF
VDD/2
RL Pin CL
VSS
CL Legend:
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 27-3 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 27-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.
T0CKI
40 41
42
T1OSO/T13CKI
45 46
47 48
TMR0 or
TMR1
Note: Refer to Figure 27-3 for load conditions.
CCPx
(Capture Mode)
50 51
52
CCPx
(Compare or PWM Mode)
53 54
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 27-3 for load conditions.
SS
70
SCK
(CKP = 0) 83
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76 77
TABLE 27-15: 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 27-3 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
TXx/CKx
pin 121 121
RXx/DTx
pin
120
122
Note: Refer to Figure 27-3 for load conditions.
TXx/CKx
pin 125
RXx/DTx
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.
XXXXXXXXXXXXXXXXX PIC18F25K22-E/SP
XXXXXXXXXXXXXXXXX e3
YYWWNNN 0810017
XXXXXXXXXXXXXXXXXXXX PIC18F25K22-E/SO e3
XXXXXXXXXXXXXXXXXXXX 0810017
XXXXXXXXXXXXXXXXXXXX
YYWWNNN
XXXXXXXXXXXXXXX PIC18F25K22-E/SS
XXXXXXXXXXXXXXX e3
XXXXXXXXXXXXXXX
YYWWNNN 0810017
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.
XXXXXXXX 18F24K22
XXXXXXXX -E/ML e3
YYWWNNN 0810017
XXXXX PIC18
XXXXXX F23K22
XXXXXX -E/MV e3
YWWNNN 810017
XXXXXXXXXXXXXXXXXX PIC18F45K22-E/P e3
XXXXXXXXXXXXXXXXXX 0810017
XXXXXXXXXXXXXXXXXX
YYWWNNN
XXXXXXXXXX PIC18F45K22
XXXXXXXXXX -E/ML e3
XXXXXXXXXX 0810017
YYWWNNN
XXXXXXXXXX PIC18F44K22
XXXXXXXXXX -E/PT e3
XXXXXXXXXX 0810017
YYWWNNN
/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 &%
/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
/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
/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
Program Memory 8192 16384 32768 65536 8192 16384 32768 65536
(Bytes)
SRAM (Bytes) 512 768 1536 3896 512 768 1536 3896
EEPROM (Bytes) 256 256 256 1024 256 256 256 1024
Interrupt Sources 26 26 33 33 26 26 33 33
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 2 2 2 2 2 2 2 2
Modules (CCP)
Enhanced CCP Modules 1 1 1 1 2 2 2 2
(ECCP) Full Bridge
ECCP Module 2 2 2 2 1 1 1 1
Half Bridge
10-bit Analog-to-Digital 17 input 17 input 17 input 17 input 28 input 28 input 28 input 28 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 28-pin UQFN
V
Voltage Reference (VR)
Specifications ........................................................... 439
VREF. SEE ADC Reference Voltage
VREFCON0 Register ....................................................... 338
VREFCON1 (Digital-to-Analog Converter Control 0)
Register .................................................................... 341
VREFCON2 (Digital-to-Analog Converter Control 1)
Register .................................................................... 342
W
Wake-up on Break ........................................................... 280
Watchdog Timer (WDT) ........................................... 349, 360
Associated Registers ............................................... 361
Control Register ....................................................... 361
Programming Considerations .................................. 360
WCOL ...................................................... 239, 242, 244, 246
WCOL Status Flag ................................... 239, 242, 244, 246
WDTCON Register .......................................................... 361
WWW Address ................................................................. 489
WWW, On-Line Support .................................................... 12
X
XORLW ............................................................................ 407
XORWF ............................................................................ 408
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
SS = SSOP
01/05/10