Professional Documents
Culture Documents
Data Sheet
28/40/44-Pin
Enhanced Flash Microcontrollers
with ECAN™ Technology, 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- 4 25 RB4/KBI0/AN9
5 24 RB3/CANRX
PIC18F2682
PIC18F2685
RA3/AN3/VREF+
RA4/T0CKI 6 23 RB2/INT2/CANTX
RA5/AN4/SS/HLVDIN 7 22 RB1/INT1/AN8
VSS 8 21 RB0/INT0/AN10
OSC1/CLKI/RA7 9 20 VDD
OSC2/CLKO/RA6 10 19 VSS
RC0/T1OSO/T13CKI 11 18 RC7/RX/DT
RC1/T1OSI 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/CVREF 2 39 RB6/KBI2/PGC
RA1/AN1 3 38 RB5/KBI1/PGM
RA2/AN2/VREF- 4 37 RB4/KBI0/AN9
RA3/AN3/VREF+ 5 36 RB3/CANRX
RA4/T0CKI 6 35 RB2/INT2/CANTX
RA5/AN4/SS/HLVDIN 7 34 RB1/INT1/AN8
PIC18F4682
PIC18F4685
RE0/RD/AN5 8 33 RB0/INT0/FLT0/AN10
RE1/WR/AN6/C1OUT 9 32 VDD
RE2/CS/AN7/C2OUT 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/ECCP1/P1A
RC0/T1OSO/T13CKI 15 26 RC7/RX/DT
RC1/T1OSI 16 25 RC6/TX/CK
RC2/CCP1 17 24 RC5/SDO
RC3/SCK/SCL 18 23 RC4/SDI/SDA
RD0/PSP0/C1IN+ 19 22 RD3/PSP3/C2IN-
RD1/PSP1/C1IN- 20 21 RD2/PSP2/C2IN+
RD2/PSP2/C2IN+
RD0/PSP0/C1IN+
RD3/PSP3/C2IN-
RD1/PSP1/C1IN-
44-Pin TQFP
RC3/SCK/SCL
RC4/SDI/SDA
RC6/TX/CK
RC1/T1OSI
RC2/CCP1
RC5/SDO
NC
44
43
42
41
40
39
38
37
36
35
34
RC7/RX/DT 1 33 NC
RD4/PSP4/ECCP1/P1A 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 PIC18F4682 29 VSS
VSS 6 28 VDD
VDD 7 PIC18F4685 27 RE2/CS/AN7/C2OUT
RB0/INT0/FLT0/AN10 8 26 RE1/WR/AN6/C1OUT
RB1/INT1/AN8 9 25 RE0/RD/AN5
RB2/INT2/CANTX 10 24 RA5/AN4/SS/HLVDIN
RB3/CANRX 11 23 RA4/T0CKI
12
13
14
15
16
17
18
19
20
21
22
NC
NC
RB6/KBI2/PGC
RB7/KBI3/PGD
RA3/AN3/VREF+
RB5/KBI1/PGM
RB4/KBI0/AN9
MCLR/VPP/RE3
RA1/AN1
RA2/AN2/VREF-
RA0/AN0/CVREF
RC0/T1OSO/T13CKI
RD2/PSP2/C2IN+
RD0/PSP0/C1IN+
44-Pin QFN
RD3/PSP3/C2IN-
RD1/PSP1/C1IN-
RC3/SCK/SCL
RC4/SDI/SDA
RC6/TX/CK
RC1/T1OSI
RC2/CCP1
RC5/SDO
34
44
43
42
41
40
39
38
37
36
35
RC7/RX/DT 1 33 OSC2/CLKO/RA6
RD4/PSP4/ECCP1/P1A 2 32 OSC1/CLKI/RA7
RD5/PSP5/P1B 3 31 VSS
RD6/PSP6/P1C 4 30 AVSS
RD7/PSP7/P1D 5 PIC18F4682 29 VDD
VSS 6 28 AVDD
AVDD 7
PIC18F4685 27 RE2/CS/AN7/C2OUT
VDD 8 26 RE1/WR/AN6/C1OUT
RB0/INT0/FLT0/AN10 9 25 RE0/RD/AN5
RB1/INT1/AN8 10 24 RA5/AN4/SS/HLVDIN
RB2/INT2/CANTX 11 23 RA4/T0CKI
12
13
14
15
16
17
18
19
20
21
22
NC
RB6/KBI2/PGC
RB7/KBI3/PGD
RA3/AN3/VREF+
RB3/CANRX
RB4/KBI0/AN9
RB5/KBI1/PGM
MCLR/VPP/RE3
RA1/AN1
RA2/AN2/VREF-
RA0/AN0/CVREF
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.
Data Bus<8>
Table Pointer<21>
8
Instruction State Machine
Decode & Control Signals
Control
PRODH PRODL
PORTC
8 x 8 Multiply RC0/T1OSO/T13CKI
3 8 RC1/T1OSI
RC2/CCP1
BITOP W RC3/SCK/SCL
8 8 8
RC4/SDI/SDA
Internal RC5/SDO
OSC1(2) Power-up RC6/TX/CK
Oscillator 8 8
Block Timer RC7/RX/DT
(2) Oscillator
OSC2 ALU<8>
INTRC Start-up Timer
T1OSI Oscillator Power-on 8
Reset
8 MHz
T1OSO Oscillator Watchdog
Timer
Brown-out Band Gap
MCLR(1) Single-Supply
Programming Reset Reference PORTE
In-Circuit Fail-Safe
VDD, VSS Clock Monitor
Debugger MCLR/VPP/RE3(1)
BOR Data
EEPROM Timer0 Timer1 Timer2 Timer3
HLVD
ADC
CCP1 ECCP1 MSSP EUSART ECAN™
10-bit
Note 1: RE3 is multiplexed with MCLR and is only available when the MCLR Resets are disabled.
2: 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/CVREF
Data Latch RA1/AN1
inc/dec logic 8 8 RA2/AN2/VREF-
Data Memory RA3/AN3/VREF+
PCLATU PCLATH (3.3 Kbytes) RA4/T0CKI
21 RA5/AN4/SS/HLVDIN
20 Address Latch OSC2/CLKO/RA6
PCU PCH PCL OSC1/CLKI/RA7
Program Counter 12
Data Address<12>
PORTB
31 Level Stack
RB0/INT0/FLT0/AN10
Address Latch 4 12 4
RB1/INT1/AN8
BSR FSR0 Access
Program Memory STKPTR Bank RB2/INT2/CANTX
(80/96 Kbytes) FSR1 RB3/CANRX
FSR2 12 RB4/KBI0/AN9
Data Latch
RB5/KBI1/PGM
RB6/KBI2/PGC
inc/dec
8 logic RB7/KBI3/PGD
Table Latch
Address PORTC
ROM Latch
Instruction Bus <16> Decode RC0/T1OSO/T13CKI
RC1/T1OSI
RC2/CCP1
IR
RC3/SCK/SCL
RC4/SDI/SDA
8 RC5/SDO
State Machine RC6/TX/CK
Instruction
Decode & Control Signals RC7/RX/DT
Control
PRODH PRODL
PORTD
8 x 8 Multiply
3 RD0/PSP0/C1IN+
8
RD1/PSP1/C1IN-
BITOP W RD2/PSP2/C2IN+
8 8 8 RD3/PSP3/C2IN-
RD4/PSP4/ECCP1/P1A
OSC1(2) Internal RD5/PSP5/P1B
Oscillator Power-up
8 8 RD6/PSP6/P1C
Block Timer
(2) RD7/PSP7/P1D
OSC2 Oscillator ALU<8>
INTRC Start-up Timer
T1OSI Oscillator Power-on 8
Reset
8 MHz
T1OSO Oscillator Watchdog PORTE
Timer
RE0/RD/AN5
Brown-out Band Gap RE1/WR/AN6/C1OUT
MCLR(1) Single-Supply
Programming Reset Reference RE2/CS/AN7/C2OUT
In-Circuit Fail-Safe MCLR/VPP/RE3(1)
VDD, VSS Clock Monitor
Debugger
BOR Data
EEPROM Timer0 Timer1 Timer2 Timer3
HLVD
ADC
Comparator CCP1 ECCP1 MSSP EUSART ECAN™
10-bit
Note 1: RE3 is multiplexed with MCLR and is only available when the MCLR Resets are disabled.
2: 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.
MUX
Recommended values: 3 kΩ ≤ REXT ≤ 100 kΩ
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
text for details.
2.6.5.1 Compensating with the EUSART 2.6.5.3 Compensating with the CCP1
An adjustment may be required when the EUSART Module in Capture Mode
begins to generate framing errors or receives data with The CCP1 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.
PIC18F2682/2685/4682/4685
Primary Oscillator LP, XT, HS, RC, EC
OSC2
T1OSO
T1OSCEN
Enable
Oscillator OSCCON<6:4>
T1OSI
1 MHz
MUX
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
T1OSI 1 2 3 n-1 n
CPU
Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
FIGURE 3-2: TRANSITION TIMING FROM SEC_RUN MODE TO PRI_RUN MODE (HSPLL)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
T1OSI
OSC1
TOST(1) TPLL(1)
1 2 n-1 n
PLL Clock
Output
Clock
Transition
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.
3.2.3 RC_RUN MODE the INTOSC multiplexer (see Figure 3-3), the primary
oscillator is shut down and the OSTS bit is cleared. The
In RC_RUN mode, the CPU and peripherals are
IRCF bits may be modified at any time to immediately
clocked from the internal oscillator block using the
change the clock speed.
INTOSC multiplexer; the primary clock is shut down.
When using the INTRC source, this mode provides the Note: Caution should be used when modifying a
best power conservation of all the Run modes, while single IRCF bit. If VDD is less than 3V, it is
still executing code. It works well for user applications possible to select a higher clock speed
which are not highly timing sensitive or do not require than is supported by the low VDD.
high-speed clocks at all times. Improper device operation may result if
If the primary clock source is the internal oscillator the VDD/FOSC specifications are violated.
block (either INTRC or INTOSC), there are no distin- If the IRCF bits and the INTSRC bit are all clear, the
guishable differences between PRI_RUN and INTOSC output is not enabled and the IOFS bit will
RC_RUN modes during execution. However, a clock remain clear; there will be no indication of the current
switch delay will occur during entry to and exit from clock source. The INTRC source is providing the
RC_RUN mode. Therefore, if the primary clock source device clocks.
is the internal oscillator block, the use of RC_RUN
If the IRCF bits are changed from all clear (thus,
mode is not recommended.
enabling the INTOSC output) or if INTSRC is set, the
This mode is entered by setting SCS1 to ‘1’. Although IOFS bit becomes set after the INTOSC output
it is ignored, it is recommended that SCS0 also be becomes stable. Clocks to the device continue while
cleared; this is to maintain software compatibility with the INTOSC source stabilizes after an interval of
future devices. When the clock source is switched to TIOBST.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
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
CPU Clock
Peripheral
Clock
Program PC PC + 2 PC + 4
Counter
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
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
Note1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
Q1 Q2 Q3 Q4 Q1
OSC1
CPU Clock
Peripheral
Clock
Program
Counter PC PC + 2
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
HSPLL OSTS
Primary Device Clock
EC, RC TCSD(2)
(PRI_IDLE mode)
INTRC(1) —
INTOSC(3) IOFS
LP, XT, HS TOST(4)
HSPLL TOST + trc(4) OSTS
(1)
T1OSC or INTRC EC, RC
TCSD(2)
INTRC(1) —
INTOSC(3) TIOBST(5) IOFS
LP, XT, HS TOST(4)
HSPLL TOST + trc(4) OSTS
(3)
INTOSC EC, RC
TCSD(2)
INTRC(1) —
(3)
INTOSC None IOFS
LP, XT, HS TOST(4)
HSPLL TOST + trc(4) OSTS
None
EC, RC
(Sleep mode) TCSD(2)
INTRC(1) —
INTOSC(3) TIOBST(5) IOFS
Note 1: In this instance, refers specifically to the 31 kHz INTRC clock source.
2: 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”).
3: Includes both the INTOSC 8 MHz source and postscaler derived frequencies.
4: TOST is the Oscillator Start-up Timer (parameter 32). trc is the PLL Lock-out Timer (parameter F12); it is
also designated as TPLL.
5: Execution continues during TIOBST (parameter 39), the INTOSC stabilization period.
RESET
Instruction
External Reset
MCLRE
MCLR
( )_IDLE
Sleep
WDT
Time-out
OST/PWRT
OST 1024 Cycles
10-Bit Ripple Counter Chip_Reset
R Q
OSC1
32 μs PWRT 65.5 ms
INTRC(1) 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 a 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.
(OST)
Bringing 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
(1)
EC, ECIO 66 ms — —
RC, RCIO 66 ms(1) — —
INTIO1, INTIO2 66 ms(1) — —
Note 1: 66 ms (65.5 ms) is the nominal Power-up Timer (PWRT) delay.
2: 2 ms is the nominal time required for the PLL to lock.
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-4: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 1
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-5: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 2
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
5V
VDD 0V 1V
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-7: TIME-OUT SEQUENCE ON POR w/PLL ENABLED (MCLR TIED TO VDD)
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
TPLL
PLL TIME-OUT
INTERNAL RESET
TABLE 4-3: STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION FOR
RCON REGISTER
FIGURE 5-1: PROGRAM MEMORY MAP AND STACK FOR PIC18F2682/2685/4682/4685 DEVICES
PIC18F2682/4682 PIC18F2685/4685
PC<20:0> PC<20:0>
CALL, RCALL, RETURN 21 CALL, RCALL, RETURN 21
RETFIE, RETLW RETFIE, RETLW
Stack Level 1 Stack Level 1
• •
• •
• •
High Priority Interrupt Vector 00008h High Priority Interrupt Vector 0008h
Low Priority Interrupt Vector 0018h Low Priority Interrupt Vector 0018h
On-Chip
Program Memory On-Chip
Program Memory
13FFFh
14000h
User Memory Space
User Memory Space
17FFFh
18000h
Read ‘0’
Read ‘0’
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)
Note: All instructions are single cycle, except for any program branches. These take two cycles since the
fetch instruction is “flushed” from the pipeline while the new instruction is being fetched and then
executed.
5.2.4 TWO-WORD INSTRUCTIONS and used by the instruction sequence. If the first word
is skipped for some reason and the second word is
The standard PIC18 instruction set has four two-word
executed by itself, a NOP is executed instead. This is
instructions: CALL, MOVFF, GOTO and LSFR. In all
necessary for cases when the two-word instruction is
cases, the second word of the instructions always has
preceded by a conditional instruction that changes the
‘1111’ as its four Most Significant bits; the other 12 bits
PC. Example 5-4 shows how this works.
are literal data, usually a data memory address.
The use of ‘1111’ in the 4 MSbs of an instruction Note: See Section 5.5 “Program Memory and
specifies a special form of NOP. If the instruction is the Extended Instruction Set” for
executed in proper sequence – immediately after the information on two-word instructions in the
first word – the data in the second word is accessed extended instruction set.
When a = 0:
BSR<3:0> Data Memory Map
The BSR is ignored and the
00h 000h Access Bank is used.
= 0000 Access RAM 05Fh
Bank 0 060h The first 128 bytes are
FFh GPR general purpose RAM
0FFh
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 When a = 1:
2FFh
= 0011 00h 300h The BSR specifies the Bank
Bank 3 GPR used by the instruction.
FFh 3FFh
00h 400h
= 0100 Bank 4 GPR
FFh 4FFh
= 0101 00h 500h
Bank 5 GPR
FFh 5FFh
= 0110 00h 600h
Bank 6 GPR
Access Bank
FFh 6FFh
= 0111 00h 700h 00h
Bank 7 GPR Access RAM Low
5Fh
FFh 7FFh Access RAM High 60h
= 1000 00h 800h (SFRs)
Bank 8 FFh
GPR
FFh 8FFh
= 1001 00h 900h
Bank 9 GPR
FFh 9FFh
00h A00h
= 1010
Bank 10 GPR
FFh AFFh
= 1011 00h B00h
Bank 11 GPR
FFh BFFh
= 1100 00h C00h
Bank 12 GPR
FFh CFFh
= 1101 D00h
Bank 13 00h CAN SFRs
FFh DFFh
00h E00h
= 1110
Bank 14 CAN SFRs
FFh EFFh
00h CAN SFRs F00h
= 1111 F5Fh
Bank 15
SFR F60h
FFh FFFh
BSR(1)
Data Memory From Opcode(2)
7 0 000h 00h 7 0
0 0 0 0 0 0 1 1 Bank 0 1 1 1 1 1 1 1 1
100h FFh
00h
Bank 1
Bank Select(2) 200h FFh
00h
Bank 2
300h FFh
00h
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.6.3 “Mapping the Access Bank in
as the “Access RAM” and is composed of GPRs. The Indexed Literal Offset Mode”.
upper half is where the device’s SFRs are mapped.
These two areas are mapped contiguously in the 5.3.3 GENERAL PURPOSE
Access Bank and can be addressed in a linear fashion REGISTER FILE
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.
Note 1: Registers available only on PIC18F4X8X devices; otherwise, the registers read as ‘0’.
2: When any TX_ENn bit in RX_TX_SELn is set, then the corresponding bit in this register has transmit properties.
3: This is not a physical register.
Note 1: Registers available only on PIC18F4X8X devices; otherwise, the registers read as ‘0’.
2: When any TX_ENn bit in RX_TX_SELn is set, then the corresponding bit in this register has transmit properties.
3: This is not a physical register.
Note 1: Registers available only on PIC18F4X8X devices; otherwise, the registers read as ‘0’.
2: When any TX_ENn bit in RX_TX_SELn is set, then the corresponding bit in this register has transmit properties.
3: This is not a physical register.
Note 1: Registers available only on PIC18F4X8X devices; otherwise, the registers read as ‘0’.
2: When any TX_ENn bit in RX_TX_SELn is set, then the corresponding bit in this register has transmit properties.
3: This is not a physical register.
Note 1: Registers available only on PIC18F4X8X devices; otherwise, the registers read as ‘0’.
2: When any TX_ENn bit in RX_TX_SELn is set, then the corresponding bit in this register has transmit properties.
3: This is not a physical register.
Note 1: Registers available only on PIC18F4X8X devices; otherwise, the registers read as ‘0’.
2: When any TX_ENn bit in RX_TX_SELn is set, then the corresponding bit in this register has transmit properties.
3: This is not a physical register.
SPBRGH EUSART Baud Rate Generator Register High Byte 0000 0000 51, 231
SPBRG EUSART Baud Rate Generator Register Low Byte 0000 0000 51, 231
RCREG EUSART Receive Register 0000 0000 51, 238
TXREG EUSART Transmit Register 0000 0000 51, 236
TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 51, 237
RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 51, 237
EEADRH — — — — — — EEPROM Addr Register High Byte ---- --00 51, 108
EEADR EEPROM Address Register Low Byte 0000 0000 51, 105
EEDATA EEPROM Data Register 0000 0000 51, 105
EECON2 EEPROM Control Register 2 (not a physical register) 0000 0000 51, 105
EECON1 EEPGD CFGS — FREE WRERR WREN WR RD xx-0 x000 51, 105
IPR3 IRXIP WAKIP ERRIP TXB2IP TXB1IP TXB0IP RXB1IP RXB0IP 1111 1111 51, 126
Mode 0
IPR3 IRXIP WAKIP ERRIP TXBnIP TXB1IP(8) TXB0IP(8) RXBnIP FIFOWMIP 1111 1111 51, 126
Mode 1, 2
PIR3 IRXIF WAKIF ERRIF TXB2IF TXB1IF TXB0IF RXB1IF RXB0IF 0000 0000 51, 120
Mode 0
PIR3 IRXIF WAKIF ERRIF TXBnIF TXB1IF(8) TXB0IF(8) RXBnIF FIFOWMIF 0000 0000 51, 120
Mode 1, 2
PIE3 IRXIE WAKIE ERRIE TXB2IE TXB1IE TXB0IE RXB1IE RXB0IE 0000 0000 51, 123
Mode 0
PIE3 IRXIE WAKIE ERRIE TXBnIE TXB1IE(8) TXB0IE(8) RXBnIE FIFOMWIE 0000 0000 51, 123
Mode 1, 2
IPR2 OSCFIP CMIP(9) — EEIP BCLIP HLVDIP TMR3IP ECCP1IP(9) 11-1 1111 51, 125
PIR2 OSCFIF CMIF(9) — EEIF BCLIF HLVDIF TMR3IF ECCP1IF(9) 00-0 0000 52, 119
PIE2 OSCFIE CMIE(9) — EEIE BCLIE HLVDIE TMR3IE ECCP1IE(9) 00-0 0000 52, 122
IPR1 PSPIP(3) ADIP RCIP TXIP SSPIP CCP1IP TMR2IP TMR1IP 1111 1111 52, 124
PIR1 PSPIF(3) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 52, 118
PIE1 PSPIE(3) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 52, 121
OSCTUNE INTSRC PLLEN(4) — TUN4 TUN3 TUN2 TUN1 TUN0 0q-0 0000 27, 52
TRISE(3) IBF OBF IBOV PSPMODE — TRISE2 TRISE1 TRISE0 0000 -111 52, 141
TRISD(3) PORTD Data Direction Register 1111 1111 52, 138
TRISC PORTC Data Direction Register 1111 1111 52, 135
TRISB PORTB Data Direction Register 1111 1111 52, 132
TRISA TRISA7(6) TRISA6(6) PORTA Data Direction Register 1111 1111 52, 129
LATE(3) — — — — — LATE Data Output Register ---- -xxx 52, 141
LATD(3) LATD Data Output Register xxxx xxxx 52, 138
LATC LATC Data Output Register xxxx xxxx 52, 135
LATB LATB Data Output Register xxxx xxxx 52, 132
LATA LATA7(6) LATA6(6) LATA Data Output Register xxxx xxxx 52, 129
PORTE(3) — — — — RE3(5) RE2(3) RE1(3) RE0(3) ---- xxxx 52, 145
PORTD(3) RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 xxxx xxxx 52, 138
PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx 52, 135
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
PORTB RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 xxxx xxxx 52, 132
PORTA RA7(6) RA6(6) RA5 RA4 RA3 RA2 RA1 RA0 xx00 0000 52, 129
ECANCON MDSEL1 MDSEL0 FIFOWM EWIN4 EWIN3 EWIN2 EWIN1 EWIN0 0001 000 52, 280
TXERRCNT TEC7 TEC6 TEC5 TEC4 TEC3 TEC2 TEC1 TEC0 0000 0000 52, 285
RXERRCNT REC7 REC6 REC5 REC4 REC3 REC2 REC1 REC0 0000 0000 52, 294
COMSTAT RXB0OVFL RXB1OVFL TXBO TXBP RXBP TXWARN RXWARN EWARN 0000 0000 52, 281
Mode 0
COMSTAT — RXBnOVFL TXBO TXBP RXBP TXWARN RXWARN EWARN -000 0000 52, 281
Mode 1
COMSTAT FIFOEMPT RXBnOVFL TXBO TXBP RXBP TXWARN RXWARN EWARN 0000 0000 52, 281
Mode 2 Y
CIOCON — — ENDRHI CANCAP — — — — --00 ---- 52, 315
BRGCON3 WAKDIS WAKFIL — — — SEG2PH2 SEG2PH1 SEG2PH0 00-- -000 53, 314
BRGCON2 SEG2PHTS SAM SEG1PH2 SEG1PH1 SEG1PH0 PRSEG2 PRSEG1 PRSEG0 0000 0000 53, 313
BRGCON1 SJW1 SJW0 BRP5 BRP4 BRP3 BRP2 BRP1 BRP0 0000 0000 53, 312
CANCON REQOP2 REQOP1 REQOP0 ABAT WIN2(7) WIN1(7) WIN0(7) —(7) 1000 000- 53, 276
Mode 0
CANCON REQOP2 REQOP1 REQOP0 ABAT —(7) —(7) —(7) —(7) 1000 ---- 53, 276
Mode 1
CANCON REQOP2 REQOP1 REQOP0 ABAT FP3(7) FP2(7) FP1(7) FP0(7) 1000 0000 53, 276
Mode 2
CANSTAT OPMODE2 OPMODE1 OPMODE0 —(7) ICODE3(7) ICODE2(7) ICODE1(7) —(7) 100- 000- 53, 277
Mode 0
CANSTAT OPMODE2 OPMODE1 OPMODE0 EICODE4(7) EICODE3(7) EICODE2(7) EICODE1(7) EICODE0(7) 1000 0000 53, 277
Modes 1, 2
RXB0D7 RXB0D77 RXB0D76 RXB0D75 RXB0D74 RXB0D73 RXB0D72 RXB0D71 RXB0D70 xxxx xxxx 53, 293
RXB0D6 RXB0D67 RXB0D66 RXB0D65 RXB0D64 RXB0D63 RXB0D62 RXB0D61 RXB0D60 xxxx xxxx 53, 293
RXB0D5 RXB0D57 RXB0D56 RXB0D55 RXB0D54 RXB0D53 RXB0D52 RXB0D51 RXB0D50 xxxx xxxx 53, 293
RXB0D4 RXB0D47 RXB0D46 RXB0D45 RXB0D44 RXB0D43 RXB0D42 RXB0D41 RXB0D40 xxxx xxxx 53, 293
RXB0D3 RXB0D37 RXB0D36 RXB0D35 RXB0D34 RXB0D33 RXB0D32 RXB0D31 RXB0D30 xxxx xxxx 53, 293
RXB0D2 RXB0D27 RXB0D26 RXB0D25 RXB0D24 RXB0D23 RXB0D22 RXB0D21 RXB0D20 xxxx xxxx 53, 293
RXB0D1 RXB0D17 RXB0D16 RXB0D15 RXB0D14 RXB0D13 RXB0D12 RXB0D11 RXB0D10 xxxx xxxx 53, 293
RXB0D0 RXB0D07 RXB0D06 RXB0D05 RXB0D04 RXB0D03 RXB0D02 RXB0D01 RXB0D00 xxxx xxxx 53, 293
RXB0DLC — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 53, 293
RXB0EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 53, 292
RXB0EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 53, 292
RXB0SIDL SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx x-xx 53, 292
RXB0SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 53, 291
RXB0CON RXFUL RXM1 RXM0(7) —(7) RXRTRRO(7) RXBODBEN(7) JTOFF(7) FILHIT0(7) 000- 0000 53, 288
Mode 0
RXB0CON RXFUL RXM1 RTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 53, 288
Mode 1, 2
RXB1D7 RXB1D77 RXB1D76 RXB1D75 RXB1D74 RXB1D73 RXB1D72 RXB1D71 RXB1D70 xxxx xxxx 53, 293
RXB1D6 RXB1D67 RXB1D66 RXB1D65 RXB1D64 RXB1D63 RXB1D62 RXB1D61 RXB1D60 xxxx xxxx 53, 293
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
RXB1D5 RXB1D57 RXB1D56 RXB1D55 RXB1D54 RXB1D53 RXB1D52 RXB1D51 RXB1D50 xxxx xxxx 53, 293
RXB1D4 RXB1D47 RXB1D46 RXB1D45 RXB1D44 RXB1D43 RXB1D42 RXB1D41 RXB1D40 xxxx xxxx 53, 293
RXB1D3 RXB1D37 RXB1D36 RXB1D35 RXB1D34 RXB1D33 RXB1D32 RXB1D31 RXB1D30 xxxx xxxx 53, 293
RXB1D2 RXB1D27 RXB1D26 RXB1D25 RXB1D24 RXB1D23 RXB1D22 RXB1D21 RXB1D20 xxxx xxxx 53, 293
RXB1D1 RXB1D17 RXB1D16 RXB1D15 RXB1D14 RXB1D13 RXB1D12 RXB1D11 RXB1D10 xxxx xxxx 53, 293
RXB1D0 RXB1D07 RXB1D06 RXB1D05 RXB1D04 RXB1D03 RXB1D02 RXB1D01 RXB1D00 xxxx xxxx 53, 293
RXB1DLC — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 53, 293
RXB1EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 53, 292
RXB1EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 53, 292
RXB1SIDL SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx xxxx 53, 292
RXB1SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 54, 291
RXB1CON RXFUL RXM1 RXM0(7) —(7) RXRTRRO(7) FILHIT2(7) FILHIT1(7) FILHIT0(7) 000- 0000 54, 290
Mode 0
RXB1CON RXFUL RXM1 RTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 54, 290
Mode 1, 2
TXB0D7 TXB0D77 TXB0D76 TXB0D75 TXB0D74 TXB0D73 TXB0D72 TXB0D71 TXB0D70 xxxx xxxx 54, 284
TXB0D6 TXB0D67 TXB0D66 TXB0D65 TXB0D64 TXB0D63 TXB0D62 TXB0D61 TXB0D60 xxxx xxxx 54, 284
TXB0D5 TXB0D57 TXB0D56 TXB0D55 TXB0D54 TXB0D53 TXB0D52 TXB0D51 TXB0D50 xxxx xxxx 54, 284
TXB0D4 TXB0D47 TXB0D46 TXB0D45 TXB0D44 TXB0D43 TXB0D42 TXB0D41 TXB0D40 xxxx xxxx 54, 284
TXB0D3 TXB0D37 TXB0D36 TXB0D35 TXB0D34 TXB0D33 TXB0D32 TXB0D31 TXB0D30 xxxx xxxx 54, 284
TXB0D2 TXB0D27 TXB0D26 TXB0D25 TXB0D24 TXB0D23 TXB0D22 TXB0D21 TXB0D20 xxxx xxxx 54, 284
TXB0D1 TXB0D17 TXB0D16 TXB0D15 TXB0D14 TXB0D13 TXB0D12 TXB0D11 TXB0D10 xxxx xxxx 54, 284
TXB0D0 TXB0D07 TXB0D06 TXB0D05 TXB0D04 TXB0D03 TXB0D02 TXB0D01 TXB0D00 xxxx xxxx 54, 284
TXB0DLC — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 54, 285
TXB0EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 54, 284
TXB0EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 54, 283
TXB0SIDL SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 54, 283
TXB0SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 54, 283
TXB0CON TXBIF TXABT TXLARB TXERR TXREQ — TXPRI1 TXPRI0 0000 0-00 54, 282
TXB1D7 TXB1D77 TXB1D76 TXB1D75 TXB1D74 TXB1D73 TXB1D72 TXB1D71 TXB1D70 xxxx xxxx 54, 284
TXB1D6 TXB1D67 TXB1D66 TXB1D65 TXB1D64 TXB1D63 TXB1D62 TXB1D61 TXB1D60 xxxx xxxx 54, 284
TXB1D5 TXB1D57 TXB1D56 TXB1D55 TXB1D54 TXB1D53 TXB1D52 TXB1D51 TXB1D50 xxxx xxxx 54, 284
TXB1D4 TXB1D47 TXB1D46 TXB1D45 TXB1D44 TXB1D43 TXB1D42 TXB1D41 TXB1D40 xxxx xxxx 54, 284
TXB1D3 TXB1D37 TXB1D36 TXB1D35 TXB1D34 TXB1D33 TXB1D32 TXB1D31 TXB1D30 xxxx xxxx 54, 284
TXB1D2 TXB1D27 TXB1D26 TXB1D25 TXB1D24 TXB1D23 TXB1D22 TXB1D21 TXB1D20 xxxx xxxx 54, 284
TXB1D1 TXB1D17 TXB1D16 TXB1D15 TXB1D14 TXB1D13 TXB1D12 TXB1D11 TXB1D10 xxxx xxxx 54, 284
TXB1D0 TXB1D07 TXB1D06 TXB1D05 TXB1D04 TXB1D03 TXB1D02 TXB1D01 TXB1D00 xxxx xxxx 54, 284
TXB1DLC — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 54, 285
TXB1EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 54, 284
TXB1EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 54, 283
TXB1SIDL SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 54, 283
TXB1SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 54, 283
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
TXB1CON TXBIF TXABT TXLARB TXERR TXREQ — TXPRI1 TXPRI0 0000 0-00 54, 282
TXB2D7 TXB2D77 TXB2D76 TXB2D75 TXB2D74 TXB2D73 TXB2D72 TXB2D71 TXB2D70 xxxx xxxx 54, 284
TXB2D6 TXB2D67 TXB2D66 TXB2D65 TXB2D64 TXB2D63 TXB2D62 TXB2D61 TXB2D60 xxxx xxxx 55, 284
TXB2D5 TXB2D57 TXB2D56 TXB2D55 TXB2D54 TXB2D53 TXB2D52 TXB2D51 TXB2D50 xxxx xxxx 55, 284
TXB2D4 TXB2D47 TXB2D46 TXB2D45 TXB2D44 TXB2D43 TXB2D42 TXB2D41 TXB2D40 xxxx xxxx 55, 284
TXB2D3 TXB2D37 TXB2D36 TXB2D35 TXB2D34 TXB2D33 TXB2D32 TXB2D31 TXB2D30 xxxx xxxx 55, 284
TXB2D2 TXB2D27 TXB2D26 TXB2D25 TXB2D24 TXB2D23 TXB2D22 TXB2D21 TXB2D20 xxxx xxxx 55, 284
TXB2D1 TXB2D17 TXB2D16 TXB2D15 TXB2D14 TXB2D13 TXB2D12 TXB2D11 TXB2D10 xxxx xxxx 55, 284
TXB2D0 TXB2D07 TXB2D06 TXB2D05 TXB2D04 TXB2D03 TXB2D02 TXB2D01 TXB2D00 xxxx xxxx 55, 284
TXB2DLC — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 55, 285
TXB2EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 55, 284
TXB2EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 55, 283
TXB2SIDL SID2 SID1 SID0 — EXIDE — EID17 EID16 xxxx x-xx 55, 283
TXB2SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxx- x-xx 55, 283
TXB2CON TXBIF TXABT TXLARB TXERR TXREQ — TXPRI1 TXPRI0 0000 0-00 55, 282
RXM1EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 55, 305
RXM1EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 55, 305
RXM1SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 55, 305
RXM1SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 55, 304
RXM0EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 55, 305
RXM0EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 55, 305
RXM0SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 55, 305
RXM0SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 55, 304
RXF5EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 55, 304
RXF5EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 55, 304
RXF5SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 55, 303
RXF5SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 55, 304
RXF4EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 55, 304
RXF4EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 55, 304
RXF4SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 55, 303
RXF4SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 55, 304
RXF3EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 55, 304
RXF3EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 55, 304
RXF3SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 56, 303
RXF3SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 56, 304
RXF2EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 56, 304
RXF2EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 56, 304
RXF2SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 56, 303
RXF2SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 56, 304
RXF1EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 56, 304
RXF1EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 56, 304
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
RXF1SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 56, 303
RXF1SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 56, 304
RXF0EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 56, 304
RXF0EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 56, 304
RXF0SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 56, 303
RXF0SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 56, 304
B5D7(8) B5D77 B5D76 B5D75 B5D74 B5D73 B5D72 B5D71 B5D70 xxxx xxxx 56, 300
B5D6(8) B5D67 B5D66 B5D65 B5D64 B5D63 B5D62 B5D61 B5D60 xxxx xxxx 56, 300
B5D5(8) B5D57 B5D56 B5D55 B5D54 B5D53 B5D52 B5D51 B5D50 xxxx xxxx 56, 300
B5D4(8) B5D47 B5D46 B5D45 B5D44 B5D43 B5D42 B5D41 B5D40 xxxx xxxx 56, 300
B5D3(8) B5D37 B5D36 B5D35 B5D34 B5D33 B5D32 B5D31 B5D30 xxxx xxxx 56, 300
B5D2(8) B5D27 B5D26 B5D25 B5D24 B5D23 B5D22 B5D21 B5D20 xxxx xxxx 56, 300
B5D1(8) B5D17 B5D16 B5D15 B5D14 B5D13 B5D12 B5D11 B5D10 xxxx xxxx 56, 300
B5D0(8) B5D07 B5D06 B5D05 B5D04 B5D03 B5D02 B5D01 B5D00 xxxx xxxx 56, 300
B5DLC(8) — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 56, 301
Receive mode
B5DLC(8) — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 56, 302
Transmit mode
B5EIDL(8) EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 56, 299
B5EIDH(8) EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 56, 299
B5SIDL(8) SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx x-xx 56, 298
Receive mode
B5SIDL(8) SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 56, 298
Transmit mode
B5SIDH(8) SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx x-xx 56, 297
B5CON(8) RXFUL RXM1 RXRTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 56, 296
Receive mode
B5CON(8) TXBIF TXABT TXLARB TXERR TXREQ RTREN TXPRI1 TXPRI0 0000 0000 56, 296
Transmit mode
B4D7(8) B4D77 B4D76 B4D75 B4D74 B4D73 B4D72 B4D71 B4D70 xxxx xxxx 56, 300
B4D6(8) B4D67 B4D66 B4D65 B4D64 B4D63 B4D62 B4D61 B4D60 xxxx xxxx 56, 300
B4D5(8) B4D57 B4D56 B4D55 B4D54 B4D53 B4D52 B4D51 B4D50 xxxx xxxx 56, 300
B4D4(8) B4D47 B4D46 B4D45 B4D44 B4D43 B4D42 B4D41 B4D40 xxxx xxxx 57, 300
B4D3(8) B4D37 B4D36 B4D35 B4D34 B4D33 B4D32 B4D31 B4D30 xxxx xxxx 57, 300
B4D2(8) B4D27 B4D26 B4D25 B4D24 B4D23 B4D22 B4D21 B4D20 xxxx xxxx 57, 300
B4D1(8) B4D17 B4D16 B4D15 B4D14 B4D13 B4D12 B4D11 B4D10 xxxx xxxx 57, 300
B4D0(8) B4D07 B4D06 B4D05 B4D04 B4D03 B4D02 B4D01 B4D00 xxxx xxxx 56, 300
B4DLC(8) — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 56, 301
Receive mode
B4DLC(8) — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 56, 302
Transmit mode
B4EIDL(8) EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 57, 299
B4EIDH(8) EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 57, 299
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
B4SIDL(8) SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx x-xx 56, 298
Receive mode
B4SIDL(8) SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 56, 298
Transmit mode
B4SIDH(8) SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 57, 297
B4CON(8) RXFUL RXM1 RXRTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 57, 296
Receive mode
B4CON(8) TXBIF TXABT TXLARB TXERR TXREQ RTREN TXPRI1 TXPRI0 0000 0000 57, 296
Transmit mode
B3D7(8) B3D77 B3D76 B3D75 B3D74 B3D73 B3D72 B3D71 B3D70 xxxx xxxx 57, 300
B3D6(8) B3D67 B3D66 B3D65 B3D64 B3D63 B3D62 B3D61 B3D60 xxxx xxxx 57, 300
B3D5(8) B3D57 B3D56 B3D55 B3D54 B3D53 B3D52 B3D51 B3D50 xxxx xxxx 57, 300
B3D4(8) B3D47 B3D46 B3D45 B3D44 B3D43 B3D42 B3D41 B3D40 xxxx xxxx 57, 300
B3D3(8) B3D37 B3D36 B3D35 B3D34 B3D33 B3D32 B3D31 B3D30 xxxx xxxx 57, 300
B3D2(8) B3D27 B3D26 B3D25 B3D24 B3D23 B3D22 B3D21 B3D20 xxxx xxxx 57, 300
B3D1(8) B3D17 B3D16 B3D15 B3D14 B3D13 B3D12 B3D11 B3D10 xxxx xxxx 57, 300
B3D0(8) B3D07 B3D06 B3D05 B3D04 B3D03 B3D02 B3D01 B3D00 xxxx xxxx 57, 300
B3DLC(8) — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 56, 301
Receive mode
B3DLC(8) — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 56, 302
Transmit mode
B3EIDL(8) EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 57, 299
B3EIDH(8) EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 57, 299
B3SIDL(8) SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx x-xx 56, 298
Receive mode
B3SIDL(8) SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 56, 298
Transmit mode
B3SIDH(8) SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 57, 297
B3CON(8) RXFUL RXM1 RXRTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 57, 296
Receive mode
B3CON(8) TXBIF TXABT TXLARB TXERR TXREQ RTREN TXPRI1 TXPRI0 0000 0000 57, 296
Transmit mode
B2D7(8) B2D77 B2D76 B2D75 B2D74 B2D73 B2D72 B2D71 B2D70 xxxx xxxx 57, 300
B2D6(8) B2D67 B2D66 B2D65 B2D64 B2D63 B2D62 B2D61 B2D60 xxxx xxxx 57, 300
B2D5(8) B2D57 B2D56 B2D55 B2D54 B2D53 B2D52 B2D51 B2D50 xxxx xxxx 57, 300
B2D4(8) B2D47 B2D46 B2D45 B2D44 B2D43 B2D42 B2D41 B2D40 xxxx xxxx 57, 300
B2D3(8) B2D37 B2D36 B2D35 B2D34 B2D33 B2D32 B2D31 B2D30 xxxx xxxx 57, 300
B2D2(8) B2D27 B2D26 B2D25 B2D24 B2D23 B2D22 B2D21 B2D20 xxxx xxxx 57, 300
B2D1(8) B2D17 B2D16 B2D15 B2D14 B2D13 B2D12 B2D11 B2D10 xxxx xxxx 58, 300
B2D0(8) B2D07 B2D06 B2D05 B2D04 B2D03 B2D02 B2D01 B2D00 xxxx xxxx 58, 300
B2DLC(8) — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 56, 301
Receive mode
B2DLC(8) — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 56, 302
Transmit mode
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
B2EIDL(8) EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 58, 299
B2EIDH(8) EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 58, 299
B2SIDL(8) SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx x-xx 56, 298
Receive mode
B2SIDL(8) SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 56, 298
Transmit mode
B2SIDH(8) SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 58, 297
B2CON(8) RXFUL RXM1 RXRTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 58, 296
Receive mode
B2CON(8) TXBIF RXM1 TXLARB TXERR TXREQ RTREN TXPRI1 TXPRI0 0000 0000 58, 296
Transmit mode
B1D7(8) B1D77 B1D76 B1D75 B1D74 B1D73 B1D72 B1D71 B1D70 xxxx xxxx 58, 300
B1D6(8) B1D67 B1D66 B1D65 B1D64 B1D63 B1D62 B1D61 B1D60 xxxx xxxx 58, 300
B1D5(8) B1D57 B1D56 B1D55 B1D54 B1D53 B1D52 B1D51 B1D50 xxxx xxxx 58, 300
B1D4(8) B1D47 B1D46 B1D45 B1D44 B1D43 B1D42 B1D41 B1D40 xxxx xxxx 58, 300
B1D3(8) B1D37 B1D36 B1D35 B1D34 B1D33 B1D32 B1D31 B1D30 xxxx xxxx 58, 300
B1D2(8) B1D27 B1D26 B1D25 B1D24 B1D23 B1D22 B1D21 B1D20 xxxx xxxx 58, 300
B1D1(8) B1D17 B1D16 B1D15 B1D14 B1D13 B1D12 B1D11 B1D10 xxxx xxxx 58, 300
B1D0(8) B1D07 B1D06 B1D05 B1D04 B1D03 B1D02 B1D01 B1D00 xxxx xxxx 58, 300
B1DLC(8) — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 56, 301
Receive mode
B1DLC(8) — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 56, 302
Transmit mode
B1EIDL(8) EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 58, 299
B1EIDH(8) EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 58, 299
B1SIDL(8) SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx x-xx 56, 298
Receive mode
B1SIDL(8) SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 56, 298
Transmit mode
B1SIDH(8) SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 58, 297
B1CON(8) RXFUL RXM1 RXRTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 58, 296
Receive mode
B1CON(8) TXBIF TXABT TXLARB TXERR TXREQ RTREN TXPRI1 TXPRI0 0000 0000 58, 296
Transmit mode
B0D7(8) B0D77 B0D76 B0D75 B0D74 B0D73 B0D72 B0D71 B0D70 xxxx xxxx 58, 300
B0D6(8) B0D67 B0D66 B0D65 B0D64 B0D63 B0D62 B0D61 B0D60 xxxx xxxx 58, 300
B0D5(8) B0D57 B0D56 B0D55 B0D54 B0D53 B0D52 B0D51 B0D50 xxxx xxxx 58, 300
B0D4(8) B0D47 B0D46 B0D45 B0D44 B0D43 B0D42 B0D41 B0D40 xxxx xxxx 58, 300
B0D3(8) B0D37 B0D36 B0D35 B0D34 B0D33 B0D32 B0D31 B0D30 xxxx xxxx 58, 300
B0D2(8) B0D27 B0D26 B0D25 B0D24 B0D23 B0D22 B0D21 B0D20 xxxx xxxx 58, 300
B0D1(8) B0D17 B0D16 B0D15 B0D14 B0D13 B0D12 B0D11 B0D10 xxxx xxxx 58, 300
B0D0(8) B0D07 B0D06 B0D05 B0D04 B0D03 B0D02 B0D01 B0D00 xxxx xxxx 58, 300
B0DLC(8) — RXRTR RB1 RB0 DLC3 DLC2 DLC1 DLC0 -xxx xxxx 56, 301
Receive mode
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
B0DLC(8) — TXRTR — — DLC3 DLC2 DLC1 DLC0 -x-- xxxx 56, 302
Transmit mode
B0EIDL(8) EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 59, 299
B0EIDH(8) EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 59, 299
B0SIDL(8) SID2 SID1 SID0 SRR EXID — EID17 EID16 xxxx x-xx 56, 298
Receive mode
B0SIDL(8) SID2 SID1 SID0 — EXIDE — EID17 EID16 xxx- x-xx 56, 298
Transmit mode
B0SIDH(8) SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 59, 297
B0CON(8) RXFUL RXM1 RXRTRRO FILHIT4 FILHIT3 FILHIT2 FILHIT1 FILHIT0 0000 0000 58, 296
Receive mode
B0CON(8) TXBIF TXABT TXLARB TXERR TXREQ RTREN TXPRI1 TXPRI0 0000 0000 58, 296
Transmit mode
TXBIE — — — TXB2IE TXB1IE TXB0IE — — ---0 00-- 59, 319
BIE0 B5IE B4IE B3IE B2IE B1IE B0IE RXB1IE RXB0IE 0000 0000 59, 319
BSEL0 B5TXEN B4TXEN B3TXEN B2TXEN B1TXEN B0TXEN — — 0000 00-- 59, 302
MSEL3 FIL15_1 FIL15_0 FIL14_1 FIL14_0 FIL13_1 FIL13_0 FIL12_1 FIL12_0 0000 0000 59, 311
MSEL2 FIL11_1 FIL11_0 FIL10_1 FIL10_0 FIL9_1 FIL9_0 FIL8_1 FIL8_0 0000 0000 59, 310
MSEL1 FIL7_1 FIL7_0 FIL6_1 FIL6_0 FIL5_1 FIL5_0 FIL4_1 FIL4_0 0000 0101 59, 309
MSEL0 FIL3_1 FIL3_0 FIL2_1 FIL2_0 FIL1_1 FIL1_0 FIL0_1 FIL0_0 0101 0000 59, 308
RXFBCON7 F15BP_3 F15BP_2 F15BP_1 F15BP_0 F14BP_3 F14BP_2 F14BP_1 F14BP_0 0000 0000 59, 307
RXFBCON6 F13BP_3 F13BP_2 F13BP_1 F13BP_0 F12BP_3 F12BP_2 F12BP_1 F12BP_0 0000 0000 59, 307
RXFBCON5 F11BP_3 F11BP_2 F11BP_1 F11BP_0 F10BP_3 F10BP_2 F10BP_1 F10BP_0 0000 0000 59, 307
RXFBCON4 F9BP_3 F9BP_2 F9BP_1 F9BP_0 F8BP_3 F8BP_2 F8BP_1 F8BP_0 0000 0000 59, 307
RXFBCON3 F7BP_3 F7BP_2 F7BP_1 F7BP_0 F6BP_3 F6BP_2 F6BP_1 F6BP_0 0000 0000 59, 307
RXFBCON2 F5BP_3 F5BP_2 F5BP_1 F5BP_0 F4BP_3 F4BP_2 F4BP_1 F4BP_0 0001 0001 59, 307
RXFBCON1 F3BP_3 F3BP_2 F3BP_1 F3BP_0 F2BP_3 F2BP_2 F2BP_1 F2BP_0 0001 0001 59, 307
RXFBCON0 F1BP_3 F1BP_2 F1BP_1 F1BP_0 F0BP_3 F0BP_2 F0BP_1 F0BP_0 0000 0000 59, 307
SDFLC — — — FLC4 FLC3 FLC2 FLC1 FLC0 ---0 0000 59, 306
RXFCON1 RXF15EN RXF14EN RXF13EN RXF12EN RXF11EN RXF10EN RXF9EN RXF8EN 0000 0000 59, 306
RXFCON0 RXF7EN RXF6EN RXF5EN RXF4EN RXF3EN RXF2EN RXF1EN RXF0EN 0000 0000 59, 306
RXF15EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 59, 304
RXF15EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 59, 304
RXF15SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 59, 303
RXF15SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 59, 303
RXF14EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 59, 304
RXF14EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 59, 304
RXF14SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 59, 303
RXF14SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 59, 303
RXF13EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF13EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF13SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF13SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
RXF12EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF12EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF12SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF12SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
RXF11EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF11EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF11SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF11SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
RXF10EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF10EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF10SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF10SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
RXF9EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF9EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF9SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF9SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
RXF8EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF8EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF8SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF8SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
RXF7EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF7EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF7SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF7SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
RXF6EIDL EID7 EID6 EID5 EID4 EID3 EID2 EID1 EID0 xxxx xxxx 60, 304
RXF6EIDH EID15 EID14 EID13 EID12 EID11 EID10 EID9 EID8 xxxx xxxx 60, 304
RXF6SIDL SID2 SID1 SID0 — EXIDEN — EID17 EID16 xxx- x-xx 60, 303
RXF6SIDH SID10 SID9 SID8 SID7 SID6 SID5 SID4 SID3 xxxx xxxx 60, 303
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: The SBOREN bit is only available when CONFIG2L<1:0> = 01; otherwise, it is disabled and reads as ‘0’. See Section 4.4 “Brown-out Reset
(BOR)”.
3: These registers and/or bits are not implemented on PIC18F2682/2685 devices and are read as ‘0’. Reset values are shown for PIC18F4682/4685
devices; individual unimplemented bits should be interpreted as ‘—’.
4: 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”.
5: The RE3 bit is only available when Master Clear Reset is disabled (CONFIG3H<7> = 0); otherwise, RE3 reads as ‘0’. This bit is read-only.
6: 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’.
7: CAN bits have multiple functions depending on the selected mode of the CAN module.
8: This register reads all ‘0’s until the ECAN™ technology is set up in Mode 1 or Mode 2.
9: These registers and/or bits are available on PIC18F4682/4685 devices only.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For Borrow, the polarity is reversed. A subtraction is executed by adding the 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
Using an instruction with one of the ADDWF, INDF1, 1 Bank 0
Indirect Addressing registers as the 100h
operand.... Bank 1
200h
Bank 2
300h
...uses the 12-bit address stored in FSR1H:FSR1L
the FSR pair associated with that
7 0 7 0
register....
x x x x 1 1 1 0 1 1 0 0 1 1 0 0
Bank 3
through
Bank 13
000h
When a = 0 and f ≥ 60h:
The instruction executes in 060h
Direct Forced mode. ‘f’ is 080h Bank 0
interpreted as a location in the 100h
Access RAM between 060h 00h
and 0FFh. This is the same as Bank 1 60h
the SFRs, or locations F60h to through
Bank 14 Valid Range
0FFh (Bank 15) of data for ‘f’
memory.
FFh
F00h Access RAM
Locations below 60h are not Bank 15
available in this addressing F60h
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
100h
interpreted as a location in
one of the 16 banks of the data 001001da ffffffff
Bank 1
memory space. The bank is through
designated by the Bank Select Bank 14
Register (BSR). The address
can be in any implemented F00h
bank in the data memory Bank 15
F60h
space.
SFRs
FFFh
Data Memory
Example Situation:
ADDWF f, d, a 000h
FSR2H:FSR2L = 120h
Bank 0
Locations in the region
from the FSR2 Pointer 100h
(120h) to the pointer plus 120h
05Fh (17Fh) are mapped Window
17Fh 00h
to the bottom of the
Bank 1
Access RAM (000h-05Fh). 200h Bank 1 “Window”
5Fh
Special Function Registers
60h
at F60h through FFFh are
mapped to 60h through Bank 2
FFh, as usual. through SFRs
Bank 0 addresses below Bank 14
5Fh are not available in FFh
this mode. They can still Access Bank
be addressed by using the F00h
BSR. Bank 15
F60h
SFRs
FFFh
Data Memory
Instruction: TBLRD*
Program Memory
Table Pointer(1)
Table Latch (8-bit)
TBLPTRU TBLPTRH TBLPTRL
TABLAT
Program Memory
(TBLPTR)
Instruction: TBLWT*
Program Memory
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 6.5 “Writing to Flash Program Memory”.
6.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 WREN bit is set, and cleared
• TBLPTR registers when the internal programming timer expires and the
write operation is complete.
6.2.1 EECON1 AND EECON2 REGISTERS Note: During normal operation, the WRERR is
The EECON1 register (Register 6-1) is the control read as ‘1’. This can indicate that a write
register for memory accesses. The EECON2 register is operation was prematurely terminated by
not a physical register; it is used exclusively in the a Reset or a write operation was
memory write and erase sequences. Reading attempted improperly.
EECON2 will read all ‘0’s.
The 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 24.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 6-1: TABLE POINTER OPERATIONS WITH TBLRD AND TBLWT INSTRUCTIONS
Example Operation on Table Pointer
TBLRD*
TBLPTR is not modified
TBLWT*
TBLRD*+
TBLPTR is incremented after the read/write
TBLWT*+
TBLRD*-
TBLPTR is decremented after the read/write
TBLWT*-
TBLRD+*
TBLPTR is incremented before the read/write
TBLWT+*
Program Memory
TABLAT
Write Register
8 8 8 8
Program Memory
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 27-1 in cleared in software.
Section 27.0 “Electrical Characteristics”) for exact
limits. Control bits, RD and WR, start read and erase/write
operations, respectively. These bits are set by firmware
7.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 Most Significant bits of the table read instructions. See Section 6.1 “Table Reads
address; the upper 6 bits are ignored. The 10-bit range and Table Writes” regarding table reads.
of the pair 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
7.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.
XXXXIF IPEN
XXXXIE PEIE/GIEL
XXXXIP
IPEN
Additional Peripheral Interrupts
High Priority Interrupt Generation
INT1IF
Additional Peripheral Interrupts INT1IE
INT1IP
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 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 reserved on PIC18F2682/2685 devices; always maintain this bit clear.
Legend:
R = Readable bit W = 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: These bits are available in PIC18F4682/4685 and reserved in PIC18F2682/2685 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
Legend:
R = Readable bit W = 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 reserved on PIC18F2682/2685 devices; always maintain this bit clear.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit is reserved on PIC18F2682/2685 devices; always maintain this bit clear.
Legend:
R = Readable bit W = 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
Q D
EXAMPLE 10-1: INITIALIZING PORTA
CLRF PORTA ; Initialize PORTA by
ENEN
; clearing output
RD PORT ; data latches
CLRF LATA ; Alternate method
; to clear output
Note 1: I/O pins have diode protection to VDD and VSS.
; data latches
MOVLW 0Fh ; Configure A/D
MOVWF ADCON1 ; for digital inputs
MOVWF 07h ; Configure comparators
MOVWF CMCON ; for digital input
MOVLW 0CFh ; Value used to
; initialize data
; direction
MOVWF TRISA ; Set RA<3:0> as inputs
; RA<5:4> as 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
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
FOSC/4 0
1
Sync with Set
1 Internal TMR0L TMR0IF
Programmable Clocks on Overflow
T0CKI pin 0
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
Internal TMR0L TMR0
1 High Byte TMR0IF
Programmable Clocks on Overflow
T0CKI pin 0 8
Prescaler
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
Set
Clear TMR1 TMR1L TMR1 TMR1IF
High Byte
(CCP1 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.
Set
Clear TMR1 TMR1 TMR1IF
TMR1L High Byte
(CCP1 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.
The module is controlled through the T2CON register The TMR2 and PR2 registers are both directly readable
(Register 13-1), which enables or disables the timer and writable. The TMR2 register is cleared on any
and configures the prescaler and postscaler. Timer2 device Reset, while the PR2 register initializes at FFh.
can be shut off by clearing control bit, TMR2ON Both the prescaler and postscaler counters are cleared
(T2CON<2>), to minimize power consumption. on the following events:
A simplified block diagram of the module is shown in • a write to the TMR2 register
Figure 13-1. • a write to the T2CON register
• any device Reset (Power-on Reset, MCLR Reset,
Watchdog Timer Reset or Brown-out Reset)
TMR2 is not cleared when T2CON is written.
Legend:
R = Readable bit W = 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
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
Note 1: Selected by CANCAP (CIOCON<4>) bit; overrides the CCP1 input pin source.
TABLE 15-2: INTERACTIONS BETWEEN CCP1 AND ECCP1 FOR TIMER RESOURCES
CCP1 Mode ECCP1 Mode Interaction
Capture Capture Each module can use TMR1 or TMR3 as the time base. Time base can be different for
each CCP1.
Capture Compare CCP1 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 CCP1 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 ECCP1 trigger event can be done. Conflicts may occur if
both modules are using the same time base.
Capture PWM* None
Compare PWM* None
PWM* Capture None
PWM* Compare None
PWM* PWM Both PWMs will have the same frequency and update rate (TMR2 interrupt).
* Includes standard and Enhanced PWM operation.
TMR3H TMR3L
Set CCP1IF
T3ECCP1 TMR3
CCP1 pin Enable
Prescaler and CCPR1H CCPR1L
÷ 1, 4, 16 Edge Detect
TMR1
T3ECCP1 Enable
4 TMR1H TMR1L
CCP1CON<3:0> Set ECCP1IF
4
Q1:Q4
4
ECCP1CON<3:0>
T3CCP1 TMR3H TMR3L
T3ECCP1
TMR3
Enable
ECCP1 pin
Prescaler and ECCPR1H ECCPR1L
÷ 1, 4, 16 Edge Detect
TMR1
Enable
T3ECCP1
T3CCP1 TMR1H TMR1L
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
ECCPR1H ECCPR1L
ECCP1CON<3:0>
EQUATION 15-2:
PWM Duty Cycle = (CCPR1L:CCP1CON<5:4>) •
TOSC • (TMR2 Prescale Value)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
ECCP1CON<5:4>
Duty Cycle Registers EPWM1M<1:0> ECCP1M<3:0>
2 4
ECCPR1L
ECCP1/P1A ECCP1/P1A
TRISD<4>
ECCPR1H (Slave)
P1B P1B
Output TRISD<5>
Comparator R Q Controller
P1C P1C
TMR2 (Note 1)
TRISD<6>
S
P1D P1D
Comparator
Clear Timer, TRISD<7>
set ECCP1 pin and
latch D.C.
PR2 ECCP1DEL
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 * (ECCPR1L<7:0>:ECCP1CON<5:4>) * (TMR2 Prescale Value)
• Delay = 4 * TOSC * (ECCP1DEL<6:0>)
Note 1: Dead-band delay is programmed using the ECCP1DEL register (Section 16.4.6 “Programmable Dead-Band Delay”).
PIC18F268X/468X FET
Driver +
P1A V
-
Load
FET
Driver
+
P1B V
-
V-
Half-Bridge Output Driving a Full-Bridge Circuit
V+
PIC18F268X/468X
FET FET
Driver Driver
P1A
Load
FET FET
Driver Driver
P1B
V-
Forward Mode
Period
P1A(2)
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.
PIC18F268X/468X
FET QA QC 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 EPWM1M1 bit in
100% duty cycle. At time t1, the outputs P1A and P1D
the ECCP1CON register allows the user to control the
become inactive, while output P1C becomes active. In
forward/reverse direction. When the application
this example, since the turn-off time of the power
firmware changes this direction control bit, the module
devices is longer than the turn-on time, a shoot-through
will 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 either be 1, 4 or 16, depend-
ing on the value of the T2CKPS bits (T2CON<1:0>). 1. Reduce PWM for a PWM period before
During the interval from the switch of the unmodulated changing directions.
outputs to the beginning of the next period, the 2. Use switch drivers that can drive the switches off
modulated outputs (P1B and P1D) remain inactive. faster than they can drive them on.
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 ECCP1 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 ECCP1 Control register (ECCP1CON<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)
Potential
t = tOFF – tON(2,3)
Shoot-Through
Current(1)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
ECCPASE bit
PWM Activity
Normal PWM
ECCPASE bit
PWM Activity
Normal PWM
ECCPASE
Shutdown Cleared by
Start of
PWM Period
Event Occurs Shutdown Firmware PWM
Event Clears Resumes
RA5/AN4/SS/HLVDIN Edge
Select
2
Clock Select
SSPM3:SSPM0
SMP:CKE 4
2 (
TMR2 Output
2
)
Edge
Select
RC3/SCK/SCL Prescaler TOSC
4, 16, 64
Data to TX/RX in SSPSR
TRIS bit
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = 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
Modes
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
SDO bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
(CKE = 0)
SDI
(SMP = 0)
bit 7 bit 0
Input
Sample
(SMP = 0)
SDI
(SMP = 1)
bit 7 bit 0
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
SSPBUF after Q2↓
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
after Q2↓
SSPSR to
SSPBUF
SS
Not Optional
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Write to
SSPBUF
SDI
(SMP = 0)
bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
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 input or output.
2: Bit combinations not specifically listed here are either reserved or implemented in SPI mode only.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Value that will be transmitted when the user initiates an Acknowledge sequence at the end of a receive.
2: 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).
DS39761B-page 202
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
Bus master
(PIR1<3>) terminates
transfer
BF (SSPSTAT<0>)
Preliminary
Cleared in software
SSPBUF is read
PIC18F2682/2685/4682/4685
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
CKP
(CKP does not reset to ‘0’ when SEN = 0)
I2C™ SLAVE MODE TIMING WITH SEN = 0 (RECEPTION, 7-BIT ADDRESS)
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
Preliminary
From SSPIF ISR From SSPIF ISR
SSPBUF is written in software SSPBUF is written in software
CKP
DS39761B-page 203
PIC18F2682/2685/4682/4685
FIGURE 17-10:
DS39761B-page 204
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 transfer
(PIR1<3>)
Cleared in software Cleared in software Cleared in software
Cleared in software
BF (SSPSTAT<0>)
SSPOV is set
Preliminary
because SSPBUF is
still full. ACK is not sent.
PIC18F2682/2685/4682/4685
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>)
Cleared in software Cleared in software Cleared in software
BF (SSPSTAT<0>)
Preliminary
Dummy read of SSPBUF Write of SSPBUF Completion of
contents of SSPSR to clear BF flag BF flag is clear
to clear BF flag initiates transmit data transmission
at the end of the
UA (SSPSTAT<1>) third address sequence clears BF flag
DS39761B-page 205
PIC18F2682/2685/4682/4685
PIC18F2682/2685/4682/4685
17.4.4 CLOCK STRETCHING 17.4.4.3 Clock Stretching for 7-Bit Slave
Both 7 and 10-Bit Slave modes implement automatic Transmit Mode
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
17.4.4.4 Clock Stretching for 10-Bit Slave
master device can initiate another receive sequence.
This will prevent buffer overruns from occurring (see Transmit Mode
Figure 17-13). In 10-Bit Slave Transmit mode, clock stretching is
controlled during the first two address sequences by
Note 1: If the user reads the contents of the
the state of the UA bit, just as it is in 10-Bit Slave
SSPBUF before the falling edge of the
Receive mode. The first two addresses are followed
ninth clock, thus clearing the BF bit, the
by a third address sequence which contains the high-
CKP bit will not be cleared and clock
order bits of the 10-bit address and the R/W bit set to
stretching will not occur.
‘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
SSPCON
DS39761B-page 208
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
Bus master
(PIR1<3>) terminates
transfer
BF (SSPSTAT<0>)
Preliminary
Cleared in software
SSPBUF is read
PIC18F2682/2685/4682/4685
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)
BF (SSPSTAT<0>)
SSPOV is set
Preliminary
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
DS39761B-page 209
PIC18F2682/2685/4682/4685
PIC18F2682/2685/4682/4685
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 Address mode, the SSPADD is required to be
The general call address is one of eight addresses updated for the second half of the address to match
reserved for specific purposes by the I2C protocol. It and the UA bit is set (SSPSTAT<1>). If the general call
consists of all ‘0’s with R/W = 0. address is sampled when the GCEN bit is set, while the
slave is configured in 10-Bit Address mode, then the
The general call address is recognized when the
second half of the address is not necessary, the UA bit
General Call Enable bit, GCEN, is enabled
will not be set and the slave will begin receiving data
(SSPCON2<7> set). Following a Start bit detect, 8 bits
after the Acknowledge (Figure 17-15).
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
Set S (SSPSTAT<3>)
Write to SSPCON2
occurs here. SDA = 1,
At completion of Start bit,
SDA = 1, SCL = 1
hardware clears RSEN bit
SCL (no change). and sets SSPIF
Sr = Repeated Start
DS39761B-page 218
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 of 10-bit Address ACK
SDA A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
BF (SSPSTAT<0>)
Preliminary
SSPBUF written SSPBUF is written in software
PIC18F2682/2685/4682/4685
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 Acknow-
Set SSPIF interrupt ledge 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
Preliminary
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)
DS39761B-page 219
PIC18F2682/2685/4682/4685
PIC18F2682/2685/4682/4685
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
Set SSPIF at the software
end of receive Cleared in
software Set SSPIF 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
SDA = 0, SCL = 1
TBRG TBRG
SDA
Interrupt cleared
in software
S ‘0’ ‘0’
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
SEN time-out
SSPIF
SDA
SCL
RSEN
BCLIF
Cleared in software
S ‘0’
SSPIF ‘0’
TBRG TBRG
SDA
SCL
S ‘0’
SSPIF
PEN
BCLIF
P ‘0’
SSPIF ‘0’
SDA
SCL goes low before SDA goes high,
Assert SDA set BCLIF
SCL
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.
Note 1: If the wake-up event requires long oscillator warm-up time, the auto-clear of the WUE bit can occur while the stposc signal is still active.
This sequence should not depend on the presence of Q clocks.
2: The EUSART remains in Idle while the WUE bit is set.
Write to TXREG
Dummy Write
BRG Output
(Shift Clock)
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
RC7/TX/CK pin
(SCKP = 0)
RC7/TX/CK pin
(SCKP = 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)
AN10
PCFG3:
AN9
AN8
AN4
AN3
AN2
AN1
AN0
PCFG0
0000(1) A A A A A A A A A A A
0001 A A A A A A A A A A A
0010 A A A A A A A A A A A
0011 A A A A A A A A A A A
0100 A A A A A A A A A A A
0101 D A A A A A A A A A A
0110 D D A A A A A A A A A
0111(1) D D D A A A A A A A A
1000 D D D D A A A A A A A
1001 D D D D D A A A A A A
1010 D D D D D D A A A A A
1011 D D D D D D D A A A A
1100 D D D D D D D D A A A
1101 D D D D D D D D D A A
1110 D D D D D D D D D D A
1111 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 bit in Configuration Register 3H.
When PBADEN = 1, PCFG<3:0> = 0000; when PBADEN = 0, PCFG<3:0> = 0111.
2: AN5 through AN7 are available only on PIC18F4682/4685 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
1010
AN10
1001
AN9
1000
AN8
0111
AN7(1)
0110
AN6(1)
0101
AN5(1)
0100
AN4
VAIN
(Input Voltage) 0011
10-Bit AN3
A/D
Converter 0010
AN2
0001
VCFG1:VCFG0 AN1
AVDD(2) 0000
AN0
X0
VREF+ X1
Reference 1X
Voltage VREF- 0X
AVSS(2)
Note 1: Channels AN5 through AN7 are not available on PIC18F2682/2685 devices.
2: I/O pins have diode protection to VDD and VSS.
VSS
TCY - TAD TAD1 TAD2 TAD3 TAD4 TAD5 TAD6 TAD7 TAD8 TAD9 TAD10 TAD11
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Conversion starts
Holding capacitor is disconnected from analog input (typically 100 ns)
FIGURE 19-4: A/D CONVERSION TAD CYCLES (ACQT<2:0> = 010, TACQ = 4 TAD)
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Automatic
Acquisition Conversion starts
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
RE1/WR/AN6/C1OUT*
A VIN-
RD3/PSP3/C2IN- A VIN-
VIN+ C2 C2OUT RD3/PSP3/C2IN-
A
RD2/PSP2/C2IN+ A VIN+ C2 C2OUT
RD2/PSP2/C2IN+
RE2/CS/AN7/C2OUT*
Two Common Reference Comparators Two Common Reference Comparators with Outputs
CM2:CM0 = 100 CM2:CM0 = 101
RD1/PSP1/C1IN- A VIN- A VIN-
RD1/PSP1/C1IN-
A VIN+ C1 C1OUT A VIN+ C1 C1OUT
RD0/PSP0/C1IN+ RD0/PSP0/C1IN+
RE1/WR/AN6/C1OUT*
A VIN-
RD3/PSP3/C2IN-
C2 C2OUT A VIN-
RD2/PSP2/C2IN+ D VIN+ RD3/PSP3/C2IN-
D VIN+ C2 C2OUT
RD2/PSP2/C2IN+
RE2/CS/AN7/C2OUT*
One Independent Comparator with Output Four Inputs Multiplexed to Two Comparators
CM2:CM0 = 001 CM2:CM0 = 110
RD1/PSP1/ A
RD1/PSP1/C1IN- A VIN-
C1IN- CIS = 0 VIN-
VIN+ C1 C1OUT RD0/PSP0/ A
RD0/PSP0/C1IN+ A CIS = 1
VIN+ C1 C1OUT
C1IN+
RE1/WR/AN6/C1OUT* RD3/PSP3/ A
C2IN- CIS = 0 VIN-
RD2/PSP2/ A CIS = 1
RD3/PSP3/C2IN- D VIN- VIN+ C2 C2OUT
C2IN+
VIN+ C2 Off
RD2/PSP2/C2IN+ D (Read as ‘0’) 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 RE1 or
-
RE2 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
Note 1: CVROE overrides the TRISA<0> bit setting. If enabled for output, RA2 must also be configured as an
input by setting TRISA<2> to ‘1’.
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
PIC18F4682/4685
CVREF R(1)
Module +
Voltage RA0 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: HLVDL3:HLVDL0 modes that result in a trip point below the valid operating voltage of the device are not tested.
Externally Generated
Trip Point
VDD
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
Acceptance Mask
BUFFERS 16 – 4 to 1 MUXs
RXM0
Acceptance Filters
TXB0 TXB1 TXB2 (RXF0-RXF05)
VCC
A MODE 0
c
MESSAGE
MESSAGE
MESSAGE
MTXBUFF
MTXBUFF
MTXBUFF
MSGREQ
MSGREQ
MSGREQ
c
TXERR
TXERR
TXERR
Acceptance Mask
MLOA
MLOA
MLOA
ABTF
ABTF
ABTF
e
p Acceptance Filters RXF15
RXM1
t (RXF06-RXF15)
MODE 1, 2
Message MODE 0
2 RX Identifier
Queue
Buffers M
Control A
Transmit Byte Sequencer Data Field B
Transmit Option
MESSAGE
BUFFERS
Transmit Err-Pas
Error Bus-Off
Counter
Transmit<7:0> Receive<8:0>
Shift<14:0>
{Transmit<5:0>, Receive<8:0>}
Comparator
Protocol
Finite
State
CRC<14:0> Machine
Bit
Transmit Clock
Timing
Logic Logic Generator
Configuration
TX RX Registers
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: To achieve maximum power saving and/or able to wake-up on CAN bus activity, switch CAN module in
Disable mode before putting device to Sleep.
2: If buffer is configured as receiver, EICODE bits will contain ‘10000’ upon interrupt.
EXAMPLE 23-2: WIN AND ICODE BITS USAGE IN INTERRUPT SERVICE ROUTINE TO ACCESS
TX/RX BUFFERS
; Save application required context.
; Poll interrupt flags and determine source of interrupt
; This was found to be CAN interrupt
; TempCANCON and TempCANSTAT are variables defined in Access Bank low
MOVFF CANCON, TempCANCON ; Save CANCON.WIN bits
; This is required to prevent CANCON
; from corrupting CAN buffer access
; in-progress while this interrupt
; occurred
MOVFF CANSTAT, TempCANSTAT ; Save CANSTAT register
; This is required to make sure that
; we use same CANSTAT value rather
; than one changed by another CAN
; interrupt.
MOVF TempCANSTAT, W ; Retrieve ICODE bits
ANDLW B’00001110’
ADDWF PCL, F ; Perform computed GOTO
; to corresponding interrupt cause
BRA NoInterrupt ; 000 = No interrupt
BRA ErrorInterrupt ; 001 = Error interrupt
BRA TXB2Interrupt ; 010 = TXB2 interrupt
BRA TXB1Interrupt ; 011 = TXB1 interrupt
BRA TXB0Interrupt ; 100 = TXB0 interrupt
BRA RXB1Interrupt ; 101 = RXB1 interrupt
BRA RXB0Interrupt ; 110 = RXB0 interrupt
; 111 = Wake-up on interrupt
WakeupInterrupt
BCF PIR3, WAKIF ; Clear the interrupt flag
;
; User code to handle wake-up procedure
;
;
; Continue checking for other interrupt source or return from here
…
NoInterrupt
… ; PC should never vector here. User may
; place a trap such as infinite loop or pin/port
; indication to catch this error.
Legend:
R = Readable bit W = 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: These bits can only be changed in Configuration mode. See Register 23-1 to change to Configuration mode.
2: This bit is used in Mode 2 only.
3: FIFO length of 4 or less will cause this bit to be set.
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7 Mode 0:
RXB0OVFL: Receive Buffer 0 Overflow bit
1 = Receive Buffer 0 overflowed
0 = Receive Buffer 0 has not overflowed
Mode 1:
Unimplemented: Read as ‘0’
Mode 2:
FIFOEMPTY: FIFO Not Empty bit
1 = Receive FIFO is not empty
0 = Receive FIFO is empty
bit 6 Mode 0:
RXB1OVFL: Receive Buffer 1 Overflow bit
1 = Receive Buffer 1 overflowed
0 = Receive Buffer 1 has not overflowed
Mode 1, 2:
RXBnOVFL: Receive Buffer n Overflow bit
1 = Receive Buffer n has overflowed
0 = Receive Buffer n has not overflowed
bit 5 TXBO: Transmitter Bus-Off bit
1 = Transmit error counter > 255
0 = Transmit error counter ≤ 255
bit 4 TXBP: Transmitter Bus Passive bit
1 = Transmit error counter > 127
0 = Transmit error counter ≤ 127
bit 3 RXBP: Receiver Bus Passive bit
1 = Receive error counter > 127
0 = Receive error counter ≤ 127
bit 2 TXWARN: Transmitter Warning bit
1 = Transmit error counter > 95
0 = Transmit error counter ≤ 95
bit 1 RXWARN: Receiver Warning bit
1 = 127 ≥ Receive error counter > 95
0 = Receive error counter ≤ 95
bit 0 EWARN: Error Warning bit
This bit is a flag of the RXWARN and TXWARN bits.
1 = The RXWARN or the TXWARN bits are set
0 = Neither the RXWARN or the TXWARN bits are set
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-0 EID15:EID8: Extended Identifier bits (not used when transmitting standard identifier message)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-0 EID7:EID0: Extended Identifier bits (not used when transmitting standard identifier message)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-0 TXBnDm7:TXBnDm0: Transmit Buffer n Data Field Byte m bits (where 0 ≤ n < 3 and 0 ≤ m < 8)
Each transmit buffer has an array of registers. For example, Transmit Buffer 0 has 7 registers: TXB0D0
to TXB0D7.
Legend:
R = Readable bit W = 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
; Now that all data bytes are loaded, mark it for transmission.
MOVLW B’00001000’ ; Normal priority; Request transmission
MOVWF TXB0CON
; Message is transmitted.
; Now that all data bytes are loaded, mark it for transmission.
MOVLW B’00001000’ ; Normal priority; Request transmission
MOVWF RXB0CON
; Message is transmitted.
; If required, reset the WIN bits to default state.
Note 1: This bit is set by the CAN module upon receiving a message and must be cleared by software after the
buffer is read. As long as RXFUL is set, no new message will be loaded and buffer will be considered full.
After clearing the RXFUL flag, the PIR3 bit, RXB0IF, can be cleared. If RXB0IF is cleared, but RXFUL is
not cleared, then RXB0IF is set again.
2: This bit allows same filter jump table for both RXB0CON and RXB1CON.
Note 1: This bit is set by the CAN module upon receiving a message and must be cleared by software after the
buffer is read. As long as RXFUL is set, no new message will be loaded and buffer will be considered full.
After clearing the RXFUL flag, the PIR3 bit, RXB0IF, can be cleared. If RXB0IF is cleared, but RXFUL is
not cleared, then RXB0IF is set again.
2: This bit allows same filter jump table for both RXB0CON and RXB1CON.
Note 1: This bit is set by the CAN module upon receiving a message and must be cleared by software after the
buffer is read. As long as RXFUL is set, no new message will be loaded and buffer will be considered full.
Note 1: This bit is set by the CAN module upon receiving a message and must be cleared by software after the
buffer is read. As long as RXFUL is set, no new message will be loaded and buffer will be considered full.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-0 RXBnDm7:RXBnDm0: Receive Buffer n Data Field Byte m bits (where 0 ≤ n < 1 and 0 < m < 7)
Each receive buffer has an array of registers. For example, Receive Buffer 0 has 8 registers: RXB0D0
to RXB0D7.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
REGISTER 23-32: BnDm: TX/RX BUFFER n DATA FIELD BYTE m REGISTERS IN RECEIVE MODE
[0 ≤ n ≤ 5, 0 ≤ m ≤ 7, TXnEN (BSEL<n>) = 0](1)
R-x R-x R-x R-x R-x R-x R-x R-x
BnDm7 BnDm6 BnDm5 BnDm4 BnDm3 BnDm2 BnDm1 BnDm0
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-0 BnDm7:BnDm0: Receive Buffer n Data Field Byte m bits (where 0 ≤ n < 3 and 0 < m < 8)
Each receive buffer has an array of registers. For example, Receive Buffer 0 has 7 registers: B0D0 to
B0D7.
REGISTER 23-33: BnDm: TX/RX BUFFER n DATA FIELD BYTE m REGISTERS IN TRANSMIT MODE
[0 ≤ n ≤ 5, 0 ≤ m ≤ 7, TXnEN (BSEL<n>) = 1](1)
R/W-x R/W-x R/W-x R/W-x R/W-x R/W-x R/W-x R/W-x
BnDm7 BnDm6 BnDm5 BnDm4 BnDm3 BnDm2 BnDm1 BnDm0
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-0 BnDm7:BnDm0: Transmit Buffer n Data Field Byte m bits (where 0 ≤ n < 3 and 0 < m < 8)
Each transmit buffer has an array of registers. For example, Transmit Buffer 0 has 7 registers: TXB0D0
to TXB0D7.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-0 SID10:SID3: Standard Identifier Mask bits or Extended Identifier Mask bits EID28:EID21
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-5 SID2:SID0: Standard Identifier Mask bits or Extended Identifier Mask bits EID20:EID18
bit 4 Unimplemented: Read as ‘0’
bit 3 Mode 0:
Unimplemented: Read as ‘0’
Mode 1, 2:
EXIDEN: Extended Identifier Filter Enable Mask bit(1)
1 = Messages selected by the EXIDEN bit in RXFnSIDL will be accepted
0 = Both standard and extended identifier messages will be accepted
bit 2 Unimplemented: Read as ‘0’
bit 1-0 EID17:EID16: Extended Identifier Mask bits
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note: Register 23-46 through Register 23-51 are writable in Configuration mode only.
REGISTER 23-46: SDFLC: STANDARD DATA BYTES FILTER LENGTH COUNT REGISTER(1)
U-0 U-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
— — — FLC4 FLC3 FLC2 FLC1 FLC0
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Always set this bit when using differential bus to avoid signal crosstalk in CANTX from other nearby pins.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
bit 7-2 B5IE:B0IE: Programmable Transmit/Receive Buffer 5-0 Interrupt Enable bit(2)
1 = Interrupt is enabled
0 = Interrupt is disabled
bit 1-0 RXB1IE:RXB0IE: Dedicated Receive Buffer 1-0 Interrupt Enable bit(2)
1 = Interrupt is enabled
0 = Interrupt is disabled
Note 1: Shaded registers are available in Access Bank low area, while the rest are available in Bank 15.
2: CANSTAT register is repeated in these locations to simplify application firmware. Unique names are given
for each instance of the controller register due to the Microchip header file requirement.
3: These registers are not CAN registers.
4: Unimplemented registers are read as ‘0’.
Note 1: Shaded registers are available in Access Bank low area, while the rest are available in Bank 15.
2: CANSTAT register is repeated in these locations to simplify application firmware. Unique names are given
for each instance of the controller register due to the Microchip header file requirement.
3: These registers are not CAN registers.
4: Unimplemented registers are read as ‘0’.
Note 1: Shaded registers are available in Access Bank low area, while the rest are available in Bank 15.
2: CANSTAT register is repeated in these locations to simplify application firmware. Unique names are given
for each instance of the controller register due to the Microchip header file requirement.
3: These registers are not CAN registers.
4: Unimplemented registers are read as ‘0’.
Note 1: Shaded registers are available in Access Bank low area, while the rest are available in Bank 15.
2: CANSTAT register is repeated in these locations to simplify application firmware. Unique names are given
for each instance of the controller register due to the Microchip header file requirement.
3: These registers are not CAN registers.
4: Unimplemented registers are read as ‘0’.
D7Fh —(4)
D7Eh —(4)
D7Dh —(4)
D7Ch —(4)
D7Bh RXF11EIDL
D7Ah RXF11EIDH
D79h RXF11SIDL
D78h RXF11SIDH
D77h RXF10EIDL
D76h RXF10EIDH
D75h RXF10SIDL
D74h RXF10SIDH
D73h RXF9EIDL
D72h RXF9EIDH
D71h RXF9SIDL
D70h RXF9SIDH
D6Fh —(4)
D6Eh —(4)
D6Dh —(4)
D6Ch —(4)
D6Bh RXF8EIDL
D6Ah RXF8EIDH
D69h RXF8SIDL
D68h RXF8SIDH
D67h RXF7EIDL
D66h RXF7EIDH
D65h RXF7SIDL
D64h RXF7SIDH
D63h RXF6EIDL
D62h RXF6EIDH
D61h RXF6SIDL
D60h RXF6SIDH
Note 1: Shaded registers are available in Access Bank low area while the rest are available in Bank 15.
2: CANSTAT register is repeated in these locations to simplify application firmware. Unique names are given
for each instance of the controller register due to the Microchip header file requirement.
3: These registers are not CAN registers.
4: Unimplemented registers are read as ‘0’.
MESSAGE
MESSAGE
MESSAGE
TXLARB
TXLARB
TXLARB
TXLARB
TXREQ
TXREQ
TXREQ
TXREQ
TXERR
TXERR
TXERR
TXERR
TXB0IF
TXB1IF
TXB2IF
TXB2IF
TXABT
TXABT
TXABT
TXABT
Message
Queue
Control
Transmit Byte Sequencer
RXFn0 RXMn0
RXFnn RXMnn
Input
Signal
TQ
Sample Point
Nominal Bit Time
Nominal Clock
Once these considerations are taken into account, it is For example, assume a CAN bit rate of 125 Kb/s, which
possible to show that the relation between the jitter and gives an NBT of 8 μs. For a 16 MHz clock generated
the total frequency error can be defined as: from a 4x PLL, the jitter at this clock frequency is:
where jitter is expressed in terms of time and NBT is the The resultant frequency error is:
Nominal Bit Time.
EQUATION 23-6:
–9
2 × ( 1.25 ×10 ) –5
--------------------------------------- = 3.125 ×10 = 0.0031%
–6
10 × ( 8 ×10 )
TABLE 23-3: FREQUENCY ERROR FROM JITTER AT VARIOUS PLL GENERATED CLOCK SPEEDS
Frequency Error at Various Nominal Bit Times (Bit Rates)
PLL
Pjitter Tjitter 8 μs 4 μs 2 μs 1 μs
Output
(125 Kb/s) (250 Kb/s) (500 Kb/s) (1 Mb/s)
40 MHz 0.5 ns 1 ns 0.00125% 0.00250% 0.005% 0.01%
24 MHz 0.83 ns 1.67 ns 0.00209% 0.00418% 0.008% 0.017%
16 MHz 1.25 ns 2.5 ns 0.00313% 0.00625% 0.013% 0.025%
TABLE 23-4: TOTAL FREQUENCY ERROR AT VARIOUS PLL GENERATED CLOCK SPEEDS
(100 PPM OSCILLATOR DRIFT, INCLUDING ERROR FROM JITTER)
Frequency Error at Various Nominal Bit Times (Bit Rates)
Nominal PLL Output 8 μs 4 μs 2 μs 1 μs
(125 Kb/s) (250 Kb/s) (500 Kb/s) (1 Mb/s)
40 MHz 0.01125% 0.01250% 0.015% 0.02%
24 MHz 0.01209% 0.01418% 0.018% 0.027%
16 MHz 0.01313% 0.01625% 0.023% 0.035%
Input
Signal
TQ
Sample Point
Nominal Bit Length
TQ Sample Point
Actual Bit Length
Nominal Bit Length
23.13.3 BRGCON3
The PHSEG2<2:0> bits set the length (in TQ) of Phase
Segment 2 if the SEG2PHTS bit is set to a ‘1’. If the
SEG2PHTS bit is set to a ‘0’, then the PHSEG2<2:0>
bits have no effect.
If a node detects a dominant bit in one of the four The PIC18F2682/2685/4682/4685 devices are error-
segments, including End-of-Frame, interframe space, active if both error counters are below the error-passive
Acknowledge delimiter or CRC delimiter, then a form limit of 128. They are error-passive if at least one of the
error has occurred and an error frame is generated. error counters equals or exceeds 128. They go to bus-
The message is repeated. off if the transmit error counter equals or exceeds the
bus-off limit of 256. The devices remain in this state
23.14.4 BIT ERROR until the bus-off recovery sequence is received. The
bus-off recovery sequence consists of 128 occurrences
A bit error occurs if a transmitter sends a dominant bit of 11 consecutive recessive bits (see Figure 23-8).
and detects a recessive bit, or if it sends a recessive bit Note that the CAN module, after going bus-off, will
and detects a dominant bit, when monitoring the actual recover back to error-active without any intervention by
bus level and comparing it to the just transmitted bit. In the MCU if the bus remains Idle for 128 x 11 bit times.
the case where the transmitter sends a recessive bit If this is not desired, the error Interrupt Service Routine
and a dominant bit is detected during the arbitration should address this. The current Error mode of the
field and the Acknowledge slot, no bit error is CAN module can be read by the MCU via the
generated because normal arbitration is occurring. COMSTAT register.
23.14.5 STUFF BIT ERROR Additionally, there is an Error State Warning flag bit,
EWARN, which is set if at least one of the error
lf, between the Start-of-Frame and the CRC delimiter,
counters equals or exceeds the error warning limit of
six consecutive bits with the same polarity are
96. EWARN is reset if both error counters are less than
detected, the bit stuffing rule has been violated. A stuff
the error warning limit.
bit error occurs and an error frame is generated. The
message is repeated.
Reset
Error-
Passive
TXERRCNT > 255
Bus-
Off
23.15 CAN Interrupts The interrupts can be broken up into two categories:
receive and transmit interrupts.
The module has several sources of interrupts. Each of
these interrupts can be individually enabled or The receive related interrupts are:
disabled. The PIR3 register contains interrupt flags. • Receive Interrupts
The PIE3 register contains the enables for the 8 main • Wake-up Interrupt
interrupts. A special set of read-only bits in the • Receiver Overrun Interrupt
CANSTAT register, the ICODE bits, can be used in
• Receiver Warning Interrupt
combination with a jump table for efficient handling of
interrupts. • Receiver Error-Passive Interrupt
All interrupts have one source, with the exception of the The transmit related interrupts are:
error interrupt and buffer interrupts in Mode 1 and 2. Any • Transmit Interrupts
of the error interrupt sources can set the error interrupt • Transmitter Warning Interrupt
flag. The source of the error interrupt can be determined
• Transmitter Error-Passive Interrupt
by reading the Communication Status register,
COMSTAT. In Mode 1 and 2, there are two interrupt • Bus-Off Interrupt
enable/disable and flag bits – one for all transmit buffers
and the other for all receive buffers.
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 — 1--- -01-
300006h CONFIG4L DEBUG XINST BBSIZ1 BBSIZ2 — LVP — STVREN 1000 -1-1
300008h CONFIG5L — — CP5(1) CP4 CP3 CP2 CP1 CP0 --11 1111
300009h CONFIG5H CPD CPB — — — — — — 11-- ----
(1)
30000Ah CONFIG6L — — WRT5 WRT4 WRT3 WRT2 WRT1 WRT0 --11 1111
30000Bh CONFIG6H WRTD WRTB WRTC — — — — — 111- ----
30000Ch CONFIG7L — — EBTR5(1) EBTR4 EBTR3 EBTR2 EBTR1 EBTR0 --11 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 xxxx xxxx(2)
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition. Shaded cells are unimplemented, read as ‘0’.
Note 1: Unimplemented in PIC18F2682/4682 devices; maintain this bIt set.
2: See Register 24-12 and Register 24-13 for DEVID1 and DEVID2 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: 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 = Read-only 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.
Legend:
R = Readable bit W = 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.
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
CPU Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4 PC + 6
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
Sample Clock
Device Oscillator
Clock Failure
Output
CM Output
(Q)
Failure
Detected
OSCFIF
24.4.3 FSCM INTERRUPTS IN time considerably longer than the FCSM sample clock
POWER-MANAGED MODES time, a false clock failure may be detected. To prevent
this, the internal oscillator block is automatically config-
By entering a power-managed mode, the clock
ured as the device clock and functions until the primary
multiplexer selects the clock source selected by the
clock is stable (the OST and PLL timers have timed
OSCCON register. Fail-Safe Monitoring of the power-
out). This is identical to Two-Speed Start-up mode.
managed clock source resumes in the power-managed
Once the primary clock is stable, the INTRC returns to
mode.
its role as the FSCM source.
If an oscillator failure occurs during power-managed
operation, the subsequent events depend on whether Note: The same logic that prevents false oscilla-
or not the oscillator failure interrupt is enabled. If tor failure interrupts on POR, or wake from
enabled (OSCFIF = 1), code execution will be clocked Sleep, will also prevent the detection of
by the INTOSC multiplexer. An automatic transition the oscillator’s failure to start at all follow-
back to the failed clock source will not occur. ing these events. This can be avoided by
monitoring the OSTS bit and using a
If the interrupt is disabled, subsequent interrupts while timing routine to determine if the oscillator
in Idle mode will cause the CPU to begin executing is taking too long to start. Even so, no
instructions while being clocked by the INTOSC oscillator failure interrupt will be flagged.
source.
As noted in Section 24.3.1 “Special Considerations
24.4.4 POR OR WAKE-UP FROM SLEEP for Using Two-Speed Start-up”, it is also possible to
The FSCM is designed to detect oscillator failure at any select another clock configuration and enter an alternate
point after the device has exited Power-on Reset power-managed mode while waiting for the primary
(POR) or low-power Sleep mode. When the primary clock to become stable. When the new power-managed
device clock is EC, RC or INTRC, monitoring can begin mode is selected, the primary clock is disabled.
immediately following these events.
For oscillator modes involving a crystal or resonator
(HS, HSPLL, LP or XT), the situation is somewhat
different. Since the oscillator may require a start-up
MEMORY SIZE/DEVICE
Block Code Protection
80 Kbytes 96 Kbytes Address Controlled By:
(PIC18F2682/4682) (PIC18F2685/4685) Range
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
00BFFFh
00C000h
Block 3 Block 3 CP3, WRT3, EBTR3
00FFFFh
010000h
Block 4 Block 4 CP4, WRT4, EBTR4
013FFFh
014000h
Unimplemented
Block 5 CP5, WRT5, EBTR5
Read ‘0’s
017FFFh
018000h
Unimplemented Unimplemented
Read ‘0’s Read ‘0’s (Unimplemented Memory Space)
1FFFFFh
24.5.1 PROGRAM MEMORY A table read instruction that executes from a location
CODE PROTECTION outside of that block is not allowed to read and will
result in reading ‘0’s. Figures 24-6 through 24-8
The program memory may be read to or written from
illustrate table write and table read protection.
any location using the table read and table write
instructions. The Device ID may be read with table Note: Code protection bits may only be written to
reads. The Configuration registers may be read and a ‘0’ from a ‘1’ state. It is not possible to
written with the table read and table write instructions. write a ‘1’ to a bit in the ‘0’ state. Code
In normal execution mode, the CPn bits have no direct protection bits are only set to ‘1’ by a full
effect. CPn bits inhibit external reads and writes. A Chip Erase or Block Erase function. The
block of user memory may be protected from table full Chip Erase and Block Erase functions
writes if the WRTn Configuration bit is ‘0’. The EBTRn can only be initiated via ICSP or an
bits control table reads. For a block of user memory external programmer.
with the EBTRn bit set to ‘0’, a table read instruction
that executes from within that block is allowed to read.
TBLPTR = 0008FFh
WRT0, EBTR0 = 01
003FFFh
004000h
PC = 007FFEh TBLRD* WRT1, EBTR1 = 11
007FFFh
008000h
WRT2, EBTR2 = 11
00BFFFh
00C000h
WRT3, EBTR3 = 11
00FFFFh
010000h
WRT4, EBTR3 = 11
013FFFh
014000h
WRT5, EBTR3 = 11
017FFFh
Results: All table reads from external blocks to Blockn are disabled whenever EBTRn = 0.
TABLAT register returns a value of ‘0’.
TBLPTR = 0008FFh
WRT0, EBTR0 = 01
1. The file register (specified by ‘f’) Section 25.1.1 “Standard Instruction Set” provides
a description of each instruction.
2. The bit in the file register (specified by ‘b’)
3. The accessed memory (specified by ‘a’)
The bit field designator ‘b’ selects the number of the bit
affected by the operation, while the file register
designator ‘f’ represents the number of the file in which
the bit is located.
Literal operations
15 8 7 0
OPCODE k (literal) MOVLW 7Fh
Control operations
CALL, GOTO and Branch operations
15 8 7 0
OPCODE n<7:0> (literal) GOTO Label
15 12 11 0
1111 n<19:8> (literal)
15 8 7 0
OPCODE S n<7:0> (literal) CALL MYFUNC
15 12 11 0
1111 n<19:8> (literal)
S = Fast bit
15 11 10 0
OPCODE n<10:0> (literal) BRA MYFUNC
15 8 7 0
OPCODE n<7:0> (literal) BC MYFUNC
BYTE-ORIENTED OPERATIONS
ADDWF f, d, a Add WREG and f 1 0010 01da ffff ffff C, DC, Z, OV, N 1, 2
ADDWFC f, d, a Add WREG and Carry bit to f 1 0010 00da ffff ffff C, DC, Z, OV, N 1, 2
ANDWF f, d, a AND WREG with f 1 0001 01da ffff ffff Z, N 1,2
CLRF f, a Clear f 1 0110 101a ffff ffff Z 2
COMF f, d, a Complement f 1 0001 11da ffff ffff Z, N 1, 2
CPFSEQ f, a Compare f with WREG, skip = 1 (2 or 3) 0110 001a ffff ffff None 4
CPFSGT f, a Compare f with WREG, skip > 1 (2 or 3) 0110 010a ffff ffff None 4
CPFSLT f, a Compare f with WREG, skip < 1 (2 or 3) 0110 000a ffff ffff None 1, 2
DECF f, d, a Decrement f 1 0000 01da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
DECFSZ f, d, a Decrement f, Skip if 0 1 (2 or 3) 0010 11da ffff ffff None 1, 2, 3, 4
DCFSNZ f, d, a Decrement f, Skip if Not 0 1 (2 or 3) 0100 11da ffff ffff None 1, 2
INCF f, d, a Increment f 1 0010 10da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
INCFSZ f, d, a Increment f, Skip if 0 1 (2 or 3) 0011 11da ffff ffff None 4
INFSNZ f, d, a Increment f, Skip if Not 0 1 (2 or 3) 0100 10da ffff ffff None 1, 2
IORWF f, d, a Inclusive OR WREG with f 1 0001 00da ffff ffff Z, N 1, 2
MOVF f, d, a Move f 1 0101 00da ffff ffff Z, N 1
MOVFF fs, fd Move fs (source) to 1st word 2 1100 ffff ffff ffff None
fd (destination)2nd word 1111 ffff ffff ffff
MOVWF f, a Move WREG to f 1 0110 111a ffff ffff None
MULWF f, a Multiply WREG with f 1 0000 001a ffff ffff None 1, 2
NEGF f, a Negate f 1 0110 110a ffff ffff C, DC, Z, OV, N
RLCF f, d, a Rotate Left f through Carry 1 0011 01da ffff ffff C, Z, N 1, 2
RLNCF f, d, a Rotate Left f (No Carry) 1 0100 01da ffff ffff Z, N
RRCF f, d, a Rotate Right f through Carry 1 0011 00da ffff ffff C, Z, N
RRNCF f, d, a Rotate Right f (No Carry) 1 0100 00da ffff ffff Z, N
SETF f, a Set f 1 0110 100a ffff ffff None 1, 2
SUBFWB f, d, a Subtract f from WREG with 1 0101 01da ffff ffff C, DC, Z, OV, N
borrow
SUBWF f, d, a Subtract WREG from f 1 0101 11da ffff ffff C, DC, Z, OV, N 1, 2
SUBWFB f, d, a Subtract WREG from f with 1 0101 10da ffff ffff C, DC, Z, OV, N
borrow
SWAPF f, d, a Swap nibbles in f 1 0011 10da ffff ffff None 4
TSTFSZ f, a Test f, skip if 0 1 (2 or 3) 0110 011a ffff ffff None 1, 2
XORWF f, d, a Exclusive OR WREG with f 1 0001 10da ffff ffff Z, N
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared
if assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second
cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all
program memory locations have a valid instruction.
5: If the table write starts the write cycle to internal memory, the write will continue until terminated.
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 subroutine1st word 2 1110 110s kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
CLRWDT — Clear Watchdog Timer 1 0000 0000 0000 0100 TO, PD
DAW — Decimal Adjust WREG 1 0000 0000 0000 0111 C
GOTO n Go to address 1st word 2 1110 1111 kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
NOP — No Operation 1 0000 0000 0000 0000 None
NOP — No Operation 1 1111 xxxx xxxx xxxx None 4
POP — Pop top of return stack (TOS) 1 0000 0000 0000 0110 None
PUSH — Push top of return stack (TOS) 1 0000 0000 0000 0101 None
RCALL n Relative Call 2 1101 1nnn nnnn nnnn None
RESET Software device Reset 1 0000 0000 1111 1111 All
RETFIE s Return from interrupt enable 2 0000 0000 0001 000s GIE/GIEH,
PEIE/GIEL
RETLW k Return with literal in WREG 2 0000 1100 kkkk kkkk None
RETURN s Return from Subroutine 2 0000 0000 0001 001s None
SLEEP — Go into Standby mode 1 0000 0000 0000 0011 TO, PD
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared
if assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second
cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all
program memory locations have a valid instruction.
5: If the table write starts the write cycle to internal memory, the write will continue until terminated.
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 5
TBLWT*+ Table Write with post-increment 0000 0000 0000 1101 None 5
TBLWT*- Table Write with post-decrement 0000 0000 0000 1110 None 5
TBLWT+* Table Write with pre-increment 0000 0000 0000 1111 None 5
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared
if assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second
cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all
program memory locations have a valid instruction.
5: If the table write starts the write cycle to internal memory, the write will continue until terminated.
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).
Cycles: 1 Q1 Q2 Q3 Q4
Decode Read literal Process Write to PC
Q Cycle Activity:
‘n’ Data
Q1 Q2 Q3 Q4 No No No No
Decode Read Process Write operation operation operation operation
register ‘f’ Data register ‘f’ If No Jump:
Q1 Q2 Q3 Q4
Example: BCF FLAG_REG, 7, 0 Decode Read literal Process No
Before Instruction ‘n’ Data operation
FLAG_REG = C7h
After Instruction Example: HERE BN Jump
FLAG_REG = 47h
Before Instruction
PC = address (HERE)
After Instruction
If Negative = 1;
PC = address (Jump)
If Negative = 0;
PC = address (HERE + 2)
Before Instruction No No No No
operation operation operation operation
PC = address (HERE)
After Instruction
If Zero = 1; Example: HERE CALL THERE, 1
PC = address (Jump)
If Zero = 0; Before Instruction
PC = address (HERE + 2) PC = address (HERE)
After Instruction
PC = address (THERE)
TOS = address (HERE + 4)
WS = W
BSRS = BSR
STATUSS= STATUS
Before Instruction
FLAG_REG = 5Ah
After Instruction
FLAG_REG = 00h
Q1 Q2 Q3 Q4 Cycles: 1
Decode Read Process Write Q Cycle Activity:
register W Data W Q1 Q2 Q3 Q4
Example 1: Decode Read Process Write to
DAW register ‘f’ Data destination
Before Instruction
W = A5h Example: DECF CNT, 1, 0
C = 0
DC = 0 Before Instruction
After Instruction CNT = 01h
W = 05h Z = 0
C = 1 After Instruction
DC = 0 CNT = 00h
Example 2: Z = 1
Before Instruction
W = CEh
C = 0
DC = 0
After Instruction
W = 34h
C = 1
DC = 0
After Instruction Q1 Q2 Q3 Q4
PC = Address (THERE) Decode Read Process Write to
register ‘f’ Data destination
Words: 1 C register f
Cycles: 1
Words: 1
Q Cycle Activity:
Cycles: 1
Q1 Q2 Q3 Q4
Decode Read Process Write to Q Cycle Activity:
register ‘f’ Data destination Q1 Q2 Q3 Q4
Decode Read Process Write to
Example: RLNCF REG, 1, 0 register ‘f’ Data destination
Before Instruction
REG = 1010 1011 Example: RRCF REG, 0, 0
After Instruction Before Instruction
REG = 0101 0111 REG = 1110 0110
C = 0
After Instruction
REG = 1110 0110
W = 0111 0011
C = 0
ADDFSR Add Literal to FSR ADDULNK Add Literal to FSR2 and Return
Syntax: ADDFSR f, k Syntax: ADDULNK k
Operands: 0 ≤ k ≤ 63 Operands: 0 ≤ k ≤ 63
f ∈ [ 0, 1, 2 ] Operation: FSR2 + k → FSR2,
Operation: FSR(f) + k → FSR(f) PC = (TOS)
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.
Q Cycle Activity: The instruction takes two cycles to
execute; a NOP is performed during the
Q1 Q2 Q3 Q4
second cycle.
Decode Read Process Write to
This may be thought of as a special case
literal ‘k’ Data FSR
of the ADDFSR instruction, where f = 3
(binary ‘11’); it operates only on FSR2.
Words: 1
Example: ADDFSR 2, 23h
Cycles: 2
Before Instruction
FSR2 = 03FFh
Q Cycle Activity:
After Instruction
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
1111 xxxx xzzz zzzzd Description: The 8-bit literal ‘k’ is written to the data
2nd word (dest.)
memory address specified by FSR2. FSR2 is
Description The contents of the source register are 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
Q Cycle Activity:
the 4096-byte data memory space
(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 Before Instruction
resultant destination address points to FSR2H:FSR2L = 01ECh
an indirect addressing register, the Memory (01ECh) = 00h
instruction will execute as a NOP.
After Instruction
Words: 2
FSR2H:FSR2L = 01EBh
Cycles: 2 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: FSRf – k → FSRf (TOS) → PC
Status Affected: None Status Affected: None
Encoding: 1110 1001 ffkk kkkk Encoding: 1110 1001 11kk kkkk
Description: The 6-bit literal ‘k’ is subtracted from Description: The 6-bit literal ‘k’ is subtracted from the
the contents of the FSR specified 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;
Cycles: 1 a NOP is performed during the second cycle.
Q Cycle Activity: This may be thought of as a special case of
the SUBFSR instruction, where f = 3 (binary
Q1 Q2 Q3 Q4
‘11’); it operates only on FSR2.
Decode Read Process Write to
Words: 1
register ‘f’ Data destination
Cycles: 2
Q Cycle Activity:
Example: SUBFSR 2, 23h Q1 Q2 Q3 Q4
Before Instruction Decode Read Process Write to
FSR2 = 03FFh register ‘f’ Data destination
After Instruction No No No No
FSR2 = 03DCh 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 PIC18F268X/468X
4.5V
Voltage
4.2V
4.0V
3.5V
3.0V
2.5V
2.0V
40 MHz
Frequency
6.0V
5.5V
5.0V
PIC18LF268X/468X
4.5V
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
Symbol Characteristic Min Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Device Typ Max Units Conditions
No.
Param
Sym Characteristic Min Typ† Max Units Conditions
No.
Internal Program Memory
Programming Specifications(1)
D110 VPP Voltage on MCLR/VPP/RE3 pin 9.00 — 13.25 V (Note 3)
D113 IDDP Supply Current during — — 10 mA
Programming
Data EEPROM Memory
D120 ED Byte Endurance 100K 1M — E/W -40°C to +85°C
D121 VDRW VDD for Read/Write VMIN — 5.5 V Using EECON to read/write
VMIN = Minimum operating
voltage
D122 TDEW Erase/Write Cycle Time — 4 — ms
D123 TRETD Characteristic Retention 40 — — Year Provided no other
specifications are violated
D124 TREF Number of Total Erase/Write 1M 10M — E/W -40°C to +85°C
Cycles before Refresh(2)
Program Flash Memory
D130 EP Cell Endurance 10K 100K — E/W -40°C to +85°C
D131 VPR VDD for Read VMIN — 5.5 V VMIN = Minimum operating
voltage
D132 VIE VDD for Block Erase 4.5 — 5.5 V Using ICSP™ port
D132A VIW VDD for Externally Timed Erase 4.5 — 5.5 V Using ICSP port
or Write
D132B VPEW VDD for Self-timed Write VMIN — 5.5 V VMIN = Minimum operating
voltage
D133 TIE ICSP™ Block Erase Cycle Time — 4 — ms VDD > 4.5V
D133A TIW ICSP Erase or Write Cycle Time 1 — — ms VDD > 4.5V
(externally timed)
D133A TIW Self-timed Write Cycle Time — 2 — ms
D134 TRETD Characteristic Retention 40 100 — Year Provided no other
specifications are violated
† Data in “Typ” column is at 5.0V, 25°C unless otherwise stated. These parameters are for design guidance
only and are not tested.
Note 1: These specifications are for programming the on-chip program memory through the use of table write
instructions.
2: Refer to Section 7.8 “Using the Data EEPROM” for a more detailed discussion on data EEPROM
endurance.
3: Required only if Single-Supply Programming is disabled.
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*
* These parameters are characterized but not tested.
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/4 LSb Low Range (CVRR = 1)
— — 1/2 LSb High Range (CVRR = 0)
D312 VRUR Unit Resistor Value (R)* — 2k — Ω
310 TSET Settling Time(1)* — — 10 μs
* These parameters are characterized but not tested.
Note 1: Settling time measured while CVRR = 1 and CVR3:CVR0 transitions from ‘0000’ to ‘1111’.
VDD
(HLVDIF can be
VLVD cleared in software)
(HLVDIF set by hardware)
HLVDIF
Param
Sym Characteristic Min Typ† Max Units Conditions
No.
D420 HLVD Voltage on HLVDL<3:0> = 0000 2.12 2.17 2.22 V
VDD Transition HLVDL<3:0> = 0001 2.18 2.23 2.28 V
High-to-Low
HLVDL<3:0> = 0010 2.31 2.36 2.42 V
HLVDL<3:0> = 0011 2.38 2.44 2.49 V
HLVDL<3:0> = 0100 2.54 2.60 2.66 V
HLVDL<3:0> = 0101 2.72 2.79 2.85 V
HLVDL<3:0> = 0110 2.82 2.89 2.95 V
HLVDL<3:0> = 0111 3.05 3.12 3.19 V
HLVDL<3:0> = 1000 3.31 3.39 3.47 V
HLVDL<3:0> = 1001 3.46 3.55 3.63 V
HLVDL<3:0> = 1010 3.63 3.71 3.80 V
HLVDL<3:0> = 1011 3.81 3.90 3.99 V
HLVDL<3:0> = 1100 4.01 4.11 4.20 V
HLVDL<3:0> = 1101 4.23 4.33 4.43 V
HLVDL<3:0> = 1110 4.48 4.59 4.69 V
HLVDL<3:0> = 1111 1.14 1.20 1.26 V
† Production tested at TAMB = 25°C. Specifications over temperature limits ensured by characterization.
VDD/2
RL Pin CL
VSS
CL
Pin
RL = 464Ω
VSS CL = 50 pF for all pins except OSC2/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(1)
PIC18LF268X/468X -2 +/-1 2 % +25°C VDD = 2.7-3.3V
-5 — 5 % -10°C to +85°C VDD = 2.7-3.3V
-10 +/-1 10 % -40°C to +85°C VDD = 2.7-3.3V
INTRC Accuracy @ Freq = 31 kHz(2)
PIC18LF268X/468X 26.562 — 35.938 kHz -40°C to +85°C VDD = 2.7-3.3V
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.
2: INTRC frequency after calibration.
OSC1
10 11
CLKO
13 12
14 19 18
16
I/O pin
(Input)
17 15
20, 21
Note: Refer to Figure 27-4 for load conditions.
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
OSC
Time-out
Internal
Reset
Watchdog
Timer
Reset
31
34 34
I/O pins
VDD BVDD
35 VBGAP = 1.2V
VIRVST
Enable Internal
Reference Voltage
Internal Reference
Voltage Stable 36
TABLE 27-10: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET REQUIREMENTS
Param.
Sym Characteristic Min Typ Max Units Conditions
No.
30 TMCL MCLR Pulse Width (low) 2 — — μs
31 TWDT Watchdog Timer Time-out Period (no 3.4 4.00 4.6 ms
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 ms
34 TIOZ I/O High-Impedance from MCLR Low — 2 — μs
or Watchdog Timer Reset
35 TBOR Brown-out Reset Pulse Width 200 — — μs VDD ≤ BVDD (see D005)
36 TIRVST Time for Internal Reference Voltage to — 20 50 μs
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 27-4 for load conditions.
70
SCK
(CKP = 0)
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76
81
SCK
(CKP = 0)
71 72
79
73
SCK
(CKP = 1)
80
78
75, 76
74
SS
70
SCK
(CKP = 0) 83
71 72
78 79
SCK
(CKP = 1)
80 79 78
75, 76 77
TABLE 27-16: EXAMPLE SPI MODE REQUIREMENTS (SLAVE MODE TIMING, CKE = 0)
Param
Symbol Characteristic Min Max Units Conditions
No.
70
SCK
83
(CKP = 0)
71 72
SCK
(CKP = 1)
80
75, 76 77
SDI
MSb In bit 6 - - - -1 LSb In
74
Note: Refer to Figure 27-4 for load conditions.
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
91 92
SDA
In
110
109 109
SDA
Out
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
SDA
Out
RC6/TX/CK
pin 121 121
RC7/RX/DT
pin
120
122
Note: Refer to Figure 27-4 for load conditions.
RC6/TX/CK
pin 125
RC7/RX/DT
pin
126
BSF ADCON0, GO
(Note 2)
131
Q4
130
A/D CLK(1) 132
ADIF TCY
GO DONE
SAMPLING STOPPED
SAMPLE
Note 1: If the A/D clock source is selected as RC, a time of TCY is added before the A/D clock starts.
This allows the SLEEP instruction to be executed.
2: This is a minimal RC delay (typically 100 ns), which also disconnects the holding capacitor from the analog input.
XXXXXXXXXXXXXXXXX PIC18F2685-I/SP e3
XXXXXXXXXXXXXXXXX 0710017
YYWWNNN
XXXXXXXXXXXXXXXXXXXX PIC18F2685-E/SO e3
XXXXXXXXXXXXXXXXXXXX 0710017
XXXXXXXXXXXXXXXXXXXX
YYWWNNN
XXXXXXXXXXXXXXXXXX PIC18F4685-I/P e3
XXXXXXXXXXXXXXXXXX 0710017
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 PIC18F4685
XXXXXXXXXX -I/PT e3
XXXXXXXXXX 0710017
YYWWNNN
XXXXXXXXXX PIC18F4685
XXXXXXXXXX -I/ML e3
XXXXXXXXXX 0710017
YYWWNNN
28-Lead Skinny Plastic Dual In-Line (SP) – 300 mil Body [SPDIP]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
NOTE 1
E1
1 2 3
A A2
L c
A1 b1
b e eB
Units INCHES
Dimension Limits MIN NOM MAX
Number of Pins N 28
Pitch e .100 BSC
Top to Seating Plane A – – .200
Molded Package Thickness A2 .120 .135 .150
Base to Seating Plane A1 .015 – –
Shoulder to Shoulder Width E .290 .310 .335
Molded Package Width E1 .240 .285 .295
Overall Length D 1.345 1.365 1.400
Tip to Seating Plane L .110 .130 .150
Lead Thickness c .008 .010 .015
Upper Lead Width b1 .040 .050 .070
Lower Lead Width b .014 .018 .022
Overall Row Spacing § eB – – .430
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. § Significant Characteristic.
3. Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010" per side.
4. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
D
N
E
E1
NOTE 1
1 2 3
e
b
h
α
h
φ c
A A2
L
A1 L1 β
Units MILLMETERS
Dimension Limits MIN NOM MAX
Number of Pins N 28
Pitch e 1.27 BSC
Overall Height A – – 2.65
Molded Package Thickness A2 2.05 – –
Standoff § A1 0.10 – 0.30
Overall Width E 10.30 BSC
Molded Package Width E1 7.50 BSC
Overall Length D 17.90 BSC
Chamfer (optional) h 0.25 – 0.75
Foot Length L 0.40 – 1.27
Footprint L1 1.40 REF
Foot Angle Top φ 0° – 8°
Lead Thickness c 0.18 – 0.33
Lead Width b 0.31 – 0.51
Mold Draft Angle Top α 5° – 15°
Mold Draft Angle Bottom β 5° – 15°
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. § Significant Characteristic.
3. Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed 0.15 mm per side.
4. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
Microchip Technology Drawing C04-052B
NOTE 1
E1
1 2 3
A A2
L c
b1
A1
b e eB
Units INCHES
Dimension Limits MIN NOM MAX
Number of Pins N 40
Pitch e .100 BSC
Top to Seating Plane A – – .250
Molded Package Thickness A2 .125 – .195
Base to Seating Plane A1 .015 – –
Shoulder to Shoulder Width E .590 – .625
Molded Package Width E1 .485 – .580
Overall Length D 1.980 – 2.095
Tip to Seating Plane L .115 – .200
Lead Thickness c .008 – .015
Upper Lead Width b1 .030 – .070
Lower Lead Width b .014 – .023
Overall Row Spacing § eB – – .700
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. § Significant Characteristic.
3. Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010" per side.
4. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
Microchip Technology Drawing C04-016B
D
D1
E
e
E1
N
b
NOTE 1 1 2 3
NOTE 2
A α
c φ
β A1 A2
L L1
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Number of Leads N 44
Lead Pitch e 0.80 BSC
Overall Height A – – 1.20
Molded Package Thickness A2 0.95 1.00 1.05
Standoff A1 0.05 – 0.15
Foot Length L 0.45 0.60 0.75
Footprint L1 1.00 REF
Foot Angle φ 0° 3.5° 7°
Overall Width E 12.00 BSC
Overall Length D 12.00 BSC
Molded Package Width E1 10.00 BSC
Molded Package Length D1 10.00 BSC
Lead Thickness c 0.09 – 0.20
Lead Width b 0.30 0.37 0.45
Mold Draft Angle Top α 11° 12° 13°
Mold Draft Angle Bottom β 11° 12° 13°
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Chamfers at corners are optional; size may vary.
3. Dimensions D1 and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed 0.25 mm per side.
4. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
Microchip Technology Drawing C04-076B
44-Lead Plastic Quad Flat, No Lead Package (ML) – 8x8 mm Body [QFN]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
D D2
EXPOSED
PAD
E2
b
2 2
1 1
N N K
NOTE 1 L
A3 A1
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Number of Pins N 44
Pitch e 0.65 BSC
Overall Height A 0.80 0.90 1.00
Standoff A1 0.00 0.02 0.05
Contact Thickness A3 0.20 REF
Overall Width E 8.00 BSC
Exposed Pad Width E2 6.30 6.45 6.80
Overall Length D 8.00 BSC
Exposed Pad Length D2 6.30 6.45 6.80
Contact Width b 0.25 0.30 0.38
Contact Length L 0.30 0.40 0.50
Contact-to-Exposed Pad K 0.20 – –
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Package is saw singulated.
3. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
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?
12/08/06