Microchip PIC18F1xK22
Microchip PIC18F1xK22
Microchip PIC18F1xK22
Comparators
8-bit/16-bit
10-bit A/D
Channels
SR Latch
EUSART
Timers
MSSP
ECCP
Device Data Pins I/O(1)
SRAM
Bytes Words EEPROM
(bytes)
(bytes)
Note: For other small form-factor package availability and marking information, please visit
http://www.microchip.com/packaging or contact your local sales office.
Pin Diagrams
VDD 1 20 VSS
RA5 2 19 RA0/PGD
RA4
PIC18(L)F13K22
PIC18(L)F14K22
3 18 RA1/PGC
RA3/MCLR/VPP 4 17 RA2
RC5 5 16 RC0
RC4 6 15 RC1
RC3/PGM 7 14 RC2
RC6 8 13 RB4
RC7 9 12 RB5
RB7 10 11 RB6
20 19 18 17 16
RA3/MCLR/VPP 1 15 RA1/PGC
RC5 2 PIC18(L)F13K22 14 RA2
RC4 3
RC3/PGM PIC18(L)F14K22 13 RC0
4 12 RC1
RC6 5 11 RC2
6 7 8 9 10
RB6
RB5
RB4
RC7
RB7
20-Pin PDIP/SSOP/SOIC
Comparator
20-Pin QFN
Reference
Interrupts
SR Latch
EUSART
Analog
Pull-up
Timers
MSSP
ECCP
Basic
I/O
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 Website; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
IR
8
Instruction State machine
Decode and control signals
Control
PRODH PRODL
PORTC
8 x 8 Multiply RC0
3 8 RC1
RC2
BITOP W RC3
Power-up 8 8 8
Internal RC4
OSC1(2) Oscillator Timer RC5
Block RC6
Oscillator 8 8
LFINTOSC RC7
(2) Start-up Timer
OSC2 Oscillator ALU<8>
Power-on
16 MHz Reset 8
Oscillator
MCLR(1)
Watchdog
Timer
Single-Supply
Precision FVR
VDD, VSS Programming Fail-Safe Band Gap
Clock Monitor Reference
DAC
Data
BOR EEPROM Timer0 Timer1 Timer2 Timer3
FVR FVR
ADC
CVREF/DAC1 Comparator ECCP1 MSSP EUSART CVREF/DAC1
10-bit
PDIP/SSOP/
Pin Buffer
Pin Name Description
SOIC
Type Type
QFN
RA0/AN0/CVREF/VREF-/C1IN+/INT0/PGD 19 16
RA0 I/O TTL Digital I/O
AN0 I Analog ADC channel 0
CVREF/DAC1OUT O Analog DAC reference voltage output
VREF- I Analog ADC and DAC reference voltage (low) input
C1IN+ I Analog Comparator C1 noninverting input
INT0 I ST External interrupt 0
PGD I/O ST ICSP™ programming data pin
RA1/AN1/C12IN0-/VREF+/INT1/PGC 18 15
RA1 I/O TTL Digital I/O
AN1 I Analog ADC channel 1
C12IN0- 1 Analog Comparator C1 and C2 inverting input
VREF+ I Analog ADC and DAC reference voltage (high) input
INT1 I ST External interrupt 1
PGC I/O ST ICSP programming clock pin
RA2/AN2/C1OUT/T0CKI/INT2/SRQ 17 14
RA2 I/O ST Digital I/O
AN2 I Analog ADC channel 2
C1OUT — CMOS Comparator C1 output
T0CKI I ST Timer0 external clock input
INT2 I ST External interrupt 2
SRQ O CMOS SR latch output
RA3/MCLR/VPP 4 1
RA3 I ST Digital input
MCLR I ST Active-low Master Clear with internal pull-up
VPP P — High voltage programming input
RA4/AN3/OSC2/CLKOUT 3 20
RA4 I/O TTL Digital I/O
AN3 I Analog ADC channel 3
OSC2 O XTAL Oscillator crystal output. Connect to crystal or resonator
in Crystal Oscillator mode
CLKOUT O CMOS In RC mode, OSC2 pin outputs CLKOUT which
has 1/4 the frequency of OSC1 and denotes
the instruction cycle rate
RA5/OSC1/CLKIN/T13CKI 2 19
RA5 I/O TTL Digital I/O
OSC1 I XTAL Oscillator crystal input or external clock input
ST buffer when configured in RC mode; analog other
wise
CLKIN I CMOS External clock source input. Always associated with the
pin function OSC1 (See related OSC1/CLKIN, OSC2,
CLKOUT pins
T13CKI I ST Timer0 and Timer3 external clock input
RB4/AN10/SDI/SDA 13 10
RB4 I/O TTL Digital I/O
AN10 I Analog ADC channel 10
SDI I ST SPI data in
SDA I/O ST I2C data I/O
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output
ST = Schmitt Trigger input I = Input
O = Output P = Power
XTAL= Crystal Oscillator
PDIP/SSOP/
Pin Buffer
Pin Name Description
SOIC
Type Type
QFN
RB5/AN11/RX/DT 12 9
RB5 I/O TLL Digital I/O
AN11 I Analog ADC channel 11
RX I ST EUSART asynchronous receive
DT I/O ST EUSART synchronous data (see related RX/TX)
RB6/SCK/SCL 11 8
RB6 I/O TLL Digital I/O
SCK I/O ST Synchronous serial clock input/output for SPI mode
SCL I/O ST Synchronous serial clock input/output for I2C mode
RB7/TX/CK 10 7
RB7 I/O TLL Digital I/O
TX O CMOS EUSART asynchronous transmit
CK I/O ST EUSART synchronous clock (see related RX/DT)
RC0/AN4/C2IN+ 16 13
RC0 I/O ST Digital I/O
AN4 I Analog ADC channel 4
C2IN+ I Analog Comparator C2 noninverting input
RC1/AN5/C12IN- 15 12
RC1 I/O ST Digital I/O
AN5 I Analog ADC channel 5
C12IN- I Analog Comparator C1 and C2 inverting input
RC2/AN6/C12IN2-/P1D 14 11
RC2 I/O ST Digital I/O
AN6 I Analog ADC channel 6
C12IN2- I Analog Comparator C1 and C2 inverting input
P1D O CMOS Enhanced CCP1 PWM output
RC3/AN7/C12IN3-/P1C/PGM 7 4
RC3 I/O ST Digital I/O
AN7 I Analog ADC channel 7
C12IN3- I Analog Comparator C1 and C2 inverting input
P1C O CMOS Enhanced CCP1 PWM output
PGM I/O ST Low-Voltage ICSP Programming enable pin
RC4/C2OUT/P1B/SRNQ 6 3
RC4 I/O ST Digital I/O
C2OUT O CMOS Comparator C2 output
P1B O CMOS Enhanced CCP1 PWM output
SRNQ O CMOS SR latch inverted output
RC5/CCP1/P1A 5 2
RC5 I/O ST Digital I/O
CCP1 I/O ST Capture 1 input/Compare 1 output/PWM 1 output
P1A O CMOS Enhanced CCP1 PWM output
RC6/AN8/SS 8 5
RC6 I/O ST Digital I/O
AN8 I Analog ADC channel 8
SS I TTL SPI slave select input
RC7/AN9/SDO 9 6
RC7 I/O ST Digital I/O
AN9 I Analog ADC channel 9
SDO O CMOS SPI data out
VSS 20 17 P — Ground reference for logic and I/O pins
VDD 1 18 P — Positive supply for logic and I/O pins
Legend: TTL = TTL compatible input CMOS = CMOS compatible input or output
ST = Schmitt Trigger input I = Input
O = Output P = Power
XTAL= Crystal Oscillator
Primary
Oscillator, PIC18(L)F1XK22
External
and Timer1/Timer3
OSC1/T13CKI Secondary
Oscillator
Sleep
PCLKEN LP, XT, HS, RC, EC, IDLEN
PRI_SD 4 x PLL 1 Secondary Osc.
OSC2 0x Sleep
0
T1OSCEN FOSC<3:0> Peripherals
PLL_EN
PLLEN Internal Osc. System
MUX
1x
Clock
CPU
IRCF<2:0>
Sleep
16 MHz
8 MHz
Internal 110
Oscillator 4 MHz
Block 101
Postscaler
2 MHz
FOSC<3:0>
MUX
16 MHz 100
Clock
1 MHz
HFINTOSC 011 Control SCS<1:0>
500 kHz
31 kHz 010
LFINTOSC 250 kHz
001
1 31 kHz
000
0
INTSRC
Fail-Safe
Clock
Watchdog
Timer Two-Speed
Start-up
LP Oscillator mode selects the lowest gain setting of the 2: Always verify oscillator performance over
internal inverter-amplifier. LP mode current consumption the VDD and temperature range that is
is the least of the three modes. This mode is best suited expected for the application.
to drive resonators with a low drive level specification, for 3: For oscillator design assistance, reference
example, tuning fork type crystals. the following Microchip Applications Notes:
XT Oscillator mode selects the intermediate gain • AN826, Crystal Oscillator Basics and
setting of the internal inverter-amplifier. XT mode Crystal Selection for rfPIC® and
current consumption is the medium of the three modes. PICmicro® Devices (DS00826)
This mode is best suited to drive resonators with a • AN849, Basic PICmicro® Oscillator
medium drive level specification. Design (DS00849)
HS Oscillator mode selects the highest gain setting of the • AN943, Practical PICmicro® Oscillator
internal inverter-amplifier. HS mode current consumption Analysis and Design (DS00943)
is the highest of the three modes. This mode is best • AN949, Making Your Oscillator Work
suited for resonators that require a high drive setting. (DS00949)
Figure 2-2 and Figure 2-3 show typical circuits for
quartz crystal and ceramic resonators, respectively.
VDD
PIC® MCU
REXT
OSC1/CLKIN Internal
Clock
CEXT
VSS
FOSC/4 or OSC2/CLKOUT(1)
I/O(2)
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
-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
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.
CONFIG1H IESO FCMEN PCLKEN PLL_EN FOSC3 FOSC2 FOSC1 FOSC0 251
INTCON GIE/GIEH PEIE/GIEL TMR0IE INT0IE RABIE TMR0IF INT0IF RABIF 245
OSCCON IDLEN IRCF2 IRCF1 IRCF0 OSTS HFIOFS SCS1 SCS0 246
OSCCON2 — — — — — PRI_SD HFIOFL LFIOFS 246
OSCTUNE INTSRC PLLEN TUN5 TUN4 TUN3 TUN2 TUN1 TUN0 248
IPR2 OSCFIP C1IP C2IP EEIP BCLIP — TMR3IP — 248
PIE2 OSCFIE C1IE C2IE EEIE BCLIE — TMR3IE — 248
PIR2 OSCFIF C1IF C2IF EEIF BCLIF — TMR3IF — 248
T1CON RD16 T1RUN T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON 246
Legend: x = unknown, u = unchanged, – = unimplemented locations read as ‘0’. Shaded cells are not used by oscillators.
Note 1: Other (non Power-up) Resets include MCLR Reset and Watchdog Timer Reset during normal operation.
Additional detailed information on the operation of the PIC18 devices have two interrupt vectors and one
Flash program memory is provided in Section 4.0 Reset vector. The Reset vector address is at 0000h
“Flash Program Memory”. Data EEPROM is and the interrupt vector addresses are at 0008h and
discussed separately in Section 5.0 “Data EEPROM 0018h.
Memory”. The program memory map for PIC18(L)F1XK22
devices is shown in Figure 3-1. Memory block details
are shown in Figure 3-2.
FIGURE 3-1: PROGRAM MEMORY MAP AND STACK FOR PIC18(L)F1XK22 DEVICES
PC<20:0>
CALL,RCALL,RETURN 21
RETFIE,RETLW
Stack Level 1
Stack Level 31
PIC18(L)F14K22
1FFFFFh
200000h
11111
11110
Top-of-Stack Registers 11101 Stack Pointer
Legend:
R = Readable bit W = Writable bit U = Unimplemented C = Clearable only bit
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
Q1
Q2 Internal
Q3 Phase
Clock
Q4
PC PC PC + 2 PC + 4
OSC2/CLKOUT
(RC mode)
Execute INST (PC – 2)
Fetch INST (PC) Execute INST (PC)
Fetch INST (PC + 2) Execute INST (PC + 2)
Fetch INST (PC + 4)
All instructions are single cycle, except for any program branches. These take two cycles since the fetch instruction
is “flushed” from the pipeline while the new instruction is being fetched and then executed.
3.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 (MSb); the other
PC. Example 3-4 shows how this works.
12 bits are literal data, usually a data memory address.
The use of ‘1111’ in the 4 MSbs of an instruction Note: See Section 3.6 “PIC18 Instruction
specifies a special form of NOP. If the instruction is Execution and the Extended Instruc-
executed in proper sequence – immediately after the tion Set” for information on two-word
first word – the data in the second word is accessed instructions in the extended instruction set.
When ‘a’ = 0:
BSR<3:0> Data Memory Map
The BSR is ignored and the
00h 000h Access Bank is used.
= 0000 Access RAM 05Fh
Bank 0 The first 96 bytes are
GPR 060h
FFh 0FFh general purpose RAM
00h 100h (from Bank 0).
= 0001
Bank 1 The second 160 bytes are
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4
FFh 4FFh
= 0101 00h 500h
Bank 5
FFh 5FFh
= 0110 00h 600h
Bank 6
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 Access RAM Low
5Fh
Unused
FFh 7FFh Access RAM High 60h
Read 00h 800h (SFRs)
= 1000 00h
Bank 8 FFh
FFh 8FFh
= 1001 00h 900h
Bank 9
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
Unused
= 1111 F53h
Bank 15 SFR(1) F5Fh
F60h
FFh SFR FFFh
Note 1: SFRs occupying F53h to F5Fh address space are not in the virtual bank.
When ‘a’ = 0:
BSR<3:0> Data Memory Map
The BSR is ignored and the
00h 000h Access Bank is used.
= 0000 Access RAM 05Fh
Bank 0 The first 96 bytes are
GPR 060h
FFh 0FFh general purpose RAM
00h 100h (from Bank 0).
= 0001
Bank 1 GPR The second 160 bytes are
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4
FFh 4FFh
= 0101 00h 500h
Bank 5
FFh 5FFh
= 0110 00h 600h
Bank 6
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
Unused
FFh 8FFh
Read 00h
= 1001 00h 900h
Bank 9
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
Unused
= 1111 F53h
Bank 15 SFR(1) F5Fh
F60h
FFh SFR FFFh
Note 1: SFRs occupying F53h to F5Fh address space are not in the virtual bank.
Bank 3
through
Bank 13
FFh
E00h 00h
Bank 14
FFh
F00h 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.
SSPCON1 WCOL SSPOV SSPEN CKP SSPM3 SSPM2 SSPM1 SSPM0 0000 0000 246,
128, 138
SSPCON2 GCEN ACKSTAT ACKDT ACKEN RCEN PEN RSEN SEN 0000 0000 246, 139
ADRESH A/D Result Register, High Byte xxxx xxxx 247, 197
ADRESL A/D Result Register, Low Byte xxxx xxxx 247, 197
ADCON0 — — CHS3 CHS2 CHS1 CHS0 GO/DONE ADON --00 0000 247, 203
VREFCON1 D1EN D1LPS DAC1OE --- D1PSS<1:0> — D1NSS 000- 00-0 247, 235
T3CON RD16 — T3CKPS1 T3CKPS0 T3CCP1 T3SYNC TMR3CS TMR3ON 0-00 0000 247, 102
Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition
Note 1: The SBOREN bit is only available when the BOREN<1:0> Configuration bits = 01; otherwise it is disabled and reads as ‘0’. See
Section 22.4 “Brown-out Reset (BOR)”.
2: The RA3 bit is only available when Master Clear Reset is disabled (MCLRE Configuration bit = 0). Otherwise, RA3 reads as ‘0’. This bit is
read-only.
3: Unimplemented, read as ‘1’.
SPBRGH EUSART Baud Rate Generator Register, High Byte 0000 0000 247, 182
SPBRG EUSART Baud Rate Generator Register, Low Byte 0000 0000 247, 182
RCREG EUSART Receive Register 0000 0000 247, 175
TXREG EUSART Transmit Register 0000 0000 247, 172
TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 247, 179
RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 247, 180
247, 45,
EEADR EEADR7 EEADR6 EEADR5 EEADR4 EEADR3 EEADR2 EEADR1 EEADR0 0000 0000
54
247, 45,
EEDATA EEPROM Data Register 0000 0000
54
247, 45,
EECON2 EEPROM Control Register 2 (not a physical register) 0000 0000
54
247, 45,
EECON1 EEPGD CFGS — FREE WRERR WREN WR RD xx-0 x000
54
IPR2 OSCFIP C1IP C2IP EEIP BCLIP — TMR3IP — 1111 1-1- 248, 70
PIR2 OSCFIF C1IF C2IF EEIF BCLIF — TMR3IF — 0000 0-0- 248, 66
PIE2 OSCFIE C1IE C2IE EEIE BCLIE — TMR3IE — 0000 0-0- 248, 68
IPR1 — ADIP RCIP TXIP SSPIP CCP1IP TMR2IP TMR1IP -111 1111 248, 69
PIR1 — ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF -000 0000 248, 65
PIE1 — ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE -000 0000 248, 67
OSCTUNE INTSRC PLLEN TUN5 TUN4 TUN3 TUN2 TUN1 TUN0 0000 0000 248, 19
TRISC TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 1111 1111 248, 84
TRISB TRISB7 TRISB6 TRISB5 TRISB4 — — — — 1111 ---- 248, 80
TRISA — — TRISA5 TRISA4 —(3) TRISA2 TRISA1 TRISA0 --11 1111 248, 75
LATC LATC7 LATC6 LATC5 LATC4 LATC3 LATC2 LATC1 LATC0 xxxx xxxx 248, 85
LATB LATB7 LATB6 LATB5 LATB4 — — — — xxxx ---- 248, 80
LATA — — LATA5 LATA4 — LATA2 LATA1 LATA0 --xx -xxx 248, 76
PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx 248, 84
PORTB RB7 RB6 RB5 RB4 — — — — xxxx ---- 248, 80
PORTA — — RA5 RA4 RA3(2) RA2 RA1 RA0 --xx xxxx 248, 75
ANSELH — — — — ANS11 ANS10 ANS9 ANS8 ---- 1111 248, 89
ANSEL ANS7 ANS6 ANS5 ANS4 ANS3 ANS2 ANS1 ANS0 1111 1111 248, 88
IOCB IOCB7 IOCB6 IOCB5 IOCB4 — — — — 0000 ---- 248, 81
IOCA — — IOCA5 IOCA4 IOCA3 IOCA2 IOCA1 IOCA0 --00 0000 248, 76
WPUB WPUB7 WPUB6 WPUB5 WPUB4 — — — — 1111 ---- 248, 81
WPUA — — WPUA5 WPUA4 WPUA3 WPUA2 WPUA1 WPUA0 --11 1111 245, 76
SLRCON — — — — — SLRC SLRB SLRA ---- -111 248, 90
SSPMSK MSK7 MSK6 MSK5 MSK4 MSK3 MSK2 MSK1 MSK0 1111 1111 248, 146
CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1R C1CH1 C1CH0 0000 0000 248, 216
CM2CON1 MC1OUT MC2OUT C1RSEL C2RSEL C1HYS C2HYS C1SYNC C2SYNC 0000 0000 248, 220
CM2CON0 C2ON C2OUT C2OE C2POL C2SP C2R C2CH1 C2CH0 0000 0000 248, 217
SRCON1 SRSPE SRSCKE SRSC2E SRSC1E SRRPE SRRCKE SRRC2E SRRC1E 0000 0000 248, 230
SRCON0 SRLEN SRCLK2 SRCLK1 SRCLK0 SRQEN SRNQEN SRPS SRPR 0000 0000 248, 229
Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition
Note 1: The SBOREN bit is only available when the BOREN<1:0> Configuration bits = 01; otherwise it is disabled and reads as ‘0’. See
Section 22.4 “Brown-out Reset (BOR)”.
2: The RA3 bit is only available when Master Clear Reset is disabled (MCLRE Configuration bit = 0). Otherwise, RA3 reads as ‘0’. This bit is
read-only.
3: Unimplemented, read as ‘1’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: 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 Bank 0
BSR
When ‘a’ = 1 (all values of f): 000h 00000000
FIGURE 3-10: 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
determine where the write block will eventually be written. The process for writing the holding registers
to the program memory array is discussed in Section 4.5 “Writing to Flash Program Memory”.
4.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.
4.2.1 EECON1 AND EECON2 REGISTERS
Note: During normal operation, the WRERR is
The EECON1 register (Register 4-1) is the control read as ‘1’. This can indicate that a write
register for memory accesses. The EECON2 register is operation was prematurely terminated by
not a physical register; it is used exclusively in the a Reset, or a write operation was
memory write and erase sequences. Reading attempted improperly.
EECON2 will read all ‘0’s.
The EEPGD control bit determines if the access will be The WR control bit initiates write operations. The WR
a program or data EEPROM memory access. When bit cannot be cleared, only set, by firmware. Then WR
EEPGD is clear, any subsequent operations will bit is cleared by hardware at the completion of the write
operate on the data EEPROM memory. When EEPGD operation.
is set, any subsequent operations will operate on the
Note: The EEIF interrupt flag bit of the PIR2
program memory.
register is set when the write is complete.
The CFGS control bit determines if the access will be The EEIF flag stays set until cleared by
to the Configuration/Calibration registers or to program firmware.
memory/data EEPROM memory. When CFGS is set,
subsequent operations will operate on Configuration
registers regardless of EEPGD (see Section 23.0
“Special Features of the CPU”). When CFGS is clear,
memory selection access is determined by EEPGD.
Legend:
R = Readable bit W = Writable bit
S = Bit can be set by software, but not cleared U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the
error condition.
TABLE 4-2: TABLE POINTER OPERATIONS WITH TBLRD AND TBLWT INSTRUCTIONS
Example Operation on Table Pointer
TBLRD*
TBLPTR is not modified
TBLWT*
TBLRD*+
TBLPTR is incremented after the read/write
TBLWT*+
TBLRD*-
TBLPTR is decremented after the read/write
TBLWT*-
TBLRD+*
TBLPTR is incremented before the read/write
TBLWT+*
Program Memory
TABLAT
Write Register
8 8 8 8
Program Memory
The EEADR register is used to address the data The WR control bit initiates write operations. The bit
EEPROM for read and write operations. The 8-bit can be set but not cleared by software. It is cleared only
range of the register can address a memory range of by hardware at the completion of the write operation.
256 bytes (00h to FFh).
Note: The EEIF interrupt flag bit of the PIR2
register is set when the write is complete.
It must be cleared by software.
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.
6.2 Operation
Example 6-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 6-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
Idle or Sleep modes
TMR0IF
TMR0IE
TMR0IP
(1)
RABIF
RABIE
RABIP
INT0IF
INT0IE
Interrupt to CPU
INT1IF Vector to Location
INT1IE 0008h
SSPIF INT1IP
SSPIE INT2IF
SSPIP INT2IE
INT2IP
ADIF GIEH/GIE
ADIE
ADIP IPEN
RCIF IPEN
RCIE GIEL/PEIE
RCIP
IPEN
Additional Peripheral Interrupts
High Priority Interrupt Generation
SSPIF
SSPIE
SSPIP
Interrupt to CPU
TMR0IF Vector to Location
TMR0IE 0018h
ADIF TMR0IP
ADIE (1)
ADIP RABIF
RABIE
RCIF RABIP GIEH/GIE
RCIE GIEL/PEIE
RCIP
INT1IF
INT1IE
INT1IP
Additional Peripheral Interrupts
INT2IF
INT2IE
INT2IP
Note 1: The RABIF interrupt also requires the individual pin IOCA and IOCB enable.
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 RABIF bit. Reading PORTA and PORTB will end the mismatch condition and allow the bit to
be cleared.
2: RA and RB port change interrupts also require the individual pin IOCA and IOCB enable.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PSPIF bit is unimplemented on 28-pin devices and will read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
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
RD TRIS
Q D
ENEN
RD Port
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 RA3 bit is only available when Master Clear Reset is disabled (MCLRE Configuration bit = 0).
Otherwise, RA3 reads as ‘0’. This bit is read-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
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
bit 7-4 LATB<7:4>: RB<7:4> Port I/O Output Latch Register bits
bit 3-0 Unimplemented: Read as ‘0’
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
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
bit 7-0 LATC<7:0>: RB<7:0> Port I/O Output Latch Register bits
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The slew rate of RA4 defaults to standard rate when the pin is used as CLKOUT.
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. TMR0 Prescaler is set to maximum (1:256),
but on Reset is not assigned to the timer.
FOSC/4 0
1
Sync with Set
Internal TMR0
1 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. TMR0 Prescaler is set to maximum (1:256), but on Reset
is not assigned to the timer.
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
OSC1/T13CKI 1
Prescaler Synchronize
FOSC/4 0
1, 2, 4, 8 Detect
Internal
Clock 0
OSC2 2
Sleep Input
TMR1CS Timer1
INTOSC On/Off
Without CLKOUT
T1OSCEN(1)
T1CKPS<1:0>
T1SYNC
TMR1ON
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
8
Read TMR1L
Write TMR1L
8
8
TMR1H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
4 1:1 to 1:16
T2OUTPS<3:0> Set TMR2IF
Postscaler
2
T2CKPS<1:0> TMR2 Output
(to PWM or MSSP)
TMR2/PR2
Reset Match
1:1, 1:4, 1:16
FOSC/4 TMR2 Comparator PR2
Prescaler
8 8
8
Internal Data Bus
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T3CKPS<1:0>
T3SYNC
TMR3ON
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Read TMR1L
Write TMR1L
8
8
TMR3H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
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
TMR3H TMR3L
Set CCP1IF
T3CCP1 TMR3
CCP1 pin Enable
Prescaler and CCPR1H CCPR1L
1, 4, 16 Edge Detect
TMR1
T3CCP1 Enable
4 TMR1H TMR1L
CCP1CON<3:0>
4
Q1:Q4
0 TMR1H TMR1L
Compare Output S Q
Comparator
Match Logic
R
TRIS
4 Output Enable
CCPR1H CCPR1L
CCP1CON<3:0>
FIGURE 13-3: EXAMPLE SIMPLIFIED BLOCK DIAGRAM OF THE ENHANCED PWM MODE
DC1B<1:0> P1M<1:0> CCP1M<3:0>
Duty Cycle Registers
2 4
CCPR1L
CCP1/P1A CCP1/P1A
TRIS
CCPR1H (Slave)
P1B P1B
Output TRIS
Comparator R Q
Controller
P1C P1C
TMR2 (1)
S TRIS
P1D P1D
Comparator
Clear Timer2, TRIS
toggle PWM pin and
latch duty cycle
PR2 PWM1CON
Note 1: The 8-bit timer TMR2 register is concatenated with the 2-bit internal Q clock, or 2 bits of the prescaler to create the 10-bit
time base.
TABLE 13-2: EXAMPLE PIN ASSIGNMENTS FOR VARIOUS PWM ENHANCED MODES
ECCP Mode P1M<1:0> CCP1/P1A P1B P1C P1D
(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: Outputs are enabled by pulse steering in Single mode. See Register 13-4.
P1A Active
P1D Modulated
P1A Inactive
P1D Inactive
Relationships:
• Period = 4 * TOSC * (PR2 + 1) * (TMR2 Prescale Value)
• Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 Prescale Value)
• Delay = 4 * TOSC * (PWM1CON<6:0>)
Note 1: Dead-band delay is programmed using the PWM1CON register (Section 13.4.6 “Programmable Dead-Band Delay
Mode”).
Pulse PR2+1
P1M<1:0> Signal 0
Width
Period
P1A Modulated
Delay(1) Delay(1)
10 (Half-Bridge) P1B Modulated
P1A Active
P1D Modulated
P1A Inactive
P1D Inactive
Relationships:
• Period = 4 * TOSC * (PR2 + 1) * (TMR2 Prescale Value)
• Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 Prescale Value)
• Delay = 4 * TOSC * (PWM1CON<6:0>)
Note 1: Dead-band delay is programmed using the PWM1CON register (Section 13.4.6 “Programmable Dead-Band Delay
Mode”).
FET
Driver +
P1A
-
Load
FET
Driver
+
P1B
-
V+
FET FET
Driver Driver
P1A
Load
FET FET
Driver Driver
P1B
FET QA QC FET
Driver Driver
P1A
Load
P1B
FET FET
Driver Driver
P1C
QB QD
V-
P1D
P1B(2)
P1C(2)
P1D(2)
(1) (1)
Reverse Mode
Period
Pulse Width
P1A(2)
P1B(2)
P1C(2)
P1D(2)
(1) (1)
Note 1: At this time, the TMR2 register is equal to the PR2 register.
2: Output signal is shown as active-high.
P1A (Active-High)
P1B (Active-High)
Pulse Width
P1C (Active-High)
(2)
P1D (Active-High)
Pulse Width
Note 1: The direction bit P1M1 of the CCP1CON register is written any time during the PWM cycle.
2: When changing directions, the P1A and P1C signals switch before the end of the current PWM cycle. The
modulated P1B and P1D signals are inactive at this time. The length of this time is (1/FOSC) TMR2 prescale
value.
P1A
P1B
PW
P1C
P1D PW
TON
External Switch C
TOFF
External Switch D
13.4.3 START-UP CONSIDERATIONS The P1A, P1B, P1C and P1D output latches may not be
in the proper states when the PWM module is
When any PWM mode is used, the application
initialized. Enabling the PWM pin output drivers at the
hardware must use the proper external pull-up and/or
same time as the Enhanced PWM modes may cause
pull-down resistors on the PWM output pins.
damage to the application circuit. The Enhanced PWM
Note: When the microcontroller is released from modes must be enabled in the proper Output mode and
Reset, all of the I/O pins are in the complete a full PWM cycle before enabling the PWM
high-impedance state. The external pin output drivers. The completion of a full PWM cycle
circuits must keep the power switch is indicated by the TMR2IF bit of the PIR1 register
devices in the Off state until the being set as the second PWM period begins.
microcontroller drives the I/O pins with the
proper signal levels or activates the PWM
output(s).
The CCP1M<1:0> bits of the CCP1CON register allow
the user to choose whether the PWM output signals are
active-high or active-low for each pair of PWM output pins
(P1A/P1C and P1B/P1D). The PWM output polarities
must be selected before the PWM pin output drivers are
enabled. Changing the polarity configuration while the
PWM pin output drivers are enable is not recommended
since it may result in damage to the application circuits.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
PWM Period
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
ECCPASE
Cleared by
Start of Shutdown Shutdown Firmware PWM
PWM Period Event Occurs Event Clears Resumes
PWM Period
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
FET
Driver +
P1A V
-
Load
FET
Driver
+
P1B V
-
V-
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PWM Steering mode is available only when the CCP1CON register bits CCP1M<3:2> = 11 and
P1M<1:0> = 00.
PORT Data
0
TRIS
STRB
PORT Data 0
TRIS
STRC
P1C pin
CCP1M1 1
PORT Data 0
TRIS
STRD
PORT Data 0
TRIS
PWM Period
PWM
STRn
P1n = PWM
PWM
STRn
P1n = PWM
TABLE 13-3: REGISTERS ASSOCIATED WITH ECCP1 MODULE AND TIMER1 TO TIMER3
Reset
Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Values
on page
CCPR1H Capture/Compare/PWM Register 1, High Byte 247
CCPR1L Capture/Compare/PWM Register 1, Low Byte 247
CCP1CON P1M1 P1M0 DC1B1 DC1B0 CCP1M3 CCP1M2 CCP1M1 CCP1M0 247
ECCP1AS ECCPASE ECCPAS2 ECCPAS1 ECCPAS0 PSSAC1 PSSAC0 PSSBD1 PSSBD0 247
INTCON GIE/GIEH PEIE/GIEL TMR0IE INT0IE RABIE TMR0IF INT0IF RABIF 245
IPR1 — ADIP RCIP TXIP SSPIP CCP1IP TMR2IP TMR1IP 248
IPR2 OSCFIP C1IP C2IP EEIP BCLIP — TMR3IP — 248
PIE1 — ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 248
PIE2 OSCFIE C1IE C2IE EEIE BCLIE — TMR3IE — 248
PIR1 — ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 248
PIR2 OSCFIF C1IF C2IF EEIF BCLIF — TMR3IF — 248
PR2 Timer2 Period Register 246
PWM1CON PRSEN PDC6 PDC5 PDC4 PDC3 PDC2 PDC1 PDC0 247
RCON IPEN SBOREN — RI TO PD POR BOR 246
TMR1H Timer1 Register, High Byte 246
TMR1L Timer1 Register, Low Byte 246
TMR2 Timer2 Register 246
TMR3H Timer3 Register, High Byte 247
TMR3L Timer3 Register, Low Byte 247
TRISC TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 248
T1CON RD16 T1RUN T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON 246
T2CON — T2OUTPS3 T2OUTPS2 T2OUTPS1 T2OUTPS0 TMR2ON T2CKPS1 T2CKPS0 246
T3CON RD16 — T3CKPS1 T3CKPS0 T3CCP1 T3SYNC TMR3CS TMR3ON 247
Legend: — = unimplemented, read as ‘0’. Shaded cells are not used during ECCP operation.
SDI/SDA
SSPSR Reg
SDO bit 0 Shift
Clock
SS SS Control
Enable
Edge
Select
2
Clock Select
SSPM<3:0>
SCK/SCL
4 (TMR22Output)
Edge
Select Prescaler TOSC
4, 16, 64
TRIS bit
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Polarity of clock state is set by the CKP bit of the SSPCON1 register.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: In Master mode, the overflow bit is not set since each new reception (and transmission) is initiated by
writing to the SSPBUF register.
2: When enabled, these pins must be properly configured as input or output.
3: Bit combinations not specifically listed here are either reserved or implemented in I2C mode only.
Slave Select
General I/O SS
Processor 1 (optional) Processor 2
Write to
SSPBUF
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
4 Clock
SCK Modes
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Input
Sample
(SMP = 1)
SSPIF
SSPSR to
SSPBUF
SS
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI bit 0
(SMP = 0) bit 7 bit 7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
SSPSR to
SSPBUF
SS
Optional
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI
(SMP = 0) bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
SSPSR to
SSPBUF
SS
Not Optional
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Write to
SSPBUF
SDI
(SMP = 0) bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
SSPSR to
SSPBUF
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For bits ACKEN, RCEN, PEN, RSEN, SEN: If the I2C module is not in the Idle mode, these bits may not
be set (no spooling) and the SSPBUF may not be written (or writes to the SSPBUF are disabled).
2: Value that will be transmitted when the user initiates an Acknowledge sequence at the end of a receive.
DS40001365F-page 142
Receiving Address R/W = 0 Receiving Data ACK Receiving Data ACK
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
PIC18(L)F1XK22
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF
Bus master
(PIR1<3>) terminates
transfer
BF (SSPSTAT<0>)
Cleared by software
SSPBUF is read
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
SSPIF (PIR1<3>)
Bus master
terminates software
BF (SSPSTAT<0>)
Cleared by software Cleared by software
From SSPIF ISR From SSPIF ISR
SSPBUF is written by software SSPBUF is written by software
SSPBUF is read by software
CKP
DS40001365F-page 143
PIC18(L)F1XK22
FIGURE 14-10:
DS40001365F-page 144
taken place taken place
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
Bus master
PIC18(L)F1XK22
terminates
SSPIF transfer
(PIR1<3>)
Cleared by software Cleared by software Cleared by software
Cleared by software
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S Sr P
SSPIF
BF
SSPBUF is written with Dummy read of SSPBUF Dummy read of SSPBUF Write of SSPBUF
contents of SSPSR Completion of
to clear BF flag to clear BF flag Dummy read of SSPBUF data transmission
UA to clear BF flag clears BF flag
DS40001365F-page 145
PIC18(L)F1XK22
PIC18(L)F1XK22
14.3.3.4 SSP Mask Register This register must be initiated prior to setting
2 SSPM<3:0> bits to select the I2C Slave mode (7-bit or
An SSP Mask (SSPMSK) register is available in I C
10-bit address).
Slave mode as a mask for the value held in the
SSPSR register during an address comparison The SSP Mask register is active during:
operation. A zero (‘0’) bit in the SSPMSK register has • 7-bit Address mode: address compare of A<7:1>.
the effect of making the corresponding bit in the
• 10-bit Address mode: address compare of A<7:0>
SSPSR register a “don’t care”.
only. The SSP mask has no effect during the
This register is reset to all ‘1’s upon any Reset reception of the first (high) byte of the address.
condition and, therefore, has no effect on standard
SSP operation until written with a mask value.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The MSK0 bit is used only in 10-bit Slave mode. In all other modes, this bit has no effect.
REGISTER 14-7: SSPADD: MSSP ADDRESS AND BAUD RATE REGISTER (I2C MODE)
R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
ADD7 ADD6 ADD5 ADD4 ADD3 ADD2 ADD1 ADD0
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Master mode:
bit 7-3 Not used: Unused for Most Significant Address Byte. Bit state of this register is a “don’t care.” Bit
pattern sent by master is fixed by I2C specification and must be equal to ‘11110’. However, those bits
are compared by hardware and are not affected by the value in this register.
bit 2-1 ADD<9:8>: Two Most Significant bits of 10-bit address
bit 0 Not used: Unused in this mode. Bit state is a “don’t care.”
10-Bit Slave mode — Least Significant Address Byte:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
SDA DX DX – 1
SCL
Master device
CKP asserts clock
Master device
deasserts clock
WR
SSPCON1
DS40001365F-page 150
Clock is not held low
because buffer full bit is
clear prior to falling edge Clock is held low until Clock is not held low
of 9th clock CKP is set to ‘1’ because ACK = 1
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
PIC18(L)F1XK22
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF
Bus master
(PIR1<3>) terminates
transfer
BF (SSPSTAT<0>)
Cleared by software
SSPBUF is read
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
CKP
CKP
If BF is cleared written
prior to the falling to ‘1’ in
edge of the 9th clock, software
CKP will not be reset BF is set after falling
to ‘0’ and no clock edge of the 9th clock,
stretching will occur CKP is reset to ‘0’ and
clock stretching occurs
I2C SLAVE MODE TIMING WITH SEN = 1 (RECEPTION, 7-BIT ADDRESS)
SSPIF
Bus master
(PIR1<3>) terminates
Cleared by software Cleared by software Cleared by software transfer
Cleared by software
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
DS40001365F-page 151
PIC18(L)F1XK22
PIC18(L)F1XK22
14.3.5 GENERAL CALL ADDRESS If the general call address matches, the SSPSR is
SUPPORT transferred to the SSPBUF, the BF flag bit is set (eighth
bit) and on the falling edge of the ninth bit (ACK bit), the
The addressing procedure for the I2C bus is such that
SSPIF interrupt flag bit is set.
the first byte after the Start condition usually
determines which device will be the slave addressed by When the interrupt is serviced, the source for the
the master. The exception is the general call address interrupt can be checked by reading the contents of the
which can address all devices. When this address is SSPBUF. The value can be used to determine if the
used, all devices should, in theory, respond with an address was device specific or a general call address.
Acknowledge. In 10-bit mode, the SSPADD is required to be updated
The general call address is one of eight addresses for the second half of the address to match and the UA
reserved for specific purposes by the I2C protocol. It bit of the SSPSTAT register is set. If the general call
consists of all ‘0’s with R/W = 0. address is sampled when the GCEN bit is set, while the
slave is configured in 10-bit Address mode, then the
The general call address is recognized when the
second half of the address is not necessary, the UA bit
GCEN bit of the SSPCON2 is set. Following a Start bit
will not be set and the slave will begin receiving data
detect, eight bits are shifted into the SSPSR and the
after the Acknowledge (Figure 14-15).
address is compared against the SSPADD. It is also
compared to the general call address and fixed in
hardware.
SCL
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
SSPIF
BF (SSPSTAT<0>)
Cleared by software
SSPBUF is read
SSPOV (SSPCON1<6>) ‘0’
GCEN (SSPCON2<7>)
‘1’
Internal SSPM<3:0>
Data Bus SSPADD<6:0>
Read Write
SSPBUF Baud
Rate
Generator
SDA Shift
Clock Arbitrate/WCOL Detect
SDA In Clock
SSPSR
(hold off clock source)
MSb LSb
Receive Enable
Acknowledge
Generate
SCL
SSPM<3:0> SSPADD<7:0>
SDA DX DX – 1
BRG decrements on
Q2 and Q4 cycles
BRG
03h 02h 01h 00h (hold off) 03h 02h
Value
SCL
TBRG
S
Sr = Repeated Start
DS40001365F-page 160
Write SSPCON2<0> SEN = 1 ACKSTAT in
Start condition begins SSPCON2 = 1
From slave, clear ACKSTAT bit SSPCON2<6>
SEN = 0
Transmitting Data or Second Half
Transmit Address to Slave R/W = 0 ACK
of 10-bit Address
SDA A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SCL held low
while CPU
responds to SSPIF
SSPIF
Cleared by software service routine
Cleared by software from SSP interrupt
Cleared by software
BF (SSPSTAT<0>)
PEN
R/W
I 2C MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
begin Start condition ACK from Master Set ACKEN, start Acknowledge sequence
Master configured as a receiver SDA = ACKDT = 0 SDA = ACKDT = 1
SEN = 0 by programming SSPCON2<3> (RCEN = 1)
PEN bit = 1
Write to SSPBUF occurs here, RCEN cleared RCEN = 1, start RCEN cleared
ACK from Slave next receive automatically written here
start XMIT automatically
Transmit Address to Slave R/W = 0 Receiving Data from Slave Receiving Data from Slave
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK
Set P bit
Cleared by software Cleared by software Cleared by software Cleared by software (SSPSTAT<4>)
SDA = 0, SCL = 1 Cleared in
while CPU software and SSPIF
responds to SSPIF
BF
(SSPSTAT<0>) Last bit is shifted into SSPSR and
contents are unloaded into SSPBUF
SSPOV
ACKEN
I 2C MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS)
RCEN
Master configured as a receiver RCEN cleared ACK from Master RCEN cleared
by programming SSPCON2<3> (RCEN = 1) automatically SDA = ACKDT = 0 automatically
DS40001365F-page 161
PIC18(L)F1XK22
PIC18(L)F1XK22
14.3.12 ACKNOWLEDGE SEQUENCE 14.3.13 STOP CONDITION TIMING
TIMING A Stop bit is asserted on the SDA pin at the end of a
An Acknowledge sequence is enabled by setting the receive/transmit by setting the Stop Sequence Enable
Acknowledge Sequence Enable bit, ACKEN bit of the bit, PEN bit of the SSPCON2 register. At the end of a
SSPCON2 register. When this bit is set, the SCL pin is receive/transmit, the SCL line is held low after the
pulled low and the contents of the Acknowledge data bit falling edge of the ninth clock. When the PEN bit is set,
are presented on the SDA pin. If the user wishes to the master will assert the SDA line low. When the SDA
generate an Acknowledge, then the ACKDT bit should 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 SCL pin will be brought high
Rate Generator then counts for one rollover period and one TBRG (Baud Rate Generator rollover count)
(TBRG) and the SCL pin is deasserted (pulled high). later, the SDA pin will be deasserted. When the SDA
When the SCL pin is sampled high (clock arbitration), pin is sampled high while SCL is high, the P bit of the
the Baud Rate Generator counts for TBRG. The SCL pin SSPSTAT register is set. A TBRG later, the PEN bit is
is then pulled low. Following this, the ACKEN bit is cleared and the SSPIF bit is set (Figure 14-24).
automatically cleared, the Baud Rate Generator is
turned off and the MSSP module then goes into Idle 14.3.13.1 WCOL Status Flag
mode (Figure 14-23). If the user writes the SSPBUF when a Stop sequence
is in progress, then the WCOL bit is set and the
14.3.12.1 WCOL Status Flag contents of the buffer are unchanged (the write doesn’t
If the user writes the SSPBUF when an Acknowledge occur).
sequence is in progress, then WCOL is set and the
contents of the buffer are unchanged (the write doesn’t
occur).
SCL 8 9
SSPIF
Cleared in
SSPIF set at software
the end of receive Cleared in
software SSPIF set at the end
of Acknowledge sequence
Note: TBRG = one Baud Rate Generator period.
SDA ACK
P
TBRG TBRG TBRG
SCL brought high after TBRG
SDA asserted low before rising edge of clock
to setup Stop condition
SDA
BCLIF
SDA
SCL
Set SEN, enable Start SEN cleared automatically because of bus collision.
condition if SDA = 1, SCL = 1 SSP module reset into Idle state.
SEN
SDA sampled low before
Start condition. Set BCLIF.
S bit and SSPIF set because
BCLIF SDA = 0, SCL = 1.
SSPIF and BCLIF are
cleared by software
SSPIF
TBRG TBRG
SDA
FIGURE 14-28: BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
SDA = 0, SCL = 1
Set S Set SSPIF
Less than TBRG
TBRG
SCL S
SCL pulled low after BRG
time-out
SEN
Set SEN, enable START
sequence if SDA = 1, SCL = 1
BCLIF ‘0’
SSPIF
SDA = 0, SCL = 1, Interrupts cleared
set SSPIF by software
SDA
SCL
RSEN
BCLIF
Cleared by software
S ‘0’
SSPIF ‘0’
TBRG TBRG
SDA
SCL
S ‘0’
SSPIF
PEN
BCLIF
P ‘0’
SSPIF ‘0’
SDA
PEN
BCLIF
P ‘0’
SSPIF ‘0’
TXEN
TRMT SPEN
Baud Rate Generator FOSC
÷n
TX9
BRG16 n
+1 Multiplier x4 x16 x64
TX9D
SYNC 1 X 0 0 0
SPBRGH SPBRG BRGH X 1 1 0 0
BRG16 X 1 0 1 0
BRG16
+1 n
Multiplier x4 x16 x64
SYNC 1 X 0 0 0
SPBRGH SPBRG BRGH FIFO
X 1 1 0 0 FERR RX9D RCREG Register
BRG16 X 1 0 1 0
8
Data Bus
RCIF Interrupt
RCIE
Write to TXREG
Word 1
BRG Output
(Shift Clock)
RB7/TX/CK
pin Start bit bit 0 bit 1 bit 7/8 Stop bit
Word 1
TXIF bit
(Transmit Buffer 1 TCY
Reg. Empty Flag)
Word 1
TRMT bit
Transmit Shift Reg
(Transmit Shift
Reg. Empty Flag)
Write to TXREG
Word 1 Word 2
BRG Output
(Shift Clock)
RB7/TX/CK
pin Start bit bit 0 bit 1 bit 7/8 Stop bit Start bit bit 0
TXIF bit 1 TCY Word 1 Word 2
(Interrupt Reg. Flag)
1 TCY
TRMT bit Word 1 Word 2
(Transmit Shift Transmit Shift Reg
Reg. Empty Flag) Transmit Shift Reg
• CREN = 1 Immediately after all data bits and the Stop bit have
been received, the character in the RSR is transferred
• SYNC = 0
to the EUSART receive FIFO and the RCIF interrupt
• SPEN = 1 flag bit of the PIR1 register is set. The top character in
All other EUSART control bits are assumed to be in the FIFO is transferred out of the FIFO by reading the
their default state. RCREG register.
Setting the CREN bit of the RCSTA register enables the Note: If the receive FIFO is overrun, no additional
receiver circuitry of the EUSART. Clearing the SYNC bit characters will be received until the overrun
of the TXSTA register configures the EUSART for condition is cleared. See Section 15.1.2.6
asynchronous operation. Setting the SPEN bit of the “Receive Overrun Error” for more
RCSTA register enables the EUSART. The RX/DT I/O information on overrun errors.
pin must be configured as an input by setting the
corresponding TRIS control bit. If the RX/DT pin is 15.1.2.3 Receive Data Polarity
shared with an analog peripheral the analog I/O function
The polarity of the receive data can be controlled with
must be disabled by clearing the corresponding ANSEL
the DTRXP bit of the BAUDCON register. The default
bit.
state of this bit is ‘0’ which selects high true receive idle
Note: When the SPEN bit is set the TX/CK I/O and data bits. Setting the DTRXP bit to ‘1’ will invert the
pin is automatically configured as an receive data resulting in low true idle and data bits. The
output, regardless of the state of the DTRXP bit controls receive data polarity only in
corresponding TRIS bit and whether or Asynchronous mode. In Synchronous mode the
not the EUSART transmitter is enabled. DTRXP bit has a different function.
The PORT latch is disconnected from the
output driver so it is not possible to use the
TX/CK pin as a general purpose output.
Read Rcv
Buffer Reg
RCREG
RCIF
(Interrupt Flag)
OERR bit
CREN
Note: This timing diagram shows three words appearing on the RX input. The RCREG (receive buffer) is read after the third word,
causing the OERR (overrun) bit to be set.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
BAUD FOSC = 48.000 MHz FOSC = 18.432 MHz FOSC = 12.000 MHz FOSC = 11.0592 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 — — — — — — — — — — — —
1200 — — — — — — — — — — — —
2400 — — — — — — — — — — — —
9600 — — — 9600 0.00 119 9615 0.16 77 9600 0.00 71
10417 — — — 10378 -0.37 110 10417 0.00 71 10473 0.53 65
19.2k 19.23k 0.16 155 19.20k 0.00 59 19.23k 0.16 38 19.20k 0.00 35
57.6k 57.69k 0.16 51 57.60k 0.00 19 57.69k 0.16 12 57.60k 0.00 11
115.2k 115.38k 0.16 25 115.2k 0.00 9 — — — 115.2k 0.00 5
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 — — — — — — — — — 300 0.16 207
1200 — — — 1202 0.16 207 1200 0.00 191 1202 0.16 51
2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25
9600 9615 0.16 51 9615 0.16 25 9600 0.00 23 — — —
10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5
19.2k 19231 0.16 25 19.23k 0.16 12 19.2k 0.00 11 — — —
57.6k 55556 -3.55 8 — — — 57.60k 0.00 3 — — —
115.2k — — — — — — 115.2k 0.00 1 — — —
BAUD FOSC = 48.000 MHz FOSC = 18.432 MHz FOSC = 12.000 MHz FOSC = 11.0592 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300.0 0.00 9999 300.0 0.00 3839 300 0.00 2499 300.0 0.00 2303
1200 1200.1 0.00 2499 1200 0.00 959 1200 0.00 624 1200 0.00 575
2400 2400 0.00 1249 2400 0.00 479 2404 0.16 311 2400 0.00 287
9600 9615 0.16 311 9600 0.00 119 9615 0.16 77 9600 0.00 71
10417 10417 0.00 287 10378 -0.37 110 10417 0.00 71 10473 0.53 65
19.2k 19.23k 0.16 155 19.20k 0.00 59 19.23k 0.16 38 19.20k 0.00 35
57.6k 57.69k 0.16 51 57.60k 0.00 19 57.69k 0.16 12 57.60k 0.00 11
115.2k 115.38k 0.16 25 115.2k 0.00 9 — — — 115.2k 0.00 5
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 299.9 -0.02 1666 300.1 0.04 832 300.0 0.00 767 300.5 0.16 207
1200 1199 -0.08 416 1202 0.16 207 1200 0.00 191 1202 0.16 51
2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25
9600 9615 0.16 51 9615 0.16 25 9600 0.00 23 — — —
10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5
19.2k 19.23k 0.16 25 19.23k 0.16 12 19.20k 0.00 11 — — —
57.6k 55556 -3.55 8 — — — 57.60k 0.00 3 — — —
115.2k — — — — — — 115.2k 0.00 1 — — —
BAUD FOSC = 48.000 MHz FOSC = 18.432 MHz FOSC = 12.000 MHz FOSC = 11.0592 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300 0.00 39999 300.0 0.00 15359 300 0.00 9999 300.0 0.00 9215
1200 1200 0.00 9999 1200 0.00 3839 1200 0.00 2499 1200 0.00 2303
2400 2400 0.00 4999 2400 0.00 1919 2400 0.00 1249 2400 0.00 1151
9600 9600 0.00 1249 9600 0.00 479 9615 0.16 311 9600 0.00 287
10417 10417 0.00 1151 10425 0.08 441 10417 0.00 287 10433 0.16 264
19.2k 19.20k 0.00 624 19.20k 0.00 239 19.23k 0.16 155 19.20k 0.00 143
57.6k 57.69k 0.16 207 57.60k 0.00 79 57.69k 0.16 51 57.60k 0.00 47
115.2k 115.38k 0.16 103 115.2k 0.00 39 115.38k 0.16 25 115.2k 0.00 23
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRGH SPBRGH SPBRGH SPBRGH
Actual % Actual % Actual % Actual %
:SPBRG :SPBRG :SPBRG :SPBRG
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300.0 0.00 6666 300.0 0.01 3332 300.0 0.00 3071 300.1 0.04 832
1200 1200 -0.02 1666 1200 0.04 832 1200 0.00 767 1202 0.16 207
2400 2401 0.04 832 2398 0.08 416 2400 0.00 383 2404 0.16 103
9600 9615 0.16 207 9615 0.16 103 9600 0.00 95 9615 0.16 25
10417 10417 0.00 191 10417 0.00 95 10473 0.53 87 10417 0.00 23
19.2k 19.23k 0.16 103 19.23k 0.16 51 19.20k 0.00 47 19.23k 0.16 12
57.6k 57.14k -0.79 34 58.82k 2.12 16 57.60k 0.00 15 — — —
115.2k 117.6k 2.12 16 111.1k -3.55 8 115.2k 0.00 7 — — —
BRG Clock
RCIDL
RCIF bit
(Interrupt)
Read
RCREG
Note 1: The ABD sequence requires the EUSART module to be configured in Asynchronous mode.
RCIF
Cleared due to User Read of RCREG
Note 1: The EUSART remains in Idle while the WUE bit is set.
Note 1: If the wake-up event requires long oscillator warm-up time, the automatic clearing of the WUE bit can occur while the stposc signal is
still active. This sequence should not depend on the presence of Q clocks.
2: The EUSART remains in Idle while the WUE bit is set.
Write to TXREG
Dummy Write
BRG Output
(Shift Clock)
TX/CK pin
(SCKP = 1)
Write to
TXREG Reg Write Word 1 Write Word 2
TXIF bit
(Interrupt Flag)
TRMT bit
‘1’ ‘1’
TXEN bit
Note: Sync Master mode, SPBRG = 0, continuous transmission of two 8-bit words.
TX/CK pin
Write to
TXREG reg
TXIF bit
TRMT bit
TXEN bit
RX/DT
pin bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
TX/CK pin
(SCKP = 0)
TX/CK pin
(SCKP = 1)
Write to
bit SREN
SREN bit
RCIF bit
(Interrupt)
Read
RXREG
Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
NVCFG[1:0] = 00
AVSS
VREF- NVCFG[1:0] = 01
AVDD
PVCFG[1:0] = 00
VREF+ PVCFG[1:0] = 01
FVR PVCFG[1:0] = 10
AN0 0000
AN1 0001
AN2 0010
AN3 0011
AN4 0100
AN5 0101
AN6 0110
AN7 0111
ADC
AN8 1000
GO/DONE 10
AN9 1001
AN10 1010 0 = Left Justify
ADFM
AN11 1011 1 = Right Justify
Unused 1100 ADON 10
Unused 1101
VSS ADRESH ADRESL
DAC 1110
FVR 1111
CHS<3:0>
TABLE 16-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 16-4: A/D CONVERSION TAD CYCLES (ACQT<2:0> = 010, TACQ = 4 TAD)
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 2 TAD
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Automatic
Acquisition Conversion starts Discharge
Time (Holding capacitor is disconnected from analog input)
Set GO bit
(Holding capacitor continues On the following cycle:
acquiring input) ADRESH:ADRESL is loaded, GO bit is cleared,
ADIF bit is set, holding capacitor is connected to analog input.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T ACQ = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient
= T AMP + T C + T COFF
= 5µs + T C + Temperature - 25°C 0.05µs/°C
T C = – C HOLD R IC + R SS + R S ln(1/2047)
= – 13.5pF 1k + 700 + 10k ln(0.0004885)
= 1.20 µs
Therefore:
T ACQ = 5µs + 1.20µs + 50°C- 25°C 0.05µs/°C
= 7.45µs
VDD
Sampling
Switch
VT = 0.6V
Rs ANx RIC 1k SS Rss
Discharge VSS/VREF-
Switch
3.5V
Legend: CPIN = Input Capacitance 3.0V
VT = Threshold Voltage
VDD
2.5V
I LEAKAGE = Leakage current at the pin due to
various junctions 2.0V
RIC = Interconnect Resistance 1.5V
SS = Sampling Switch
CHOLD = Sample/Hold Capacitance .1 1 10 100
Rss (k)
Note 1: See Section 26.0 “Electrical Specifications”.
Full-Scale Range
3FFh
3FEh
3FDh
3FCh
ADC Output Code
Full-Scale
004h Transition
003h
002h
001h
000h Analog Input Voltage
1/2 LSB ideal
C1CH<1:0>
2 To
D Q Data Bus
Q1
C12IN0- 0 EN
RD_CM1CON0
C12IN1- 1
MUX Set C1IF
D Q
C12IN2- 2
Q3*RD_CM1CON0
EN
C12IN3- 3 CL
NReset
C1ON(1)
C1R
C1VIN-
-
C1IN+ 0 C1 C1OUT To PWM Logic
MUX C1VIN+
+
DAC Output 1
0 C1SP C1POL
MUX C1SYNC
FVR 1 C1VREF C1OE
0
C1RSEL
D Q 1 C1OUT
(4)
From TMR1L[0]
SYNCC1OUT
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: Positive going pulse generated on both falling and rising edges of the bit.
To
D Q
Data Bus
Q1
EN
RD_CM2CON0
C2CH<1:0> Set C2IF
2 D Q
Q3*RD_CM2CON0
EN
C12IN0- 0 C2ON(1)
CL
C12IN1- 1 NRESET
MUX C2VIN-
C12IN2- 2 C2 C2OUT To PWM Logic
C2VIN+
C12IN3- 3 C2SP
C2SYNC
C2POL C20E
C2R
C2OUT pin
0
C2IN+ 0
MUX D Q 1
DAC Output 1 (4)
0 From TMR1L[0] SYNCC2OUT
MUX
FVR 1 C2VREF
C2RSEL
Note 1: When C2ON = 0, the C2 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: Positive going pulse generated on both falling and rising edges of the bit.
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
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
OSC1
CPU
Clock
Peripheral
Clock
Sleep
Program
Counter PC PC + 2
OSC1
TOST(1) TPLL(1)
PLL Clock
Output
CPU Clock
Peripheral
Clock
Program PC PC + 2 PC + 4 PC + 6
Counter
Wake Event OSTS bit set
Note1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
Q1 Q2 Q3 Q4 Q1
OSC1
CPU Clock
Peripheral
Clock
Program PC PC + 2
Counter
FIGURE 18-4: TRANSITION TIMING FOR WAKE FROM IDLE TO RUN MODE
Q1 Q2 Q3 Q4
OSC1
TCSD
CPU Clock
Peripheral
Clock
Program PC
Counter
Wake Event
TABLE 18-2: EXIT DELAY ON WAKE-UP BY RESET FROM SLEEP MODE OR ANY IDLE MODE
(BY CLOCK SOURCES)
Clock Source Clock Source Clock Ready Status
Exit Delay
before Wake-up after Wake-up Bit (OSCCON)
LP, XT, HS
Primary Device Clock HSPLL OSTS
TCSD(1)
(PRI_IDLE mode) EC, RC
HFINTOSC(2) IOSF
LP, XT, HS TOST(3)
HSPLL TOST + tPLL(3) OSTS
T1OSC or LFINTOSC(1)
EC, RC TCSD(1)
HFINTOSC(1) TIOBST(4) IOSF
LP, XT, HS TOST(4)
HSPLL TOST + tPLL(3) OSTS
HFINTOSC(2)
EC, RC TCSD(1)
HFINTOSC(1) None IOSF
LP, XT, HS TOST(3)
None HSPLL TOST + tPLL(3) OSTS
(Sleep mode) EC, RC TCSD(1)
HFINTOSC(1) TIOBST(4) IOSF
Note 1: TCSD is a required delay when waking from Sleep and all Idle modes and runs concurrently with any other
required delays (see Section 18.4 “Idle Modes”). On Reset, HFINTOSC defaults to 1 MHz.
2: Includes both the HFINTOSC 16 MHz source and postscaler derived frequencies.
3: TOST is the Oscillator Start-up Timer. tPLL is the PLL Lock-out Timer (parameter F12).
4: Execution continues during the HFINTOSC stabilization period, TIOBST.
INT1
SRSPE S Q SRQ pin(3)
SRCLK
SRSCKE
SYNCC2OUT(4)
SRSC2E
SYNCC1OUT(4) SR
SRSC1E
Latch(1)
SRPR Pulse
Gen(2)
INT1
SRRPE R Q SRNQ pin(3)
SRCLK
SRRCKE SRLEN
SYNCC2OUT(4) SRNQEN
SRRC2E
SYNCC1OUT(4)
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 FVR1S<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, (FVR1BUF2) the reference is buffered
The FVR can be enabled by setting the FVR1EN 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 16.0 “Analog-to-Digital Converter
(ADC) Module”, Section 21.0 “Digital-to-Analog
Converter (DAC) Module” and Section 17.0 “Com-
parator Module”.
FVR_buf2_enable(1)
FVR1BUF2
x1
x2 to ADC module
x4
FVR1S<1:0>
2
FVR1BUF1
x1
x2 to Comparators, DAC
x4
1.024V
+
-
FVR1EN
Fixed
FVR1ST
Voltage
Reference
Note 1: FVR_buf2_enable = ‘1’ when (ADON = ‘1’)AND [(PVCFG<1:0> = ‘10’) OR ( CHS<4:0> = ‘11111’)]
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
EQUATION 21-1: DAC OUTPUT VOLTAGE • Clearing the D1EN bit in the VREFCON1 register.
• Clearing the DAC1R bit in the VREFCON1 register.
VOUT = VSRC+ – VSRC- ------------------------------- + VSRC-
DACR<4:0>
• Configuring the D1PSS bits to the proper negative
5
2 source.
• Configuring the DAC1Rx bits to ‘00000’ in the
VSRC+ = VDD, VREF+ or FVR1 VREFCON2 register.
This allows the comparator to detect a zero-crossing
VSRC- = VSS or VREF- while not consuming additional current through the DAC
module.
Reserved 11
FVR1BUF1 10 VSRC+
VREF+ 01
DAC1R<4:0>
5
VDD 00
R
2
11111
R
D1PSS<1:0>
11110
R
D1EN
D1LPS R
32-to-1 MUX
32
Steps DAC Output
(to Comparators and
ADC Modules)
R
R
00001 CVREF/DAC1OUT
R
00000
DAC1OE
D1NSS
VREF- 1 VSRC-
VSS 0
PIC® MCU
DAC
R
Module
+
Voltage DAC1OUT 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
External Reset
MCLRE
MCLR
( )_IDLE
Sleep
WDT
Time-out
OST/PWRT
OST(2) 1024 Cycles
Chip_Reset
10-bit Ripple Counter R Q
OSC1
32 s
PWRT(2) 65.5 ms
LFINTOSC 11-bit Ripple Counter
Enable PWRT
Enable OST(1)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
HSPLL 66 ms(1) + 1024 TOSC + 2 ms(2) 1024 TOSC + 2 ms(2) 1024 TOSC + 2 ms(2)
HS, XT, LP 66 ms(1) + 1024 TOSC 1024 TOSC 1024 TOSC
EC, ECIO 66 ms(1) — —
RC, RCIO 66 ms(1) — —
(1)
INTIO1, INTIO2 66 ms — —
Note 1: 66 ms (65.5 ms) is the nominal Power-up Timer (PWRT) delay.
2: 2 ms is the nominal time required for the PLL to lock.
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 22-4: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 1
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 22-5: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 2
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 22-7: TIME-OUT SEQUENCE ON POR W/PLL ENABLED (MCLR TIED TO VDD)
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
PLL TIME-OUT
INTERNAL RESET
TABLE 22-3: STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION
FOR RCON REGISTER
Program RCON Register STKPTR Register
Condition
Counter SBOREN RI TO PD POR BOR STKOVF STKUNF
Power-on Reset 0000h 1 1 1 1 0 0 0 0
RESET Instruction 0000h u(2) 0 u u u u u u
(2)
Brown-out Reset 0000h u 1 1 1 u 0 u u
MCLR during Power-Managed 0000h u(2) u 1 u u u u u
Run Modes
MCLR during Power-Managed 0000h u(2) u 1 0 u u u u
Idle Modes and Sleep Mode
WDT Time-out during Full Power 0000h u(2) u 0 u u u u u
or Power-Managed Run Mode
MCLR during Full Power 0000h u(2) u u u u u u u
Execution
Stack Full Reset (STVREN = 1) 0000h u(2) u u u u u 1 u
Stack Underflow Reset 0000h u(2) u u u u u u 1
(STVREN = 1)
Stack Underflow Error (not an 0000h u(2) u u u u u u 1
actual Reset, STVREN = 0)
WDT Time-out during PC + 2 u(2) u 0 0 u u u u
Power-Managed Idle or Sleep
Modes
Interrupt Exit from PC + 2(1) u(2) u u 0 u u u u
Power-Managed Modes
Legend: u = unchanged
Note 1: When the wake-up is due to an interrupt and the GIEH or GIEL bits are set, the PC is loaded with the
interrupt vector (008h or 0018h).
2: Reset state is ‘1’ for POR and unchanged for all other Resets when software BOR is enabled
(BOREN<1:0> Configuration bits = 01 and SBOREN = 1). Otherwise, the Reset state is ‘0’.
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
Note 1: BKBUG is only used for ICD device. Otherwise, this bit is unimplemented and reads as ‘1’.
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Note 1: This bit is read-only in normal execution mode; it can be written only in Program mode.
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Legend:
R = Readable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed C = Clearable only bit
Note 1: These values for DEV<10:3> may be shared with other devices. The specific device is always identified
by using the entire DEV<10:0> bit sequence.
WDTPS<3:0> 4
Sleep
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit has no effect if the Configuration bit, WDTEN, is enabled.
23.3 Program Verification and Figure 23-2 shows the program memory organization
Code Protection for 8, 16 and 32-Kbyte devices and the specific code
protection bit associated with each block. The actual
The overall structure of the code protection on the locations of the bits are summarized in Table 23-3.
PIC18 Flash devices differs significantly from other PIC
microcontroller devices.
The user program memory is divided into five blocks.
One of these is a boot block of 0.5K or 2K bytes,
depending on the device. The remainder of the
memory is divided into individual blocks on binary
boundaries.
Each of the five blocks has three code protection bits
associated with them. They are:
• Code-Protect bit (CPn)
• Write-Protect bit (WRTn)
• External Block Table Read bit (EBTRn)
Device
Address (from/to) 14K22 13K22
BBSIZ = 1 BBSIZ = 0 BBSIZ = 1 BBSIZ = 0
0000h Boot Block, 4 KB Boot Block, 2 KB Boot Block, 2 KB Boot Block, 1 KB CPB,
03FFh CPB, WRTB, EBTRB CPB, WRTB, EBTRB CPB, WRTB, EBTRB WRTB, EBTRB
0400h Block 0
07FFh 1.512 KB
0800h Block 0 Block 0 CP0, WRT0, EBTR0
0BFFh 6 KB 2 KB
0C00h CP0, WRT0, EBTR0 CP0, WRT0, EBTR0
0FFFh
1000h Block 0 Block 1 Block 1
1FFFh 4 KB 4 KB 4 KB
CP0, WRT0, EBTR0 CP1, WRT1, EBTR1 CP1, WRT1, EBTR1
2000h Block 1 Block 1 Reads all ‘0’s Reads all ‘0’s
3FFFh 8 KB 8 KB
CP1, WRT1, EBTR1 CP1, WRT1, EBTR1
4000h Reads all ‘0’s Reads all ‘0’s
4FFEh
5000h
5FFEh
6000h
6FFEh
7000h
7FFEh
8000h
8FFEh
9000h
9FFEh
A000h
AFFEh
B000h
BFFEh
C000h
CFFEh
D000h
DFFEh
E000h
EFFEh
F000h
FFFEh
H000h
HFFEh
Note: Refer to the test section for requirements on test memory mapping.
23.3.1 PROGRAM MEMORY instruction that executes from a location outside of that
CODE PROTECTION block is not allowed to read and will result in reading ‘0’s.
Figures 23-3 through 23-5 illustrate table write and table
The program memory may be read to or written from
read protection.
any location using the table read and table write
instructions. The device ID may be read with table Note: Code protection bits may only be written
reads. The Configuration registers may be read and to a ‘0’ from a ‘1’ state. It is not possible to
written with the table read and table write instructions. write a ‘1’ to a bit in the ‘0’ state. Code
In normal execution mode, the CPn bits have no direct protection bits are only set to ‘1’ by a full
effect. CPn bits inhibit external reads and writes. A block chip erase or block erase function. The full
of user memory may be protected from table writes if the chip erase and block erase functions can
WRTn Configuration bit is ‘0’. The EBTRn bits control only be initiated via ICSP or an external
table reads. For a block of user memory with the EBTRn programmer.
bit cleared to ‘0’, a table READ instruction that executes
from within that block is allowed to read. A table read
TBLPTR = 0008FFh
WRT0, EBTR0 = 01
007FFFh
000000h
WRTB, EBTRB = 11
0007FFh
000800h
TBLPTR = 0008FFh
WRT0, EBTR0 = 10
001FFFh
002000h
PC = 003FFEh TBLRD* WRT1, EBTR1 = 11
003FFFh
004000h
WRT2, EBTR2 = 11
005FFFh
006000h
WRT3, EBTR3 = 11
007FFFh
Results: All table reads from external blocks to Blockn are disabled whenever EBTRn = 0.
TABLAT register returns a value of ‘0’.
007FFFh
All bit-oriented instructions have three operands: The Instruction Set Summary, shown in Table 24-2,
lists the standard instructions recognized by the
1. The file register (specified by ‘f’) Microchip Assembler (MPASMTM).
2. The bit in the file register (specified by ‘b’)
Section 24.1.1 “Standard Instruction Set” provides
3. The accessed memory (specified by ‘a’) a description of each instruction.
The bit field designator ‘b’ selects the number of the bit
affected by the operation, while the file register
designator ‘f’ represents the number of the file in which
the bit is located.
Literal operations
15 8 7 0
OPCODE k (literal) MOVLW 7Fh
Control operations
CALL, GOTO and Branch operations
15 8 7 0
OPCODE n<7:0> (literal) GOTO Label
15 12 11 0
1111 n<19:8> (literal)
15 8 7 0
OPCODE S n<7:0> (literal) CALL MYFUNC
15 12 11 0
1111 n<19:8> (literal)
S = Fast bit
15 11 10 0
OPCODE n<10:0> (literal) BRA MYFUNC
15 8 7 0
OPCODE n<7:0> (literal) BC MYFUNC
BYTE-ORIENTED OPERATIONS
ADDWF f, d, a Add WREG and f 1 0010 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, b, 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 k, 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 k 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 2-cycle instruction. this a 2-cycle instruction.
If ‘a’ is ‘0’, the Access Bank is selected. If If ‘a’ is ‘0’, the Access Bank is selected. If
‘a’ is ‘1’, the BSR is used to select the ‘a’ is ‘1’, the BSR is used to select the
GPR bank (default). GPR bank (default).
If ‘a’ is ‘0’ and the extended instruction If ‘a’ is ‘0’ and the extended instruction
set is enabled, this instruction operates in set is enabled, this instruction operates
Indexed Literal Offset Addressing in Indexed Literal Offset Addressing
mode whenever f 95 (5Fh). mode whenever f 95 (5Fh).
See Section 24.2.3 “Byte-Oriented and See Section 24.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed Bit-Oriented Instructions in Indexed
Literal Offset Mode” for details. Literal Offset Mode” for details.
Words: 1 Words: 1
Cycles: 1(2) Cycles: 1(2)
Note: 3 cycles if skip and followed Note: 3 cycles if skip and followed
by a 2-word instruction. by a 2-word instruction.
Q Cycle Activity: Q Cycle Activity:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Decode Read Process No Decode Read Process No
register ‘f’ Data operation register ‘f’ Data operation
If skip: If skip:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
If skip and followed by 2-word instruction: If skip and followed by 2-word instruction:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
No No No No No No No No
operation operation operation operation operation operation operation operation
CPFSGT Compare f with W, skip if f > W CPFSLT Compare f with W, skip if f < W
Syntax: CPFSGT f {,a} Syntax: CPFSLT f {,a}
Operands: 0 f 255 Operands: 0 f 255
a [0,1] a [0,1]
Operation: (f) –W), Operation: (f) –W),
skip if (f) > (W) skip if (f) < (W)
(unsigned comparison) (unsigned comparison)
Status Affected: None Status Affected: None
Encoding: 0110 010a ffff ffff
Encoding: 0110 000a ffff ffff
Description: Compares the contents of data memory
Description: Compares the contents of data memory
location ‘f’ to the contents of the W by
location ‘f’ to the contents of W by
performing an unsigned subtraction.
performing an unsigned subtraction.
If the contents of ‘f’ are greater than the
If the contents of ‘f’ are less than the
contents of WREG, then the fetched
contents of W, then the fetched
instruction is discarded and a NOP is
instruction is discarded and a NOP is
executed instead, making this a
executed instead, making this a
2-cycle instruction.
2-cycle instruction.
If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘1’, the BSR is used to select the
If ‘a’ is ‘1’, the BSR is used to select the
GPR bank (default).
GPR bank (default).
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: Three cycles if skip and
Section 24.2.3 “Byte-Oriented and followed 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)
After Instruction Q1 Q2 Q3 Q4
PC = Address (THERE) Decode Read Process Write to
register ‘f’ Data destination
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 (default). 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 (default).
in Indexed Literal Offset Addressing If ‘a’ is ‘0’ and the extended instruction
mode whenever f 95 (5Fh). See set is enabled, this instruction operates
Section 24.2.3 “Byte-Oriented and in Indexed Literal Offset Addressing
Bit-Oriented Instructions in Indexed mode whenever f 95 (5Fh). See
Literal Offset Mode” for details. Section 24.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed
register f
Literal Offset Mode” for details.
Words: 1 C register f
Cycles: 1
Words: 1
Q Cycle Activity:
Cycles: 1
Q1 Q2 Q3 Q4
Decode Read Process Write to Q Cycle Activity:
register ‘f’ Data destination Q1 Q2 Q3 Q4
Decode Read Process Write to
Example: RLNCF REG, 1, 0 register ‘f’ Data destination
Before Instruction
REG = 1010 1011 Example: RRCF REG, 0, 0
After Instruction Before Instruction
REG = 0101 0111 REG = 1110 0110
C = 0
After Instruction
REG = 1110 0110
W = 0111 0011
C = 0
ADDFSR Add Literal to FSR ADDULNK Add Literal to FSR2 and Return
Syntax: ADDFSR f, k Syntax: ADDULNK k
Operands: 0 k 63 Operands: 0 k 63
f [ 0, 1, 2 ] Operation: FSR2 + k FSR2,
Operation: FSR(f) + k FSR(f) (TOS) PC
Status Affected: None Status Affected: None
Encoding: 1110 1000 ffkk kkkk Encoding: 1110 1000 11kk kkkk
Description: The 6-bit literal ‘k’ is added to the Description: The 6-bit literal ‘k’ is added to the
contents of the FSR specified by ‘f’. contents of FSR2. A RETURN is then
Words: 1 executed by loading the PC with the
Cycles: 1 TOS.
The instruction takes two cycles to
Q Cycle Activity:
execute; a NOP is performed during
Q1 Q2 Q3 Q4 the second cycle.
Decode Read Process Write to This may be thought of as a special
literal ‘k’ Data FSR case of the ADDFSR instruction,
where f = 3 (binary ‘11’); it operates
only on FSR2.
Example: ADDFSR 2, 23h Words: 1
Before Instruction Cycles: 2
FSR2 = 03FFh
After Instruction
Q Cycle Activity:
FSR2 = 0422h
Q1 Q2 Q3 Q4
Decode Read Process Write to
literal ‘k’ Data FSR
No No No No
Operation Operation Operation Operation
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction syntax then becomes: {label} instruction argument(s).
MOVSS Move Indexed to Indexed PUSHL Store Literal at FSR2, Decrement FSR2
Syntax: MOVSS [zs], [zd] Syntax: PUSHL k
Operands: 0 zs 127 Operands: 0k 255
0 zd 127
Operation: k (FSR2),
Operation: ((FSR2) + zs) ((FSR2) + zd) FSR2 – 1 FSR2
Status Affected: None
Status Affected: None
Encoding:
Encoding: 1110 1010 kkkk kkkk
1st word (source) 1110 1011 1zzz zzzzs
2nd word (dest.) 1111 xxxx xzzz zzzzd Description: The 8-bit literal ‘k’ is written to the data
memory address specified by FSR2. FSR2
Description The contents of the source register are
is decremented by 1 after the operation.
moved to the destination register. The
This instruction allows users to push values
addresses of the source and destination
onto a software stack.
registers are determined by adding the
7-bit literal offsets ‘zs’ or ‘zd’, Words: 1
respectively, to the value of FSR2. Both
Cycles: 1
registers can be located anywhere in
the 4096-byte data memory space Q Cycle Activity:
(000h to FFFh). Q1 Q2 Q3 Q4
The MOVSS instruction cannot use the Decode Read ‘k’ Process Write to
PCL, TOSU, TOSH or TOSL as the data destination
destination register.
If the resultant source address points to
an indirect addressing register, the Example: PUSHL 08h
value returned will be 00h. If the
resultant destination address points to Before Instruction
an indirect addressing register, the FSR2H:FSR2L = 01ECh
Memory (01ECh) = 00h
instruction will execute as a NOP.
Words: 2 After Instruction
Cycles: 2 FSR2H:FSR2L = 01EBh
Memory (01ECh) = 08h
Q Cycle Activity:
Q1 Q2 Q3 Q4
Decode Determine Determine Read
source addr source addr source reg
Decode Determine Determine Write
dest addr dest addr to dest reg
SUBFSR Subtract Literal from FSR SUBULNK Subtract Literal from FSR2 and Return
Syntax: SUBFSR f, k Syntax: SUBULNK k
Operands: 0 k 63 Operands: 0 k 63
f [ 0, 1, 2 ] Operation: FSR2 – k FSR2
Operation: FSR(f) – k FSRf (TOS) PC
Status Affected: None Status Affected: None
Encoding: 1110 1001 ffkk kkkk Encoding: 1110 1001 11kk kkkk
Description: The 6-bit literal ‘k’ is subtracted from Description: The 6-bit literal ‘k’ is subtracted from the
the contents of the FSR specified by contents of the FSR2. A RETURN is then
‘f’. executed by loading the PC with the TOS.
Words: 1 The instruction takes two cycles to
execute; a NOP is performed during the
Cycles: 1
second cycle.
Q Cycle Activity: This may be thought of as a special case of
Q1 Q2 Q3 Q4 the SUBFSR instruction, where f = 3 (binary
Decode Read Process Write to ‘11’); it operates only on FSR2.
register ‘f’ Data destination Words: 1
Cycles: 2
Q Cycle Activity:
Example: SUBFSR 2, 23h
Before Instruction Q1 Q2 Q3 Q4
FSR2 = 03FFh Decode Read Process Write to
register ‘f’ Data destination
After Instruction
FSR2 = 03DCh No No No No
Operation Operation Operation Operation
The MPASM Assembler generates relocatable object • Support for the entire device instruction set
files for the MPLINK Object Linker, Intel® standard HEX • Support for fixed-point and floating-point data
files, MAP files to detail memory usage and symbol • Command-line interface
reference, absolute LST files that contain source lines • Rich directive set
and generated machine code, and COFF files for • Flexible macro language
debugging.
• MPLAB X IDE compatibility
The MPASM Assembler features include:
• Integration into MPLAB X IDE projects
• User-defined macros to streamline
assembly code
• Conditional assembly for multipurpose
source files
• Directives that allow complete control over the
assembly process
Note 1: Maximum current rating requires even load distribution across I/O pins. Maximum current rating may be
limited by the device package power dissipation characterizations, see Table 26-8 to calculate device
specifications.
2: Power dissipation is calculated as follows:
PDIS = VDD x {IDD – ΣIOH} + Σ{VDD – VOH) x IOH} + Σ(VOL x IOI).
† NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure above maximum rating conditions for
extended periods may affect device reliability.
5.5
3.6
VDD (V)
3.0
2.3
0 10 20 40 48 64
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 26-13 for each Oscillator mode’s supported frequencies.
5.5
3.6
VDD (V)
3.0
2.3
0 10 20 40 48 64
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 26-13 for each Oscillator mode’s supported frequencies.
3.6
VDD (V)
3.0
2.0
1.8
0 10 16 20 40 48 64
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 26-13 for each Oscillator mode’s supported frequencies.
3.6
VDD (V)
3.0
2.0
1.8
0 10 16 20 40 48 64
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 26-13 for each Oscillator mode’s supported frequencies.
125
± 5%
85
± 3%
Temperature (°C)
60
25 ± 2%
0
-20 ± 5%
-40
1.8 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
VDD
VPOR
VPORR
VSS
NPOR
POR REARM
VSS
TVLOW(2) TPOR(3)
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D008 Supply Current (IDD)(1, 2, 4, 5) 6 9 A -40°C
7 10 A +25°C
VDD = 1.8V
8 14 A +85°C
11 17 A +125°C FOSC = 31 kHz(4)
(RC_RUN mode,
D008A 11 15 A -40°C LFINTOSC source)
12 16 A +25°C
VDD = 3.0V
13 25 A +85°C
17 28 A +125°C
D008 22 45 A -40°C
23 48 A +25°C
VDD = 2.3V
25 50 A +85°C
28 55 A +125°C
D008A 25 50 A -40°C
27 55 A +25°C FOSC = 31 kHz(4)
VDD = 3.0V (RC_RUN mode,
30 60 A +85°C LFINTOSC source)
32 75 A +125°C
D008B 30 55 A -40°C
33 60 A +25°C
VDD = 5.0V
37 65 A +85°C
40 80 A +125°C
D009 0.4 0.5 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
(RC_RUN mode,
D009A 0.6 0.8 mA -40°C to +125°C VDD = 3.0V HFINTOSC source)
D009 0.45 0.55 mA -40°C to +125°C VDD = 2.3V FOSC = 1 MHz
D009A 0.60 0.82 mA -40°C to +125°C VDD = 3.0V (RC_RUN mode,
D009B 0.80 1.0 mA -40°C to +125°C VDD = 5.0V HFINTOSC source)
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D011 Supply Current (IDD)(1, 2, 4, 5) 2 5 A -40°C
2 6 A +25°C
VDD = 1.8V
3 9 A +85°C
8 11 A +125°C FOSC = 31 kHz(4)
(RC_IDLE mode,
D011A 4 8 A -40°C LFINTOSC source)
4 10 A +25°C
VDD = 3.0V
5 13 A +85°C
8 15 A +125°C
D011 20 28 A -40°C
21 35 A +25°C
VDD = 2.3V
23 41 A +85°C
24 50 A +125°C
D011A 23 35 A -40°C
25 40 A +25°C FOSC = 31 kHz(4)
VDD = 3.0V (RC_IDLE mode,
28 46 A +85°C LFINTOSC source)
30 65 A +125°C
D011B 28 43 A -40°C
30 48 A +25°C
VDD = 5.0V
32 51 A +85°C
33 71 A +125°C
D012 0.30 0.45 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
(RC_IDLE mode,
D012A 0.45 0.60 mA -40°C to +125°C VDD = 3.0V HF-INTOSC source)
D012 0.32 0.45 mA -40°C to +125°C VDD = 2.3V
FOSC = 1 MHz
D012A 0.47 0.62 mA -40°C to +125°C VDD = 3.0V (RC_IDLE mode,
D012B 0.78 -40°C to +125°C VDD = 5.0V HF-INTOSC source)
0.63 mA
D013 0.89 1.20 mA -40°C to +125°C VDD = 1.8V FOSC = 16 MHz
(RC_IDLE mode,
D013A 1.45 2.00 mA -40°C to +125°C VDD = 3.0V HF-INTOSC source)
D013 1.10 1.50 mA -40°C to +125°C VDD = 2.3V
FOSC = 16 MHz
D013A 1.45 2.00 mA -40°C to +125°C VDD = 3.0V (RC_IDLE mode,
D013B 2.20 -40°C to +125°C VDD = 5.0V HF-INTOSC source)
1.53 mA
* These parameters are characterized but not tested.
Note 1: 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 disabled.
2: The supply current is mainly a function of the operating voltage and frequency. Other factors, such as I/O pin loading
and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact on the current
consumption.
3: For RC oscillator configurations, current through REXT is not included. The current through the resistor can be extended
by the formula IR = VDD/2REXT (mA) with REXT in k
4: FVR and BOR are disabled.
5: When a single temperature range is provided for a parameter, the specification applies to both industrial and extended
temperature devices.
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D014 Supply Current (IDD)(1, 2, 4, 5) 0.20 0.32 mA -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D014A (PRI_RUN,
0.27 0.39 mA -40°C to +125°C VDD = 3.0V EC Med Osc)
D014 .20 .32 mA -40°C to +125°C VDD = 2.3V FOSC = 1 MHz
D014A .27 .39 mA -40°C to +125°C VDD = 3.0V (PRI_RUN,
D014B .30 .42 mA -40°C to +125°C VDD = 5.0V EC Med Osc)
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D019 Supply Current (IDD)(1, 2, 4, 5) 70 105 A -40°C to +125°C VDD = 1.8V FOSC = 1 MHz
D019A (PRI_IDLE mode,
140 180 A -40°C to +125°C VDD = 3.0V EC Med Osc)
D019 80 120 A -40°C to +125°C VDD = 2.3V
FOSC = 1 MHz
D019A 140 180 A -40°C to +125°C VDD = 3.0V (PRI_IDLE mode,
D019B 151 230 A -40°C to +125°C VDD = 5.0V EC Med Osc)
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D022 Supply Current (IDD)(1, 2, 4) 6 9 A -40°C
6 10 A +25°C
VDD = 1.8V
7 14 A +85°C
11 17 A +125°C FOSC = 32 kHz(3)
(SEC_RUN mode,
D022A 11 15 A -40°C Timer1 as clock)
11 16 A +25°C
VDD = 3.0V
12 25 A +85°C
26 28 A +125°C
D022 22 65 A -40°C
23 67 A +25°C
VDD = 2.3V
25 69 A +85°C
28 75 A +125°C
D022A 25 70 A -40°C
27 72 A +25°C FOSC = 32 kHz(3)
VDD = 3.0V (SEC_RUN mode,
30 74 A +85°C Timer1 as clock)
32 77 A +125°C
D022B 30 75 A -40°C
32 77 A +25°C
VDD = 5.0V
34 79 A +85°C
35 83 A +125°C
* These parameters are characterized but not tested.
Note 1: 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 disabled.
2: The supply current is mainly a function of the operating voltage and frequency. Other factors, such as I/O pin
loading and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact
on the current consumption.
3: For RC oscillator configurations, current through REXT is not included. The current through the resistor can be
extended by the formula IR = VDD/2REXT (mA) with REXT in k
4: FVR and BOR are disabled.
Param.
Device Characteristics Typ. Max. Units Conditions
No.
D023 Supply Current (IDD)(1, 2, 4) 2 5 A -40°C
2 5 A +25°C
VDD = 1.8V
3 9 A +85°C
8 11 A +125°C FOSC = 32 kHz(3)
(SEC_IDLE mode,
D023A 4 8 A -40°C Timer1 as clock)
5 10 A +25°C
VDD = 3.0V
9 20 A +85°C
20 23 A +125°C
D023 20 40 A -40°C
21 41 A +25°C
VDD = 2.3V
23 44 A +85°C
24 47 A +125°C
D023A 23 45 A -40°C
25 47 A +25°C FOSC = 32 kHz(3)
VDD = 3.0V (SEC_IDLE mode,
28 49 A +85°C Timer1 as clock)
30 52 A +125°C
D023B 28 50 A -40°C
30 54 A +25°C
VDD = 5.0V
32 59 A +85°C
33 62 A +125°C
* These parameters are characterized but not tested.
Note 1: 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 disabled.
2: The supply current is mainly a function of the operating voltage and frequency. Other factors, such as I/O pin
loading and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact
on the current consumption.
3: For RC oscillator configurations, current through REXT is not included. The current through the resistor can be
extended by the formula IR = VDD/2REXT (mA) with REXT in k
4: FVR and BOR are disabled.
— 20 45 80 A 5.0
Power-down Module Current
D028 — .46 1.3 10 A 1.8 LPWDT Current(1)
— .74 3.0 11 A 3.0
D028 — 18 44 60 A 2.3 LPWDT Current(1)
— 21 46 70 A 3.0
— 22 48 85 A 5.0
D029 — 12 20 28 A 1.8 FVR Current (3)
— 14 22 30 A 3.0
D029 — 40 65 80 A 2.3 FVR Current(3)
— 50 70 85 A 3.0
— 70 120 135 A 5.0
D030 — 12 17 23 A 3.0 BOR Current(1, 3)
D030 — 30 55 80 A 3.0 BOR Current(1, 3)
— 64 100 120 A 5.0
D031 — .65 1.5 11 A 1.8 T1OSC Current(1)
— 0.90 4.0 12 A 3.0
D031 — 19 45 60 A 2.3 T1OSC Current(1)
— 20 50 70 A 3.0
— 22 55 80 A 5.0
* These parameters are characterized but not tested.
† Data in “Typ” column is at 3.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are
not tested.
Note 1: The peripheral current is the sum of the base IDD or IPD and the additional current consumed when this peripheral is
enabled. The peripheral current can be determined by subtracting the base IDD or IPD current from this limit. Max
values should be used when calculating total current consumption.
2: The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD.
3: Fixed Voltage Reference is automatically enabled whenever the BOR is enabled.
4: A/D oscillator source is FRC.
— 22 46 80 A 5.0
D033 — 8 30 32 A 1.8 Comparator Current, low power
— 11 32 35 A 3.0 C1 and C2 enabled
Param.
Sym. Characteristic Min. Typ.† Max. Units Conditions
No.
Param.
Sym. Characteristic Min. Typ.† Max. Units Conditions
No.
Param.
Sym. Characteristic Min. Typ.† Max. Units Conditions
No.
TH01 JA Thermal Resistance Junction to Ambient 62.2 C/W 20-pin PDIP package
75.0 C/W 20-pin SOIC package
89.3 C/W 20-pin SSOP package
43.0 C/W 20-pin QFN 4x4mm package
TH02 JC Thermal Resistance Junction to Case 27.5 C/W 20-pin PDIP package
23.1 C/W 20-pin SOIC package
31.1 C/W 20-pin SSOP package
5.3 C/W 20-pin QFN 4x4mm package
TH03 TJMAX Maximum Junction Temperature 150 C
TH04 PD Power Dissipation — W PD = PINTERNAL + PI/O
TH05 PINTERNAL Internal Power Dissipation — W PINTERNAL = IDD x VDD(1)
TH06 PI/O I/O Power Dissipation — W PI/O = (IOL * VOL) + (IOH * (VDD - VOH))
TH07 PDER Derated Power — W PDER = PDMAX (TJ - TA)/JA(2)
Note 1: IDD is current to run the chip alone without driving any load on the output pins.
2: TA = Ambient Temperature.
3: TJ = Junction Temperature.
1. TppS2ppS
2. TppS
T
F Frequency T Time
Lowercase letters (pp) and their meanings:
pp
cc CCP1 osc OSC1
ck CLKOUT rd RD
cs CS rw RD or WR
di SDI sc SCK
do SDO ss SS
dt Data in t0 T0CKI
io I/O PORT t1 T1CKI
mc MCLR wr WR
Uppercase letters and their meanings:
S
F Fall P Period
H High R Rise
I Invalid (High-impedance) V Valid
L Low Z High-impedance
Pin CL
VSS
Q4 Q1 Q2 Q3 Q4 Q1
OSC1/CLKIN
OS02
OS04 OS04
OS03
OSC2/CLKOUT
(LP,XT,HS Modes)
OSC2/CLKOUT
(CLKOUT Mode)
FOSC
OS11 OS12
OS20
CLKOUT OS21
OS19 OS16 OS18
OS13 OS17
I/O pin
(Input)
OS15 OS14
I/O pin Old Value New Value
(Output)
OS18, OS19
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
OSC
Start-Up Time
Internal Reset(1)
Watchdog Timer
Reset(1)
31/
34 31A
34
I/O pins
VDD
VBOR and VHYST
VBOR
TBORREJ
37
Reset
33(1)
(due to BOR)
Note 1: 64 ms delay only if PWRTE bit in the Configuration Word register is programmed to ‘0’. 2 ms delay if PWRTE = 0.
TABLE 26-16: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER,
AND BROWN-OUT RESET PARAMETERS
Standard Operating Conditions (unless otherwise stated)
Param.
Sym. Characteristic Min. Typ.† Max. Units Conditions
No.
T0CKI
40 41
42
T1CKI
45 46
47 49
TMR0 or
TMR1
CC01 CC02
CC03
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.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
CM01 VIOFF Input Offset Voltage — 10 50 mV VREF = VDD/2,
High-Power mode
— 12 80 mV VREF = VDD/2,
Low-Power mode
CM02 VICM Input Common-mode Voltage VSS — VDD V
CM04 TRESP Response Time — 200 400 ns High-Power mode
— 300 600 ns Low-Power mode
CM05 TMC2OV Comparator Mode Change to — — 10 s
Output Valid*
* These parameters are characterized but not tested.
Note 1: Response time measured with one comparator input at VDD/2, while the other input transitions from VSS
to VDD.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
DAC01* CLSB Step Size — VDD/32 — V
DAC02* CACC Absolute Accuracy — — 1/2 LSb
DAC03* CR Unit Resistor Value (R) — 5k —
DAC04* CST Settling Time(1) — — 10 s
* These parameters are characterized but not tested.
Note 1: Settling time measured while DACR<4:0> transitions from ‘0000’ to ‘1111’.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
D003 VADFVR Fixed Voltage Reference Voltage for -8 — 6 % 1.024V, VDD 2.5V(1)
ADC, Initial Accuracy 2.048V, VDD 2.5V
4.096V, VDD 4.75V
D003A VCDAFVR Fixed Voltage Reference Voltage for -11 — 7 % 1.024V, VDD 2.5V
Comparator and DAC, Initial Accuracy 2.048V, VDD 2.5V
4.096V, VDD 4.75V
D004* SVDD VDD Rise Rate to ensure internal 0.05 — — V/ms See Section 22.3 “Power-on
Power-on Reset signal Reset (POR)” for details.
* These parameters are characterized but not tested.
Note 1: For proper operation, the minimum value of the ADC positive voltage reference must be 1.8V or greater.
When selecting the FVR or the VREF+ pin as the source of the ADC positive voltage reference, be aware
that the voltage must be 1.8V or greater.
CK
US121 US121
DT
US120 US122
Param.
Symbol Characteristic Min. Max. Units Conditions
No.
US120 TCKH2DTV SYNC XMIT (Master and Slave) 3.0-5.5V — 80 ns
Clock high to data-out valid 1.8-5.5V — 100 ns
US121 TCKRF Clock out rise time and fall time 3.0-5.5V — 45 ns
(Master mode) 1.8-5.5V — 50 ns
US122 TDTRF Data-out rise time and fall time 3.0-5.5V — 45 ns
1.8-5.5V — 50 ns
CK
US125
DT
US126
Param.
Symbol Characteristic Min. Max. Units Conditions
No.
US125 TDTV2CKL SYNC RCV (Master and Slave)
Data-hold before CK (DT hold time) 10 — ns
US126 TCKL2DTL Data-hold after CK (DT hold time) 15 — ns
SS
SP70
SCK
(CKP = 0)
SP71 SP72
SP78 SP79
SCK
(CKP = 1)
SP79 SP78
SP80
SP75, SP76
SP74
SP73
SS
SP81
SCK
(CKP = 0)
SP71 SP72
SP79
SP73
SCK
(CKP = 1)
SP80
SP78
SP75, SP76
SP74
SS
SP70
SCK SP83
(CKP = 0)
SP71 SP72
SP78 SP79
SCK
(CKP = 1)
SP79 SP78
SP80
SP74
SP73
SP82
SS
SP70
SCK SP83
(CKP = 0)
SP71 SP72
SCK
(CKP = 1)
SP80
SP77
SP75, SP76
SDI
MSb In bit 6 - - - -1 LSb In
SP74
SCL
SP91 SP93
SP90 SP92
SDA
Start Stop
Condition Condition
SP90* TSU:STA Start condition 100 kHz mode 4700 — — ns Only relevant for Repeated
Setup time 400 kHz mode 600 — — Start condition
SP91* THD:STA Start condition 100 kHz mode 4000 — — ns After this period, the first
Hold time 400 kHz mode 600 — — clock pulse is generated
SP92* TSU:STO Stop condition 100 kHz mode 4700 — — ns
Setup time 400 kHz mode 600 — —
SP93 THD:STO Stop condition 100 kHz mode 4000 — — ns
Hold time 400 kHz mode 600 — —
* These parameters are characterized but not tested.
SCL
SP90
SP106
SP107
SP91 SP92
SDA
In
SP110
SP109
SP109
SDA
Out
4.5
4
125°C
3.5
3
IPD (uA)
2.5
1.5
1
85°C
25°C
0.5
-40°C
0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
6.0
5.4
4.8 125°C
4.2
3.6
IPD (uA)
3.0
2.4
1.8 85°C
1.2
0.0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
16
14
12 125°C
10
85°C
IPD (uA)
8
Typ. 25°C
0
2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3
VDD (V)
35
30
25
125°C
IPD (uA)
20 85°C
25°C
15
10
0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
25.0
20.0
IPD (uA)
15.0
125°C
85°C
10.0 25°C
-40°C
5.0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
125
100
75
125°C
IPD (uA)
85°C
25°C
50
-40°C
25
0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
25
20
IDD (uA)
15
125°C
85°C
10 25°C
-40°C
0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
5.0
4.5
4.0
3.5
3.0
IDD (mA)
16 MHz
2.5
2.0
1.5
1.0
0.5 1 MHz
0.0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
4.0
3.5
3.0
16 MHz
2.5
IDD (mA)
2.0
1.5
1.0
0.5
1 MHz
0.0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
5.0
4.5
4.0
3.5
3.0
16 MHz
(4 MHz Input)
IDD (mA)
2.5
2.0
1.5
1.0
0.5
0.0
1.8 2 2.2 2.4 2.6 2.8 3
VDD (V)
50
45
40
35
30 125°C
IPD (uA)
25 85°C
20 25°C
15 -40°C
10
0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
35.0
125°C
30.0
85°C
25.0
Typ. 25°C
IPD (uA)
20.0
15.0
15 0
10.0
5.0
0.0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
70
60
125°C
85°C
50
Typ. 25°C
40
IPD (uA)
30
20
10
0
3 3.2 3.4 3.6 3.8 4 4.2 4.4 4.6 4.8 5
VDD (V)
70
60
125°C
50 85°C
IPD (uA)
25°C
40
30
20
10
0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
55.0
50.0
45.0 125°C
40.0
85°C
IPD (uA)
35.0
25°C
30.0
25.0 -40°C
20.0
15.0
10.0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
FIGURE 27-16: MEMLOW ICOMP – TYPICAL IPD FOR COMPARATOR IN HIGH-POWER MODE
150
125
125°C
100 85°C
25°C
IPD (uA)
75
-40°C
50
25
0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
50
45
40
125°C
35
85°C
25°C
30
IDD (uA)
-40°C
25
20
15
10
0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
4.5
4.0
16 MHz
3.5
3.0
IDD (mA)
2.5
2.0
1.5
1.0
1 MHz
0.5
0.0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
14
12 64 MHz
10
8
IDD (mA)
4
16 MHz
1 MHz
0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
14
64 MHz
12 (16 MHz Input)
10
IDD (mA)
4
16 MHz
(4 MHz Input)
0
2.3 2.8 3.3 3.8 4.3 4.8
VDD (V)
1.9 Min.
1.7
1.5
1.3 -40°C
VIH (V)
25°C
1.1 85°C
125°C
0.9
0.7
0.5
0.3
0.1
1.8 2.3 2.8 3.3 3.8 4.3 4.8 5.3
VDD (V)
4.0
3.5
Min.
3.0
VIH (V)
2.5
2.0
-40°C
1.5
125°C
1.0
1.8 2.3 2.8 3.3 3.8 4.3 4.8 5.3
VDD (V)
1.9
1.7
1.5
1.3
25°C
VIL (V)
1.1
-40°C
0.9
125°C 85°C
0.7
Max.
0.5
0.3
0.1
1.8 2.3 2.8 3.3 3.8 4.3 4.8 5.3
VDD (V)
1.8
1.6
-40°C
1.4
VIL (V)
1.2
1.0
125°C
0.8 Max.
0.6
0.4
0.2
1.8 2.3 2.8 3.3 3.8 4.3 4.8 5.3
VDD (V)
32.3
25°C
Frequency (kHz)
31.3 -40°C
85°C
30.3
F
125°C
29.3
28.3
2 2.5 3 3.5 4 4.5 5 5.5
VDD (V)
FIGURE 27-26: MEMLOW TYPICAL LF-INTOSC FREQUENCY (MAX./MIN. = 31.25 kHz ± 15%)
32.5
32.0 2.5V
3.0V
31.5
5.5V
(kHz)
31.0
Frequency
30.5
F
30.0
29.5
29.0
-40 -20 0 20 40 60 80 100 120
Temperature (°C)
32.3
31.3
30.3
Frequency (kHz)
25°C
29.3 -40°C
85°C
28.3
125°C
27.3
26.3
25.3
2 2.4 2.8 3.2 3.6
VDD (V)
32 0
32.0
31.0
Hz)
Frequency (kH
30.0 2.5V
3V
3.6V
29.0
F
28.0
27.0
26.0
-40 -20 0 20 40 60 80 100 120
Temperature (°C)
4
VOH (V)
3
5.5V
2
4.0V
3.0V
1
2.0V
0
0 5 10 15 20 25 30 35
IOH (mA)
2.0
1.5
1.8V
VOL (V)
3.0
1.0
4.0V
5.5V
0.5
0.0
0 5 10 15 20 25 30
IOL (mA)
XXXXXXXXXXXXXXXXX PIC18F13K22
XXXXXXXXXXXXXXXXX -E/P e3
YYWWNNN 0910017
PIC18F13K22
-I/SS e3
0910017
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.
PIC18F14K22
-E/SO e3
0910017
PIC18
PIN 1 PIN 1
F14K22
E/ML e3
910017
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.
/HDG3ODVWLF'XDO,Q/LQH3±PLO%RG\>3',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
/HDG3ODVWLF6KULQN6PDOO2XWOLQH66±PP%RG\>6623@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D
N
E1
NOTE 1
1 2
e
b
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\
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
/HDG3ODVWLF4XDG)ODW1R/HDG3DFNDJH0/±[[PP%RG\>4)1@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D D2
EXPOSED
PAD
e
E2
E
2 2 b
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 &%
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
Revision B (04/2009)
Revised data sheet title; Revised Peripheral Features
section; Revised Table 3-1, Table 3-2; Revised
Example 15-1; Revised Table 21-4.
Revision C (10/2009)
Updated Table 1-1; Updated the “Electrical
Specifications” section (Figures 25-1 to 25-4; sub-
sections 25.1, 25.2, 25.3, 25.4, 25.5, 25.6, 25.7, 25.8,
Added Param No. OS09 to Table 25-2; Added Param
No. D003A and Note 1 to Table 25-12); Added graphs
to the “DC and AC Characteristics Graphs and Charts”
section; Other minor corrections.
Revision D (05/2010)
Revised Section 1.3 (deleted #2); Revised Figure 1-1;
Added Table 2-4; Removed register EEADRH from
Tables 3-1 and 3-2; Revised Section 5 (Data EEPROM
Memory); Updated Example 5-2 and Table 5-1;
Revised Section 13.4.4 (Enhanced PWM Auto-Shut-
down Mode); Added Note 4 below Register 13-2;
Revised Figure 16-1; Revised Equation 20-1;
Removed sub-section 20.1.3 (Output Clamped to VSS);
Updated Figure 20-1; Revised Tables 21-4 and Table
22-1; Updated Register 22-5, Figure 25-5, Table 25-2,
Table 25-8, Table 25-10 and Table 25-12; Updated the
Electrical Specification section; Other minor
corrections.
Revision E (10/2011)
Updated data sheet to new format; Updated the Pin
Diagrams; Updated the Electrical Specifications
section; Updated the Packaging Information section;
Updated Table B-1; Updated the Product Identification
System section; Other minor corrections.
Revision F (04/2016)
Updated Analog Features section on page 1; Updated
Tables 1-2, 3-2, 8-5, 8-6, 16-2 and 22-4; Added Note 3
to Tables 3-2, 8-1 and 8-2; Added Note 1 to Tables 9-1,
10-2, 12-1 and 17-2, and Register 8-4; Updated
Figures 3-7, 9-1 and 9-2; Updated Registers 13-2,
16-2, 19-1; Updated Section 1.1.2, 7.9 and 8.1;
Replaced chapter 20.0 (Voltage References) with
chapter 20.0 (Fixed Voltage Reference) and 21.0
(Digital-to-Analog Converter (DAC) Module); Updated
Chapter 26.0 (Electrical Specifications); Other minor
corrections.
Package: ML = QFN
P = PDIP Note 1: Tape and Reel option is available for ML,
SO = SOIC MV, PT, SO and SS packages with industrial
SS = SSOP Temperature Range only.
2: Tape and Reel identifier only appears in
catalog part number description. This
Pattern: QTP, SQTP, Code or Special Requirements
identifier is used for ordering purposes and
(blank otherwise)
is not printed on the device package.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
CERTIFIED BY DNV Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
== ISO/TS 16949 ==
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: