Professional Documents
Culture Documents
PIC18F4525
PIC18F4525
PIC18F4525
Data Sheet
28/40/44-Pin
Enhanced Flash Microcontrollers
with 10-Bit A/D and nanoWatt Technology
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
MCLR/VPP/RE3 1 28 RB7/KBI3/PGD
RA0/AN0 2 27 RB6/KBI2/PGC
RA1/AN1 3 26 RB5/KBI1/PGM
RA2/AN2/VREF-/CVREF 4 25 RB4/KBI0/AN11
RA3/AN3/VREF+ 5 24 RB3/AN9/CCP2(1)
PIC18F2525
PIC18F2620
RA4/T0CKI/C1OUT 6 23 RB2/INT2/AN8
RA5/AN4/SS/HLVDIN/C2OUT 7 22 RB1/INT1/AN10
VSS 8 21 RB0/INT0/FLT0/AN12
OSC1/CLKI/RA7 9 20 VDD
OSC2/CLKO/RA6 10 19 VSS
RC0/T1OSO/T13CKI 11 18 RC7/RX/DT
RC1/T1OSI/CCP2(1) 12 17 RC6/TX/CK
RC2/CCP1 13 16 RC5/SDO
RC3/SCK/SCL 14 15 RC4/SDI/SDA
40-Pin PDIP
MCLR/VPP/RE3 1 40 RB7/KBI3/PGD
RA0/AN0 2 39 RB6/KBI2/PGC
RA1/AN1 3 38 RB5/KBI1/PGM
RA2/AN2/VREF-/CVREF 4 37 RB4/KBI0/AN11
RA3/AN3/VREF+ 5 36 RB3/AN9/CCP2(1)
RA4/T0CKI/C1OUT 6 35 RB2/INT2/AN8
RA5/AN4/SS/HLVDIN/C2OUT 7 34 RB1/INT1/AN10
PIC18F4525
PIC18F4620
RE0/RD/AN5 8 33 RB0/INT0/FLT0/AN12
RE1/WR/AN6 9 32 VDD
RE2/CS/AN7 10 31 VSS
VDD 11 30 RD7/PSP7/P1D
VSS 12 29 RD6/PSP6/P1C
OSC1/CLKI/RA7 13 28 RD5/PSP5/P1B
OSC2/CLKO/RA6 14 27 RD4/PSP4
RC0/T1OSO/T13CKI 15 26 RC7/RX/DT
RC1/T1OSI/CCP2(1) 16 25 RC6/TX/CK
RC2/CCP1/P1A 17 24 RC5/SDO
RC3/SCK/SCL 18 23 RC4/SDI/SDA
RD0/PSP0 19 22 RD3/PSP3
RD1/PSP1 20 21 RD2/PSP2
RC1/T1OSI/CCP2(1)
44-Pin TQFP
RC2/CCP1/P1A
RC3/SCK/SCL
RC4/SDI/SDA
RC6/TX/CK
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC5/SDO
NC
44
43
42
41
40
39
38
37
36
35
34
RC7/RX/DT 1 33 NC
RD4/PSP4 2 32 RC0/T1OSO/T13CKI
RD5/PSP5/P1B 3 31 OSC2/CLKO/RA6
RD6/PSP6/P1C 4 30 OSC1/CLKI/RA7
RD7/PSP7/P1D 5 PIC18F4525 29 VSS
VSS 6 28 VDD
VDD 7
PIC18F4620 27 RE2/CS/AN7
RB0/INT0/FLT0/AN12 8 26 RE1/WR/AN6
RB1/INT1/AN10 9 25 RE0/RD/AN5
RB2/INT2/AN8 10 24 RA5/AN4/SS/HLVDIN/C2OUT
RB3/AN9/CCP2(1) 11 23 RA4/T0CKI/C1OUT
12
13
14
15
16
17
18
19
20
21
22
RC1/T1OSI/CCP2(1) RA2/AN2/VREF-/CVREF
RB5/KBI1/PGM
RB4/KBI0/AN11
MCLR/VPP/RE3
RA0/AN0
RA1/AN1
NC
NC
RB6/KBI2/PGC
RB7/KBI3/PGD
RC0/T1OSO/T13CKI RA3/AN3/VREF+
RC2/CCP1/P1A
RC3/SCK/SCL
RC4/SDI/SDA
RC6/TX/CK
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC5/SDO
44-Pin QFN(2)
44
43
42
41
40
39
38
37
36
35
34
RC7/RX/DT 1 33 OSC2/CLKO/RA6
RD4/PSP4 2 32 OSC1/CLKI/RA7
RD5/PSP5/P1B 3 31 VSS
RD6/PSP6/P1C 4 30 VSS
RD7/PSP7/P1D 5 PIC18F4525 29 VDD
VSS 6 28 VDD
VDD 7
PIC18F4620 27 RE2/CS/AN7
VDD 8 26 RE1/WR/AN6
RB0/INT0/FLT0/AN12 9 25 RE0/RD/AN5
RB1/INT1/AN10 10 24 RA5/AN4/SS/HLVDIN/C2OUT
RB2/INT2/AN8 11 23 RA4/T0CKI/C1OUT
12
13
14
15
16
17
18
19
20
21
22
RA2/AN2/VREF-/CVREF
NC
RB6/KBI2/PGC
RB7/KBI3/PGD
RA3/AN3/VREF+
RB3/AN9/CCP2(1)
RB5/KBI1/PGM
RB4/KBI0/AN11
MCLR/VPP/RE3
RA0/AN0
RA1/AN1
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.
8
Instruction State Machine
Decode & Control Signals
Control
PRODH PRODL
PORTC
8 x 8 Multiply RC0/T1OSO/T13CKI
3 8 RC1/T1OSI/CCP2(1)
RC2/CCP1
BITOP W RC3/SCK/SCL
8 8 8
RC4/SDI/SDA
RC5/SDO
OSC1(3) Internal Power-up RC6/TX/CK
Oscillator Timer 8 8
Block RC7/RX/DT
(3) Oscillator
OSC2 ALU<8>
INTRC Start-up Timer
T1OSI Oscillator Power-on 8
Reset
8 MHz
T1OSO Oscillator Watchdog
Timer
Precision
Single-Supply Brown-out Band Gap
MCLR(2) PORTE
Programming Reset Reference
In-Circuit Fail-Safe
VDD, VSS Clock Monitor
Debugger MCLR/VPP/RE3(2)
BOR Data
EEPROM Timer0 Timer1 Timer2 Timer3
LVD
ADC
Comparator CCP1 CCP2 MSSP EUSART 10-Bit
Note 1: CCP2 is multiplexed with RC1 when Configuration bit, CCP2MX, is set, or RB3 when CCP2MX is not set.
2: RE3 is only available when MCLR functionality is disabled.
3: OSC1/CLKI and OSC2/CLKO are only available in select oscillator modes and when these pins are not being used as digital I/O.
Refer to Section 2.0 “Oscillator Configurations” for additional information.
Data Bus<8>
Table Pointer<21> PORTA
RA0/AN0
Data Latch RA1/AN1
inc/dec logic 8 8
RA2/AN2/VREF-/CVREF
Data Memory RA3/AN3/VREF+
PCLATU PCLATH (3.9 Kbytes) RA4/T0CKI/C1OUT
21
RA5/AN4/SS/HLVDIN/C2OUT
20 Address Latch
PCU PCH PCL OSC2/CLKO(3)/RA6
OSC1/CLKI(3)/RA7
Program Counter 12
Data Address<12>
PORTB
31 Level Stack RB0/INT0/FLT0/AN12
Address Latch 4 12 4
RB1/INT1/AN10
BSR Access
Program Memory STKPTR FSR0 Bank RB2/INT2/AN8
(48/64 Kbytes) FSR1 RB3/AN9/CCP2(1)
Data Latch FSR2 12 RB4/KBI0/AN11
RB5/KBI1/PGM
RB6/KBI2/PGC
inc/dec
8 logic RB7/KBI3/PGD
Table Latch
8 x 8 Multiply
3 8 PORTD
RD0/PSP0:RD4/PSP4
BITOP W
8 RD5/PSP5/P1B
8 8
RD6/PSP6/P1C
OSC1(3) Internal RD7/PSP7/P1D
Power-up
Oscillator Timer 8 8
Block
OSC2(3) Oscillator ALU<8>
INTRC Start-up Timer
T1OSI Oscillator Power-on 8
Reset
8 MHz
T1OSO Oscillator Watchdog PORTE
Timer
Precision RE0/RD/AN5
Single-Supply Brown-out Band Gap RE1/WR/AN6
MCLR(2) Reset
Programming Reference RE2/CS/AN7
In-Circuit Fail-Safe MCLR/VPP/RE3(2)
VDD, VSS Debugger Clock Monitor
BOR Data
EEPROM Timer0 Timer1 Timer2 Timer3
LVD
ADC
Comparator ECCP1 CCP2 MSSP EUSART 10-Bit
Note 1: CCP2 is multiplexed with RC1 when Configuration bit, CCP2MX, is set, or RB3 when CCP2MX is not set.
2: RE3 is only available when MCLR functionality is disabled.
3: OSC1/CLKI and OSC2/CLKO are only available in select oscillator modes and when these pins are not being used as digital I/O.
Refer to Section 2.0 “Oscillator Configurations” for additional information.
CEXT Loop
PIC18FXXXX Filter
VSS
OSC2/CLKO
FOSC/4
÷4 VCO
Recommended values: 3 kΩ ≤ REXT ≤ 100 kΩ SYSCLK
MUX
CEXT > 20 pF
CEXT
PIC18FXXXX
VSS
RA6 I/O (OSC2)
Legend:
R = Readable bit W = 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: Available only in certain oscillator configurations; otherwise, this bit is unavailable and reads as ‘0’. See
Section 2.6.4 “PLL in INTOSC Modes” for details.
2.6.5.1 Compensating with the EUSART 2.6.5.3 Compensating with the CCP Module
An adjustment may be required when the EUSART in Capture Mode
begins to generate framing errors or receives data with A CCP module can use free-running Timer1 (or
errors while in Asynchronous mode. Framing errors Timer3), clocked by the internal oscillator block and an
indicate that the device clock frequency is too high; to external event with a known period (i.e., AC power
adjust for this, decrement the value in OSCTUNE to frequency). The time of the first event is captured in the
reduce the clock frequency. On the other hand, errors CCPRxH:CCPRxL registers and is recorded for use
in data may suggest that the clock speed is too low; to later. When the second event causes a capture, the
compensate, increment OSCTUNE to increase the time of the first event is subtracted from the time of the
clock frequency. second event. Since the period of the external event is
known, the time difference between events can be
2.6.5.2 Compensating with the Timers calculated.
This technique compares device clock speed to some If the measured time is much greater than the
reference clock. Two timers may be used; one timer is calculated time, the internal oscillator block is running
clocked by the peripheral clock, while the other is too fast; to compensate, decrement the OSCTUNE
clocked by a fixed reference source, such as the register. If the measured time is much less than the
Timer1 oscillator. calculated time, the internal oscillator block is running
Both timers are cleared, but the timer clocked by the too slow; to compensate, increment the OSCTUNE
reference generates interrupts. When an interrupt register.
occurs, the internally clocked timer is read and both
timers are cleared. If the internally clocked timer value
is greater than expected, then the internal oscillator
block is running too fast. To adjust for this, decrement
the OSCTUNE register.
PIC18F2525/2620/4525/4620
Primary Oscillator LP, XT, HS, RC, EC
OSC2
T1OSO
T1OSCEN
Enable
T1OSI Oscillator OSCCON<6:4> Internal Oscillator
OSCCON<6:4> 8 MHz CPU
111
4 MHz
Internal 110
Oscillator 2 MHz IDLEN
Block 101
Postscaler
1 MHz Clock
Control
MUX
8 MHz 100
Source 500 kHz
8 MHz 011
(INTOSC) 250 kHz
INTRC 010 FOSC3:FOSC0 OSCCON<1:0>
Source 125 kHz
001
1 31 kHz Clock Source Option
31 kHz (INTRC) 000 for Other Modules
0
OSCTUNE<7>
WDT, PWRT, FSCM
and Two-Speed Start-up
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T1OSI 1 2 3 n-1 n
Clock Transition(1)
OSC1
CPU
Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
FIGURE 3-2: TRANSITION TIMING FROM SEC_RUN MODE TO PRI_RUN MODE (HSPLL)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
T1OSI
OSC1
TOST(1) TPLL(1)
1 2 n-1 n
PLL Clock
Output
Clock
Transition(2)
CPU Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
2: Clock transition typically occurs within 2-4 TOSC.
3.2.3 RC_RUN MODE This mode is entered by setting the SCS1 bit to ‘1’.
Although it is ignored, it is recommended that the SCS0
In RC_RUN mode, the CPU and peripherals are
bit also be cleared; this is to maintain software compat-
clocked from the internal oscillator block using the
ibility with future devices. When the clock source is
INTOSC multiplexer. In this mode, the primary clock is
switched to the INTOSC multiplexer (see Figure 3-3),
shut down. When using the INTRC source, this mode
the primary oscillator is shut down and the OSTS bit is
provides the best power conservation of all the Run
cleared. The IRCF bits may be modified at any time to
modes, while still executing code. It works well for user
immediately change the clock speed.
applications which are not highly timing sensitive or do
not require high-speed clocks at all times. Note: Caution should be used when modifying a
If the primary clock source is the internal oscillator block single IRCF bit. If VDD is less than 3V, it is
(either INTRC or INTOSC), there are no distinguishable possible to select a higher clock speed
differences between PRI_RUN and RC_RUN modes than is supported by the low VDD.
during execution. However, a clock switch delay will Improper device operation may result if
occur during entry to and exit from RC_RUN mode. the VDD/FOSC specifications are violated.
Therefore, if the primary clock source is the internal
oscillator block, the use of RC_RUN mode is not
recommended.
INTRC 1 2 3 n-1 n
CPU
Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
INTOSC
Multiplexer
OSC1
TOST(1) TPLL(1)
1 2 n-1 n
PLL Clock
Output
Clock
Transition(2)
CPU Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
2: Clock transition typically occurs within 2-4 TOSC.
OSC1
CPU
Clock
Peripheral
Clock
Sleep
Program
Counter PC PC + 2
OSC1
TOST(1) TPLL(1)
PLL Clock
Output
CPU Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4 PC + 6
Q1 Q2 Q3 Q4 Q1
OSC1
CPU Clock
Peripheral
Clock
Program PC PC + 2
Counter
FIGURE 3-8: TRANSITION TIMING FOR WAKE FROM IDLE TO RUN MODE
Q1 Q2 Q3 Q4
OSC1
TCSD
CPU Clock
Peripheral
Clock
Program
Counter PC
Wake Event
TABLE 3-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
INTOSC(2) IOFS
LP, XT, HS TOST(3)
HSPLL TOST + trc(3) OSTS
T1OSC
EC, RC TCSD(1)
INTOSC(2) TIOBST(4) IOFS
LP, XT, HS TOST(3)
HSPLL TOST + trc(3) OSTS
INTOSC(3)
EC, RC TCSD(1)
INTOSC(2) None IOFS
LP, XT, HS TOST(3)
None HSPLL TOST + trc(3) OSTS
(Sleep mode) EC, RC TCSD(1)
INTOSC(2) TIOBST(4) IOFS
Note 1: TCSD (parameter 38) is a required delay when waking from Sleep and all Idle modes and runs concurrently
with any other required delays (see Section 3.4 “Idle Modes”). On Reset, INTOSC defaults to 1 MHz.
2: Includes both the INTOSC 8 MHz source and postscaler derived frequencies.
3: TOST is the Oscillator Start-up Timer (parameter 32). trc is the PLL Lock-out Timer (parameter F12); it is
also designated as TPLL.
4: Execution continues during TIOBST (parameter 39), the INTOSC stabilization period.
External Reset
MCLRE
MCLR
( )_IDLE
Sleep
WDT
Time-out
OST/PWRT
OST 1024 Cycles
Chip_Reset
10-bit Ripple Counter R Q
OSC1
32 μs PWRT 65.5 ms
(1)
INTRC 11-bit Ripple Counter
Enable PWRT
Enable OST(2)
Note 1: This is the INTRC source from the internal oscillator block and is separate from the RC oscillator of the CLKI pin.
2: See Table 4-2 for time-out situations.
Legend:
R = Readable bit W = 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: It is recommended that the POR bit be set after a Power-on Reset has been detected so that subsequent
Power-on Resets may be detected.
2: Brown-out Reset is said to have occurred when BOR is ‘0’ and POR is ‘1’ (assuming that POR was set to
‘1’ by software immediately after Power-on Reset).
4.5.2 OSCILLATOR START-UP TIMER Since the time-outs occur from the POR pulse, if MCLR
is kept low long enough, all time-outs will expire. Bring-
(OST)
ing MCLR high will begin execution immediately
The Oscillator Start-up Timer (OST) provides a (Figure 4-5). This is useful for testing purposes or to
1024 oscillator cycle (from OSC1 input) delay after the synchronize more than one PIC18FXXXX device
PWRT delay is over (parameter 33). This ensures that operating in parallel.
the crystal oscillator or resonator has started and
stabilized.
The OST time-out is invoked only for XT, LP, HS and
HSPLL modes and only on Power-on Reset, or on exit
from most power-managed modes.
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) — —
INTIO1, INTIO2 66 ms(1) — —
Note 1: 66 ms (65.5 ms) is the nominal Power-up Timer (PWRT) delay.
2: 2 ms is the nominal time required for the PLL to lock.
VDD
MCLR
INTERNAL POR
TPWRT
OST TIME-OUT
INTERNAL RESET
FIGURE 4-4: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 1
VDD
MCLR
INTERNAL POR
TPWRT
OST TIME-OUT
INTERNAL RESET
FIGURE 4-5: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 2
VDD
MCLR
INTERNAL POR
TPWRT
OST TIME-OUT
INTERNAL RESET
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-7: TIME-OUT SEQUENCE ON POR W/PLL ENABLED (MCLR TIED TO VDD)
VDD
MCLR
INTERNAL POR
TPWRT
PLL TIME-OUT
INTERNAL RESET
TABLE 4-3: STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION
FOR RCON REGISTER
Program RCON Register STKPTR Register
Condition
Counter SBOREN RI TO PD POR BOR STKFUL STKUNF
Power-on Reset 0000h 1 1 1 1 0 0 0 0
RESET Instruction 0000h u(2) 0 u u u u u u
Brown-out Reset 0000h u(2) 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
(2)
Stack Underflow Reset 0000h u 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
(BOREN1:BOREN0 Configuration bits = 01 and SBOREN = 1); otherwise, the Reset state is ‘0’.
FIGURE 5-1: PROGRAM MEMORY MAP AND STACK FOR PIC18F2525/2620/4525/4620 DEVICES
PIC18FX525 PIC18FX620
PC<20:0> PC<20:0>
CALL,RCALL,RETURN 21 CALL,RCALL,RETURN 21
RETFIE,RETLW RETFIE,RETLW
Stack Level 1 Stack Level 1
• •
• •
• •
Stack Level 31 Stack Level 31
On-Chip
Program Memory On-Chip
Program Memory
BFFFh
C000h
User Memory Space
1FFFFFh 1FFFFFh
200000h 200000h
11111
11110
Top-of-Stack Registers 11101 Stack Pointer
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/CLKO
(RC mode)
Execute INST (PC – 2)
Fetch INST (PC) Execute INST (PC)
Fetch INST (PC + 2) Execute INST (PC + 2)
Fetch INST (PC + 4)
All instructions are single cycle, except for any program branches. These take two cycles since the fetch instruction
is “flushed” from the pipeline while the new instruction is being fetched and then executed.
5.2.4 TWO-WORD INSTRUCTIONS the instruction sequence. If the first word is skipped for
some reason and the second word is executed by itself,
The standard PIC18 instruction set has four two-word
a NOP is executed instead. This is necessary for cases
instructions: CALL, MOVFF, GOTO and LSFR. In all
when the two-word instruction is preceded by a condi-
cases, the second word of the instructions always has
tional instruction that changes the PC. Example 5-4
‘1111’ as its four Most Significant bits; the other 12 bits
shows how this works.
are literal data, usually a data memory address.
The use of ‘1111’ in the 4 MSbs of an instruction spec- Note: See Section 5.6 “PIC18 Instruction
ifies a special form of NOP. If the instruction is executed Execution and the Extended Instruc-
in proper sequence – immediately after the first word – tion Set” for information on two-word
the data in the second word is accessed and used by 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 07Fh
Bank 0 The first 128 bytes are
GPR 080h
FFh 0FFh general purpose RAM
00h 100h (from Bank 0).
= 0001
Bank 1 GPR The second 128 bytes are
FFh 1FFh Special Function Registers
= 0010 00h 200h (from Bank 15).
Bank 2 GPR
FFh 2FFh When a = 1:
= 0011 00h 300h
Bank 3 The BSR specifies the Bank
GPR
used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4 GPR
FFh 4FFh
= 0101 00h 500h
Bank 5 GPR
FFh 5FFh
= 0110 00h 600h
Bank 6 GPR
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 GPR Access RAM Low
7Fh
FFh 7FFh Access RAM High 80h
= 1000 00h 800h (SFRs)
Bank 8 FFh
GPR
FFh 8FFh
= 1001 00h 900h
Bank 9 GPR
FFh 9FFh
00h A00h
= 1010
Bank 10 GPR
FFh AFFh
= 1011 00h B00h
Bank 11 GPR
FFh BFFh
= 1100 00h C00h
Bank 12 GPR
FFh CFFh
= 1101 D00h
Bank 13 00h GPR
FFh DFFh
00h E00h
= 1110
Bank 14 GPR
FFh EFFh
00h GPR F00h
= 1111 F7Fh
Bank 15
SFR F80h
FFh FFFh
Bank 3
through
Bank 13
FFh
E00h
00h
Bank 14
F00h FFh
00h
Bank 15
FFFh FFh
Note 1: The Access RAM bit of the instruction can be used to force an override of the selected bank (BSR<3:0>) to
the registers of the Access Bank.
2: The MOVFF instruction embeds the entire 12-bit address in the instruction.
5.3.2 ACCESS BANK however, the instruction is forced to use the Access
Bank address map; the current value of the BSR is
While the use of the BSR with an embedded 8-bit
ignored entirely.
address allows users to address the entire range of
data memory, it also means that the user must always Using this “forced” addressing allows the instruction to
ensure that the correct bank is selected. Otherwise, operate on a data address in a single cycle, without
data may be read from or written to the wrong location. updating the BSR first. For 8-bit addresses of 80h and
This can be disastrous if a GPR is the intended target above, this means that users can evaluate and operate
of an operation, but an SFR is written to instead. on SFRs more efficiently. The Access RAM below 80h
Verifying and/or changing the BSR for each read or is a good place for data values that the user might need
write to data memory can become very inefficient. to access rapidly, such as immediate computational
results or common program variables. Access RAM
To streamline access for the most commonly used data
also allows for faster and more code efficient context
memory locations, the data memory is configured with
saving and switching of variables.
an Access Bank, which allows users to access a
mapped block of memory without specifying a BSR. The mapping of the Access Bank is slightly different
The Access Bank consists of the first 128 bytes of when the extended instruction set is enabled (XINST
memory (00h-7Fh) in Bank 0 and the last 128 bytes of Configuration bit = 1). This is discussed in more detail
memory (80h-FFh) in Block 15. The lower half is known in Section 5.5.3 “Mapping the Access Bank in
as the “Access RAM” and is composed of GPRs. This Indexed Literal Offset Addressing Mode”.
upper half is also where the device’s SFRs are
mapped. These two areas are mapped contiguously in 5.3.3 GENERAL PURPOSE
the Access Bank and can be addressed in a linear REGISTER FILE
fashion by an 8-bit address (Figure 5-5). PIC18 devices may have banked memory in the GPR
The Access Bank is used by core PIC18 instructions area. This is data RAM, which is available for use by all
that include the Access RAM bit (the ‘a’ parameter in instructions. GPRs start at the bottom of Bank 0
the instruction). When ‘a’ is equal to ‘1’, the instruction (address 000h) and grow upwards towards the bottom of
uses the BSR and the 8-bit address included in the the SFR area. GPRs are not initialized by a Power-on
opcode for the data memory address. When ‘a’ is ‘0’, Reset and are unchanged on all other Resets.
SPBRGH EUSART Baud Rate Generator Register High Byte 0000 0000 51, 206
SPBRG EUSART Baud Rate Generator Register Low Byte 0000 0000 51, 206
RCREG EUSART Receive Register 0000 0000 51, 213
TXREG EUSART Transmit Register 0000 0000 51, 211
TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 51, 202
RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 51, 203
EEADRH — — — — — — EEPROM Addr Register High ---- --00 51, 73
EEADR EEPROM Address Register 0000 0000 51, 80, 73
EEDATA EEPROM Data Register 0000 0000 51, 80, 73
EECON2 EEPROM Control Register 2 (not a physical register) 0000 0000 51, 80, 73
EECON1 EEPGD CFGS — FREE WRERR WREN WR RD xx-0 x000 51, 81, 74
IPR2 OSCFIP CMIP — EEIP BCLIP HLVDIP TMR3IP CCP2IP 11-1 1111 52, 119
PIR2 OSCFIF CMIF — EEIF BCLIF HLVDIF TMR3IF CCP2IF 00-0 0000 52, 115
PIE2 OSCFIE CMIE — EEIE BCLIE HLVDIE TMR3IE CCP2IE 00-0 0000 52, 117
IPR1 PSPIP(2) ADIP RCIP TXIP SSPIP CCP1IP TMR2IP TMR1IP 1111 1111 52, 118
PIR1 PSPIF(2) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 52, 114
PIE1 PSPIE(2) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 52, 116
OSCTUNE INTSRC PLLEN(3) — TUN4 TUN3 TUN2 TUN1 TUN0 00-0 0000 27, 52
TRISE(2) IBF OBF IBOV PSPMODE — TRISE2 TRISE1 TRISE0 0000 -111 52, 104
TRISD(2) PORTD Data Direction Control Register 1111 1111 52, 100
TRISC PORTC Data Direction Control Register 1111 1111 52, 97
TRISB PORTB Data Direction Control Register 1111 1111 52, 94
TRISA TRISA7(5) TRISA6(5) Data Direction Control Register for PORTA 1111 1111 52, 91
LATE(2) — — — — — PORTE Data Latch Register ---- -xxx 52, 103
(Read and Write to Data Latch)
LATD(2) PORTD Data Latch Register (Read and Write to Data Latch) xxxx xxxx 52, 100
LATC PORTC Data Latch Register (Read and Write to Data Latch) xxxx xxxx 52, 97
LATB PORTB Data Latch Register (Read and Write to Data Latch) xxxx xxxx 52, 94
LATA LATA7(5) LATA6(5) PORTA Data Latch Register (Read and Write to Data Latch) xxxx xxxx 52, 91
PORTE — — — — RE3(4) RE2(2) RE1(2) RE0(2) ---- xxxx 52, 103
PORTD(2) RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 xxxx xxxx 52, 100
PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx 52, 97
PORTB RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 xxxx xxxx 52, 94
PORTA RA7(5) RA6(5) RA5 RA4 RA3 RA2 RA1 RA0 xx0x 0000 52, 91
Legend: x = unknown, u = unchanged, — = unimplemented, q = value depends on condition
Note 1: The SBOREN bit is only available when the BOREN1:BOREN0 Configuration bits = 01; otherwise, it is disabled and reads as ‘0’. See
Section 4.4 “Brown-out Reset (BOR)”.
2: These registers and/or bits are not implemented on 28-pin devices and are read as ‘0’. Reset values are shown for 40/44-pin devices;
individual unimplemented bits should be interpreted as ‘-’.
3: The PLLEN bit is only available in specific oscillator configurations; otherwise, it is disabled and reads as ‘0’. See Section 2.6.4 “PLL in
INTOSC Modes”.
4: The RE3 bit is only available when Master Clear Reset is disabled (MCLRE Configuration bit = 0); otherwise, RE3 reads as ‘0’. This bit is
read-only.
5: RA6/RA7 and their associated latch and direction bits are individually configured as port pins based on various primary oscillator modes.
When disabled, these bits read as ‘0’.
6: Bit 7 and bit 6 are cleared by user software or by a POR.
Legend:
R = Readable bit W = 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 2’s complement of the second
operand. For rotate (RRF, RLF) instructions, this bit is loaded with either bit 4 or bit 3 of the source register.
2: For borrow, the polarity is reversed. A subtraction is executed by adding the 2’s complement of the second
operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high or low-order bit of the
source register.
000h
When ‘a’ = 0 and f ≥ 60h:
060h
The instruction executes in
080h
Direct Forced mode. ‘f’ is inter- Bank 0
preted as a location in the 100h
Access RAM between 060h 00h
Bank 1
and 0FFh. This is the same as through 60h
locations 060h to 07Fh Bank 14 80h
Valid range
(Bank 0) and F80h to FFFh for ‘f’
(Bank 15) of data memory.
FFh
F00h Access RAM
Locations below 60h are not
Bank 15
available in this addressing
F80h
mode. SFRs
FFFh
Data Memory
BSR
When ‘a’ = 1 (all values of f): 000h 00000000
Bank 0
The instruction executes in
080h
Direct mode (also known as
Direct Long mode). ‘f’ is inter- 100h
preted as a location in one of
the 16 banks of the data Bank 1 001001da ffffffff
memory space. The bank is through
Bank 14
designated by the Bank Select
Register (BSR). The address
can be in any implemented F00h
bank in the data memory Bank 15
space. F80h
SFRs
FFFh
Data Memory
FIGURE 5-9: REMAPPING THE ACCESS BANK WITH INDEXED LITERAL OFFSET
ADDRESSING MODE
Example Situation:
000h
ADDWF f, d, a Bank 0
05Fh
FSR2H:FSR2L = 120h 07Fh
Locations in the region Bank 0
from the FSR2 Pointer 100h Bank 1
(120h) to the pointer plus 120h
05Fh (17Fh) are mapped Window
17Fh 00h
to the bottom of the
Bank 1 Bank 1 “Window”
Access RAM (000h-05Fh). 200h
Locations in Bank 0 from 5Fh
Bank 0
060h to 07Fh are mapped, 7Fh
as usual, to the middle of Bank 2 80h
the Access Bank. through SFRs
Special Function Registers Bank 14
at F80h through FFFh are FFh
mapped to 80h through Access Bank
FFh, as usual. F00h
Bank 0 addresses below Bank 15
5Fh can still be addressed F80h
by using the BSR. SFRs
FFFh
Data Memory
The EEPROM data memory is rated for high erase/write The WR control bit initiates write operations. The bit
cycle endurance. A byte write automatically erases the cannot be cleared, only set, in software; it is cleared in
location and writes the new data (erase-before-write). hardware at the completion of the write operation.
The write time is controlled by an on-chip timer; it will Note: The EEIF interrupt flag bit (PIR2<4>) is set
vary with voltage and temperature as well as from chip when the write is complete. It must be
to chip. Please refer to parameter D122 (Table 26-1 in cleared in software.
Section 26.0 “Electrical Characteristics”) for exact
limits. Control bits, RD and WR, start read and erase/write
operations, respectively. These bits are set by firmware
6.1 EEADR and EEADRH Registers and cleared by hardware at the completion of the
operation.
The EEADRH:EEADR register pair is used to address The RD bit cannot be set when accessing program
the data EEPROM for read and write operations. memory (EEPGD = 1). Program memory is read using
EEADRH holds the two MSbits of the address; the table read instructions. See Section 7.1 “Table Reads
upper 6 bits are ignored. The 10-bit range of the pair and Table Writes” regarding table reads.
can address a memory range of 1024 bytes (00h to
3FFh). The EECON2 register is not a physical register. It is
used exclusively in the memory write and erase
6.2 EECON1 and EECON2 Registers sequences. Reading EECON2 will read all ‘0’s.
Note 1: When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the error
condition.
Instruction: TBLRD*
Program Memory
Table Pointer(1)
Table Latch (8-bit)
TBLPTRU TBLPTRH TBLPTRL
TABLAT
Program Memory
(TBLPTR)
Instruction: TBLWT*
Program Memory
Holding Registers
Table Pointer(1) Table Latch (8-bit)
TBLPTRU TBLPTRH TBLPTRL TABLAT
Program Memory
(TBLPTR)
Note 1: Table Pointer actually points to one of 64 holding registers, the address of which is determined by
TBLPTRL<5:0>. The process for physically writing data to the program memory array is discussed in
Section 7.5 “Writing to Flash Program Memory”.
7.2 Control Registers The FREE bit, when set, will allow a program memory
erase operation. When FREE is set, the erase
Several control registers are used in conjunction with operation is initiated on the next WR command. When
the TBLRD and TBLWT instructions. These include the: FREE is clear, only writes are enabled.
• EECON1 register The WREN bit, when set, will allow a write operation.
• EECON2 register On power-up, the WREN bit is clear. The WRERR bit is
• TABLAT register set in hardware when the WR bit is set and cleared
• TBLPTR registers when the internal programming timer expires and the
write operation is complete.
7.2.1 EECON1 AND EECON2 REGISTERS Note: During normal operation, the WRERR
The EECON1 register (Register 7-1) is the control may read as ‘1’. This can indicate that a
register for memory accesses. The EECON2 register is write operation was prematurely termi-
not a physical register; it is used exclusively in the nated by a Reset, or a write operation was
memory write and erase sequences. Reading attempted improperly.
EECON2 will read all ‘0’s.
The WR control bit initiates write operations. The bit
The EEPGD control bit determines if the access will be
cannot be cleared, only set, in software; it is cleared in
a program or data EEPROM memory access. When
hardware at the completion of the write operation.
clear, any subsequent operations will operate on the
data EEPROM memory. When set, any subsequent Note: The EEIF interrupt flag bit (PIR2<4>) is set
operations will operate on the program memory. when the write is complete. It must be
The CFGS control bit determines if the access will be cleared in software.
to the Configuration/Calibration registers or to program
memory/data EEPROM memory. When set,
subsequent operations will operate on Configuration
registers regardless of EEPGD (see Section 23.0
“Special Features of the CPU”). When clear, memory
selection access is determined by EEPGD.
Note 1: When a WRERR occurs, the EEPGD and CFGS bits are not cleared. This allows tracing of the error
condition.
TABLE 7-1: TABLE POINTER OPERATIONS WITH TBLRD AND TBLWT INSTRUCTIONS
Example Operation on Table Pointer
TBLRD*
TBLPTR is not modified
TBLWT*
TBLRD*+
TBLPTR is incremented after the read/write
TBLWT*+
TBLRD*-
TBLPTR is decremented after the read/write
TBLWT*-
TBLRD+*
TBLPTR is incremented before the read/write
TBLWT+*
Program Memory
TABLAT
Write Register
8 8 8 8
Program Memory
FIGURE 9-1: GENERIC I/O PORT Pins RA0 through RA5 may also be used as comparator
inputs or outputs by setting the appropriate bits in the
OPERATION
CMCON register. To use RA3:RA0 as digital inputs, it is
also necessary to turn off the comparators.
RD LAT
Note: On a Power-on Reset, RA5 and RA3:RA0
Data are configured as analog inputs and read
Bus D Q as ‘0’. RA4 is configured as a digital input.
WR LAT I/O pin(1)
or Port
CK
The RA4/T0CKI/C1OUT pin is a Schmitt Trigger input.
All other PORTA pins have TTL input levels. All PORTA
Data Latch
pins have full CMOS output drivers.
D Q The TRISA register controls the direction of the PORTA
pins, even when they are being used as analog inputs.
WR TRIS
CK The user must ensure the bits in the TRISA register are
TRIS Latch Input maintained set when using them as analog inputs.
Buffer
RA0/AN0 RA0 0 O DIG LATA<0> data output; not affected by analog input.
1 I TTL PORTA<0> data input; disabled when analog input enabled.
AN0 1 I ANA A/D input channel 0 and Comparator C1- input. Default input
configuration on POR; does not affect digital output.
RA1/AN1 RA1 0 O DIG LATA<1> data output; not affected by analog input.
1 I TTL PORTA<1> data input; disabled when analog input enabled.
AN1 1 I ANA A/D input channel 1 and Comparator C2- input. Default input
configuration on POR; does not affect digital output.
RA2/AN2/ RA2 0 O DIG LATA<2> data output; not affected by analog input. Disabled when
VREF-/CVREF CVREF output enabled.
1 I TTL PORTA<2> data input. Disabled when analog functions enabled;
disabled when CVREF output enabled.
AN2 1 I ANA A/D input channel 2 and Comparator C2+ input. Default input
configuration on POR; not affected by analog output.
VREF- 1 I ANA A/D and comparator voltage reference low input.
CVREF x O ANA Comparator voltage reference output. Enabling this feature disables
digital I/O.
RA3/AN3/VREF+ RA3 0 O DIG LATA<3> data output; not affected by analog input.
1 I TTL PORTA<3> data input; disabled when analog input enabled.
AN3 1 I ANA A/D input channel 3 and Comparator C1+ input. Default input
configuration on POR.
VREF+ 1 I ANA A/D and comparator voltage reference high input.
RA4/T0CKI/C1OUT RA4 0 O DIG LATA<4> data output.
1 I ST PORTA<4> data input; default configuration on POR.
T0CKI 1 I ST Timer0 clock input.
C1OUT 0 O DIG Comparator 1 output; takes priority over port data.
RA5/AN4/SS/ RA5 0 O DIG LATA<5> data output; not affected by analog input.
HLVDIN/C2OUT 1 I TTL PORTA<5> data input; disabled when analog input enabled.
AN4 1 I ANA A/D input channel 4. Default configuration on POR.
SS 1 I TTL Slave Select input for MSSP module.
HLVDIN 1 I ANA High/Low-Voltage Detect external trip point input.
C2OUT 0 O DIG Comparator 2 output; takes priority over port data.
OSC2/CLKO/RA6 RA6 0 O DIG LATA<6> data output. Enabled in RCIO, INTIO2 and ECIO modes only.
1 I TTL PORTA<6> data input. Enabled in RCIO, INTIO2 and ECIO modes only.
OSC2 x O ANA Main oscillator feedback output connection (XT, HS and LP modes).
CLKO x O DIG System cycle clock output (FOSC/4) in RC, INTIO1 and EC Oscillator
modes.
OSC1/CLKI/RA7 RA7 0 O DIG LATA<7> data output. Disabled in external oscillator modes.
1 I TTL PORTA<7> data input. Disabled in external oscillator modes.
OSC1 x I ANA Main oscillator input connection.
CLKI x I ANA Main clock input connection.
Legend: DIG = Digital level output; TTL = TTL input buffer; ST = Schmitt Trigger input buffer; ANA = Analog level input/output;
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
RB0/INT0/FLT0/ RB0 0 O DIG LATB<0> data output; not affected by analog input.
AN12
1 I TTL PORTB<0> data input; weak pull-up when RBPU bit is cleared.
Disabled when analog input enabled.(1)
INT0 1 I ST External interrupt 0 input.
FLT0 1 I ST Enhanced PWM Fault input (ECCP1 module); enabled in software.
AN12 1 I ANA A/D input channel 12.(1)
RB1/INT1/AN10 RB1 0 O DIG LATB<1> data output; not affected by analog input.
1 I TTL PORTB<1> data input; weak pull-up when RBPU bit is cleared.
Disabled when analog input enabled.(1)
INT1 1 I ST External interrupt 1 input.
AN10 1 I ANA A/D input channel 10.(1)
RB2/INT2/AN8 RB2 0 O DIG LATB<2> data output; not affected by analog input.
1 I TTL PORTB<2> data input; weak pull-up when RBPU bit is cleared.
Disabled when analog input enabled.(1)
INT2 1 I ST External interrupt 2 input.
AN8 1 I ANA A/D input channel 8.(1)
RB3/AN9/CCP2 RB3 0 O DIG LATB<3> data output; not affected by analog input.
1 I TTL PORTB<3> data input; weak pull-up when RBPU bit is cleared.
Disabled when analog input enabled.(1)
AN9 1 I ANA A/D input channel 9.(1)
(2)
CCP2 0 O DIG CCP2 compare and PWM output.
1 I ST CCP2 capture input.
RB4/KBI0/AN11 RB4 0 O DIG LATB<4> data output; not affected by analog input.
1 I TTL PORTB<4> data input; weak pull-up when RBPU bit is cleared.
Disabled when analog input enabled.(1)
KBI0 1 I TTL Interrupt on pin change.
AN11 1 I ANA A/D input channel 11.(1)
RB5/KBI1/PGM RB5 0 O DIG LATB<5> data output.
1 I TTL PORTB<5> data input; weak pull-up when RBPU bit is cleared.
KBI1 1 I TTL Interrupt on pin change.
PGM x I ST Single-Supply Programming mode entry (ICSP™). Enabled by LVP
Configuration bit; all other pin functions disabled.
RB6/KBI2/PGC RB6 0 O DIG LATB<6> data output.
1 I TTL PORTB<6> data input; weak pull-up when RBPU bit is cleared.
KBI2 1 I TTL Interrupt on pin change.
PGC x I ST Serial execution (ICSP™) clock input for ICSP and ICD operation.(3)
RB7/KBI3/PGD RB7 0 O DIG LATB<7> data output.
1 I TTL PORTB<7> data input; weak pull-up when RBPU bit is cleared.
KBI3 1 I TTL Interrupt on pin change.
PGD x O DIG Serial execution data output for ICSP and ICD operation.(3)
x I ST Serial execution data input for ICSP and ICD operation.(3)
Legend: DIG = Digital level output; TTL = TTL input buffer; ST = Schmitt Trigger input buffer; ANA = Analog level input/output;
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
Note 1: Configuration on POR is determined by the PBADEN Configuration bit. Pins are configured as analog inputs by default
when PBADEN is set and digital inputs when PBADEN is cleared.
2: Alternate assignment for CCP2 when the CCP2MX Configuration bit is ‘0’. Default assignment is RC1.
3: All other pin functions are disabled when ICSP or ICD is enabled.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
RE0/RD/AN5 RE0 0 O DIG LATE<0> data output; not affected by analog input.
1 I ST PORTE<0> data input; disabled when analog input enabled.
RD 1 I TTL PSP read enable input (PSP enabled).
AN5 1 I ANA A/D input channel 5; default input configuration on POR.
RE1/WR/AN6 RE1 0 O DIG LATE<1> data output; not affected by analog input.
1 I ST PORTE<1> data input; disabled when analog input enabled.
WR 1 I TTL PSP write enable input (PSP enabled).
AN6 1 I ANA A/D input channel 6; default input configuration on POR.
RE2/CS/AN7 RE2 0 O DIG LATE<2> data output; not affected by analog input.
1 I ST PORTE<2> data input; disabled when analog input enabled.
CS 1 I TTL PSP write enable input (PSP enabled).
AN7 1 I ANA A/D input channel 7; default input configuration on POR.
MCLR/VPP/RE3(1) MCLR — I ST External Master Clear input; enabled when MCLRE Configuration bit
is set.
VPP — I ANA High-voltage detection; used for ICSP™ mode entry detection. Always
available, regardless of pin mode.
RE3 —(2) I ST PORTE<3> data input; enabled when MCLRE Configuration bit is
clear.
Legend: DIG = Digital level output; TTL = TTL input buffer; ST = Schmitt Trigger input buffer; ANA = Analog level input/output;
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
Note 1: RE3 is available on both 28-pin and 40/44-pin devices. All other PORTE pins are only implemented on 40/44-pin devices.
2: RE3 does not have a corresponding TRIS bit to control data direction.
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
Wake-up if in
Idle or Sleep modes
TMR0IF
TMR0IE
TMR0IP
RBIF
RBIE
RBIP
INT0IF
INT0IE
Interrupt to CPU
INT1IF Vector to Location
INT1IE
INT1IP 0008h
SSPIF
SSPIE INT2IF
SSPIP INT2IE
INT2IP
GIE/GIEH
ADIF
ADIE
ADIP IPEN
RCIF IPEN
RCIE PEIE/GIEL
RCIP
IPEN
Additional Peripheral Interrupts
High-Priority Interrupt Generation
SSPIF
SSPIE
SSPIP
Interrupt to CPU
TMR0IF Vector to Location
TMR0IE 0018h
ADIF TMR0IP
ADIE
ADIP RBIF
RBIE
RCIF RBIP GIE/GIEH
RCIE PEIE/GIEL
RCIP
INT1IF
INT1IE
INT1IP
Additional Peripheral Interrupts
INT2IF
INT2IE
INT2IP
Legend:
R = Readable bit W = 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 this bit. Reading PORTB and waiting 1 TCY will end the mismatch
condition and allow the bit to be cleared.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note: Interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding
enable bit or the global interrupt enable bit. User software should ensure the appropriate interrupt flag bits
are clear prior to enabling an interrupt. This feature allows for software polling.
Legend:
R = Readable bit W = 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: Interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding
enable bit or the global interrupt enable bit. User software should ensure the appropriate interrupt flag bits
are clear prior to enabling an interrupt. This feature allows for software polling.
Legend:
R = Readable bit W = 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 unimplemented on 28-pin devices and will read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit is unimplemented on 28-pin devices and will read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit is unimplemented on 28-pin devices and will read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Actual Reset values are determined by device configuration and the nature of the device Reset. See
Register 4-1 for additional information.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
FOSC/4 0
1
Sync with Set
1 Internal TMR0L TMR0IF
T0CKI pin Programmable 0 Clocks on Overflow
Prescaler
T0SE (2 TCY Delay)
T0CS 8
3
T0PS2:T0PS0
8
PSA Internal Data Bus
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI max. prescale.
FOSC/4 0
1
Sync with Set
1 Internal TMR0L TMR0
High Byte TMR0IF
T0CKI pin Programmable 0 Clocks on Overflow
Prescaler 8
T0SE (2 TCY Delay)
T0CS 3 Read TMR0L
T0PS2:T0PS0
Write TMR0L
PSA
8
8
TMR0H
8
8
Internal Data Bus
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI max. prescale.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T1OSO/T13CKI 1
Prescaler Synchronize
FOSC/4 0
1, 2, 4, 8 Detect
Internal
Clock 0
T1OSI 2
Sleep Input
T1OSCEN(1) TMR1CS Timer1
On/Off
T1CKPS1:T1CKPS0
T1SYNC
TMR1ON
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
8
Read TMR1L
Write TMR1L
8
8
TMR1H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
4 1:1 to 1:16
T2OUTPS3:T2OUTPS0 Set TMR2IF
Postscaler
2
T2CKPS1:T2CKPS0 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
T1OSO/T13CKI 1
Prescaler Synchronize
FOSC/4 0
1, 2, 4, 8 Detect
Internal
Clock 0
T1OSI 2
Sleep Input
T1OSCEN (1) TMR3CS Timer3
On/Off
T3CKPS1:T3CKPS0
T3SYNC
TMR3ON
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Read TMR1L
Write TMR1L
8
8
TMR3H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
TABLE 15-2: INTERACTIONS BETWEEN CCP1 AND CCP2 FOR TIMER RESOURCES
CCP1 Mode CCP2 Mode Interaction
Capture Capture Each module can use TMR1 or TMR3 as the time base. The time base can be different
for each CCP.
Capture Compare CCP2 can be configured for the Special Event Trigger to reset TMR1 or TMR3
(depending upon which time base is used). Automatic A/D conversions on trigger event
can also be done. Operation of CCP1 could be affected if it is using the same timer as a
time base.
Compare Capture CCP1 can be configured for the Special Event Trigger to reset TMR1 or TMR3
(depending upon which time base is used). Operation of CCP2 could be affected if it is
using the same timer as a time base.
Compare Compare Either module can be configured for the Special Event Trigger to reset the time base.
Automatic A/D conversions on CCP2 trigger event can be done. Conflicts may occur if
both modules are using the same time base.
Capture PWM(1) None
Compare PWM(1) None
PWM(1) Capture None
(1)
PWM Compare None
PWM(1) PWM Both PWMs will have the same frequency and update rate (TMR2 interrupt).
Note 1: Includes standard and Enhanced PWM operation.
4 TMR1H TMR1L
CCP1CON<3:0> Set CCP2IF
4
Q1:Q4
4
CCP2CON<3:0>
T3CCP1 TMR3H TMR3L
T3CCP2
TMR3
Enable
CCP2 pin
Prescaler and CCPR2H CCPR2L
÷ 1, 4, 16 Edge Detect
TMR1
Enable
T3CCP2
TMR1H TMR1L
T3CCP1
Compare Output S Q
Comparator
Match Logic
R
TRIS
4 Output Enable
CCP1CON<3:0>
0 TMR1H TMR1L
0
Compare Output S Q
Comparator
Match Logic
R
TRIS
4 Output Enable
CCPR2H CCPR2L
CCP2CON<3:0>
Duty Cycle
TMR2 = PR2
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
TRISx<x>
CCPR1H (Slave)
P1B P1B
Output TRISx<x>
Comparator R Q
Controller
P1C
P1C
TMR2 (Note 1)
S TRISx<x>
P1D P1D
Comparator
Clear Timer, TRISx<x>
set CCP1 pin and
latch D.C.
PR2 PWM1CON
Note: The 8-bit TMR2 register is concatenated with the 2-bit internal Q clock, or 2 bits of the prescaler, to create the 10-bit
time base.
P1A Active
P1D Modulated
P1A Inactive
P1D Inactive
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)
• Duty Cycle = 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 (see Section 16.4.6 “Programmable
Dead-Band Delay”).
PIC18F4X2X FET
Driver +
P1A V
-
Load
FET
Driver
+
P1B V
-
V-
Half-Bridge Output Driving a Full-Bridge Circuit
V+
PIC18F4X2X
FET FET
Driver Driver
P1A
Load
FET FET
Driver Driver
P1B
V-
Forward Mode
Period
(2)
P1A
Duty Cycle
P1B(2)
P1C(2)
P1D(2)
(1) (1)
Reverse Mode
Period
Duty Cycle
P1A(2)
P1B(2)
P1C(2)
P1D(2)
(1) (1)
Note 1: At this time, the TMR2 register is equal to the PR2 register.
Note 2: Output signal is shown as active-high.
PIC18F4X2X QC
FET QA FET
Driver Driver
P1A
Load
P1B
FET FET
Driver Driver
P1C
QB QD
V-
P1D
16.4.5.1 Direction Change in Full-Bridge Mode Figure 16-9 shows an example where the PWM
direction changes from forward to reverse at a near
In the Full-Bridge Output mode, the P1M1 bit in the
100% duty cycle. At time t1, the outputs P1A and P1D
CCP1CON register allows user to control the forward/
become inactive, while output P1C becomes active. In
reverse direction. When the application firmware
this example, since the turn-off time of the power
changes this direction control bit, the module will
devices is longer than the turn-on time, a shoot-through
assume the new direction on the next PWM cycle.
current may flow through power devices, QC and QD
Just before the end of the current PWM period, the (see Figure 16-7), for the duration of ‘t’. The same
modulated outputs (P1B and P1D) are placed in their phenomenon will occur to power devices, QA and QB,
inactive state, while the unmodulated outputs (P1A and for PWM direction change from reverse to forward.
P1C) are switched to drive in the opposite direction.
If changing PWM direction at high duty cycle is required
This occurs in a time interval of 4 TOSC * (Timer2
for an application, one of the following requirements
Prescale Value) before the next PWM period begins.
must be met:
The Timer2 prescaler will be either 1, 4 or 16, depend-
ing on the value of the T2CKPS1:T2CKPS0 bits 1. Reduce PWM for a PWM period before
(T2CON<1:0>). During the interval from the switch of changing directions.
the unmodulated outputs to the beginning of the next 2. Use switch drivers that can drive the switches off
period, the modulated outputs (P1B and P1D) remain faster than they can drive them on.
inactive. This relationship is shown in Figure 16-8.
Other options to prevent shoot-through current may
Note that in the Full-Bridge Output mode, the CCP1 exist.
module does not provide any dead-band delay. In
general, since only one output is modulated at all times,
dead-band delay is not required. However, there is a
situation where a dead-band delay might be required.
This situation occurs when both of the following
conditions are true:
1. The direction of the PWM output changes when
the duty cycle of the output is at or near 100%.
2. The turn-off time of the power switch, including
the power device and driver circuit, is greater
than the turn-on time.
P1A (Active-High)
P1B (Active-High)
DC
P1C (Active-High)
(Note 2)
P1D (Active-High)
DC
Note 1: The direction bit in the CCP1 Control register (CCP1CON<7>) is written any time during the PWM cycle.
2: When changing directions, the P1A and P1C signals switch before the end of the current PWM cycle at intervals
of 4 TOSC, 16 TOSC or 64 TOSC, depending on the Timer2 prescaler value. The modulated P1B and P1D signals
are inactive at this time.
P1A(1)
P1B(1) DC
P1C(1)
P1D(1) DC
tON(2)
External Switch C(1)
tOFF(3)
When the CCP1 is programmed for any of the Enhanced Note: Writing to the ECCPASE bit is disabled
PWM modes, the active output pins may be configured while a shutdown condition is active.
for auto-shutdown. Auto-shutdown immediately places
the Enhanced PWM output pins into a defined shutdown
state when a shutdown event occurs.
Legend:
R = Readable bit W = 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
PWM Activity
Dead Time Dead Time Dead Time
Shutdown Event
ECCPASE bit
PWM Activity
Dead Time Dead Time Dead Time
Shutdown Event
ECCPASE bit
ECCPASE
Cleared by Firmware
Edge
Select
2
Clock Select
SSPM3:SSPM0
SMP:CKE 4
RC3/SCK/
SCL 2 2
(
TMR2 Output )
Edge
Select Prescaler TOSC
4, 16, 64
Legend:
R = Readable bit W = 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: In Master mode, the overflow bit is not set since each new reception (and transmission) is initiated by
writing to the SSPBUF register.
2: When enabled, these pins must be properly configured as input or output.
3: Bit combinations not specifically listed here are either reserved or implemented in I2C™ mode only.
SDO SDI
Write to
SSPBUF
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
4 Clock
SCK Modes
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Input
Sample
(SMP = 1)
SSPIF
Next Q4 Cycle
SSPSR to after Q2↓
SSPBUF
SS
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI bit 0
(SMP = 0) bit 7 bit 7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
SSPSR to after Q2↓
SSPBUF
SS
Optional
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI
(SMP = 0) bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
SSPSR to after Q2↓
SSPBUF
SS
Not Optional
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Write to
SSPBUF
SDI
(SMP = 0) bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
after Q2↓
SSPSR to
SSPBUF
Legend:
R = Readable bit W = 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: When enabled, the SDA and SCL pins must be properly configured as inputs or outputs.
Legend:
R = Readable bit W = 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.
DS39626E-page 176
Receiving Address R/W = 0 Receiving Data ACK Receiving Data ACK
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF (PIR1<3>)
Bus master
terminates
transfer
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
PIC18F2525/2620/4525/4620
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
SCL
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
Data in SCL held low P
sampled while CPU
responds to SSPIF
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
Cleared in software Cleared in software
From SSPIF ISR From SSPIF ISR
SSPBUF is written in software SSPBUF is written in software
Clear by reading
CKP
DS39626E-page 177
PIC18F2525/2620/4525/4620
FIGURE 17-10:
DS39626E-page 178
Clock is held low until Clock is held low until
update of SSPADD has update of SSPADD has
taken place taken place
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
Bus master
terminates
SSPIF (PIR1<3>) transfer
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
PIC18F2525/2620/4525/4620
UA (SSPSTAT<1>)
Bus master
terminates
Clock is held low until Clock is held low until transfer
update of SSPADD has update of SSPADD has Clock is held low until
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S Sr P
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
DS39626E-page 179
PIC18F2525/2620/4525/4620
PIC18F2525/2620/4525/4620
17.4.4 CLOCK STRETCHING 17.4.4.3 Clock Stretching for 7-Bit Slave
Both 7-bit and 10-bit Slave modes implement Transmit Mode
automatic clock stretching during a transmit sequence. 7-Bit Slave Transmit mode implements clock stretch-
The SEN bit (SSPCON2<0>) allows clock stretching to ing by clearing the CKP bit after the falling edge of the
be enabled during receives. Setting SEN will cause ninth clock if the BF bit is clear. This occurs regardless
the SCL pin to be held low at the end of each data of the state of the SEN bit.
receive sequence. The user’s ISR must set the CKP bit before transmis-
sion is allowed to continue. By holding the SCL line
17.4.4.1 Clock Stretching for 7-Bit Slave low, the user has time to service the ISR and load the
Receive Mode (SEN = 1) contents of the SSPBUF before the master device can
In 7-Bit Slave Receive mode, on the falling edge of the initiate another transmit sequence (see Figure 17-9).
ninth clock at the end of the ACK sequence if the BF Note 1: If the user loads the contents of SSPBUF,
bit is set, the CKP bit in the SSPCON1 register is setting the BF bit before the falling edge of
automatically cleared, forcing the SCL output to be the ninth clock, the CKP bit will not be
held low. The CKP being cleared to ‘0’ will assert the cleared and clock stretching will not occur.
SCL line low. The CKP bit must be set in the user’s
ISR before reception is allowed to continue. By holding 2: The CKP bit can be set in software
the SCL line low, the user has time to service the ISR regardless of the state of the BF bit.
and read the contents of the SSPBUF before the
master device can initiate another receive sequence. 17.4.4.4 Clock Stretching for 10-Bit Slave
This will prevent buffer overruns from occurring (see Transmit Mode
Figure 17-13). In 10-Bit Slave Transmit mode, clock stretching is
Note 1: If the user reads the contents of the controlled during the first two address sequences by
SSPBUF before the falling edge of the the state of the UA bit, just as it is in 10-Bit Slave
ninth clock, thus clearing the BF bit, the Receive mode. The first two addresses are followed
CKP bit will not be cleared and clock by a third address sequence which contains the high-
stretching will not occur. order bits of the 10-bit address and the R/W bit set to
‘1’. After the third address sequence is performed, the
2: The CKP bit can be set in software
UA bit is not set, the module is now configured in
regardless of the state of the BF bit. The
Transmit mode and clock stretching is controlled by
user should be careful to clear the BF bit
the BF flag as in 7-Bit Slave Transmit mode (see
in the ISR before the next receive
Figure 17-11).
sequence in order to prevent an overflow
condition.
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
SSPCONx
DS39626E-page 182
Clock is not held low
because buffer full bit is
clear prior to falling edge Clock is held low until Clock is not held low
of 9th clock CKP is set to ‘1’ because ACK = 1
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF (PIR1<3>)
Bus master
terminates
transfer
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
PIC18F2525/2620/4525/4620
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 (PIR1<3>)
Bus master
terminates
Cleared in software Cleared in software Cleared in software transfer
Cleared in software
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
DS39626E-page 183
PIC18F2525/2620/4525/4620
PIC18F2525/2620/4525/4620
17.4.5 GENERAL CALL ADDRESS If the general call address matches, the SSPSR is
SUPPORT transferred to the SSPBUF, the BF flag bit is set (eighth
bit) and on the falling edge of the ninth bit (ACK bit), the
The addressing procedure for the I2C bus is such that
SSPIF interrupt flag bit is set.
the first byte after the Start condition usually
determines which device will be the slave addressed by When the interrupt is serviced, the source for the
the master. The exception is the general call address interrupt can be checked by reading the contents of the
which can address all devices. When this address is SSPBUF. The value can be used to determine if the
used, all devices should, in theory, respond with an address was device specific or a general call address.
Acknowledge. In 10-bit mode, the SSPADD is required to be updated
The general call address is one of eight addresses for the second half of the address to match and the UA
reserved for specific purposes by the I2C protocol. It bit (SSPSTAT<1>) is set. If the general call address is
consists of all ‘0’s with R/W = 0. sampled when the GCEN bit is set, while the slave is
configured in 10-Bit Addressing mode, then the second
The general call address is recognized when the
half of the address is not necessary, the UA bit will not
General Call Enable bit, GCEN, is enabled
be set and the slave will begin receiving data after the
(SSPCON2<7> is set). Following a Start bit detect,
Acknowledge (Figure 17-15).
8 bits are shifted into the SSPSR and the 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 in software
SSPBUF is read
SSPOV (SSPCON1<6>) ‘0’
GCEN (SSPCON2<7>)
‘1’
Internal SSPM3:SSPM0
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
SSPM3:SSPM0 SSPADD<6: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
DS39626E-page 192
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
BF (SSPSTAT<0>)
SEN
PEN
R/W
I 2C™ MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
Write to SSPCON2<4>
to start Acknowledge sequence
SDA = ACKDT (SSPCON2<5>) = 0
Write to SSPCON2<0> (SEN = 1),
begin Start condition ACK from Master Set ACKEN, start Acknowledge sequence
Master configured as a receiver SDA = ACKDT = 0 SDA = ACKDT = 1
SEN = 0 by programming SSPCON2<3> (RCEN = 1)
Bus master
ACK is not sent terminates
transfer
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SCL S P
Data shifted in on falling edge of CLK Set SSPIF at end
of receive Set SSPIF interrupt
Set SSPIF interrupt at end of Acknowledge
Set SSPIF interrupt sequence
at end of receive
at end of Acknowledge
SSPIF sequence
Set P bit
Cleared in software Cleared in software Cleared in software Cleared in software (SSPSTAT<4>)
SDA = 0, SCL = 1 Cleared in
while CPU software and SSPIF
responds to SSPIF
BF
(SSPSTAT<0>) Last bit is shifted into SSPSR and
contents are unloaded into SSPBUF
SSPOV
ACKEN
I 2C™ MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS)
DS39626E-page 193
PIC18F2525/2620/4525/4620
PIC18F2525/2620/4525/4620
17.4.12 ACKNOWLEDGE SEQUENCE 17.4.13 STOP CONDITION TIMING
TIMING A Stop bit is asserted on the SDA pin at the end of a
An Acknowledge sequence is enabled by setting the receive/transmit by setting the Stop Sequence Enable
Acknowledge Sequence Enable bit, ACKEN bit, PEN (SSPCON2<2>). At the end of a receive/
(SSPCON2<4>). When this bit is set, the SCL pin is transmit, the SCL line is held low after the falling edge
pulled low and the contents of the Acknowledge data bit of the ninth clock. When the PEN bit is set, the master
are presented on the SDA pin. If the user wishes to gen- will assert the SDA line low. When the SDA line is
erate an Acknowledge, then the ACKDT bit should be sampled low, the Baud Rate Generator is reloaded and
cleared. If not, the user should set the ACKDT bit before counts down to 0. When the Baud Rate Generator
starting an Acknowledge sequence. The Baud Rate times out, the SCL pin will be brought high and one
Generator then counts for one rollover period (TBRG) TBRG (Baud Rate Generator rollover count) later, the
and the SCL pin is deasserted (pulled high). When the SDA pin will be deasserted. When the SDA pin is
SCL pin is sampled high (clock arbitration), the Baud sampled high while SCL is high, the P bit
Rate Generator counts for TBRG. The SCL pin is then (SSPSTAT<4>) is set. A TBRG later, the PEN bit is
pulled low. Following this, the ACKEN bit is automatically cleared and the SSPIF bit is set (Figure 17-24).
cleared, the Baud Rate Generator is turned off and the
MSSP module then goes into Idle mode (Figure 17-23). 17.4.13.1 WCOL Status Flag
If the user writes the SSPBUF when a Stop sequence
17.4.12.1 WCOL Status Flag is in progress, then the WCOL bit is set and the
If the user writes the SSPBUF when an Acknowledge contents of the buffer are unchanged (the write doesn’t
sequence is in progress, then WCOL is set and the occur).
contents of the buffer are unchanged (the write doesn’t
occur).
SCL 8 9
SSPIF
Cleared in
SSPIF set at software
the end of receive Cleared in
software SSPIF set at the end
of Acknowledge sequence
Note: TBRG = one Baud Rate Generator period.
SDA ACK
P
TBRG TBRG TBRG
SCL brought high after TBRG
SDA asserted low before rising edge of clock
to setup Stop condition
SDA
BCLIF
SDA
SCL
Set SEN, enable Start SEN cleared automatically because of bus collision.
condition if SDA = 1, SCL = 1 MSSP 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 in software
SSPIF
SDA = 0, SCL = 1
TBRG TBRG
SDA
FIGURE 17-28: BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
SDA = 0, SCL = 1
Set S Set SSPIF
Less than TBRG
TBRG
SCL S
SCL pulled low after BRG
time-out
SEN
Set SEN, enable START
sequence if SDA = 1, SCL = 1
BCLIF ‘0’
SSPIF
SDA = 0, SCL = 1, Interrupts cleared
set SSPIF in software
SDA
SCL
RSEN
BCLIF
Cleared in software
S ‘0’
SSPIF ‘0’
SDA
SCL
S ‘0’
SSPIF
PEN
BCLIF
P ‘0’
SSPIF ‘0’
SDA
PEN
BCLIF
P ‘0’
SSPIF ‘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
0.3 — — — — — — — — — — — —
1.2 — — — 1.221 1.73 255 1.202 0.16 129 1.201 -0.16 103
2.4 2.441 1.73 255 2.404 0.16 129 2.404 0.16 64 2.403 -0.16 51
9.6 9.615 0.16 64 9.766 1.73 31 9.766 1.73 15 9.615 -0.16 12
19.2 19.531 1.73 31 19.531 1.73 15 19.531 1.73 7 — — —
57.6 56.818 -1.36 10 62.500 8.51 4 52.083 -9.58 2 — — —
115.2 125.000 8.51 4 104.167 -9.58 2 78.125 -32.18 1 — — —
0.3 — — — — — — — — — — — —
1.2 — — — — — — — — — — — —
2.4 — — — — — — 2.441 1.73 255 2.403 -0.16 207
9.6 9.766 1.73 255 9.615 0.16 129 9.615 0.16 64 9.615 -0.16 51
19.2 19.231 0.16 129 19.231 0.16 64 19.531 1.73 31 19.230 -0.16 25
57.6 58.140 0.94 42 56.818 -1.36 21 56.818 -1.36 10 55.555 3.55 8
115.2 113.636 -1.36 21 113.636 -1.36 10 125.000 8.51 4 — — —
0.3 0.300 0.00 8332 0.300 0.02 4165 0.300 0.02 2082 0.300 -0.04 1665
1.2 1.200 0.02 2082 1.200 -0.03 1041 1.200 -0.03 520 1.201 -0.16 415
2.4 2.402 0.06 1040 2.399 -0.03 520 2.404 0.16 259 2.403 -0.16 207
9.6 9.615 0.16 259 9.615 0.16 129 9.615 0.16 64 9.615 -0.16 51
19.2 19.231 0.16 129 19.231 0.16 64 19.531 1.73 31 19.230 -0.16 25
57.6 58.140 0.94 42 56.818 -1.36 21 56.818 -1.36 10 55.555 3.55 8
115.2 113.636 -1.36 21 113.636 -1.36 10 125.000 8.51 4 — — —
0.3 0.300 0.04 832 0.300 -0.16 415 0.300 -0.16 207
1.2 1.202 0.16 207 1.201 -0.16 103 1.201 -0.16 51
2.4 2.404 0.16 103 2.403 -0.16 51 2.403 -0.16 25
9.6 9.615 0.16 25 9.615 -0.16 12 — — —
19.2 19.231 0.16 12 — — — — — —
57.6 62.500 8.51 3 — — — — — —
115.2 125.000 8.51 1 — — — — — —
0.3 0.300 0.00 33332 0.300 0.00 16665 0.300 0.00 8332 0.300 -0.01 6665
1.2 1.200 0.00 8332 1.200 0.02 4165 1.200 0.02 2082 1.200 -0.04 1665
2.4 2.400 0.02 4165 2.400 0.02 2082 2.402 0.06 1040 2.400 -0.04 832
9.6 9.606 0.06 1040 9.596 -0.03 520 9.615 0.16 259 9.615 -0.16 207
19.2 19.193 -0.03 520 19.231 0.16 259 19.231 0.16 129 19.230 -0.16 103
57.6 57.803 0.35 172 57.471 -0.22 86 58.140 0.94 42 57.142 0.79 34
115.2 114.943 -0.22 86 116.279 0.94 42 113.636 -1.36 21 117.647 -2.12 16
0.3 0.300 0.01 3332 0.300 -0.04 1665 0.300 -0.04 832
1.2 1.200 0.04 832 1.201 -0.16 415 1.201 -0.16 207
2.4 2.404 0.16 415 2.403 -0.16 207 2.403 -0.16 103
9.6 9.615 0.16 103 9.615 -0.16 51 9.615 -0.16 25
19.2 19.231 0.16 51 19.230 -0.16 25 19.230 -0.16 12
57.6 58.824 2.12 16 55.555 3.55 8 — — —
115.2 111.111 -3.55 8 — — — — — —
BRG Clock
RCIF bit
(Interrupt)
Read
RCREG
Note: The ABD sequence requires the EUSART module to be configured in Asynchronous mode and WUE = 0.
BRG Clock
ABDEN bit
ABDOVF bit
FFFFh
BRG Value XXXXh 0000h 0000h
TRMT SPEN
BRG16 SPBRGH SPBRG
TX9
Baud Rate Generator TX9D
Write to TXREG
Word 1
BRG Output
(Shift Clock)
TX (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)
TX (pin)
Start bit bit 0 bit 1 bit 7/8 Stop bit Start bit bit 0
RX9
SPEN
8
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.
RX/DT Line
RCIF
Cleared due to user read of RCREG
Note 1: The EUSART remains in Idle while the WUE bit is set.
RX/DT Line
Note 1
RCIF
Cleared due to user read of RCREG
Sleep Command Executed Sleep Ends
Note 1: If the wake-up event requires long oscillator warm-up time, the auto-clear of the WUE bit can occur before the oscillator is ready. 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)
Break
TXIF bit
(Transmit Buffer
Reg. Empty Flag)
TRMT bit
(Transmit Shift
Reg. Empty Flag)
SENDB sampled here Auto-Cleared
SENDB
(Transmit Shift
Reg. Empty Flag)
Write to
TXREG Reg
Write Word 1 Write Word 2
TXIF bit
(Interrupt Flag)
TRMT bit
Note: Sync Master mode, SPBRG = 0, continuous transmission of two 8-bit words.
RC6/TX/CK pin
Write to
TXREG reg
TXIF bit
TRMT bit
TXEN bit
RC7/RX/DT
pin bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
RC6/TX/CK pin
(TXCKP = 0)
RC6/TX/CK pin
(TXCKP = 1)
Write to
bit SREN
SREN bit
CREN bit ‘0’ ‘0’
RCIF bit
(Interrupt)
Read
RXREG
Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 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
AN6(2)
AN5(2)
AN12
AN10
AN11
PCFG3:
AN9
AN8
AN4
AN3
AN2
AN1
AN0
PCFG0
0000(1) A A A A A A A A A A A A A
0001 A A A A A A A A A A A A A
0010 A A A A A A A A A A A A A
0011 D A A A A A A A A A A A A
0100 D D A A A A A A A A A A A
0101 D D D A A A A A A A A A A
0110 D D D D A A A A A A A A A
0111(1) D D D D D A A A A A A A A
1000 D D D D D D A A A A A A A
1001 D D D D D D D A A A A A A
1010 D D D D D D D D A A A A A
1011 D D D D D D D D D A A A A
1100 D D D D D D D D D D A A A
1101 D D D D D D D D D D D A A
1110 D D D D D D D D D D D D A
1111 D D D D D D D D D D D D D
A = Analog input D = Digital I/O
Note 1: The POR value of the PCFG bits depends on the value of the PBADEN Configuration bit. When
PBADEN = 1, PCFG<2:0> = 000; when PBADEN = 0, PCFG<2:0> = 111.
2: AN5 through AN7 are available only on 40/44-pin devices.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: If the A/D FRC clock source is selected, a delay of one TCY (instruction cycle) is added before the A/D
clock starts. This allows the SLEEP instruction to be executed before starting a conversion.
CHS3:CHS0
1100
AN12
1011
AN11
1010
AN10
1001
AN9
1000
AN8
0111
AN7(1)
0110
AN6(1)
0101
AN5(1)
0100
AN4
VAIN
(Input Voltage) 0011
10-Bit AN3
Converter
A/D 0010
AN2
0001
VCFG1:VCFG0 AN1
VDD 0000
AN0
X0
VREF+ X1
Reference 1X
Voltage VREF- 0X
VSS
Note 1: Channels AN5 through AN7 are not available on 28-pin devices.
2: I/O pins have diode protection to VDD and VSS.
1022 LSB
1022.5 LSB
1023 LSB
1023.5 LSB
• Set GIE bit
3. Wait the required acquisition time (if required).
4. Start conversion:
Analog Input Voltage
• Set GO/DONE bit (ADCON0 register)
VSS
FIGURE 19-5: 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 TAD1
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Automatic
Acquisition Conversion starts Discharge
Time (Holding capacitor is disconnected)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Two Common Reference Comparators Two Common Reference Comparators with Outputs
CM2:CM0 = 100 CM2:CM0 = 101
A VIN- A VIN-
RA0/AN0 RA0/AN0
VIN+ C1 C1OUT VIN+ C1 C1OUT
RA3/AN3/ A RA3/AN3/ A
VREF+ VREF+
RA4/T0CKI/C1OUT*
A VIN-
RA1/AN1
C2 C2OUT RA1/AN1 A VIN-
RA2/AN2/ D VIN+
VREF-/CVREF RA2/AN2/ D VIN+ C2 C2OUT
VREF-/CVREF
RA5/AN4/SS/HLVDIN/C2OUT*
One Independent Comparator with Output Four Inputs Multiplexed to Two Comparators
CM2:CM0 = 001 CM2:CM0 = 110
A VIN- A
RA0/AN0 RA0/AN0
CIS = 0 VIN-
RA3/AN3/ A VIN+ C1 C1OUT RA3/AN3/ A CIS = 1
VIN+ C1 C1OUT
VREF+ VREF+
RA4/T0CKI/C1OUT* RA1/AN1 A
CIS = 0 VIN-
RA2/AN2/ A CIS = 1
D VIN- VIN+ C2 C2OUT
RA1/AN1 VREF-/CVREF
RA2/AN2/ D VIN+ C2 Off (Read as ‘0’)
CVREF
VREF-/CVREF From VREF Module
A = Analog Input, port reads zeros always D = Digital Input CIS (CMCON<3>) is the Comparator Input Switch
* Setting the TRISA<5:4> bits will disable the comparator outputs by configuring the pins as inputs.
MULTIPLEX
+
Port pins
To RA4 or
-
RA5 pin
D Q Bus
CxINV Data
Read CMCON EN
D Q Set
CMIF
bit
EN CL
From
other
Reset Comparator
VDD
VT = 0.6V RIC
RS < 10k
Comparator
AIN Input
CPIN ILEAKAGE
VA VT = 0.6V ±500 nA
5 pF
VSS
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
CVRSS = 1
VREF+
VDD
CVRSS = 0 8R
CVR3:CVR0
CVREN R
16-to-1 MUX
R
16 Steps
CVREF
R
R
R
CVRR 8R
CVRSS = 1
VREF-
CVRSS = 0
PIC18FXXXX
CVREF
R(1)
Module
+
Voltage RA2 CVREF Output
–
Reference
Output
Impedance
Note 1: R is dependent upon the voltage reference configuration bits, CVRCON<3:0> and CVRCON<5>.
Legend:
R = Readable bit W = 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: See Table 26-4 in Section 26.0 “Electrical Characteristics”for the specifications.
The module is enabled by setting the HLVDEN bit. The VDIRMAG bit determines the overall operation of
Each time that the HLVD module is enabled, the the module. When VDIRMAG is cleared, the module
circuitry requires some time to stabilize. The IRVST bit monitors for drops in VDD below a predetermined set
is a read-only bit and is used to indicate when the circuit point. When the bit is set, the module monitors for rises
is stable. The module can only generate an interrupt in VDD above the set point.
after the circuit is stable and IRVST is set.
Set
HLVDIF
HLVDEN
Internal Voltage
BOREN Reference
VDD
VLVD
HLVDIF
Enable HLVD
TIRVST
IRVST
HLVDIF cleared in software
Internal Reference is stable
CASE 2:
VDD
VLVD
HLVDIF
Enable HLVD
TIRVST
IRVST
Internal Reference is stable
HLVDIF cleared in software
VLVD
VDD
HLVDIF
Enable HLVD
IRVST TIRVST
CASE 2:
VLVD
VDD
HLVDIF
Enable HLVD
IRVST TIRVST
300001h CONFIG1H IESO FCMEN — — FOSC3 FOSC2 FOSC1 FOSC0 00-- 0111
300002h CONFIG2L — — — BORV1 BORV0 BOREN1 BOREN0 PWRTEN ---1 1111
300003h CONFIG2H — — — WDTPS3 WDTPS2 WDTPS1 WDTPS0 WDTEN ---1 1111
300005h CONFIG3H MCLRE — — — — LPT1OSC PBADEN CCP2MX 1--- -011
300006h CONFIG4L DEBUG XINST — — — LVP — STVREN 10-- -1-1
300008h CONFIG5L — — — — CP3(1) CP2 CP1 CP0 ---- 1111
300009h CONFIG5H CPD CPB — — — — — — 11-- ----
30000Ah CONFIG6L — — — — WRT3(1) WRT2 WRT1 WRT0 ---- 1111
30000Bh CONFIG6H WRTD WRTB WRTC — — — — — 111- ----
30000Ch CONFIG7L — — — — EBTR3(1) EBTR2 EBTR1 EBTR0 ---- 1111
30000Dh CONFIG7H — EBTRB — — — — — — -1-- ----
3FFFFEh DEVID1 DEV2 DEV1 DEV0 REV4 REV3 REV2 REV1 REV0 xxxx xxxx(2)
3FFFFFh DEVID2 DEV10 DEV9 DEV8 DEV7 DEV6 DEV5 DEV4 DEV3 0000 1100(2)
Legend: x = unknown, u = unchanged, - = unimplemented. Shaded cells are unimplemented, read as ‘0’.
Note 1: Unimplemented in PIC18FX525 devices; maintain this bit set.
2: See Register 23-12 and Register 23-13 for DEVID1 values. DEVID registers are read-only and cannot be programmed
by the user.
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Note 1: See Section 26.1 “DC Characteristics: Supply Voltage” for specifications.
2: The Power-up Timer is decoupled from Brown-out Reset, allowing these features to be independently
controlled.
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Note 1: This bit is read-only in normal execution mode; it can be written only in Program mode.
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Read-only bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Note 1: These values for DEV10:DEV3 may be shared with other devices. The specific device is always identified
by using the entire DEV10:DEV0 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.
OSC1
TOST(1) TPLL(1)
1 2 n-1 n
PLL Clock
Output
Clock
Transition(2)
CPU Clock
Peripheral
Clock
Program PC PC + 2 PC + 4 PC + 6
Counter
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
2: Clock transition typically occurs within 2-4 TOSC.
Sample Clock
Device Oscillator
Clock Failure
Output
CM Output
(Q)
Failure
Detected
OSCFIF
000000h
Boot Block Boot Block CPB, WRTB, EBTRB
0007FFh
000800h
Block 0 Block 0 CP0, WRT0, EBTR0
003FFFh
004000h
Block 1 Block 1 CP1, WRT1, EBTR1
007FFFh
008000h
Block 2 Block 2 CP2, WRT2, EBTR2
00B7FFh
00C000h
Unimplemented
Block 3 CP3, WRT3, EBTR3
Read ‘0’s
00FFFFh
010000h
Unimplemented Unimplemented
Read ‘0’s Read ‘0’s (Unimplemented Memory Space)
1FFFFFh
TBLPTR = 0008FFh
WRT0, EBTR0 = 01
00FFFFh
000000h
WRTB, EBTRB = 11
0007FFh
000800h
TBLPTR = 0008FFh
WRT0, EBTR0 = 10
003FFFh
004000h
PC = 007FFEh TBLRD* WRT1, EBTR1 = 11
007FFFh
008000h
WRT2, EBTR2 = 11
00BFFFh
00C000h
WRT3, EBTR3 = 11
00FFFFh
Results: All table reads from external blocks to Blockn are disabled whenever EBTRx = 0.
TABLAT register returns a value of ‘0’.
00FFFFh
All bit-oriented instructions have three operands: The instruction set summary, shown in Table 24-2, lists
the standard instructions recognized by the Microchip
1. The file register (specified by ‘f’) MPASM™ Assembler.
2. The bit in the file register (specified by ‘b’)
Section 24.1.1 “Standard Instruction Set” provides
3. The accessed memory (specified by ‘a’) a description of each instruction.
The bit field designator ‘b’ selects the number of the bit
affected by the operation, while the file register
designator ‘f’ represents the number of the file in which
the bit is located.
Literal operations
15 8 7 0
OPCODE k (literal) MOVLW 7Fh
Control operations
CALL, GOTO and Branch operations
15 8 7 0
OPCODE n<7:0> (literal) GOTO Label
15 12 11 0
1111 n<19:8> (literal)
15 8 7 0
OPCODE S n<7:0> (literal) CALL MYFUNC
15 12 11 0
1111 n<19:8> (literal)
S = Fast bit
15 11 10 0
OPCODE n<10:0> (literal) BRA MYFUNC
15 8 7 0
OPCODE n<7:0> (literal) BC MYFUNC
BYTE-ORIENTED OPERATIONS
ADDWF f, d, a Add WREG and f 1 0010 01da ffff ffff C, DC, Z, OV, N 1, 2
ADDWFC f, d, a Add WREG and Carry bit to f 1 0010 00da ffff ffff C, DC, Z, OV, N 1, 2
ANDWF f, d, a AND WREG with f 1 0001 01da ffff ffff Z, N 1,2
CLRF f, a Clear f 1 0110 101a ffff ffff Z 2
COMF f, d, a Complement f 1 0001 11da ffff ffff Z, N 1, 2
CPFSEQ f, a Compare f with WREG, Skip = 1 (2 or 3) 0110 001a ffff ffff None 4
CPFSGT f, a Compare f with WREG, Skip > 1 (2 or 3) 0110 010a ffff ffff None 4
CPFSLT f, a Compare f with WREG, Skip < 1 (2 or 3) 0110 000a ffff ffff None 1, 2
DECF f, d, a Decrement f 1 0000 01da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
DECFSZ f, d, a Decrement f, Skip if 0 1 (2 or 3) 0010 11da ffff ffff None 1, 2, 3, 4
DCFSNZ f, d, a Decrement f, Skip if Not 0 1 (2 or 3) 0100 11da ffff ffff None 1, 2
INCF f, d, a Increment f 1 0010 10da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
INCFSZ f, d, a Increment f, Skip if 0 1 (2 or 3) 0011 11da ffff ffff None 4
INFSNZ f, d, a Increment f, Skip if Not 0 1 (2 or 3) 0100 10da ffff ffff None 1, 2
IORWF f, d, a Inclusive OR WREG with f 1 0001 00da ffff ffff Z, N 1, 2
MOVF f, d, a Move f 1 0101 00da ffff ffff Z, N 1
MOVFF fs, fd Move fs (source) to 1st word 2 1100 ffff ffff ffff None
fd (destination) 2nd word 1111 ffff ffff ffff
MOVWF f, a Move WREG to f 1 0110 111a ffff ffff None
MULWF f, a Multiply WREG with f 1 0000 001a ffff ffff None 1, 2
NEGF f, a Negate f 1 0110 110a ffff ffff C, DC, Z, OV, N
RLCF f, d, a Rotate Left f through Carry 1 0011 01da ffff ffff C, Z, N 1, 2
RLNCF f, d, a Rotate Left f (No Carry) 1 0100 01da ffff ffff Z, N
RRCF f, d, a Rotate Right f through Carry 1 0011 00da ffff ffff C, Z, N
RRNCF f, d, a Rotate Right f (No Carry) 1 0100 00da ffff ffff Z, N
SETF f, a Set f 1 0110 100a ffff ffff None 1, 2
SUBFWB f, d, a Subtract f from WREG with 1 0101 01da ffff ffff C, DC, Z, OV, N
Borrow
SUBWF f, d, a Subtract WREG from f 1 0101 11da ffff ffff C, DC, Z, OV, N 1, 2
SUBWFB f, d, a Subtract WREG from f with 1 0101 10da ffff ffff C, DC, Z, OV, N
Borrow
SWAPF f, d, a Swap Nibbles in f 1 0011 10da ffff ffff None 4
TSTFSZ f, a Test f, Skip if 0 1 (2 or 3) 0110 011a ffff ffff None 1, 2
XORWF f, d, a Exclusive OR WREG with f 1 0001 10da ffff ffff Z, N
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that value
present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is driven low by an
external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared if
assigned.
3: If the Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second
cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP unless the
first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all program memory
locations have a valid instruction.
BIT-ORIENTED OPERATIONS
BCF f, b, a Bit Clear f 1 1001 bbba ffff ffff None 1, 2
BSF f, b, a Bit Set f 1 1000 bbba ffff ffff None 1, 2
BTFSC f, b, a Bit Test f, Skip if Clear 1 (2 or 3) 1011 bbba ffff ffff None 3, 4
BTFSS f, b, a Bit Test f, Skip if Set 1 (2 or 3) 1010 bbba ffff ffff None 3, 4
BTG f, b, a Bit Toggle f 1 0111 bbba ffff ffff None 1, 2
CONTROL OPERATIONS
BC n Branch if Carry 1 (2) 1110 0010 nnnn nnnn None
BN n Branch if Negative 1 (2) 1110 0110 nnnn nnnn None
BNC n Branch if Not Carry 1 (2) 1110 0011 nnnn nnnn None
BNN n Branch if Not Negative 1 (2) 1110 0111 nnnn nnnn None
BNOV n Branch if Not Overflow 1 (2) 1110 0101 nnnn nnnn None
BNZ n Branch if Not Zero 1 (2) 1110 0001 nnnn nnnn None
BOV n Branch if Overflow 1 (2) 1110 0100 nnnn nnnn None
BRA n Branch Unconditionally 2 1101 0nnn nnnn nnnn None
BZ n Branch if Zero 1 (2) 1110 0000 nnnn nnnn None
CALL 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 the 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 the 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
0≤b≤7 0≤b<7
a ∈ [0,1] a ∈ [0,1]
Operation: skip if (f<b>) = 0 Operation: skip if (f<b>) = 1
Status Affected: None Status Affected: None
Encoding: 1011 bbba ffff ffff Encoding: 1010 bbba ffff ffff
Description: If bit ‘b’ in register ‘f’ is ‘0’, then the next Description: If bit ‘b’ in register ‘f’ is ‘1’, then the next
instruction is skipped. If bit ‘b’ is ‘0’, then instruction is skipped. If bit ‘b’ is ‘1’, then
the next instruction fetched during the the next instruction fetched during the
current instruction execution is discarded current instruction execution is discarded
and a NOP is executed instead, making and a NOP is executed instead, making
this a two-cycle instruction. this a two-cycle instruction.
If ‘a’ is ‘0’, the Access Bank is selected. If If ‘a’ is ‘0’, the Access Bank is selected. If
‘a’ is ‘1’, the BSR is used to select the ‘a’ is ‘1’, the BSR is used to select the
GPR bank. GPR bank.
If ‘a’ is ‘0’ and the extended instruction If ‘a’ is ‘0’ and the extended instruction
set is enabled, this instruction operates in set is enabled, this instruction operates
Indexed Literal Offset Addressing in Indexed Literal Offset Addressing
mode whenever f ≤ 95 (5Fh). mode whenever f ≤ 95 (5Fh).
See Section 24.2.3 “Byte-Oriented and See Section 24.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed Bit-Oriented Instructions in Indexed
Literal Offset Mode” for details. Literal Offset Mode” for details.
Words: 1 Words: 1
Cycles: 1(2) Cycles: 1(2)
Note: 3 cycles if skip and followed Note: 3 cycles if skip and followed
by a 2-word instruction. by a 2-word instruction.
Q Cycle Activity: Q Cycle Activity:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Decode Read Process No Decode Read Process No
register ‘f’ Data operation register ‘f’ Data operation
If skip: If skip:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
If skip and followed by 2-word instruction: If skip and followed by 2-word instruction:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
No No No No No No No No
operation operation operation operation operation operation operation operation
No No No No No No No No
operation operation operation operation operation operation operation operation
CPFSGT Compare f with W, Skip if f > W CPFSLT Compare f with W, Skip if f < W
Syntax: CPFSGT f {,a} Syntax: CPFSLT f {,a}
Operands: 0 ≤ f ≤ 255 Operands: 0 ≤ f ≤ 255
a ∈ [0,1] a ∈ [0,1]
Operation: (f) – (W), Operation: (f) – (W),
skip if (f) > (W) skip if (f) < (W)
(unsigned comparison) (unsigned comparison)
Status Affected: None Status Affected: None
Encoding: 0110 010a ffff ffff
Encoding: 0110 000a ffff ffff
Description: Compares the contents of data memory
Description: Compares the contents of data memory
location ‘f’ to the contents of the W by
location ‘f’ to the contents of W by
performing an unsigned subtraction.
performing an unsigned subtraction.
If the contents of ‘f’ are greater than the
If the contents of ‘f’ are less than the
contents of WREG, then the fetched
contents of W, then the fetched
instruction is discarded and a NOP is
instruction is discarded and a NOP is
executed instead, making this a
executed instead, making this a
two-cycle instruction.
two-cycle instruction.
If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘1’, the BSR is used to select the
If ‘a’ is ‘1’, the BSR is used to select the
GPR bank.
GPR bank.
If ‘a’ is ‘0’ and the extended instruction
set is enabled, this instruction operates Words: 1
in Indexed Literal Offset Addressing Cycles: 1(2)
mode whenever f ≤ 95 (5Fh). See
Note: 3 cycles if skip and followed
Section 24.2.3 “Byte-Oriented and by a 2-word instruction.
Bit-Oriented Instructions in Indexed
Literal Offset Mode” for details. Q Cycle Activity:
Words: 1 Q1 Q2 Q3 Q4
Cycles: 1(2) Decode Read Process No
Note: 3 cycles if skip and followed register ‘f’ Data operation
by a 2-word instruction. If skip:
Q Cycle Activity: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 No No No No
Decode Read Process No operation operation operation operation
register ‘f’ Data operation If skip and followed by 2-word instruction:
If skip: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 No No No No
No No No No operation operation operation operation
operation operation operation operation No No No No
If skip and followed by 2-word instruction: operation operation operation operation
Q1 Q2 Q3 Q4
No No No No
Example: HERE CPFSLT REG, 1
operation operation operation operation NLESS :
No No No No LESS :
operation operation operation operation
Before Instruction
PC = Address (HERE)
Example: HERE CPFSGT REG, 0 W = ?
NGREATER : After Instruction
GREATER :
If REG < W;
Before Instruction PC = Address (LESS)
PC = Address (HERE) If REG ≥ W;
W = ? PC = Address (NLESS)
After Instruction
If REG > W;
PC = Address (GREATER)
If REG ≤ W;
PC = Address (NGREATER)
Q1 Q2 Q3 Q4 Q Cycle Activity:
Decode Read Process Write to Q1 Q2 Q3 Q4
register ‘f’ Data destination Decode Read Process Write to
If skip: register ‘f’ Data destination
Q1 Q2 Q3 Q4 If skip:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
If skip and followed by 2-word instruction: operation operation operation operation
Q1 Q2 Q3 Q4 If skip and followed by 2-word instruction:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
No No No No operation operation operation operation
operation operation operation operation No No No No
operation operation operation operation
Example: HERE DECFSZ CNT, 1, 1
GOTO LOOP Example: HERE DCFSNZ TEMP, 1, 0
CONTINUE ZERO :
NZERO :
Before Instruction
PC = Address (HERE) Before Instruction
After Instruction TEMP = ?
CNT = CNT – 1 After Instruction
If CNT = 0; TEMP = TEMP – 1,
PC = Address (CONTINUE) If TEMP = 0;
If CNT ≠ 0; PC = Address (ZERO)
PC = Address (HERE + 2) If TEMP ≠ 0;
PC = Address (NZERO)
POP Pop Top of Return Stack PUSH Push Top of Return Stack
Syntax: POP Syntax: PUSH
Operands: None Operands: None
Operation: (TOS) → bit bucket Operation: (PC + 2) → TOS
Status Affected: None Status Affected: None
Encoding: 0000 0000 0000 0110 Encoding: 0000 0000 0000 0101
Description: The TOS value is pulled off the return Description: The PC + 2 is pushed onto the top of
stack and is discarded. The TOS value the return stack. The previous TOS
then becomes the previous value that value is pushed down on the stack.
was pushed onto the return stack. This instruction allows implementing a
This instruction is provided to enable software stack by modifying TOS and
the user to properly manage the return then pushing it onto the return stack.
stack to incorporate a software stack.
Words: 1
Words: 1
Cycles: 1
Cycles: 1 Q Cycle Activity:
Q Cycle Activity: Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4 Decode PUSH No No
Decode No POP TOS No PC + 2 onto operation operation
operation value operation return stack
RLNCF Rotate Left f (No Carry) RRCF Rotate Right f through Carry
Syntax: RLNCF f {,d {,a}} Syntax: RRCF f {,d {,a}}
Operands: 0 ≤ f ≤ 255 Operands: 0 ≤ f ≤ 255
d ∈ [0,1] d ∈ [0,1]
a ∈ [0,1] a ∈ [0,1]
Operation: (f<n>) → dest<n + 1>, Operation: (f<n>) → dest<n – 1>,
(f<7>) → dest<0> (f<0>) → C,
Status Affected: N, Z (C) → dest<7>
Status Affected: C, N, Z
Encoding: 0100 01da ffff ffff
Encoding: 0011 00da ffff ffff
Description: The contents of register ‘f’ are rotated
one bit to the left. If ‘d’ is ‘0’, the result Description: The contents of register ‘f’ are rotated
is placed in W. If ‘d’ is ‘1’, the result is one bit to the right through the Carry
stored back in register ‘f’ (default). flag. If ‘d’ is ‘0’, the result is placed in W.
If ‘a’ is ‘0’, the Access Bank is selected. If ‘d’ is ‘1’, the result is placed back in
If ‘a’ is ‘1’, the BSR is used to select the register ‘f’ (default).
GPR bank. If ‘a’ is ‘0’, the Access Bank is selected.
If ‘a’ is ‘0’ and the extended instruction If ‘a’ is ‘1’, the BSR is used to select the
set is enabled, this instruction operates GPR bank.
in Indexed Literal Offset Addressing If ‘a’ is ‘0’ and the extended instruction
mode whenever f ≤ 95 (5Fh). See set is enabled, this instruction operates
Section 24.2.3 “Byte-Oriented and in Indexed Literal Offset Addressing
Bit-Oriented Instructions in Indexed mode whenever f ≤ 95 (5Fh). See
Literal Offset Mode” for details. Section 24.2.3 “Byte-Oriented and
Bit-Oriented Instructions in Indexed
register f
Literal Offset Mode” for details.
Words: 1 C register f
Cycles: 1
Words: 1
Q Cycle Activity:
Cycles: 1
Q1 Q2 Q3 Q4
Decode Read Process Write to Q Cycle Activity:
register ‘f’ Data destination Q1 Q2 Q3 Q4
Decode Read Process Write to
Example: RLNCF REG, 1, 0 register ‘f’ Data destination
Before Instruction
REG = 1010 1011 Example: RRCF REG, 0, 0
After Instruction Before Instruction
REG = 0101 0111 REG = 1110 0110
C = 0
After Instruction
REG = 1110 0110
W = 0111 0011
C = 0
Words: 1 Words: 1
Cycles: 1 Cycles: 1
Q Cycle Activity: Q Cycle Activity:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Decode Read Process Write to Decode Read Process Write to
register ‘f’ Data destination register ‘f’ Data destination
Example 1: SUBWFB REG, 1, 0
Before Instruction Example: SWAPF REG, 1, 0
REG = 19h (0001 1001)
W = 0Dh (0000 1101) Before Instruction
C = 1 REG = 53h
After Instruction After Instruction
REG = 0Ch (0000 1011) REG = 35h
W = 0Dh (0000 1101)
C = 1
Z = 0
N = 0 ; result is positive
Example 2: SUBWFB REG, 0, 0
Before Instruction
REG = 1Bh (0001 1011)
W = 1Ah (0001 1010)
C = 0
After Instruction
REG = 1Bh (0001 1011)
W = 00h
C = 1
Z = 1 ; result is zero
N = 0
Example 3: SUBWFB REG, 1, 0
Before Instruction
REG = 03h (0000 0011)
W = 0Eh (0000 1101)
C = 1
After Instruction
REG = F5h (1111 0100)
; [2’s comp]
W = 0Eh (0000 1101)
C = 0
Z = 0
N = 1 ; result is negative
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: 0 ≤ k ≤ 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) → FSR(f) (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 contents of the FSR2. A RETURN is then
by ‘f’. executed by loading the PC with the TOS.
Words: 1 The instruction takes two cycles to
execute; a NOP is performed during the
Cycles: 1
second cycle.
Q Cycle Activity: This may be thought of as a special case of
Q1 Q2 Q3 Q4 the SUBFSR instruction, where f = 3 (binary
Decode Read Process Write to ‘11’); it operates only on FSR2.
register ‘f’ Data destination Words: 1
Cycles: 2
Q Cycle Activity:
Example: SUBFSR 2, 23h
Before Instruction Q1 Q2 Q3 Q4
FSR2 = 03FFh Decode Read Process Write to
register ‘f’ Data destination
After Instruction
FSR2 = 03DCh No No No No
Operation Operation Operation Operation
† NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
6.0V
5.5V
5.0V PIC18F2X2X/4X2X
4.5V
Voltage
4.2V
4.0V
3.5V
3.0V
2.5V
2.0V
40 MHz
Frequency
6.0V
5.5V
5.0V PIC18F2X2X/4X2X
4.5V
Voltage
4.2V
4.0V
3.5V
3.0V
2.5V
2.0V
25 MHz
Frequency
6.0V
5.5V
5.0V
4.5V PIC18LF2X2X/4X2X
Voltage
4.2V
4.0V
3.5V
3.0V
2.5V
2.0V
4 MHz 40 MHz
Frequency
FMAX = (16.36 MHz/V) (VDDAPPMIN – 2.0V) + 4 MHz
Note: VDDAPPMIN is the minimum voltage of the PIC® device in the application.
Param
Sym Characteristics Min Typ Max Units Comments
No.
D300 VIOFF Input Offset Voltage — ±5.0 ±10 mV
D301 VICM Input Common Mode Voltage 0 — VDD – 1.5 V
D302 CMRR Common Mode Rejection Ratio 55 — — dB
300 TRESP Response Time(1) — 150 400 ns PIC18FXXXX
300A — 150 600 ns PIC18LFXXXX,
VDD = 2.0V
301 TMC2OV Comparator Mode Change to — — 10 μs
Output Valid
Note 1: Response time measured with one comparator input at (VDD – 1.5)/2, while the other input transitions
from VSS to VDD.
Param
Sym Characteristics Min Typ Max Units Comments
No.
D310 VRES Resolution VDD/24 — VDD/32 LSb
D311 VRAA Absolute Accuracy — — 1/2 LSb
D312 VRUR Unit Resistor Value (R) — 2k — Ω
310 TSET Settling Time(1) — — 10 μs
Note 1: Settling time measured while CVRR = 1 and CVR3:CVR0 transitions from ‘0000’ to ‘1111’.
VDD
(HLVDIF can be
VLVD cleared in software)
(HLVDIF set by hardware)
HLVDIF(1)
Note 1: VDIRMAG = 0.
VDD/2
RL Pin CL
VSS
CL
Pin
RL = 464Ω
VSS CL = 50 pF for all pins except OSC2/CLKO
and including D and E outputs as ports
OSC1
1 3 3 4 4
2
CLKO
Param
Device Min Typ Max Units Conditions
No.
INTOSC Accuracy @ Freq = 8 MHz, 4 MHz, 2 MHz, 1 MHz, 500 kHz, 250 kHz, 125 kHz, 31 kHz(1)
PIC18LF2525/2620/4525/4620 -2 +/-1 2 % +25°C VDD = 2.7-3.3V
-5 +/-1 5 % -40°C to +85°C VDD = 2.7-3.3V
PIC18F2525/2620/4525/4620 -2 +/-1 2 % +25°C VDD = 4.5-5.5V
-5 +/-1 5 % -40°C to +85°C VDD = 4.5-5.5V
INTRC Accuracy @ Freq = 31 kHz
PIC18LF2525/2620/4525/4620 26.562 — 35.938 kHz -40°C to +85°C VDD = 2.7-3.3V
PIC18F2525/2620/4525/4620 26.562 — 35.938 kHz -40°C to +85°C VDD = 4.5-5.5V
Legend: Shading of rows is to assist in readability of the table.
Note 1: Frequency calibrated at 25°C. OSCTUNE register can be used to compensate for temperature drift.
OSC1
10 11
CLKO
13 12
14 19 18
16
I/O pin
(Input)
17 15
20, 21
Note: Refer to Figure 26-5 for load conditions.
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
OSC
Time-out
Internal
Reset
Watchdog
Timer
Reset 31
34 34
I/O pins
VDD BVDD
35
VIRVST
Enable Internal
Reference Voltage
Internal Reference
Voltage Stable 36
TABLE 26-10: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET REQUIREMENTS
Param.
Symbol Characteristic Min Typ Max Units Conditions
No.
30 TmcL MCLR Pulse Width (low) 2 — — μs
31 TWDT Watchdog Timer Time-out Period 3.4 4.1 4.71 ms
(no postscaler)
32 TOST Oscillation Start-up Timer Period 1024 TOSC — 1024 TOSC — TOSC = OSC1 period
33 TPWRT Power-up Timer Period 55.6 65.5 75.4 ms
34 TIOZ I/O High-Impedance from MCLR — 2 — μs
Low or Watchdog Timer Reset
35 TBOR Brown-out Reset Pulse Width 200 — — μs VDD ≤ BVDD (see D005)
36 TIVRST Time for Internal Reference — 20 50 μs
Voltage to become Stable
37 TLVD High/Low-Voltage Detect Pulse Width 200 — — μs VDD ≤ VLVD
38 TCSD CPU Start-up Time — 10 — μs
39 TIOBST Time for INTOSC to Stabilize — 1 — μs
T0CKI
40 41
42
T1OSO/T13CKI
45 46
47 48
TMR0 or
TMR1
CCPx
(Capture Mode)
50 51
52
CCPx
(Compare or PWM Mode)
53 54
RE2/CS
RE0/RD
RE1/WR
65
RD7:RD0
62
64
63
Note: Refer to Figure 26-5 for load conditions.
SS
70
SCK
(CKP = 0)
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76
SS
81
SCK
(CKP = 0)
71 72
79
73
SCK
(CKP = 1)
80
78
75, 76
74
Note: Refer to Figure 26-5 for load conditions.
SS
70
SCK
(CKP = 0) 83
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76 77
70
SCK 83
(CKP = 0)
71 72
SCK
(CKP = 1)
80
75, 76 77
SDI
MSb In bit 6 - - - -1 LSb In
74
Note: Refer to Figure 26-5 for load conditions.
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
91 92
SDA
In
110
109 109
SDA
Out
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
SDA
Out
RC6/TX/CK
pin 121 121
RC7/RX/DT
pin
120
122
Note: Refer to Figure 26-5 for load conditions.
RC6/TX/CK
pin 125
RC7/RX/DT
pin
126
BSF ADCON0, GO
(Note 2)
131
Q4
130
(1) 132
A/D CLK
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.
Test instrument results are compressed to about 0.05 μA for actual values below 0.05 μA.
Measurements below 0.01 μA are suspect, and are considered unmeasurable.
This is supported by the instrument specifications.
10
5.5
5.0
4.5
4.0
Ipd (uA)
3.5
1
3.0
2.5
2.0
0.1
0.01
-50 -25 0 25 50 75 100 125
Temp (C)
10
125C
IPD (uA)
1 85C
25C
0.1
-40C
0.01
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 27-3: MAXIMUM IPD vs. VDD ACROSS TEMPERATURE (SLEEP MODE)
100
125C
10
85C
IPD (uA)
25C
-40C
0.1
0.01
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
2.5
2.0
85C
IPD (uA)
1.5
25C
1.0
-10C
0.5
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 27-5: MAXIMUM T1OSC DELTA CURRENT vs. VDD ACROSS TEMP. (DEVICE IN
SLEEP, TIOSC IN LOW-POWER MODE)
4
85C
25C -10C
IPD (uA)
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
14
12
10
IPD (uA)
8
85C
25C
6
-40C
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 27-7: MAXIMUM T1OSC DELTA CURRENT vs. VDD ACROSS TEMP. (DEVICE IN
SLEEP, T1OSC IN HIGH-POWER MODE)
30
25
20
IPD (uA)
15
85C
10
25C
-40C
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
50.00
Device
Held in MAX (125C)
RESET
45.00
MAX (85C)
40.00
TYP (25C)
IPD (uA)
35.00
MIN (-40C)
30.00
Device
in
SLEEP
25.00
20.00
2 2.5 3 3.5 4 4.5 5 5.5
VDD (V)
5.00 85C
125C
3.00
2.00
1.00
0.00
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 27-10: MAXIMUM WDT CURRENT vs. VDD ACROSS TEMPERATURE (WDT DELTA
CURRENT IN SLEEP MODE)
12.0
10.0
125C
8.0
85C
IPD (uA)
6.0
25C -40C
4.0
2.0
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
(4.2V
8 MHz
4 MHz
2 MHz
IDD (mA)
1 1 MHz
500 kHz
250 kHz
125 kHz
0.1
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
8 MHz
(4.2V
4 MHz
2 MHz
IDD (mA)
1 MHz
1
0.1
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
Maximum
IDD (uA)
100 (-40C)
Typical
(25C)
10
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
(4.2V)
8 MHz
1 4 MHz
2 MHz
IDD (mA)
1 MHz
0.01
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
(4.2V
8 MHz
IDD (mA)
4 MHz
1
2 MHz
1 MHz
125 kHz
0.1
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 27-16: TYPICAL AND MAXIMUM IDD ACROSS VDD (RC_IDLE MODE, 31 kHz)
25
20
15
IDD (uA)
Maximum
(85C)
10
Typical
(25C)
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
120.0
Max (-10C)
100.0
80.0
IDD (uA)
60.0
Typ (85C)
Typ (25C)
Typ (-10C)
40.0
20.0
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 27-18: TYPICAL AND MAXIMUM SEC_IDLE CURRENT vs. VDD ACROSS
TEMPERATURE (T1OSC IN LOW-POWER MODE)
14.0
12.0
Max (85C)
8.0
IDD (uA)
Typ (85C)
6.0
Typ (-10C)
4.0
2.0
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
2.5
5.5V
5.0V
2.0
4.5V
IDD (mA)
4.0V
1.5
3.5V
3.0V
1.0
2.5V
2.0V
0.5
0.0
0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Fosc (MHz)
FIGURE 27-20: MAXIMUM IDD vs. FOSC, 500 kHz TO 4 MHz (PRI_RUN MODE (EC CLOCK),
-40°C TO +125°C)
4.5
5.5V
4.0
3.5 5.0V
3.0 4.5V
2.5 4.0V
IDD (mA)
2.0 3.5V
1.5 3.0V
1.0 2.5V
2.0V
0.5
0.0
0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Fosc (MHz)
5.5V
18
5.0V
16
4.5V
14
12
4.0V
IDD (mA)
10
8 3.5V
3.0V
4
2 2.5V
2.0V
0
4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
FIGURE 27-22: MAXIMUM IDD vs. FOSC, 4 MHz TO 40 MHz (PRI_RUN MODE (EC CLOCK),
-40°C TO +125°C)
24
22
5.5V
20
5.0V
18
4.5V
16
14 4.0V
IDD (mA)
12
10
3.5V
8
6
3.0V
4
2.5V
2
2.0V
0
4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
22
20
18
5.5V
16
IDD (mA)
5.0V
14
4.5V
12
4.2V
10
4
16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
FIGURE 27-24: MAXIMUM IDD vs. FOSC, HS/PLL (PRI_RUN MODE, -40°C)
24
22
20
5.5V
18
5.0V
16
IDD (mA)
4.5V
14
4.2V
12
10
4
16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
1.0
0.9
5.5V
0.8
5.0V
0.7
4.5V
0.6
IDD (mA)
4.0V
0.5
3.5V
0.4 3.0V
0.3 2.5V
2.0V
0.2
0.1
0.0
0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Fosc (MHz)
FIGURE 27-26: MAXIMUM IDD vs. FOSC, 500 kHz TO 4 MHz (PRI_IDLE MODE, -40°C TO +125°C)
1.2
1.1
1.0
5.5V
0.9
5.0V
0.8
4.5V
0.7
IDD (mA)
4.0V
0.6
3.5V
0.5
3.0V
0.4
2.5V
0.3
2.0V
0.2
0.1
0.0
0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Fosc (MHz)
11
10
9 5.5V
8 5.0V
7 4.5V
IDD (mA)
6
4.0V
5
4
3.5V
2 3.0V
1
2.5V
2.0V
0
4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
FIGURE 27-28: MAXIMUM IDD vs. FOSC, 4 MHz TO 40 MHz (PRI_IDLE MODE, -40°C TO +125°C)
12
11
10
5.5V
9
5.0V
8
4.5V
7
IDD (mA)
6 4.0V
4 3.5V
3.0V
2
1 2.5V
2.0V
0
4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
11
10
8
5.5V
7
5.0V
IDD (mA)
6
4.5V
4.2V
5
0
16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
FIGURE 27-30: MAXIMUM IDD vs. FOSC, HS/PLL (PRI_IDLE MODE, -40°C)
12
11
10
9
5.5
8
5.0
7
IDD (mA)
4.5
6
4.2
0
16 18 20 22 24 26 28 30 32 34 36 38 40
Fosc (MHz)
3.5
VIH Min
(-40C)
VIH Typ
3.0 (25C)
VIH Max
(125C)
2.5
VIN (V)
2.0
1.5
1.0
VIL Max
VIL Typ (-40C)
VIL Min
0.5 (25C)
(125C)
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
1.0
VIN (V)
0.8
0.6
0.4
0.2
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
1.8
1.6
1.4
Max (85C)
1.2
VOL (V)
1.0
0.8
Typ (25C)
0.6
0.4
Min (-40C)
0.2
0.0
0 5 10 15 20 25
IOL (-ma)
1.8
1.6
1.4
1.2
VOL (V)
1.0
0.8
Max (85C)
0.6
Typ (25C)
0.4
0.2
Min (-40C)
0.0
0 5 10 15 20 25
IOL (-ma)
3.0
2.5
2.0
Max (-40C)
VOH (V)
1.5
1.0
0.5
0.0
0 5 10 15 20 25
IOH (-ma)
4.5
Max (-40C)
4.0
3.5
Typ (25C)
3.0
VOH (V)
2.5
Min (125C)
2.0
1.5
1.0
0.5
0.0
0 5 10 15 20 25
IOH (-ma)
Max Freq
8.3
8.2
125C Typ
85C Typ
8.1
Freq (MHz)
25C Typ
8.0
-40C Typ
7.9
7.8
Min Freq
7.7
7.6
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
39
38
37 Max (125C)
36
35
34
Max (-40C)
Freq (kHz)
33
32
31
Typ (25C)
30
29 Min (85C)
28
27
Min (125C)
26
25
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
Longest
4.4
4.2
3.8
3.6
3.4
3.2
3.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
XXXXXXXXXXXXXXXXX PIC18F2620-I/SP e3
XXXXXXXXXXXXXXXXX 0810017
YYWWNNN
XXXXXXXXXXXXXXXXXXXX PIC18F2620-E/SO e3
XXXXXXXXXXXXXXXXXXXX 0810017
XXXXXXXXXXXXXXXXXXXX
YYWWNNN
XXXXXXXXXXXXXXXXXX PIC18F4620-I/P e3
XXXXXXXXXXXXXXXXXX 0810017
XXXXXXXXXXXXXXXXXX
YYWWNNN
Note: In the event the full Microchip part number cannot be marked on one line, it will
be carried over to the next line, thus limiting the number of available characters
for customer-specific information.
XXXXXXXXXX PIC18F4620
XXXXXXXXXX -I/ML e3
XXXXXXXXXX 0810017
YYWWNNN
XXXXXXXXXX PIC18F4620
XXXXXXXXXX -I/PT e3
XXXXXXXXXX 0810017
YYWWNNN
!" 3
&'
!&" &4# *!(!!&
4%&
&#&
&&255***'
'54
N
NOTE 1
E1
1 2 3
A A2
L c
A1 b1
b e eB
6&! 7,8.
'!
9'&! 7 7: ;
7"')
%! 7 <
& 1,
&
& = =
##4
4!! -
1!&
& = =
"# &
"# >#& . - --
##4>#& . <
: 9& - -?
&
& 9 -
9#
4!! <
6 9#>#& )
9
* 9#>#& ) <
:
*+ 1 = = -
!"
!"#$%&" ' ()"&'"!&)
&#*&&&#
+%&, & !&
- '!
!#.#
&"#'
#%!
& "!
!
#%!
& "!
!!
&$#/ !#
'!
#&
.0
1,2 1!'!
&$& "!
**&
"&&
!
* ,1
D
N
E
E1
NOTE 1
1 2 3
e
b
h
α
h
φ c
A A2
L
A1 L1 β
&
I B = <B
9#
4!! < = --
9#>#& ) - =
# %&
D B = B
# %&1
&&
' E B = B
!"
!"#$%&" ' ()"&'"!&)
&#*&&&#
+%&, & !&
- '!
!#.#
&"#'
#%!
& "!
!
#%!
& "!
!!
&$#'' !#
'!
#&
.0
1,2 1!'!
&$& "!
**&
"&&
!
.32 % '!
("!"*&
"&&
(%
%
'&
"
!!
* ,1
NOTE 1
E1
1 2 3
A A2
L c
b1
A1
b e eB
6&! 7,8.
'!
9'&! 7 7: ;
7"')
%! 7
& 1,
&
& = =
##4
4!! =
1!&
& = =
"# &
"# >#& . = ?
##4>#& . < = <
: 9& < =
&
& 9 =
9#
4!! < =
6 9#>#& ) - =
9
* 9#>#& ) = -
:
*+ 1 = =
!"
!"#$%&" ' ()"&'"!&)
&#*&&&#
+%&, & !&
- '!
!#.#
&"#'
#%!
& "!
!
#%!
& "!
!!
&$#/ !#
'!
#&
.0
1,2 1!'!
&$& "!
**&
"&&
!
* ,?1
D D2
EXPOSED
PAD
E2
b
2 2
1 1
N N K
NOTE 1 L
A3 A1
* ,-1
D
D1
E
e
E1
N
b
NOTE 1 1 2 3
NOTE 2
A α
c φ
β A1 A2
L L1
& I B -B B
: >#& . 1,
: 9& 1,
##4>#& . 1,
##49& 1,
9#
4!! =
9#>#& ) - -
# %&
D B B -B
# %&1
&&
' E B B -B
!"
!"#$%&" ' ()"&'"!&)
&#*&&&#
,'% !&
!
&
D!E'
- '!
!#.#
&"#'
#%!
& "!
!
#%!
& "!
!!
&$#'' !#
'!
#&
.0
1,2 1!'!
&$& "!
**&
"&&
!
.32 % '!
("!"*&
"&&
(%
%
'&
"
!!
* ,?1
From: Name
Company
Address
City / State / ZIP / Country
Telephone: (_______) _________ - _________ FAX: (______) _________ - _________
Application (optional):
Would you like a reply? Y N
Questions:
2. How does this document meet your hardware and software development needs?
3. Do you find the organization of this document easy to follow? If not, why?
4. What additions to the document do you think would enhance the structure and subject?
5. What deletions from the document could be made without affecting the overall usefulness?
01/02/08