Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
A/D (ch)(2)
EUSART
# Single-Word
8/16-bit
Timers
Comp.
(PWM)
ECCP
10-bit
Instructions
I/O(1)
USB
EEPROM
Device
(bytes)
(bytes)
(bytes)
SRAM
Master
Flash
I2C™
SPI
PIC18F13K50/ (A) 8K 4096 512(3) 256 15 11 1 Y Y 1 2 1/3 Y
PIC18LF13K50
PIC18F14K50/ (A) 16K 8192 768(3) 256 15 11 1 Y Y 1 2 1/3 Y
PIC18LF14K50
Note 1: One pin is input only.
2: Channel count includes internal Fixed Voltage Reference (FVR) and Programmable Voltage Reference (CVREF) channels.
3: Includes the dual port RAM used by the USB module which is shared with the data memory.
Data Sheet Index: (Unshaded devices are described in this document)
A. DS40001350 PIC18(L)F1XK50 Data Sheet, 20-Pin USB Flash Microcontrollers with XLP Technology.
Note: For other small form-factor package availability and marking information, please visit
http://www.microchip.com/packaging or contact your local sales office.
VDD 1 20 VSS
IOCA5/OSC1/CLKIN/RA5 2 19 RA0/IOCA0/D+/PGD
AN3/IOCA3/OSC2/CLKOUT/RA4 3 18 RA1/IOCA1/D-/PGC
PIC18(L)F1XK50
IOCA3/MCLR/VPP/RA3 4 17 VUSB
CCP1/P1A/T0CKI/RC5 5 16 RC0/AN4/C12IN+/INT0/VREF+
P1B/C12OUT/SRQ/RC4 6 15 RC1/AN5/C12IN1-/INT1/VREF-
N7/P1C/C12IN3-/PGM/RC3 7 14 RC2/AN6/P1D/C12IN2-/CVREF/INT2
AN8/SS/T13CKI/T1OSCI/RC6 8 13 RB4/AN10/IOCB4/SDI/SDA
AN9/SDO/T1OSCO/RC7 9 12 RB5/AN11/IOCB5/RX/DT
IOCB7/TX/CK/RB7 10 11 RB6/IOCB6/SCK/SCL
RA0/IOCA0/D+/PGD
VDD
Vss
20 19 18 17 16
IOCA3/MCLR/VPP/RA3 1 15 RA1/IOCA1/D-/PGC
CCP1/P1A/T0CKI/RC5 2 14 VUSB
P1B/C12OUT/SRQ/RC4 3 PIC18(L)F1XK50 13 RC0/AN4/C12IN+/INT0/VREF+
AN7/P1C/C12IN3-/PGM/RC3 4 12 RC1/AN1/C12IN1-/INT1/VREF-
AN8/SS/T13CKI/T1OSCI/RC6 5 11 RC2/AN6/P1D/C12IN2-/CVREF/INT2
6 7 8 9 10
AN9/SDO/T1OSCO/RC7
IOCB7/TX/CK/RB7
IOCB4/AN10/SDI/SDA/RB4
IOCB6/SCK/SCL/RB6
IOCB5/AN11/RX/DT/RB5
20-Pin PDIP/SSOP/SOIC
Comparator
20-Pin QFN
Reference
Interrupts
EUSART
Analog
Pull-up
Timers
MSSP
ECCP
Basic
USB
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 Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
IR
8
Instruction State machine
Decode and control signals
Control
PRODH PRODL
PORTC
8 x 8 Multiply RC0
3 8 RC1
Internal RC2
OSC1(2) BITOP W RC3
Oscillator 8
Block Power-up 8 8 RC4
OSC2(2) Timer RC5
LFINTOSC RC6
Oscillator Oscillator 8 8
T1OSI RC7
Start-up Timer
16 MHz ALU<8>
T1OSO Oscillator Power-on
Reset 8
VUSB USB
Module Watchdog
MCLR(1) Timer
Single-Supply Precision FVR
Fail-Safe Band Gap
VDD, VSS Programming Clock Monitor Reference
LDO(3)
Regulator
Data
BOR EEPROM Timer0 Timer1 Timer2 Timer3
FVR FVR
ADC
CVREF Comparator ECCP1 USB MSSP EUSART CVREF
10-bit
PIC18(L)F1XK50
MUX
CPU
IRCF<2:0>
01 Sleep
16 MHz
111
8 MHz
Internal 110
Oscillator 4 MHz
Block 101
Postscaler
2 MHz
FOSC<3:0>
MUX
16 MHz 100
1 MHz Clock
HFINTOSC 011 Control SCS<1:0>
500 kHz
31 kHz 010
LFINTOSC 250 kHz
001
1 31 kHz
000
0
INTSRC
Secondary
Oscillator
T1OSI
T1OSCEN Fail-Safe
Enable Clock
T1OSO Oscillator
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 PIC®
current consumption is the medium of the three modes. Devices” (DS00826)
This mode is best suited to drive resonators with a • AN849, “Basic PIC® Oscillator Design”
medium drive level specification. (DS00849)
HS Oscillator mode selects the highest gain setting of the • AN943, “Practical PIC® 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)
2.5.2 HFINTOSC
The High-Frequency Internal Oscillator (HFINTOSC) is
a precision oscillator that is factory-calibrated to
operate at 16 MHz. The output of the HFINTOSC
connects to a postscaler and a multiplexer (see
Figure 2-1). One of eight frequencies can be selected
using the IRCF<2:0> bits of the OSCCON register. The
following frequencies are available from the
HFINTOSC:
• 16 MHZ
• 8 MHZ
• 4 MHZ
• 2 MHZ
• 1 MHZ (Default after Reset)
• 500 kHz
• 250 kHz
• 31 kHz
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.
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)F1XK50
devices is shown in Figure 3-1. Memory block details
are shown in Figure 24-2.
FIGURE 3-1: PROGRAM MEMORY MAP AND STACK FOR PIC18(L)F1XK50 DEVICES
PC<20:0>
CALL,RCALL,RETURN 21
RETFIE,RETLW
Stack Level 1
Stack Level 31
PIC18F14K50
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 Unused
Bank 1 The second 160 bytes are
Read 00h
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2 GPR
(DPRAM)
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4
FFh 4FFh
= 0101 00h 500h
Bank 5
FFh 5FFh
= 0110 00h 600h
Bank 6
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
FFh 8FFh
= 1001 00h Unused 900h
Bank 9 Read 00h
FFh 9FFh
00h A00h
= 1010
Bank 10
FFh AFFh
= 1011 00h B00h
Bank 11
FFh BFFh
= 1100 00h C00h
Bank 12
FFh CFFh
= 1101 D00h
Bank 13 00h
FFh DFFh
00h E00h
= 1110
Bank 14
FFh EFFh
00h 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 GPR
(DPRAM)
FFh 2FFh When ‘a’ = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4
FFh 4FFh
= 0101 00h 500h
Bank 5
FFh 5FFh
= 0110 00h 600h
Bank 6
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
FFh 8FFh
= 1001 00h Unused 900h
Bank 9 Read 00h
FFh 9FFh
00h A00h
= 1010
Bank 10
FFh AFFh
= 1011 00h B00h
Bank 11
FFh BFFh
= 1100 00h C00h
Bank 12
FFh CFFh
= 1101 D00h
Bank 13 00h
FFh DFFh
00h E00h
= 1110
Bank 14
FFh EFFh
00h 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
F00h FFh
00h
Bank 15
FFFh FFh
Note 1: The Access RAM bit of the instruction can be used to force an override of the selected bank (BSR<3:0>) to
the registers of the Access Bank.
2: The MOVFF instruction embeds the entire 12-bit address in the instruction.
ADCON2 ADFM — ACQT2 ACQT1 ACQT0 ADCS2 ADCS1 ADCS0 0-00 0000 277, 210
CCPR1H Capture/Compare/PWM Register 1, High Byte xxxx xxxx 277, 132
CCPR1L Capture/Compare/PWM Register 1, Low Byte xxxx xxxx 277, 132
CCP1CON P1M1 P1M0 DC1B1 DC1B0 CCP1M3 CCP1M2 CCP1M1 CCP1M0 0000 0000 277, 111
REFCON2 — — — DAC1R4 DAC1R3 DAC1R2 DAC1R1 DAC1R0 ---0 0000 277, 239
REFCON1 D1EN D1LPS DAC1OE --- D1PSS1 D1PSS0 — D1NSS 000- 00-0 277, 239
PSTRCON — — — STRSYNC STRD STRC STRB STRA ---0 0001 277, 128
BAUDCON ABDOVF RCIDL DTRXP CKTXP BRG16 — WUE ABDEN 0100 0-00 277, 186
PWM1CON PRSEN PDC6 PDC5 PDC4 PDC3 PDC2 PDC1 PDC0 0000 0000 277, 127
ECCP1AS ECCPASE ECCPAS2 ECCPAS1 ECCPAS0 PSSAC1 PSSAC0 PSSBD1 PSSBD0 0000 0000 277, 123
TMR3H Timer3 Register, High Byte xxxx xxxx 277, 109
TMR3L Timer3 Register, Low Byte xxxx xxxx 277, 109
T3CON RD16 — T3CKPS1 T3CKPS0 T3CCP1 T3SYNC TMR3CS TMR3ON 0-00 0000 277, 107
SPBRGH EUSART Baud Rate Generator Register, High Byte 0000 0000 277, 175
SPBRG EUSART Baud Rate Generator Register, Low Byte 0000 0000 277, 175
RCREG EUSART Receive Register 0000 0000 277, 176
TXREG EUSART Transmit Register 0000 0000 277, 175
TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 277, 184
RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 277, 185
EEADR EEADR7 EEADR6 EEADR5 EEADR4 EEADR3 EEADR2 EEADR1 EEADR0 0000 0000 277, 50,
58
EEDATA EEPROM Data Register 0000 0000 277, 50,
58
EECON2 EEPROM Control Register 2 (not a physical register) 0000 0000 277, 50,
58
EECON1 EEPGD CFGS — FREE WRERR WREN WR RD xx-0 x000 277, 51,
58
IPR2 OSCFIP C1IP C2IP EEIP BCLIP USBIP TMR3IP – 1111 111- 278, 74
PIR2 OSCFIF C1IF C2IF EEIF BCLIF USBIF TMR3IF – 0000 000- 278, 70
PIE2 OSCFIE C1IE C2IE EEIE BCLIE USBIE TMR3IE – 0000 000- 278, 72
IPR1 – ADIP RCIP TXIP SSPIP CCP1IP TMR2IP TMR1IP -111 1111 278, 73
PIR1 – ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF -000 0000 278, 69
PIE1 – ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE -000 0000 278, 71
OSCTUNE INTSRC SPLLEN TUN5 TUN4 TUN3 TUN2 TUN1 TUN0 0000 0000 20, 278
TRISC TRISC7 TRISC6 TRISC5 TRISC4 TRISC3 TRISC2 TRISC1 TRISC0 1111 1111 278, 89
LATC LATC7 LATC6 LATC5 LATC4 LATC3 LATC2 LATC1 LATC0 xxxx xxxx 278, 89
PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx 278, 89
PORTB RB7 RB6 RB5 RB4 – – – – xxxx ---- 278, 84
CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1R C1CH1 C1CH0 0000 1000 278, 221
CM2CON1 MC1OUT MC2OUT C1RSEL C2RSEL C1HYS C2HYS C1SYNC C2SYNC 0000 0000 278, 222
CM2CON0 C2ON C2OUT C2OE C2POL C2SP C2R C2CH1 C2CH0 0000 1000 278, 222
SRCON1 SRSPE SRSCKE SRSC2E SRSC1E SRRPE SRRCKE SRRC2E SRRC1E 0000 0000 278, 235
SRCON0 SRLEN SRCLK2 SRCLK1 SRCLK0 SRQEN SRNQEN SRPS SRPR 0000 0000 278, 234
UCON — PPBRST SE0 PKTDIS USBEN RESUME SUSPND — -0x0 000- 278, 242
USTAT — ENDP3 ENDP2 ENDP1 ENDP0 DIR PPBI — -xxx xxx- 279, 246
UIR — SOFIF STALLIF IDLEIF TRNIF ACTVIF UERRIF URSTIF -000 0000 279, 256
UCFG UTEYE — — UPUEN — FSEN PPB1 PPB0 0--0 -000 279, 244
UIE — SOFIE STALLIE IDLEIE TRNIE ACTVIE UERRIE URSTIE -000 0000 279, 258
UEIR BTSEF — — BTOEF DFN8EF CRC16EF CRC5EF PIDEF 0--0 0000 279, 259
UFRML FRM7 FRM6 FRM5 FRM4 FRM3 FRM2 FRM1 FRM0 xxxx xxxx 279, 242
UADDR — ADDR6 ADDR5 ADDR4 ADDR3 ADDR2 ADDR1 ADDR0 -000 0000 279, 248
UEIE BTSEE — — BTOEE DFN8EE CRC16EE CRC5EE PIDEE 0--0 0000 279, 260
UEP7 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 279, 247
UEP6 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 279, 247
UEP5 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 279, 247
UEP4 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 279, 247
UEP3 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 279, 247
UEP2 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 279, 247
UEP1 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 279, 247
UEP0 – – – EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL ---0 0000 275, 247
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For Borrow, the polarity is reversed. A subtraction is executed by adding the two’s complement of the
second operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high-order or low-order
bit of the source register.
000h
When ‘a’ = 0 and f 60h:
060h
The instruction executes in
Direct Forced mode. ‘f’ is inter- Bank 0
BSR
When ‘a’ = 1 (all values of f): 000h 00000000
FIGURE 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 deter-
mine where the write block will eventually be written. The process for writing the holding registers to the
program memory array is discussed in Section 4.5 “Writing to Flash Program Memory”.
4.2 Control Registers The FREE bit allows the program memory erase oper-
ation. When FREE is set, an erase operation is initiated
Several control registers are used in conjunction with on the next WR command. When FREE is clear, only
the TBLRD and TBLWT instructions. These include the: writes are enabled.
• EECON1 register The WREN bit, when set, will allow a write operation.
• EECON2 register The WREN bit is clear on power-up.
• TABLAT register The WRERR bit is set by hardware when the WR bit is
• TBLPTR registers set and cleared when the internal programming timer
expires and the write operation is complete.
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 24.0
“Special Features of the CPU”). When CFGS is clear,
memory selection access is determined by EEPGD.
Legend:
R = Readable bit W = Writable bit
S = Bit can be set by software, but not cleared U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the
error condition.
TABLE 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
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 argu-
ments, each argument’s Most Significant bit (MSb) is
tested and the appropriate subtractions are done.
Wake-up if in
Idle or Sleep modes
TMR0IF
TMR0IE
TMR0IP
(1)
RABIF
RABIE
RABIP
INT0IF
INT0IE
Interrupt to CPU
INT1IF Vector to Location
INT1IE
INT1IP 0008h
SSPIF
SSPIE INT2IF
SSPIP INT2IE
INT2IP
ADIF GIEH/GIE
ADIE
ADIP IPEN
RCIF IPEN
RCIE 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
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
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
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
bit 7-0 LATC<7:0>: RB<7:0> Port I/O Output Latch Register bits
T1OSCI x O ANA Timer1 oscillator input; enabled when Timer1 oscillator enabled.
Disables digital I/O.
RC7/AN9/SDO/ RC7 0 O DIG LATC<7> data output.
T1OSCO 1 I ST PORTC<7> data input.
AN9 1 I ANA A/D input channel 9.
SDO 0 I DIG SPI data output (MSSP module); takes priority over port data.
T1OSCO x O ANA Timer1 oscillator output; enabled when Timer1 oscillator enabled.
Disables digital I/O.
Legend: DIG = Digital level output; TTL = TTL input buffer; ST = Schmitt Trigger input buffer; ANA = Analog level input/output;
I2C/SMB = I2C/SMBus input buffer; x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
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
0
Sync with Set
1 Internal TMR0L TMR0IF
Programmable Clocks on Overflow
T0CKI pin 1
Prescaler
T0SE (2 TCY Delay)
8
T0CS 3
T0PS<2:0>
8
PSA Internal Data Bus
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI max. prescale.
FOSC/4 0
0
Sync with Set
1 Internal TMR0
TMR0L High Byte TMR0IF
T0CKI pin Programmable 1 Clocks on Overflow
Prescaler 8
T0SE (2 TCY Delay)
T0CS 3 Read TMR0L
T0PS<2:0>
Write TMR0L
PSA
8
8
TMR0H
8
8
Internal Data Bus
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI max. prescale.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T1OSI/T13CKI 1
Prescaler Synchronize
FOSC/4 0
1, 2, 4, 8 Detect
Internal
Clock 0
T1OSO 2
Sleep Input
T1OSCEN(1) TMR1CS Timer1
On/Off
T1CKPS<1:0>
T1SYNC
TMR1ON
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
8
Read TMR1L
Write TMR1L
8
8
TMR1H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
XTAL
32.768 kHz
T1OSO
C2
27 pF
OSC1
OSC2
RC0
RC1
RC2
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
4 1:1 to 1:16
T2OUTPS<3:0> Set TMR2IF
Postscaler
2
T2CKPS<1:0> TMR2 Output
(to PWM or MSSP)
TMR2/PR2
Reset Match
1:1, 1:4, 1:16
FOSC/4 TMR2 Comparator PR2
Prescaler
8 8
8
Internal Data Bus
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Read TMR1L
Write TMR1L
8
8
TMR3H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
13.2 Timer3 16-Bit Read/Write Mode 13.3 Using the Timer1 Oscillator as the
Timer3 can be configured for 16-bit reads and writes
Timer3 Clock Source
(see Figure 13-2). When the RD16 control bit of the The Timer1 internal oscillator may be used as the clock
T3CON register is set, the address for TMR3H is source for Timer3. The Timer1 oscillator is enabled by
mapped to a buffer register for the high byte of Timer3. setting the T1OSCEN bit of the T1CON register. To use
A read from TMR3L will load the contents of the high it as the Timer3 clock source, the TMR3CS bit must
byte of Timer3 into the Timer3 High Byte Buffer register. also be set. As previously noted, this also configures
This provides the user with the ability to accurately read Timer3 to increment on every rising edge of the
all 16 bits of Timer1 without having to determine oscillator source.
whether a read of the high byte, followed by a read of
The Timer1 oscillator is described in Section 11.0
the low byte, has become invalid due to a rollover
“Timer1 Module”.
between reads.
A write to the high byte of Timer3 must also take place 13.4 Timer3 Interrupt
through the TMR3H Buffer register. The Timer3 high
byte is updated with the contents of TMR3H when a The TMR3 register pair (TMR3H:TMR3L) increments
write occurs to TMR3L. This allows a user to write all from 0000h to FFFFh and overflows to 0000h. The
16 bits to both the high and low bytes of Timer3 at once. Timer3 interrupt, if enabled, is generated on overflow
The high byte of Timer3 is not directly readable or and is latched in interrupt flag bit, TMR3IF of the PIR2
writable in this mode. All reads and writes must take register. This interrupt can be enabled or disabled by
place through the Timer3 High Byte Buffer register. setting or clearing the Timer3 Interrupt Enable bit,
TMR3IE of the PIE2 register.
Writes to TMR3H do not clear the Timer3 prescaler.
The prescaler is only cleared on writes to TMR3L.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
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 14-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.
Note 1: The TRIS register value for each PWM output must be configured appropriately.
2: Any pin not used by an Enhanced PWM mode is available for alternate pin functions.
TABLE 14-2: EXAMPLE PIN ASSIGNMENTS FOR VARIOUS PWM ENHANCED MODES
ECCP Mode P1M<1:0> CCP1/P1A P1B P1C P1D
Single 00 Yes(1) Yes(1) Yes(1) Yes(1)
Half-Bridge 10 Yes Yes No No
Full-Bridge, Forward 01 Yes Yes Yes Yes
Full-Bridge, Reverse 11 Yes Yes Yes Yes
Note 1: Outputs are enabled by pulse steering in Single mode. See Register 14-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 14.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 14.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)
P1D (Active-High)
Pulse Width
Note 1: The direction bit P1M1 of the CCP1CON register is written any time during the PWM cycle.
P1A
P1B
PW
P1C
P1D PW
TON
External Switch C
TOFF
External Switch D
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
PWM Period
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
ECCPASE
Cleared by
Start of Shutdown Shutdown Firmware PWM
PWM Period Event Occurs Event Clears Resumes
PWM Period
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
FET
Driver +
P1A V
-
Load
FET
Driver
+
P1B V
-
V-
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The PWM Steering mode is available only when the CCP1CON register bits CCP1M<3:2> = 11 and
P1M<1:0> = 00.
PORT Data
0
TRIS
STRB
PORT Data 0
TRIS
STRC
1 P1C pin
CCP1M1
PORT Data 0
TRIS
STRD
PORT Data 0
TRIS
PWM Period
PWM
STRn
P1n = PWM
PWM
STRn
P1n = PWM
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.
DS40001350F-page 148
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)F1XK50
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
DS40001350F-page 149
PIC18(L)F1XK50
FIGURE 15-10:
DS40001350F-page 150
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)F1XK50
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
DS40001350F-page 151
PIC18(L)F1XK50
PIC18(L)F1XK50
15.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 15-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 pat-
tern 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
DS40001350F-page 156
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)F1XK50
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>)
DS40001350F-page 157
PIC18(L)F1XK50
PIC18(L)F1XK50
15.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 15-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
DS40001350F-page 166
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
RCEN
I 2C™ MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS)
Master configured as a receiver RCEN cleared ACK from Master RCEN cleared
by programming SSPCON2<3> (RCEN = 1) automatically SDA = ACKDT = 0 automatically
DS40001350F-page 167
PIC18(L)F1XK50
PIC18(L)F1XK50
15.3.12 ACKNOWLEDGE SEQUENCE 15.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 gen- the master will assert the SDA line low. When the SDA
erate an Acknowledge, then the ACKDT bit should be line is sampled low, the Baud Rate Generator is
cleared. If not, the user should set the ACKDT bit before reloaded and counts down to ‘0’. When the Baud Rate
starting an Acknowledge sequence. The Baud Rate Generator times out, the SCL pin will be brought high
Generator then counts for one rollover period (TBRG) and one TBRG (Baud Rate Generator rollover count)
and the SCL pin is deasserted (pulled high). When the later, the SDA pin will be deasserted. When the SDA
SCL pin is sampled high (clock arbitration), the Baud pin is sampled high while SCL is high, the P bit of the
Rate Generator counts for TBRG. The SCL pin is then SSPSTAT register is set. A TBRG later, the PEN bit is
pulled low. Following this, the ACKEN bit is automatically cleared and the SSPIF bit is set (Figure 15-24).
cleared, the Baud Rate Generator is turned off and the
MSSP module then goes into Idle mode (Figure 15-23). 15.3.13.1 WCOL Status Flag
If the user writes the SSPBUF when a Stop sequence
15.3.12.1 WCOL Status Flag is in progress, then the WCOL bit is set and the
If the user writes the SSPBUF when an Acknowledge contents of the buffer are unchanged (the write does
sequence is in progress, then WCOL is set and the not occur).
contents of the buffer are unchanged (the write does
not 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 15-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 X 1 1 0 0 FIFO
FERR RX9D RCREG Register
BRG16 X 1 0 1 0
8
Data Bus
RCIF Interrupt
RCIE
Write to TXREG
Word 1
BRG Output
(Shift Clock)
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 16.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 16.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
Unused 0000
Unused 0001
Unused 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 17-1: ADC CLOCK PERIOD (TAD) VS. DEVICE OPERATING FREQUENCIES
ADC Clock Period (TAD) Device Frequency (FOSC)
ADRESH ADRESL
(ADFM = 0) MSB LSB
bit 7 bit 0 bit 7 bit 0
Set GO bit
On the following cycle:
ADRESH:ADRESL is loaded, GO bit is cleared,
ADIF bit is set, holding capacitor is connected to analog input.
FIGURE 17-4: A/D CONVERSION TAD CYCLES (ACQT<2:0> = 010, TACQ = 4 TAD)
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 2 TAD
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Automatic
Acquisition Conversion starts Discharge
Time (Holding capacitor is disconnected from analog input)
Set GO bit
(Holding capacitor continues On the following cycle:
acquiring input) ADRESH:ADRESL is loaded, GO bit is cleared,
ADIF bit is set, holding capacitor is connected to analog input.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T ACQ = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient
= T AMP + T C + T COFF
= 5µs + T C + Temperature - 25°C 0.05µs/°C
T C = – C HOLD R IC + R SS + R S ln(1/2047)
= – 13.5pF 1k + 700 + 10k ln(0.0004885)
= 1.20 µs
Therefore:
T ACQ = 5µs + 1.20µs + 50°C- 25°C 0.05µs/°C
= 7.45µs
Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out.
2: The charge holding capacitor (CHOLD) is discharged after each conversion.
3: The maximum recommended impedance for analog sources is 10 k. This is required to meet the pin
leakage specification.
VDD
Sampling
Switch
VT = 0.6V
Rs ANx RIC 1k SS Rss
Discharge VSS/VREF-
Switch
3.5V
Legend: CPIN = Input Capacitance 3.0V
VDD
VT = Threshold Voltage 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 27.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
AGND 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+
+
VREF 1
0 C1SP
MUX C1POL C1SYNC
C2OE
FVR 1 C1VREF C1OE
0
C1RSEL
D Q 1 C12OUT
(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
AGND 0 C2ON(1)
CL
C12IN1- 1 NRESET
MUX C2VIN-
C12IN2- 2 C2 C2OUT To PWM Logic
C2VIN+
C12IN3- 3 C2SP
C2SYNC
C2POL C20E
C2R
C12OUT pin
0
C2IN+ 0
MUX D Q 1
VREF 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.
Setting the CxR bit of the CMxCON0 register directs an 18.2.6 COMPARATOR SPEED SELECTION
internal voltage reference or an analog input pin to the
non-inverting input of the comparator. See The trade-off between speed or power can be opti-
Section 21.0 “Voltage References” for more mized during program execution with the CxSP control
information on the Internal Voltage Reference module. bit. The default state for this bit is ‘1’ which selects the
normal speed mode. Device power consumption can
18.2.4 COMPARATOR OUTPUT be optimized at the cost of slower comparator propaga-
SELECTION tion delay by clearing the CxSP bit to ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Comparator output requires the following three conditions: C1OE = 1, C1ON = 1 and corresponding port
TRIS bit = 0.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Comparator output requires the following three conditions: C2OE = 1, C2ON = 1 and corresponding port
TRIS bit = 0.
VT 0.6V RIC
Rs < 10K
AIN
CPIN ILEAKAGE(1)
VA
5 pF VT 0.6V
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 19-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 19-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 19.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
SRCLK
SRSCKE
SYNCC2OUT(4)
SRSC2E
SYNCC1OUT(4) SR
SRSC1E
Latch(1) SRQ pin(3)
SRPR Pulse
Gen(2) SRLEN
SRNQEN
INT1
SRRPE R Q
SRCLK
SRRCKE
SYNCC2OUT(4)
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
The voltage reference module provides an internally 21.1.2 OUTPUT VOLTAGE SELECTION
generated voltage reference for the comparators and
The VREF voltage reference has 32 voltage level
the DAC module. The following features are available:
ranges. The 32 levels are set with the DAC1R<4:0>
• Independent from Comparator operation bits of the REFCON2 register.
• Single 32-level voltage ranges The VREF output voltage is determined by the following
• Output clamped to VSS equations:
• Ratiometric with VDD
• 1.024V Fixed Reference Voltage (FVR)
The REFCON1 register (Register 21-2) controls the
voltage reference module shown in Figure 21-1.
V OUT = V SOURCE +
IF D1EN = 0 & D1LPS = 1 & DAC1R[4:0] = 00000:
V OUT = V SOURCE -
D1PSS<1:0> = 00
VDD DAC1R<4:0>
D1PSS<1:0> = 01
VREF+
D1PSS<1:0> = 10
FVR1 R
16-to-1 MUX
R
32 Steps
VREF
R
DAC1OE
R
D1EN CVREF pin
R
D1LPS
D1NSS = 1
VREF-
D1NSS = 0
FVR1S<1:0> 2
X1
X2 FVR
X4
+
FVR1EN 1.024V Fixed
FVR1ST _ Reference
PIC18F1XK50/
PIC18LF1XK50
CVREF
R(1)
Module
+
Voltage CVREF Buffered CVREF Output
–
Reference
Output
Impedance
Note 1: R is dependent upon the voltage reference Configuration bits, CVR<3:0> and CVRR.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: The output select bits are always right justified to ensure that any number of bits can be used without
affecting the register layout.
PIC18(L)F1XK50 Family
USB
SIE
256 byte
USB RAM
Note 1: The internal pull-up resistors should be disabled (UPUEN = 0) if external pull-up resistors are used.
2: PIC18F13K50 and PIC18F14K50 only.
Note 1: This bit cannot be set if the USB module does not have an appropriate clock source.
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 UPUEN, and FSEN bits should never be changed while the USB module is enabled. These values
must be preconfigured prior to enabling the module.
VUSB
1.5 k
D+
D-
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit is only valid for endpoints with available Even and Odd BD registers.
REGISTER 22-4: UEPn: USB ENDPOINT n CONTROL REGISTER (UEP0 THROUGH UEP7)
U-0 U-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
— — — EPHSHK EPCONDIS EPOUTEN EPINEN EPSTALL(1)
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
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 must be initialized by the user to the desired value prior to enabling the USB module.
2: This bit is ignored unless DTSEN = 1.
3: If these bits are set, USB communication may not work. Hence, these bits should always be maintained 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
Mode 3
Mode 0 Mode 1 Mode 2
Endpoint (Ping-Pong on all other EPs,
(No Ping-Pong) (Ping-Pong on EP0 OUT) (Ping-Pong on all EPs)
except EP0)
SOFIF
SOFIE
BTSEF
BTSEE TRNIF USBIF
TRNIE
BTOEF
BTOEE
IDLEIF
DFN8EF IDLEIE
DFN8EE UERRIF
CRC16EF UERRIE
CRC16EE
CRC5EF STALLIF
STALLIE
CRC5EE
PIDEF
PIDEE ACTVIF
ACTVIE
URSTIF
URSTIE
Control Transfer(1)
1 ms Frame
Note 1: The control transfer shown here is only an example showing events that can occur for every transaction. Typical control transfers
will spread across multiple frames.
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: Once an Idle state is detected, the user may want to place the USB module in Suspend mode.
2: Clearing this bit will cause the USTAT FIFO to advance (valid only for IN, OUT and SETUP tokens).
3: This bit is typically unmasked only following the detection of a UIDLE interrupt event.
4: Only error conditions enabled through the UEIE register will set this bit. This bit is a Status bit only and
cannot be set or cleared by the user.
C:
UCONbits.SUSPND = 0;
while (UIRbits.ACTVIF) { UIRbits.ACTVIF = 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 C = Clearable 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
VBUS VDD
VUSB
VSS
Legend: VUSB: Voltage applied to the VUSB pin in volts. (Should be 3.0V to 3.6V.)
PZERO: Percentage (in decimal) of the IN traffic bits sent by the PIC® device that are a value of ‘0’.
PIN: Percentage (in decimal) of total bus bandwidth that is used for IN traffic.
LCABLE: Length (in meters) of the USB cable. The USB 2.0 specification requires that full-speed applications
use cables no longer than 5m.
IPULLUP: Current which the nominal, 1.5 k pull-up resistor (when enabled) must supply to the USB cable. On
the host or hub end of the USB cable, 15 k nominal resistors (14.25 k to 24.8 k) are present which
pull both the D+ and D- lines to ground. During bus Idle conditions (such as between packets or during
USB Suspend mode), this results in up to 218 A of quiescent current drawn at 3.3V.
IPULLUP is also dependant on bus traffic conditions and can be as high as 2.2 mA when the USB bandwidth
is fully utilized (either IN or OUT traffic) for data that drives the lines to the “K” state most of the time.
The calculated value should be considered an approximation and additional guardband or application-specific prod-
uct testing is recommended. The transceiver current is “in addition to” the rest of the current consumed by the
PIC18(L)F1XK50 device that is needed to run the core, drive the other I/O lines, power the various modules, etc.
Device
Configuration
Interface Interface
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 23-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 23-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 23-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 23-3: STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION
FOR RCON REGISTER
Program RCON Register STKPTR Register
Condition
Counter SBOREN RI TO PD POR BOR STKFUL STKUNF
Power-on Reset 0000h 1 1 1 1 0 0 0 0
RESET Instruction 0000h u(2) 0 u u u u u u
(2)
Brown-out Reset 0000h u 1 1 1 u 0 u u
MCLR during Power-Managed 0000h u(2) u 1 u u u u u
Run Modes
MCLR during Power-Managed 0000h u(2) u 1 0 u u u u
Idle Modes and Sleep Mode
WDT Time-out during Full Power 0000h u(2) u 0 u u u u u
or Power-Managed Run Mode
MCLR during Full Power 0000h u(2) u u u u u u u
Execution
Stack Full Reset (STVREN = 1) 0000h u(2) u u u u u 1 u
Stack Underflow Reset 0000h u(2) u u u u u u 1
(STVREN = 1)
Stack Underflow Error (not an 0000h u(2) u u u u u u 1
actual Reset, STVREN = 0)
WDT Time-out during PC + 2 u(2) u 0 0 u u u u
Power-Managed Idle or Sleep
Modes
Interrupt Exit from PC + 2(1) u(2) u u 0 u u u u
Power-Managed Modes
Legend: u = unchanged
Note 1: When the wake-up is due to an interrupt and the GIEH or GIEL bits are set, the PC is loaded with the
interrupt vector (008h or 0018h).
2: Reset state is ‘1’ for 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
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 the 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.
24.3 Program Verification and Figure 24-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 24-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 mem-
ory is divided into individual blocks on binary boundar-
ies.
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) 14K50 13K50
BBSIZ = 1 BBSIZ = 0 BBSIZ = 1 BBSIZ = 0
0000h Boot Block, 2 KW Boot Block, 1 KW Boot Block, 1 KW Boot Block, 0.512 KW
01FFh CPB, WRTB, EBTRB CPB, WRTB, EBTRB CPB, WRTB, EBTRB CPB, WRTB, EBTRB
0200h Block 0
03FFh 1.512 KW
0400h Block 0 Block 0 CP0, WRT0, EBTR0
05FFh 3 KW 1 KW
0600h CP0, WRT0, EBTR0 CP0, WRT0, EBTR0
07FFh
0800h Block 0 Block 1 Block 1
0FFFh 2 KW 2 KW 2 KW
CP0, WRT0, EBTR0 CP1, WRT1, EBTR1 CP1, WRT1, EBTR1
1000h Block 1 Block 1 Reads all ‘0’s Reads all ‘0’s
1FFFh 4 KW 4 KW
CP1, WRT1, EBTR1 CP1, WRT1, EBTR1
2000h Reads all ‘0’s Reads all ‘0’s
27FFh
2800h
2FFFh
3000h
37FFh
3800h
3FFFh
4000h
47FFh
4800h
4FFFh
5000h
57FFh
5800h
5FFFh
6000h
67FFh
6800h
6FFFh
7000h
77FFh
7800h
7FFFh
8000h
FFFFh
Note: Refer to the test section for requirements on test memory mapping.
24.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 24-3 through 24-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 pro-
In normal execution mode, the CPn bits have no direct tection bits are only set to ‘1’ by a full chip
effect. CPn bits inhibit external reads and writes. A block erase or block erase function. The full chip
of user memory may be protected from table writes if the erase and block erase functions can only
WRTn Configuration bit is ‘0’. The EBTRn bits control 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 25-2,
lists the standard instructions recognized by the
1. The file register (specified by ‘f’) Microchip Assembler (MPASMTM).
2. The bit in the file register (specified by ‘b’)
Section 25.1.1 “Standard Instruction Set” provides
3. The accessed memory (specified by ‘a’) a description of each instruction.
The bit field designator ‘b’ selects the number of the bit
affected by the operation, while the file register
designator ‘f’ represents the number of the file in which
the bit is located.
Literal operations
15 8 7 0
OPCODE k (literal) MOVLW 7Fh
Control operations
CALL, GOTO and Branch operations
15 8 7 0
OPCODE n<7:0> (literal) GOTO Label
15 12 11 0
1111 n<19:8> (literal)
15 8 7 0
OPCODE S n<7:0> (literal) CALL MYFUNC
15 12 11 0
1111 n<19:8> (literal)
S = Fast bit
15 11 10 0
OPCODE n<10:0> (literal) BRA MYFUNC
15 8 7 0
OPCODE n<7:0> (literal) BC MYFUNC
BYTE-ORIENTED OPERATIONS
ADDWF f, d, a Add WREG and f 1 0010 01da0 ffff ffff C, DC, Z, OV, N 1, 2
ADDWFC f, d, a Add WREG and CARRY bit to f 1 0010 0da ffff ffff C, DC, Z, OV, N 1, 2
ANDWF f, d, a AND WREG with f 1 0001 01da ffff ffff Z, N 1,2
CLRF f, a Clear f 1 0110 101a ffff ffff Z 2
COMF f, d, a Complement f 1 0001 11da ffff ffff Z, N 1, 2
CPFSEQ f, a Compare f with WREG, skip = 1 (2 or 3) 0110 001a ffff ffff None 4
CPFSGT f, a Compare f with WREG, skip > 1 (2 or 3) 0110 010a ffff ffff None 4
CPFSLT f, a Compare f with WREG, skip < 1 (2 or 3) 0110 000a ffff ffff None 1, 2
DECF f, d, a Decrement f 1 0000 01da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
DECFSZ f, d, a Decrement f, Skip if 0 1 (2 or 3) 0010 11da ffff ffff None 1, 2, 3, 4
DCFSNZ f, d, a Decrement f, Skip if Not 0 1 (2 or 3) 0100 11da ffff ffff None 1, 2
INCF f, d, a Increment f 1 0010 10da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
INCFSZ f, d, a Increment f, Skip if 0 1 (2 or 3) 0011 11da ffff ffff None 4
INFSNZ f, d, a Increment f, Skip if Not 0 1 (2 or 3) 0100 10da ffff ffff None 1, 2
IORWF f, d, a Inclusive OR WREG with f 1 0001 00da ffff ffff Z, N 1, 2
MOVF f, d, a Move f 1 0101 00da ffff ffff Z, N 1
MOVFF fs, fd Move fs (source) to 1st word 2 1100 ffff ffff ffff None
fd (destination) 2nd word 1111 ffff ffff ffff
MOVWF f, a Move WREG to f 1 0110 111a ffff ffff None
MULWF f, a Multiply WREG with f 1 0000 001a ffff ffff None 1, 2
NEGF f, a Negate f 1 0110 110a ffff ffff C, DC, Z, OV, N
RLCF f, d, a Rotate Left f through Carry 1 0011 01da ffff ffff C, Z, N 1, 2
RLNCF f, d, a Rotate Left f (No Carry) 1 0100 01da ffff ffff Z, N
RRCF f, d, a Rotate Right f through Carry 1 0011 00da ffff ffff C, Z, N
RRNCF f, d, a Rotate Right f (No Carry) 1 0100 00da ffff ffff Z, N
SETF f, a Set f 1 0110 100a ffff ffff None 1, 2
SUBFWB f, d, a Subtract f from WREG with 1 0101 01da ffff ffff C, DC, Z, OV, N
borrow
SUBWF f, d, a Subtract WREG from f 1 0101 11da ffff ffff C, DC, Z, OV, N 1, 2
SUBWFB f, d, a Subtract WREG from f with 1 0101 10da ffff ffff C, DC, Z, OV, N
borrow
SWAPF f, d, a Swap nibbles in f 1 0011 10da ffff ffff None 4
TSTFSZ f, a Test f, skip if 0 1 (2 or 3) 0110 011a ffff ffff None 1, 2
XORWF f, d, a Exclusive OR WREG with f 1 0001 10da ffff ffff Z, N
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the
first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program memory
locations have a valid instruction.
BIT-ORIENTED OPERATIONS
BCF f, b, a Bit Clear f 1 1001 bbba ffff ffff None 1, 2
BSF f, b, a Bit Set f 1 1000 bbba ffff ffff None 1, 2
BTFSC f, b, a Bit Test f, Skip if Clear 1 (2 or 3) 1011 bbba ffff ffff None 3, 4
BTFSS f, b, a Bit Test f, Skip if Set 1 (2 or 3) 1010 bbba ffff ffff None 3, 4
BTG f, d, a Bit Toggle f 1 0111 bbba ffff ffff None 1, 2
CONTROL OPERATIONS
BC n Branch if Carry 1 (2) 1110 0010 nnnn nnnn None
BN n Branch if Negative 1 (2) 1110 0110 nnnn nnnn None
BNC n Branch if Not Carry 1 (2) 1110 0011 nnnn nnnn None
BNN n Branch if Not Negative 1 (2) 1110 0111 nnnn nnnn None
BNOV n Branch if Not Overflow 1 (2) 1110 0101 nnnn nnnn None
BNZ n Branch if Not Zero 1 (2) 1110 0001 nnnn nnnn None
BOV n Branch if Overflow 1 (2) 1110 0100 nnnn nnnn None
BRA n Branch Unconditionally 2 1101 0nnn nnnn nnnn None
BZ n Branch if Zero 1 (2) 1110 0000 nnnn nnnn None
CALL n, s Call subroutine 1st word 2 1110 110s kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
CLRWDT — Clear Watchdog Timer 1 0000 0000 0000 0100 TO, PD
DAW — Decimal Adjust WREG 1 0000 0000 0000 0111 C
GOTO n Go to address 1st word 2 1110 1111 kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
NOP — No Operation 1 0000 0000 0000 0000 None
NOP — No Operation 1 1111 xxxx xxxx xxxx None 4
POP — Pop top of return stack (TOS) 1 0000 0000 0000 0110 None
PUSH — Push top of return stack (TOS) 1 0000 0000 0000 0101 None
RCALL n Relative Call 2 1101 1nnn nnnn nnnn None
RESET Software device Reset 1 0000 0000 1111 1111 All
RETFIE s Return from interrupt enable 2 0000 0000 0001 000s GIE/GIEH,
PEIE/GIEL
RETLW k Return with literal in WREG 2 0000 1100 kkkk kkkk None
RETURN s Return from Subroutine 2 0000 0000 0001 001s None
SLEEP — Go into Standby mode 1 0000 0000 0000 0011 TO, PD
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the
first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program memory
locations have a valid instruction.
LITERAL OPERATIONS
ADDLW k Add literal and WREG 1 0000 1111 kkkk kkkk C, DC, Z, OV, N
ANDLW k AND literal with WREG 1 0000 1011 kkkk kkkk Z, N
IORLW k Inclusive OR literal with WREG 1 0000 1001 kkkk kkkk Z, N
LFSR f, k Move literal (12-bit) 2nd word 2 1110 1110 00ff kkkk None
to FSR(f) 1st word 1111 0000 kkkk kkkk
MOVLB k Move literal to BSR<3:0> 1 0000 0001 0000 kkkk None
MOVLW k Move literal to WREG 1 0000 1110 kkkk kkkk None
MULLW k Multiply literal with WREG 1 0000 1101 kkkk kkkk None
RETLW k Return with literal in WREG 2 0000 1100 kkkk kkkk None
SUBLW k Subtract WREG from literal 1 0000 1000 kkkk kkkk C, DC, Z, OV, N
XORLW k Exclusive OR literal with WREG 1 0000 1010 kkkk kkkk Z, N
DATA MEMORY PROGRAM MEMORY OPERATIONS
TBLRD* Table Read 2 0000 0000 0000 1000 None
TBLRD*+ Table Read with post-increment 0000 0000 0000 1001 None
TBLRD*- Table Read with post-decrement 0000 0000 0000 1010 None
TBLRD+* Table Read with pre-increment 0000 0000 0000 1011 None
TBLWT* Table Write 2 0000 0000 0000 1100 None
TBLWT*+ Table Write with post-increment 0000 0000 0000 1101 None
TBLWT*- Table Write with post-decrement 0000 0000 0000 1110 None
TBLWT+* Table Write with pre-increment 0000 0000 0000 1111 None
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the
first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program memory
locations have a valid instruction.
Q Cycle Activity:
Q1 Q2 Q3 Q4
Decode Read Process Write to
register ‘f’ Data destination
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction format then becomes: {label} instruction argument(s).
BTFSC Bit Test File, Skip if Clear BTFSS Bit Test File, Skip if Set
Syntax: BTFSC f, b {,a} Syntax: BTFSS f, b {,a}
Operands: 0 f 255 Operands: 0 f 255
0b7 0b<7
a [0,1] a [0,1]
Operation: skip if (f<b>) = 0 Operation: skip if (f<b>) = 1
Status Affected: None Status Affected: None
Encoding: 1011 bbba ffff ffff Encoding: 1010 bbba ffff ffff
Description: If bit ‘b’ in register ‘f’ is ‘0’, then the next Description: If bit ‘b’ in register ‘f’ is ‘1’, then the next
instruction is skipped. If bit ‘b’ is ‘0’, then instruction is skipped. If bit ‘b’ is ‘1’, then
the next instruction fetched during the the next instruction fetched during the
current instruction execution is discarded current instruction execution is discarded
and a NOP is executed instead, making and a NOP is executed instead, making
this a 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 25.2.3 “Byte-Oriented and See Section 25.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed Bit-Oriented Instructions in Indexed
Literal Offset Mode” for details. Literal Offset Mode” for details.
Words: 1 Words: 1
Cycles: 1(2) Cycles: 1(2)
Note: 3 cycles if skip and followed Note: 3 cycles if skip and followed
by a 2-word instruction. by a 2-word instruction.
Q Cycle Activity: Q Cycle Activity:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Decode Read Process No Decode Read Process No
register ‘f’ Data operation register ‘f’ Data operation
If skip: If skip:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
If skip and followed by 2-word instruction: If skip and followed by 2-word instruction:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
No No No No No No No No
operation operation operation operation operation operation operation operation
CPFSGT Compare f with W, skip if f > W CPFSLT Compare f with W, skip if f < W
Syntax: CPFSGT f {,a} Syntax: CPFSLT f {,a}
Operands: 0 f 255 Operands: 0 f 255
a [0,1] a [0,1]
Operation: (f) –W), Operation: (f) –W),
skip if (f) > (W) skip if (f) < (W)
(unsigned comparison) (unsigned comparison)
Status Affected: None Status Affected: None
Encoding: 0110 010a ffff ffff
Encoding: 0110 000a ffff ffff
Description: Compares the contents of data memory
Description: Compares the contents of data memory
location ‘f’ to the contents of the W by
location ‘f’ to the contents of W by
performing an unsigned subtraction.
performing an unsigned subtraction.
If the contents of ‘f’ are greater than the
If the contents of ‘f’ are less than the
contents of WREG, then the fetched
contents of W, then the fetched
instruction is discarded and a NOP is
instruction is discarded and a NOP is
executed instead, making this a
executed instead, making this a
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: 3 cycles if skip and followed
Section 25.2.3 “Byte-Oriented and by a 2-word instruction.
Bit-Oriented Instructions in Indexed
Literal Offset Mode” for details. Q Cycle Activity:
Words: 1 Q1 Q2 Q3 Q4
Cycles: 1(2) Decode Read Process No
Note: 3 cycles if skip and followed register ‘f’ Data operation
by a 2-word instruction. If skip:
Q Cycle Activity: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 No No No No
Decode Read Process No operation operation operation operation
register ‘f’ Data operation If skip and followed by 2-word instruction:
If skip: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 No No No No
No No No No operation operation operation operation
operation operation operation operation No No No No
If skip and followed by 2-word instruction: operation operation operation operation
Q1 Q2 Q3 Q4
No No No No
Example: HERE CPFSLT REG, 1
operation operation operation operation NLESS :
No No No No LESS :
operation operation operation operation
Before Instruction
PC = Address (HERE)
Example: HERE CPFSGT REG, 0 W = ?
NGREATER : After Instruction
GREATER :
If REG < W;
Before Instruction PC = Address (LESS)
PC = Address (HERE) If REG W;
W = ? PC = Address (NLESS)
After Instruction
If REG W;
PC = Address (GREATER)
If REG W;
PC = Address (NGREATER)
Q1 Q2 Q3 Q4 Q Cycle Activity:
Decode Read Process Write to Q1 Q2 Q3 Q4
register ‘f’ Data destination Decode Read Process Write to
If skip: register ‘f’ Data destination
Q1 Q2 Q3 Q4 If skip:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
If skip and followed by 2-word instruction: operation operation operation operation
Q1 Q2 Q3 Q4 If skip and followed by 2-word instruction:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
No No No No operation operation operation operation
operation operation operation operation No No No No
operation operation operation operation
Example: HERE DECFSZ CNT, 1, 1
GOTO LOOP Example: HERE DCFSNZ TEMP, 1, 0
CONTINUE ZERO :
NZERO :
Before Instruction
PC = Address (HERE) Before Instruction
After Instruction TEMP = ?
CNT = CNT - 1 After Instruction
If CNT = 0; TEMP = TEMP – 1,
PC = Address (CONTINUE) If TEMP = 0;
If CNT 0; PC = Address (ZERO)
PC = Address (HERE + 2) If TEMP 0;
PC = Address (NZERO)
POP Pop Top of Return Stack PUSH Push Top of Return Stack
Syntax: POP Syntax: PUSH
Operands: None Operands: None
Operation: (TOS) bit bucket Operation: (PC + 2) TOS
Status Affected: None Status Affected: None
Encoding: 0000 0000 0000 0110 Encoding: 0000 0000 0000 0101
Description: The TOS value is pulled off the return Description: The PC + 2 is pushed onto the top of
stack and is discarded. The TOS value the return stack. The previous TOS
then becomes the previous value that value is pushed down on the stack.
was pushed onto the return stack. This instruction allows implementing a
This instruction is provided to enable software stack by modifying TOS and
the user to properly manage the return then pushing it onto the return stack.
stack to incorporate a software stack.
Words: 1
Words: 1
Cycles: 1
Cycles: 1 Q Cycle Activity:
Q Cycle Activity: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 Decode PUSH No No
Decode No POP TOS No PC + 2 onto operation operation
operation value operation return stack
RLNCF Rotate Left f (No Carry) RRCF Rotate Right f through Carry
Syntax: RLNCF f {,d {,a}} Syntax: RRCF f {,d {,a}}
Operands: 0 f 255 Operands: 0 f 255
d [0,1] d [0,1]
a [0,1] a [0,1]
Operation: (f<n>) dest<n + 1>, Operation: (f<n>) dest<n – 1>,
(f<7>) dest<0> (f<0>) C,
Status Affected: N, Z (C) dest<7>
Status Affected: C, N, Z
Encoding: 0100 01da ffff ffff
Encoding: 0011 00da ffff ffff
Description: The contents of register ‘f’ are rotated
one bit to the left. If ‘d’ is ‘0’, the result Description: The contents of register ‘f’ are rotated
is placed in W. If ‘d’ is ‘1’, the result is one bit to the right through the CARRY
stored back in register ‘f’ (default). flag. If ‘d’ is ‘0’, the result is placed in W.
If ‘a’ is ‘0’, the Access Bank is selected. If ‘d’ is ‘1’, the result is placed back in
If ‘a’ is ‘1’, the BSR is used to select the register ‘f’ (default).
GPR bank (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 25.2.3 “Byte-Oriented and in Indexed Literal Offset Addressing
Bit-Oriented Instructions in Indexed mode whenever f 95 (5Fh). See
Literal Offset Mode” for details. Section 25.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed
register f
Literal Offset Mode” for details.
Words: 1 C register f
Cycles: 1
Words: 1
Q Cycle Activity:
Cycles: 1
Q1 Q2 Q3 Q4
Decode Read Process Write to Q Cycle Activity:
register ‘f’ Data destination Q1 Q2 Q3 Q4
Decode Read Process Write to
Example: RLNCF REG, 1, 0 register ‘f’ Data destination
Before Instruction
REG = 1010 1011 Example: RRCF REG, 0, 0
After Instruction Before Instruction
REG = 0101 0111 REG = 1110 0110
C = 0
After Instruction
REG = 1110 0110
W = 0111 0011
C = 0
ADDFSR Add Literal to FSR ADDULNK Add Literal to FSR2 and Return
Syntax: ADDFSR f, k Syntax: ADDULNK k
Operands: 0 k 63 Operands: 0 k 63
f [ 0, 1, 2 ] Operation: FSR2 + k FSR2,
Operation: FSR(f) + k FSR(f) (TOS) PC
Status Affected: None Status Affected: None
Encoding: 1110 1000 ffkk kkkk Encoding: 1110 1000 11kk kkkk
Description: The 6-bit literal ‘k’ is added to the Description: The 6-bit literal ‘k’ is added to the
contents of the FSR specified by ‘f’. contents of FSR2. A RETURN is then
Words: 1 executed by loading the PC with the
Cycles: 1 TOS.
The instruction takes two cycles to
Q Cycle Activity:
execute; a NOP is performed during
Q1 Q2 Q3 Q4 the second cycle.
Decode Read Process Write to This may be thought of as a special
literal ‘k’ Data FSR case of the ADDFSR instruction,
where f = 3 (binary ‘11’); it operates
only on FSR2.
Example: ADDFSR 2, 23h Words: 1
Before Instruction Cycles: 2
FSR2 = 03FFh
After Instruction
Q Cycle Activity:
FSR2 = 0422h
Q1 Q2 Q3 Q4
Decode Read Process Write to
literal ‘k’ Data FSR
No No No No
Operation Operation Operation Operation
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction syntax then becomes: {label} instruction argument(s).
MOVSS Move Indexed to Indexed PUSHL Store Literal at FSR2, Decrement FSR2
Syntax: MOVSS [zs], [zd] Syntax: PUSHL k
Operands: 0 zs 127 Operands: 0k 255
0 zd 127
Operation: k (FSR2),
Operation: ((FSR2) + zs) ((FSR2) + zd) FSR2 – 1 FSR2
Status Affected: None
Status Affected: None
Encoding:
Encoding: 1111 1010 kkkk kkkk
1st word (source) 1110 1011 1zzz zzzzs
2nd word (dest.) 1111 xxxx xzzz zzzzd Description: The 8-bit literal ‘k’ is written to the data
memory address specified by FSR2. FSR2
Description The contents of the source register are
is decremented by 1 after the operation.
moved to the destination register. The
This instruction allows users to push values
addresses of the source and destination
onto a software stack.
registers are determined by adding the
7-bit literal offsets ‘zs’ or ‘zd’, Words: 1
respectively, to the value of FSR2. Both
Cycles: 1
registers can be located anywhere in
the 4096-byte data memory space Q Cycle Activity:
(000h to FFFh). Q1 Q2 Q3 Q4
The MOVSS instruction cannot use the Decode Read ‘k’ Process Write to
PCL, TOSU, TOSH or TOSL as the data destination
destination register.
If the resultant source address points to
an indirect addressing register, the Example: PUSHL 08h
value returned will be 00h. If the
resultant destination address points to Before Instruction
an indirect addressing register, the FSR2H:FSR2L = 01ECh
Memory (01ECh) = 00h
instruction will execute as a NOP.
Words: 2 After Instruction
Cycles: 2 FSR2H:FSR2L = 01EBh
Memory (01ECh) = 08h
Q Cycle Activity:
Q1 Q2 Q3 Q4
Decode Determine Determine Read
source addr source addr source reg
Decode Determine Determine Write
dest addr dest addr to dest reg
SUBFSR Subtract Literal from FSR SUBULNK Subtract Literal from FSR2 and Return
Syntax: SUBFSR f, k Syntax: SUBULNK k
Operands: 0 k 63 Operands: 0 k 63
f [ 0, 1, 2 ] Operation: FSR2 – k FSR2
Operation: FSR(f) – k FSRf (TOS) PC
Status Affected: None Status Affected: None
Encoding: 1110 1001 ffkk kkkk Encoding: 1110 1001 11kk kkkk
Description: The 6-bit literal ‘k’ is subtracted from Description: The 6-bit literal ‘k’ is subtracted from the
the contents of the FSR specified by contents of the FSR2. A RETURN is then
‘f’. executed by loading the PC with the TOS.
Words: 1 The instruction takes two cycles to
execute; a NOP is performed during the
Cycles: 1
second cycle.
Q Cycle Activity: This may be thought of as a special case of
Q1 Q2 Q3 Q4 the SUBFSR instruction, where f = 3 (binary
Decode Read Process Write to ‘11’); it operates only on FSR2.
register ‘f’ Data destination Words: 1
Cycles: 2
Q Cycle Activity:
Example: SUBFSR 2, 23h
Before Instruction Q1 Q2 Q3 Q4
FSR2 = 03FFh Decode Read Process Write to
register ‘f’ Data destination
After Instruction
FSR2 = 03DCh No No No No
Operation Operation Operation Operation
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
† NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
VDD
VPOR
VPORR
VSS
NPOR(1)
POR REARM
VSS
TVLOW(3) TPOR(2)
— 26 48 A 5.0
D019 — 16 33 A 1.8 FOSC = 32 kHz
— 18 38 A 3.0 LFINTOSC Oscillator
CPU Idle
D019 — 18 35 A 1.8 FOSC = 32 kHz
— 20 40 A 3.0 LFINTOSC Oscillator
CPU Idle(5)
— 21 42 A 5.0
* 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: 330 nF capacitor on VUSB pin.
— 5.0 18 21 A 5.0
Power-down Module Current
D028 — 0.5 4.0 8.0 A 1.8 LPWDT Current(1)
— 0.8 5.0 10.0 A 3.0
D028 — 7 11 15 A 1.8 LPWDT Current(1)
— 10 15 18 A 3.0
— 11 20 23 A 5.0
D029 — 12 20 25 A 1.8 FVR current (3)
— 20 30 35 A 3.0
D029 — 28 42 50 A 1.8 FVR current(3, 5)
— 36 46 55 A 3.0
— 39 49 60 A 5.0
D030 — 6 15 20 A 3.0 BOR Current(1, 3)
D030 — 12 35 40 A 3.0 BOR Current(1, 3, 5)
— 14 40 45 A 5.0
D031 — 0.79 4.0 6.0 A 1.8 T1OSC Current(1)
— 1.8 5.0 7.0 A 3.0
D031 — 3.5 10 14 A 1.8 T1OSC Current(1)
— 4.0 14 17 A 3.0
— 5.0 19 22 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
5: 330 f capacitor on VUSB pin.
— 5.0 19 22 A 5.0
D033 — 14 38 44 A 1.8 Comparator Current, low power
— 15 40 47 A 3.0
D033 — 15 40 49 A 2.0 Comparator Current, low power
— 16 44 53 A 3.0
— 17 50 60 A 5.0
D033A — 115 239 244 A 1.8 Comparator Current, high power
— 120 242 249 A 3.0
D033A — 144 243 250 A 2.0 Comparator Current, high power
— 146 247 256 A 3.0
— 151 253 264 A 5.0
D034 — 11 20 25 A 1.8 Voltage Reference Current
— 20 30 35 A 3.0
D034 — 15 36 45 A 2.0 Voltage Reference Current
— 25 45 60 A 3.0
— 35 65 74 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
5: 330 f capacitor on VUSB pin.
Param.
Sym. Characteristic Min. Typ.† Max. Units Conditions
No.
VIL Input Low Voltage
I/O ports:
D036 with TTL buffer VSS — 0.8 V 4.5V VDD 5.5V
D036A VSS — 0.15 VDD V 1.8V VDD 4.5V
D036B VSS — 0.2 VDD V 2.0V VDD 5.5V
D037 with Schmitt Trigger buffer VSS — 0.2 VDD V 1.8V VDD 5.5V
D037A with I2C™ levels VSS — 0.3 VDD V
D037B with SMBus levels VSS — 0.8 VDD V 2.7V VDD 5.5V
D038 MCLR VSS — 0.2 VDD V
D039 OSC1 VSS — 0.3 VDD V HS, HSPLL modes
D039A OSC1 VSS — 0.2 VDD V EC, RC modes(1)
D039B OSC1 VSS — 0.3 VDD V XT, LP modes
D039C T1CKI VSS — 0.3 VDD V
VIH Input High Voltage
I/O ports:
D040 with TTL buffer 2.0 — VDD V 4.5V VDD 5.5V
D040A 0.25 VDD + — VDD V 1.8V VDD 4.5V
0.8
D041 with Schmitt Trigger buffer 0.8 VDD — VDD V 1.8V VDD 5.5V
D041A with I2C levels 0.7 VDD — VDD V
D037A with SMBus levels 2.1 — VDD V 2.7V VDD 5.5V
D042 MCLR 0.8 VDD — VDD V
D042A MCLR 0.9 VDD — 0.3 VDD V 1.8V VDD 2.4V
D043 OSC1 0.7 VDD — VDD V HS, HSPLL modes
D043A OSC1 0.8 VDD — VDD V EC mode
D043B OSC1 0.9 VDD — VDD V RC mode(1)
D043C OSC1 1.6 — VDD V XT, LP modes
D043E T1CKI 1.6 — VDD V
IIL Input Leakage Current(2)
D060 I/O ports — ±5 ± 100 nA VSS VPIN VDD, Pin at
high-impedance, -40°C to 85°C
— ±5 ± 1000 nA VSS VPIN VDD, 85°C to 125°C
D061 MCLR(3) — ± 50 ± 200 nA VSS VPIN VDD
IPUR PORTB Weak Pull-up Current
D070* 50 250 400 A VDD = 5.0V, VPIN = VSS
VOL Output Low Voltage(4)
D080 I/O ports VSS+0.6 IOL = 8 mA, VDD = 5V
— — VSS+0.6 V IOL = 6 mA, VDD = 3.3V
VSS+0.6 IOL = 3 mA, VDD = VDDMIN
* 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: In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended to use an external
clock in RC mode.
2: Negative current is defined as current sourced by the pin.
3: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent
normal operating conditions. Higher leakage current may be measured at different input voltages.
4: Including OSC2 in CLKOUT mode.
Param.
Sym. Characteristic Min. Typ.† Max. Units Conditions
No.
VOH Output High Voltage(4)
D090 I/O ports VDD-0.7 IOH = 3.5 mA, VDD = 5V
VDD-0.7 — — V IOH = 3 mA, VDD = 3.3V
VDD-0.7 IOH = 2 mA, VDD = VDDMIN
Capacitive Loading Specs on Output Pins
D101* COSC2 OSC2 pin — — 15 pF In XT, HS and LP modes when
external clock is used to drive
OSC1
D101A* CIO All I/O pins — — 50 pF
VUSB Capacitor Charging
D135 Charging current — 200 — mA
D135A Source/sink capability when — 0 — mA
charging complete
* 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: In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended to use an external
clock in RC mode.
2: Negative current is defined as current sourced by the pin.
3: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent
normal operating conditions. Higher leakage current may be measured at different input voltages.
4: Including OSC2 in CLKOUT mode.
TH01 JA Thermal Resistance Junction to 62.2 C/W 20-pin PDIP package
Ambient 77.7 C/W 20-pin SOIC package
87.3 C/W 20-pin SSOP package
36.1 C/W 20-pin QFN 5x5mm package
TH02 JC Thermal Resistance Junction to 27.5 C/W 20-pin PDIP package
Case 23.1 C/W 20-pin SOIC package
31.1 C/W 20-pin SSOP package
12.2 C/W 20-pin QFN 5x5mm package
TH03 TJMAX Maximum Junction Temperature 150 C
TH04 PD Power Dissipation — W PD = PINTERNAL + PI/O
TH05 PINTERNAL Internal Power Dissipation — W PINTERNAL = IDD x VDD(1)
TH06 PI/O I/O Power Dissipation — W PI/O = (IOL * VOL) + (IOH * (VDD - VOH))
TH07 PDER Derated Power — W PDER = PDMAX (TJ - TA)/JA(2)
Note 1: IDD is current to run the chip alone without driving any load on the output pins.
2: TA = Ambient Temperature, TJ = Junction Temperature
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)
5.5
3.6
VDD (V)
3.0
2.0
1.8
0 10 16 20 40 48
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 27-8 for each Oscillator mode’s supported frequencies.
3.6
VDD (V)
3.0
2.0
1.8
0 10 16 20 40 48
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 27-8 for each Oscillator mode’s supported frequencies.
FIGURE 27-6: HFINTOSC FREQUENCY ACCURACY OVER DEVICE VDD AND TEMPERATURE
125
± 5%
85
± 3%
Temperature (°C)
60
± 5% ± 2%
25
0
± 5%
-20
-40
1.8 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
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 27-12: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER,
AND BROWN-OUT RESET PARAMETERS
Standard Operating Conditions (unless otherwise stated)
Operating Temperature -40°C TA +125°C
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 High-Power mode;
VREF = VDD/2
— 12 ±80 mV Low-Power mode;
VREF = VDD/2
CM02 VICM Input Common Mode Voltage VSS — VDD V
CM03 CMRR Common Mode Rejection Ratio 55 — — dB
CM04 TRESP Response Time(1) — 200 400 ns
CM05 TMC2OV Comparator Mode Change to — — 10 s
Output Valid*
CM06 CHYSTER Comparator Hysteresis — 65 — mV
* 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 in High-Power mode.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
CV01* CLSB Step Size — VDD/2 — V Low Range (VRR = 1)
— 4 — V High Range (VRR = 0)
VDD/32
CV02* CACC Absolute Accuracy — — 1/4 LSb Low Range (VRR = 1)
— — 1/2 LSb High Range (VRR = 0)
CV03* CR Unit Resistor Value® — 2k —
CV04* CST Settling Time(1) — — 10 s
* These parameters are characterized but not tested.
Note 1: Settling time measured while CVRR = 1 and CVR3:CVR0 transitions from ‘0000’ to ‘1111’.
Param.
Sym. Characteristics Min. Typ. Max. Units Comments
No.
D003 VADFVR Fixed Voltage Reference Voltage -8 — 6 % VDD 2.5V
D004* SVDD VDD Rise Rate to ensure internal 0.05 — — V/ms See Section 23.3
Power-on Reset signal “Power-on Reset (POR)”
for details.
* These parameters are characterized but not tested.
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
18 1200
Max. Max: 85°C + 3ı
Max: 85°C + 3ı 4 MHz EXTRC
16
Typical: 25°C
1000
14
12 800
IDD (µA)
IDD (µA)
10 Typical
600
8 4 MHz XT
6 400
4
200 1 MHz XT
2
0 0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
FIGURE 28-1: IDD, LP Oscillator Mode, FIGURE 28-4: IDD Maximum, XT and
FOSC = 32 kHz, PIC18LF1XK50 Only. EXTRC Oscillator, PIC18LF1XK50 Only.
40 1200
Max: 85°C + 3ı Max. Typical: 25°C
Typical: 25°C 4 MHz EXTRC
35
1000
30
800
25
IDD (µA)
IDD (µA)
20 600
15 4 MHz XT
Typical
400
10
200
5 1 MHz XT
0 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
FIGURE 28-2: IDD, LP Oscillator Mode, FIGURE 28-5: IDD Typical, XT and EXTRC
FOSC = 32 kHz, PIC18F1XK50 Only. Oscillator, PIC18F1XK50 Only.
1000 1600
IDD (µA)
400 4 MHz XT
600
300
400
200
1 MHz XT 1 MHz XT
100 200
0 0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
FIGURE 28-3: IDD Typical, XT and EXTRC FIGURE 28-6: IDD Maximum, XT and
Oscillator, PIC18LF1XK50 Only. EXTRC Oscillator, PIC18F1XK50 Only.
400
800
Max: 85°C + 3ı
350 Typical: 25°C
4 MHz 700
4 MHz
300 600
250 500
IDD (µA)
IDD (µA)
200 400
150 300
100 200
1 MHz 1 MHz
50 100
0 0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
FIGURE 28-7: IDD Typical, EC Oscillator, FIGURE 28-10: IDD Maximum, EC Oscillator,
Medium-Power Mode, PIC18LF1XK50 Only. Medium-Power Mode, PIC18F1XK50 Only.
500 40
Max.
450 4 MHz
Max: 85°C + 3ı 35
400
30
350
25
300
IDD (µA)
IDD (µA)
250 20
Typical
200 15
150
10
1 MHz
100 Max: 85°C + 3ı
Typical: 25°C
5
50
0 0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
FIGURE 28-8: IDD Maximum, EC Oscillator, FIGURE 28-11: IDD, LFINTOSC Mode,
Medium-Power Mode, PIC18LF1XK50 Only. FOSC = 31 kHz, PIC18LF1XK50 Only.
500 45
0D[
450 Typical: 25°C 40
4 MHz
400
35
350
30
IDD (µA)
300
IDD (µA)
25
250
Typical
20
200
15
150
1 MHz 10
100
Max: 85°C + 3ı
5 Typical: 25°C
50
0 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5
FIGURE 28-9: IDD Typical, EC Oscillator, FIGURE 28-12: IDD, LFINTOSC Mode,
Medium-Power Mode, PIC18F1XK50 Only. FOSC = 31 kHz, PIC18F1XK50 Only.
700 6.0
Max.
500 4.0
Typical
IDD (MA)
IDD (µA)
8 MHz
400 3.0
300 2.0
1 MHz
200 1.0
100 0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
FIGURE 28-13: IDD, MFINTOSC Mode, FIGURE 28-16: IDD Maximum, HFINTOSC
FOSC = 500 kHz, PIC18LF1XK50 Only. Mode, PIC18LF1XK50 Only.
900 4.5
Max: 85°C + 3ı 16 MHz
Max.
800 Typical: 25°C 4.0
Typical: 25°C
700 3.5
3.0
600
Typical
IDD (µA)
IDD (MA)
2.5
8 MHz
500
2.0
400
1.5
300
1.0
200 1 MHz
0.5
100 0.0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
FIGURE 28-14: IDD, MFINTOSC Mode, FIGURE 28-17: IDD Typical, HFINTOSC
FOSC = 500 kHz, PIC18F1XK50 Only. Mode, PIC18F1XK50 Only.
4.0 7.0
16 MHz 16 MHz
3.5 Typical: 25°C 6.0 Max: 85°C + 3ı
3.0
5.0
2.5
IDD (MA)
8 MHz 4.0
IDD (MA)
8 MHz
2.0
3.0
1.5
1.0 2.0
1 MHz
1 MHz
0.5 1.0
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 0.0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
VDD (V)
FIGURE 28-15: IDD Typical, HFINTOSC FIGURE 28-18: IDD Maximum, HFINTOSC
Mode, PIC18LF1XK50 Only. Mode, PIC18F1XK50 Only.
6
50
Max: 85°C + 3ı
45 Typical: 25°C
5 Typical: 25°C
12 MHz 40
35
4
30
IPD (µA)
IDD (MA)
3 25
20 Max.
2 6 MHz
15
10
1 Typical
5
0 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
FIGURE 28-19: IDD Typical, HS Oscillator, FIGURE 28-22: IPD Base, Low-Power Sleep
PIC18F1XK50 Only. Mode, PIC18F1XK50 Only.
6.0 6
12 MHz Max.
Max: 85°C + 3ı
5.0 5 Max: 85°C + 3ı
Typical: 25°C
4.0 4
IPD (µA)
IDD (MA)
3.0 3
6 MHz
2.0 2
1 Typical
1.0
0
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
VDD (V)
FIGURE 28-20: IDD Maximum, HS Oscillator, FIGURE 28-23: IPD, Watchdog Timer
PIC18F1XK50 Only. (WDT), PIC18LF1XK50 Only.
2.50 25
Max: 85°C + 3ı
Max: 85°C + 3ı Typical: 25°C
Typical: 25°C
2.00 20
Max. Max.
1.50 15
IPD (µA)
IPD (µA)
Typical
1.00 10
0.50 5
Typical
0.00 0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
FIGURE 28-21: IPD Base, Low-Power Sleep FIGURE 28-24: IPD, Watchdog Timer
Mode, PIC18LF1XK50 Only. (WDT), PIC18F1XK50 Only.
25
5.0
Max.
4.5
Max. Max: 85°C + 3ı
20 Typical: 25°C
4.0
Typical 3.5
15
3.0
IPD (µA)
IPD (µA)
2.5
10 Typical
2.0
1.5
5 Max: 85°C + 3ı
Typical: 25°C 1.0
0.5
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
VDD (V)
FIGURE 28-25: IPD, Fixed Voltage FIGURE 28-28: IPD, Timer1 Oscillator,
Reference (FVR), PIC18LF1XK50 Only. FOSC = 32 kHz, PIC18LF1XK50 Only.
60 20
Max: 85°C + 3ı 18
Typical: 25°C Max. Max.
50
16
Typical 14
40
12
IPD (µA)
IPD (µA)
30 10
8
20
6 Typical
4 Max: 85°C + 3ı
10
Typical: 25°C
2
0 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
FIGURE 28-26: IPD, Fixed Voltage FIGURE 28-29: IPD, Timer1 Oscillator,
Reference (FVR), PIC18F1XK50 Only. FOSC = 32 kHz, PIC18F1XK50 Only.
45 45
Max.
40 40
Max.
35 35
30 30
IPD (µA)
25 25
IPD (µA)
20 20
Typical
15 15
Typical
10 10
Max: 85°C + 3ı
Typical: 25°C Max: 85°C + 3ı
5 5 Typical: 25°C
0 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
FIGURE 28-27: IPD, Brown-out Reset FIGURE 28-30: IPD, Comparator, Low-Power
(BOR), BORV = 1, PIC18F1XK50 Only. Mode (C x SP = 0), PIC18LF1XK50 Only.
60 6
Max: 125°C + 3ı
Typical: 25°C
50 5 Min: -45°C - 3ı
Max.
40 4
IPD (µA)
Min. (-40°C)
VOH (V)
30 3
Typical (25°C)
20 Typical 2
Max. (125°C)
10 Max: 85°C + 3ı 1
Typical: 25°C
0 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 -45 -40 -35 -30 -25 -20 -15 -10 -5 0
FIGURE 28-31: IPD, Comparator, Low-Power FIGURE 28-34: VOH vs. IOH, Over
Mode (C x SP = 0), PIC18F1XK50 Only. Temperature, VDD = 5.5V, PIC18F1XK50 Only.
300 5
200
Typical (25°C)
3
IPD (µA)
VOL (V)
150
Typical
Min. (-40°C)
2
100
Max: 85°C + 3ı
50 Typical: 25°C 1
0
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
0 10 20 30 40 50 60 70 80 90 100
VDD (V) IOL (mA)
FIGURE 28-32: IPD, Comparator, High-Power FIGURE 28-35: VOL vs. IOL, Over
Mode (C x SP = 1), PIC18LF1XK50 Only. Temperature, VDD = 5.5V, PIC18F1XK50 Only.
300
3.5
Max.
Max: 125°C + 3ı
250 3.0 Typical: 25°C
Min: -45°C - 3ı
200 2.5
VOH (V)
Typical
IPD (µA)
2.0
150
1.5
100
1.0
0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 0.0
-15 -13 -11 -9 -7 -5 -3 -1
VDD (V) IOH (mA)
FIGURE 28-33: IPD, Comparator, High-Power FIGURE 28-36: VOH vs. IOH, Over
Mode (C x SP = 1), PIC18F1XK50 Only. Temperature, VDD = 3.0V.
3.0 1.70
1.64 Typical
2.0
Voltage (V)
1.62
Max. (125°C) Typical (25°C) Min. (-40°C)
VOL (V)
Min.
1.5 1.60
1.58
1.0
1.56
Max: Typical + 3ı
1.54
Typical: 25°C
0.5 Min: Typical - 3ı
1.52
1.50
0.0
-60 -40 -20 0 20 40 60 80 100 120 140
0 5 10 15 20 25 30 35 40
Temperature (°C)
IOL (mA)
FIGURE 28-37: VOL vs. IOL, Over FIGURE 28-40: POR Release Voltage.
Temperature, VDD = 3.0V.
2.0 1.54
0.6 1.40
Min.
0.4 1.38
0.2 1.36
0.0 1.34
-4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 -60 -40 -20 0 20 40 60 80 100 120 140
Temperature (°C)
IOH (mA)
FIGURE 28-38: VOH vs. IOH, Over FIGURE 28-41: POR Rearm Voltage,
Temperature, VDD = 1.8V, PIC18LF1XK50 Only. PIC18F1XK50 Only.
2.00
1.8
1.2
Voltage (V)
Typical
1.0
VOL (V)
1.90
0.8
Max. (125°C) Typical (25°C) Min. (-40°C)
0.6
1.85 Min.
0.4 Max: Typical + 3ı
Min: Typical - 3ı
0.2
1.80
0.0 -60 -40 -20 0 20 40 60 80 100 120 140
0 1 2 3 4 5 6 7 8 9 10
IO/ (mA) Temperature (°C)
FIGURE 28-39: VOL vs. IOL, Over FIGURE 28-42: Brown-out Reset Voltage,
Temperature, VDD = 1.8V, PIC18LF1XK50 Only. BORV = 1, PIC18LF1XK50 Only.
60 2.80
50 Max. 2.75
Max: Typical + 3ı Max.
Typical: 25°C
40
Min: Typical - 3ı
Voltage (V)
2.70
Voltage (mV)
Typical Typical
30
2.65
Min.
20
Min.
Max: Typical + 3ı
2.60 Min: Typical - 3ı
10
0 2.55
-60 -40 -20 0 20 40 60 80 100 120 140 -60 -40 -20 0 20 40 60 80 100 120 140
2.60 90
80
2.55 Max. Min.
70
2.50 60
Voltage (V)
Voltage (mV)
Typical Typical
50
2.45
40 Max: Typical + 3ı
Min. Typical: 25°C
2.40 30 Min: Typical - 3ı
Max: Typical + 3ı 20
2.35 Max.
Min: Typical - 3ı
10
2.30 0
-60 -40 -20 0 20 40 60 80 100 120 140 -60 -40 -20 0 20 40 60 80 100 120 140
70 2.50
Max.
Max. Max: Typical + 3ı
60 2.40 Min: Typical - 3ı
Max: Typical + 3ı
50 Typical: 25°C
2.30
Min: Typical - 3ı
Typical
Voltage (mV)
Voltage (V)
40 2.20
Typical
30 2.10
20 2.00
Min.
Min.
10 1.90
0 1.80
-60 -40 -20 0 20 40 60 80 100 120 140 -60 -40 -20 0 20 40 60 80 100 120 140
45 350
Time (ns)
Voltage (mV)
200
25
Min. Typical
20 150
15
100
10 Max: Typical + 3ı
50 Typical: 25°C
5
0
0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
-60 -40 -20 0 20 40 60 80 100 120 140
VDD (V)
Temperature (°C)
400
80
250
Time (ns)
50
Max. (125°C)
200
40
Min.
30 150
Typical (25°C)
0 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
16 50
40
14 Max.
30
12
Max.
Typical 20
Hysteresis (mV)
10
10
Typical
8 0
Min.
6 -10
Min. -20
4
Max: Typical + 3ı -30 Max: Typical + 3ı
Typical: 25°C Typical: 25°C
2 Min: Typical - 3ı Min: Typical - 3ı
-40
0 -50
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 0.0 1.0 2.0 3.0 4.0 5.0
VDD (V) Common Mode Voltage (V)
20
40
15 Max: Typical + 3ı
35 Typical: statistical mean @ 25°C
Sink Typical Max.
Sink Max.
10
30
25
Time (us)
0
20
-5 Source Min.
15
Note:
The FVR Stabilization Period applies when:
-10 Source Max. 1) coming out of Reset or exiting Sleep mode for PIC1LFxxxx devices.
Source Typical 10
2) when exiting Sleep mode with VREGPM = 1 for PIC1Fxxxx devices
Max: Typical + 3ı
In all other cases, the FVR is stable when released from Reset.
-15 Typical:
Min: Typical - 3ı 5
-20
0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V) VDD (V)
FIGURE 28-55: CAP Sense Current Sink/ FIGURE 28-58: FVR Stabilization Period.
Source Characteristics, Fixed Voltage Reference
(CPSRM = 0), High-Current Range
(CPSRNG = 11).
5 8%
Max: Typical + 3ı
4 Typical: 6% Max: Typical + 3ı
Min: Typical - 3ı Typical: statistical mean Max.
Min: Typical - 3ı
3 Sink Max. 4%
Sink Typical
2 2%
Accuracy (%)
Sink Min.
IPIN (uA)
1
0% Typical
0
-2%
-1 Source Min.
-4%
-2
Source Typical Min.
-6%
-3 Source Max.
-8%
-4
-5 -10%
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 -50 0 50 100 150
FIGURE 28-56: CAP Sense Current Sink/ FIGURE 28-59: HFINTOSC Accuracy, Over
Source Characteristics, Fixed Voltage Reference Temperature, VDD = 1.8V, PIC18LF1XK50 Only.
(CPSRM = 0), Medium-Current Range
(CPSRNG = 10).
0.8 8%
2%
IPIN (uA)
0.0 Typical
0%
-0.2 Source Min.
-2% Min.
-0.4
Source Typical -4%
-0.6
Source Max.
-0.8 -6%
Max: Typical + 3ı
-1.0 Typical: -8%
Min: Typical - 3ı
-1.2 -10%
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 -50 0 50 100 150
FIGURE 28-57: CAP Sense Current Sink/ FIGURE 28-60: HFINTOSC Accuracy, Over
Source Characteristics, Fixed Voltage Reference Temperature, 2.3V VDD 5.5V.
(CPSRM = 0), Low-Current Range
(CPSRNG = 01).
36 5.0
34 4.5
Max.
Max.
4.0
32
3.5
30 Typical
Frequency (kHz)
Typical
Time (us)
3.0
28 2.5
26 Min. 2.0
1.5
24
Max: 85°C + 3ı
Max: Typical + 3ı (-40°C to +125°C) 1.0 Typical: 25°C
Typical: statistical mean @ 25°C
22 Min: Typical - 3ı (-40°C to +125°C)
0.5
20 0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V) VDD (V)
FIGURE 28-61: LFINTOSC Frequency, Over FIGURE 28-64: Sleep Mode, Wake Period
VDD and Temperature, PIC18LF1XK50 Only. with HFINTOSC Source, PIC18LF1XK50 Only.
36 35
34 Max.
Max. 30
32 Typical
25
30
Frequency (kHz)
15
26 Min.
24 10
Max: Typical + 3ı (-40°C to +125°C)
Typical: statistical mean @ 25°C Max: 85°C + 3ı
22 Min: Typical - 3ı (-40°C to +125°C) 5
Typical: 25°C
20 0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V) VDD (V)
FIGURE 28-62: LFINTOSC Frequency, Over FIGURE 28-65: Low-Power Sleep Mode,
VDD and Temperature, PIC18F1XK50 Only. Wake Period with HFINTOSC Source,
VREGPM = 1, PIC18F1XK50 Only.
110 12
100 Max.
10
Max.
90
8
Time (ms)
Time (us)
80 Typical Typical
6
70
Min. 4
60
40 0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V) VDD (V)
FIGURE 28-63: PWRT Period. FIGURE 28-66: Sleep Mode, Wake Period
with HFINTOSC Source, VREGPM = 0,
PIC18F1XK50 Only.
24
Max: Typical + 3ı (-40°C to +125°C)
Typical: statistical mean @ 25°C
22 Min: Typical - 3ı (-40°C to +125°C)
Max.
20
Time (ms)
18 Typical
16
14
Min.
12
10
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
XXXXXXXXXXXXXXXXX PIC18F14K50
XXXXXXXXXXXXXXXXX P
YYWWNNN 1443017
PIC18LF14K50
SO
1443017
PIC18LF13K50
SS
1443017
Note: In the event the full Microchip part number cannot be marked on one line, it will
be carried over to the next line, thus limiting the number of available
characters for customer-specific information.
PIN 1 PIN 1
F13K50
MQ
1443017
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
20-Lead Plastic Quad Flat, No Lead Package (MQ) – 5x5x0.9 mm Body [QFN]
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
Revision C (04/2009)
Revised data sheet title; Revised Features section;
Revised Table 1-2; Revised Table 3-1, Table 3-2;
Added Note 3 in Section 9.1; Revised Register 14-1;
Revised Example 16-1; Revised Section 18.8.4;
Revised Register 18-3; Revised Table 20-2; Revised
Sections 22.2.1, 22.2.2, 22.5.1.1, 22.7; Revised Tables
23-4, 27-1, 27-2, 27-3 27-4, 27-8.
Revision D (05/2010)
Revised the 20-pin PDIP, SSOP, SOIC Diagram;
Added the 20-pin QFN Diagram; Revised Table 1,
Table 1-1; Revised Figure 2-1; Added Note below Sec-
tion 2.11.1 (Low-Speed Operation); Revised Table 3-1,
Table 3-2; Revised Section 4 (Flash Program Memory)
and Section 5 (Data EEPROM Memory); Revised
Example 5-2, Table 5-1; Deleted Note 1 from Registers
7-4, 7-8; Revised Tables 9-1, 9-3; Revised Sections
14.1 (ECCP Outputs and Configuration), 14.4.4
(Enhanced PWM Auto-Shutdown Mode); Added Note 4
below Register 14-2; Revised Figure 14-10; Revised
Equation 17-1; Revised Table 18-3 and Table 20-3;
Revised Equation 21-1; Deleted Section 21.1.3 (Output
Clamped to VSS); Revised Figure 21-1; Revised Table
21-1, Table 23-4 and Table 24-1; Added Note 2 to Table
24-1; Revised Register 24-6; Deleted Note 1 from
Table 24-3; Revised Section 27 (tables); Added 20-
Lead QFN Package Marking Information and Package
Details; Revised the Product Identification System Sec-
tion; Other minor corrections.
Revision E (10/2010)
Updated Section 27.0 Electrical Specifications.
Revision F (04/2015)
Updated Figures 1, 2 and 22-5, Table 1, Register 14-2;
Updated note in Section 2.11.1; Updated Section 7.2
(Interrupt Priority), Section 27.0 (Electrical
Specifications), Section 29.0 (Packaging Information)
and the Product Identification System page; Added
graphs in Section 28.0 (DC and AC Characteristics
Graphs and Charts); Changed data sheet status from
Preliminary to Final; Other minor corrections.
Program Memory 8192 16384 32768 65536 8192 16384 32768 65536
(Bytes)
Program Memory 4096 8192 16384 32768 4096 8192 16384 32768
(Instructions)
Interrupt Sources 19 19 19 19 20 20 20 20
I/O Ports Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C, Ports A, B, C,
(E) (E) (E) (E) D, E D, E D, E D, E
Capture/Compare/ 1 1 1 1 1 1 1 1
PWM Modules
Enhanced 1 1 1 1 1 1 1 1
Capture/Compare/
PWM Modules
Parallel No No No No Yes Yes Yes Yes
Communications
(PSP)
10-bit Analog-to- 11 input 11 input 11 input 11 input 14 input 14 input 14 input 14 input
Digital Module channels channels channels channels channels channels channels channels
Packages 20-pin PDIP 20-pin PDIP 20-pin PDIP 28-pin PDIP 20-pin PDIP 40-pin PDIP 40-pin PDIP 40-pin PDIP
20-pin SOIC 20-pin SOIC 20-pin SOIC 28-pin SOIC 20-pin SOIC 44-pin TQFP 44-pin TQFP 44-pin TQFP
20-pin SSOP 20-pin SSOP 20-pin SSOP 28-pin SSOP 20-pin SSOP 44-pin QFN 44-pin QFN 44-pin QFN
20-pin QFN 20-pin QFN 20-pin QFN 28-pin QFN 20-pin QFN
Package: P = PDIP
SO = SOIC Note 1: Tape and Reel identifier only appears in the
SS = SSOP catalog part number description. This identi-
MQ = QFN fier is used for ordering purposes and is not
printed on the device package. Check with
your Microchip Sales Office for package
Pattern: QTP, SQTP, Code or Special Requirements availability with the Tape and Reel option.
(blank otherwise)
• 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.