Professional Documents
Culture Documents
Data Sheet
64/80-Pin, High-Performance
Microcontrollers with LCD Driver
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.
10-Bit
Timers
64-Pin TQFP
RE7/CCP2(1)/SEG31
RE3/COM0
RE4/COM1
RE5/COM2
RE6/COM3
RD0/SEG0
RD1/SEG1
RD2/SEG2
RD3/SEG3
RD4/SEG4
RD5/SEG5
RD6/SEG6
RD7/SEG7
LCDBIAS3
VDD
VSS
64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49
RE1/LCDBIAS2 1 48 RB0/INT0/SEG30
RE0/LCDBIAS1 2 47 RB1/INT1/SEG8
RG0/LCDBIAS0 3 46 RB2/INT2/SEG9
RG1/TX2/CK2 4 45 RB3/INT3/SEG10
RG2/RX2/DT2/VLCAP1 5 44 RB4/KBI0/SEG11
RG3/VLCAP2 6 43 RB5/KBI1/SEG29
MCLR 7 42 RB6/KBI2/PGC
PIC18F63J90
RG4/SEG26 8 41 VSS
VSS 9
PIC18F64J90 40 OSC2/CLKO/RA6
VDDCORE/VCAP 10 PIC18F65J90 39 OSC1/CLKI/RA7
RF7/AN5/SS/SEG25 11 38 VDD
RF6/AN11/SEG24 12 37 RB7/KBI3/PGD
RF5/AN10/CVREF/SEG23 13 36 RC5/SDO/SEG12
RF4/AN9/SEG22 14 35 RC4/SDI/SDA/SEG16
RF3/AN8/SEG21 15 34 RC3/SCK/SCL/SEG17
RF2/AN7/C1OUT/SEG20 16 33 RC2/CCP1/SEG13
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
RF1/AN6/C2OUT/SEG19
ENVREG
RC0/T1OSO/T13CKI
RA3/AN3/VREF+
RA2/AN2/VREF-
RA5/AN4/SEG15
RC1/T1OSI/CCP2(1)/SEG32
RC6/TX1/CK1/SEG27
RC7/RX1/DT1/SEG28
RA1/AN1/SEG18
RA0/AN0
RA4/T0CKI/SEG14
AVSS
VSS
AVDD
VDD
Note 1: The CCP2 pin placement depends on the CCP2MX bit setting.
80-Pin TQFP
RE7/CCP2(1)/SEG31
RH1/SEG46
RH0/SEG47
RJ1/SEG33
RE3/COM0
RE4/COM1
RE5/COM2
RE6/COM3
RD0/SEG0
RD1/SEG1
RD2/SEG2
RD3/SEG3
RD4/SEG4
RD5/SEG5
RD6/SEG6
RD7/SEG7
LCDBIAS3
VDD
RJ0
VSS
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61
RH2/SEG45 1 60 RJ2/SEG34
RH3/SEG44 2 59 RJ3/SEG35
RE1/LCDBIAS2 3 58 RB0/INT0/SEG30
RE0/LCDBIAS1 4 57 RB1/INT1/SEG8
RG0/LCDBIAS0 5 56 RB2/INT2/SEG9
RG1/TX2/CK2 6 55 RB3/INT3/SEG10
RG2/RX2/DT2/VLCAP1 7 54 RB4/KBI0/SEG11
RG3/VLCAP2 8 53 RB5/KBI1/SEG29
MCLR 9 PIC18F83J90 52 RB6/KBI2/PGC
RG4/SEG26 10 51 VSS
PIC18F84J90
VSS 11 50 OSC2/CLKO/RA6
VDDCORE/VCAP 12
PIC18F85J90 49 OSC1/CLKI/RA7
RF7/AN5/SS/SEG25 13 48 VDD
RF6/AN11/SEG24 14 47 RB7/KBI3/PGD
RF5/AN10/CVREF/SEG23 15 46 RC5/SDO/SEG12
RF4/AN9/SEG22 16 45 RC4/SDI/SDA/SEG16
RF3/AN8/SEG21 17 44 RC3/SCK/SCL/SEG17
RF2/AN7/C1OUT/SEG20 18 43 RC2/CCP1/SEG13
RH7/SEG43 19 42 RJ7/SEG36
RH6/SEG42 20 41 RJ6/SEG37
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
RA3/AN3/VREF+
AVSS
VSS
RH5/SEG41
RH4/SEG40
RA2/AN2/VREF-
RA1/AN1/SEG18
RF1/AN6/C2OUT/SEG19
ENVREG
AVDD
RA0/AN0
RA5/AN4/SEG15
VDD
RC6/TX1/CK1/SEG27
RA4/T0CKI/SEG14
RC1/T1OSI/CCP2(1)I/SEG32
RC7/RX1/DT1/SEG28
RJ4/SEG39
RJ5/SEG38
RC0/T1OSO/T13CKI
Note 1: The CCP2 pin placement depends on the CCP2MX bit setting.
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.
1.3 Other Special Features 1. Flash program memory (three sizes, ranging
from 8 Kbytes for PIC18FX3J90 devices to
• Communications: The PIC18F85J90 family 32 Kbytes for PIC18FX5J90 devices).
incorporates a range of serial communication 2. Data RAM (1024 bytes for PIC18FX3J90 and
peripherals, including an Addressable USART, a PIC18FX4J90 devices, 2048 bytes for
separate Enhanced USART that supports LIN PIC18FX5J90 devices).
specification 1.2, and one Master SSP module
3. I/O ports (7 bidirectional ports on 64-pin devices,
capable of both SPI and I2C™ (Master and Slave)
9 bidirectional ports on 80-pin devices).
modes of operation.
4. LCD Pixels: 132 pixels (33 SEGs x 4 COMs) can
• CCP Modules: All devices in the family incorporate
be driven by 64-pin devices; 192 pixels
two Capture/Compare/PWM (CCP) modules. Up to
(48 SEGs x 4 COMs) can be driven by 80-pin
four different time bases may be used to perform
devices.
several different operations at once.
• 10-Bit A/D Converter: This module incorporates All other features for devices in this family are identical.
programmable acquisition time, allowing for a These are summarized in Table 1-1 and Table 1-2.
channel to be selected and a conversion to be The pinouts for all devices are listed in Table 1-3 and
initiated without waiting for a sampling period and Table 1-4.
thus, reducing code overhead.
• Extended Watchdog Timer (WDT): This
enhanced version incorporates a 16-bit prescaler,
allowing an extended time-out range that is stable
across operating voltage and temperature. See
Section 25.0 “Electrical Characteristics” for
time-out periods.
TABLE 1-2: DEVICE FEATURES FOR THE PIC18F85J90 FAMILY (80-PIN DEVICES)
Features PIC18F83J90 PIC18F84J90 PIC18F85J90
Operating Frequency DC – 40 MHz
Program Memory (Bytes) 8K 16K 32K
Program Memory (Instructions) 4096 8192 16384
Data Memory (Bytes) 1024 1024 2048
Interrupt Sources 27
I/O Ports Ports A, B, C, D, E, F, G, H, J
LCD Driver (available pixels to drive) 192 (48 SEGs x 4 COMs)
Timers 4
Capture/Compare/PWM Modules 2
Serial Communications MSSP, Addressable USART, Enhanced USART
10-bit Analog-to-Digital Module 12 Input Channels
Resets (and Delays) POR, BOR, RESET Instruction, Stack Full, Stack Underflow, MCLR, WDT
(PWRT, OST)
Instruction Set 75 Instructions, 83 with Extended Instruction Set enabled
Packages 80-pin TQFP
Data Bus<8>
Table Pointer<21>
PORTA
Data Latch
inc/dec logic 8 8 RA0:RA7(1,2)
Data Memory
(2.0, 3.9
21 PCLATU PCLATH Kbytes)
20 Address Latch
PCU PCH PCL
Program Counter 12 PORTB
Data Address<12>
RB0:RB7(1)
31 Level Stack
Address Latch 4 12 4
BSR FSR0 Access
Program Memory STKPTR Bank
(96 Kbytes) FSR1
FSR2 12
Data Latch PORTC
inc/dec RC0:RC7(1)
8 logic
Table Latch
8
Instruction State Machine
Decode and Control Signals
Control PORTE
PRODH PRODL
RE0:RE1,
8 x 8 Multiply RE3:RE7(1)
Timing 3
Power-up 8
OSC2/CLKO Generation
OSC1/CLKI Timer
BITOP W
INTRC Oscillator 8 8
Oscillator 8
Start-up Timer
8 MHz PORTF
Oscillator Power-on 8 8
Reset RF1:RF7(1)
Precision ALU<8>
Band Gap Watchdog
Reference Timer
8
ENVREG BOR and
Voltage LVD(3)
Regulator
PORTG
RG0:RG4(1)
VDDCORE/VCAP VDD, VSS MCLR
ADC
Timer0 Timer1 Timer2 Timer3 10-bit Comparators
LCD
CCP1 CCP2 AUSART EUSART MSSP
Driver
Data Bus<8>
Table Pointer<21>
PORTA
Data Latch
8 8
inc/dec logic
Data Memory RA0:RA7(1,2)
(2.0, 3.9
21 PCLATU PCLATH Kbytes)
20 Address Latch
PCU PCH PCL PORTB
Program Counter 12 RB0:RB7(1)
Data Address<12>
31 Level Stack
Address Latch 4 12 4
BSR Access PORTC
Program Memory STKPTR FSR0
Bank
(96 Kbytes) FSR1 RC0:RC7(1)
Data Latch FSR2 12
inc/dec
8 logic PORTD
Table Latch
RD0:RD7(1)
PORTJ
ADC
Timer0 Timer1 Timer2 Timer3 Comparators
10-bit
LCD
CCP1 CCP2 AUSART EUSART MSSP
Driver
PIC18F85J90 Family
Primary Oscillator HS, EC
OSC2
MUX
T1OSC
T1OSO
T1OSCEN
Enable
T1OSI Oscillator Internal Oscillator
OSCCON<6:4>
OSCCON<6:4> 8 MHz CPU
111
4 MHz
Internal 110
Oscillator 2 MHz IDLEN
Block 101
Postscaler
1 MHz Clock
Control
MUX
100
8 MHz 8 MHz 500 kHz
011
Source (INTOSC) 250 kHz
010 FOSC2:FOSC0 OSCCON<1:0>
125 kHz
001
1 31 kHz Clock Source Option
000 for other modules
0
INTRC OSCTUNE<7>
Source 31 kHz (INTRC) WDT, PWRT, FSCM
and Two-Speed Start-up
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = 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 for ECPLL and HSPLL oscillator configurations; otherwise, this bit is unavailable and reads
as ‘0’.
2.3 Clock Sources and PIC18F85J90 family devices offer the Timer1 oscillator
Oscillator Switching as a secondary oscillator source. This oscillator, in all
power-managed modes, is often the time base for
Essentially, PIC18F85J90 family devices have three functions such as a Real-Time Clock. The Timer1 oscil-
independent clock sources: lator is discussed in greater detail in Section 11.3
• Primary oscillators “Timer1 Oscillator”
• Secondary oscillators In addition to being a primary clock source in some cir-
• Internal oscillator cumstances, the internal oscillator is available as a
The primary oscillators can be thought of as the main power-managed mode clock source. The INTRC
device oscillators. These are any external oscillators source is also used as the clock source for several
connected to the OSC1 and OSC2 pins, and include special features, such as the WDT and Fail-Safe Clock
the External Crystal and Resonator modes and the Monitor. The internal oscillator block is discussed in
External Clock modes. In some circumstances, the more detail in Section 2.5 “Internal Oscillator
internal oscillator block may be considered a primary Block”.
oscillator. The particular mode is defined by the FOSC The PIC18F85J90 family includes features that allow
Configuration bits. The details of these modes are the device clock source to be switched from the main
covered in Section 2.4 “External Oscillator Modes”. oscillator, chosen by device configuration, to one of the
The secondary oscillators are external clock sources alternate clock sources. When an alternate clock
that are not connected to the OSC1 or OSC2 pins. source is enabled, various power-managed operating
These sources may continue to operate even after the modes are available.
controller is placed in a power-managed mode.
OSC2 Sleep
Note 1: See Table 2-1 and Table 2-2 for initial values of
C1 and C2.
2: A series resistor (RS) may be required for AT
strip cut crystals.
3: RF varies with the oscillator mode chosen.
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 PC + 2
PC PC + 4
Counter
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
INTRC 1 2 3 n-1 n
Clock Transition
OSC1
CPU
Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
INTRC
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 PC PC + 2 PC + 4 PC + 6
Counter
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
Q1 Q2 Q3 Q4 Q1
OSC1
CPU Clock
Peripheral
Clock
Program
PC PC + 2
Counter
FIGURE 3-8: TRANSITION TIMING FOR WAKE FROM IDLE TO RUN MODE
Q1 Q2 Q3 Q4
OSC1
TCSD
CPU Clock
Peripheral
Clock
Program PC
Counter
Wake Event
External Reset
MCLR ( )_IDLE
Sleep
WDT
Time-out
PWRT
Note 1: The ENVREG pin must be tied high to enable Brown-out Reset. The Brown-out Reset is provided by the on-chip
voltage regulator when there is insufficient source voltage to maintain regulation.
Legend:
R = Readable bit W = 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: If the on-chip voltage regulator is disabled, BOR remains ‘0’ at all times. See Section 4.4.1 “Detecting
BOR” for more information.
3: 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).
FIGURE 4-3: TIME-OUT SEQUENCE ON POWER-UP (MCLR TIED TO VDD, VDD RISE < TPWRT)
VDD
MCLR
INTERNAL POR
TPWRT
PWRT 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
INTERNAL RESET
VDD
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
INTERNAL RESET
FIGURE 4-6: SLOW RISE TIME (MCLR TIED TO VDD, VDD RISE > TPWRT)
3.3V
VDD 0V 1V
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
INTERNAL RESET
TABLE 4-1: STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION FOR
RCON REGISTER
Program RCON Register STKPTR Register
Condition
Counter(1) RI TO PD POR BOR STKFUL STKUNF
Power-on Reset 0000h 1 1 1 0 0 0 0
RESET Instruction 0000h 0 u u u u u u
Brown-out Reset 0000h 1 1 1 u 0 u u
MCLR during power-managed 0000h u 1 u u u u u
Run modes
MCLR during power-managed 0000h u 1 0 u u u u
Idle modes and Sleep mode
WDT time-out during full power 0000h u 0 u u u u u
or power-managed Run modes
MCLR during full power 0000h u u u u u u u
execution
Stack Full Reset (STVREN = 1) 0000h u u u u u 1 u
Stack Underflow Reset 0000h u u u u u u 1
(STVREN = 1)
Stack Underflow Error (not an 0000h u u u u u u 1
actual Reset, STVREN = 0)
WDT time-out during PC + 2 u 0 0 u u u u
power-managed Idle or Sleep
modes
Interrupt exit from PC + 2 u u 0 u u u u
power-managed modes
Legend: u = unchanged
Note 1: When the wake-up is due to an interrupt and the GIEH or GIEL bit is set, the PC is loaded with the
interrupt vector (0008h or 0018h).
PC<20:0>
CALL, CALLW, RCALL, 21
RETURN, RETFIE, RETLW,
ADDULNK, SUBULNK
Stack Level 1
••
•
Stack Level 31
Config. Words
001FFFh
Config. Words
003FFFh
Config. Words
007FFFh
1FFFFFh
Note: Sizes of memory areas are not to scale. Sizes of program memory areas are enhanced to show detail.
Read ‘0’
1FFFFFh
00011
Top-of-Stack 001A34h 00010
000D58h 00001
00000
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
Q1
Q2 Internal
Phase
Q3 Clock
Q4
PC PC PC + 2 PC + 4
OSC2/CLKO
(RC mode)
Execute INST (PC – 2)
Fetch INST (PC) Execute INST (PC)
Fetch INST (PC + 2) Execute INST (PC + 2)
Fetch INST (PC + 4)
All instructions are single cycle, except for any program branches. These take two cycles since the fetch instruction
is “flushed” from the pipeline while the new instruction is being fetched and then executed.
5.2.4 TWO-WORD INSTRUCTIONS 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 Access Bank is used.
Access RAM 000h
= 0000 The first 96 bytes are general
05Fh
Bank 0 060h purpose RAM (from Bank 0).
GPR
FFh 0FFh The second 160 bytes are
00h 100h Special Function Registers
= 0001
Bank 1 GPR (from Bank 15).
FFh 1FFh
00h 200h When a = 1:
= 0010
Bank 2 GPR The BSR specifies the bank
FFh 2FFh used by the instruction.
00h 300h
= 0011
Bank 3 GPR
FFh 3FFh
00h 400h
= 0100
Bank 4
Access Bank
00h
Access RAM Low
5Fh
Unused
Access RAM High 60h
Read as ‘0’
to (SFRs) FFh
= 1110
Bank 14
FFh EFFh
= 1111 00h Unused F00h
Bank 15 F5Fh
SFR F60h
FFh FFFh
When a = 0:
BSR<3:0> Data Memory Map The BSR is ignored and the
00h Access Bank is used.
Access RAM 000h
= 0000 The first 96 bytes are general
05Fh
Bank 0 060h purpose RAM (from Bank 0).
GPR
FFh 0FFh The second 160 bytes are
00h 100h Special Function Registers
= 0001
Bank 1 GPR (from Bank 15).
FFh 1FFh
00h 200h When a = 1:
= 0010
Bank 2 GPR The BSR specifies the bank
FFh 2FFh used by the instruction.
00h 300h
= 0011
Bank 3 GPR
FFh 3FFh
00h 400h
= 0100
Bank 4 GPR
FFh 4FFh
00h 500h
= 0101
Bank 5 GPR
FFh 5FFh
00h 600h
= 0110
Bank 6 GPR
FFh 6FFh
00h 700h Access Bank
= 0111
Bank 7 GPR
FFh 00h
7FFh Access RAM Low
00h 800h 5Fh
Access RAM High 60h
(SFRs) FFh
= 1000
Bank 8
Unused
to Read as ‘0’
= 1110
Bank 14
FFh EFFh
= 1111 00h Unused F00h
Bank 15 F5Fh
SFR F60h
FFh FFFh
Bank 3
through
Bank 13
FFh
E00h
00h
Bank 14
F00h FFh
00h
Bank 15
FFFh FFh
Note 1: The Access RAM bit of the instruction can be used to force an override of the selected bank (BSR<3:0>)
to the registers of the Access Bank.
2: The MOVFF instruction embeds the entire 12-bit address in the instruction.
5.3.2 ACCESS BANK however, the instruction is forced to use the Access
Bank address map; the current value of the BSR is
While the use of the BSR with an embedded 8-bit
ignored entirely.
address allows users to address the entire range of data
memory, it also means that the user must always ensure Using this “forced” addressing allows the instruction to
that the correct bank is selected. Otherwise, data may operate on a data address in a single cycle without
be read from, or written to, the wrong location. This can updating the BSR first. For 8-bit addresses of 60h and
be disastrous if a GPR is the intended target of an oper- above, this means that users can evaluate and operate
ation, but an SFR is written to instead. Verifying and/or on SFRs more efficiently. The Access RAM below 60h
changing the BSR for each read or write to data memory is a good place for data values that the user might need
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 96 bytes of when the extended instruction set is enabled (XINST
memory (00h-5Fh) in Bank 0 and the last 160 bytes of Configuration bit = 1). This is discussed in more detail
memory (60h-FFh) in Bank 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-6). 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.
TABLE 5-2: SPECIAL FUNCTION REGISTER MAP FOR PIC18F85J90 FAMILY DEVICES
Address Name Address Name Address Name Address Name Address Name
(1) (3)
FFFh TOSU FDFh INDF2 FBFh LCDDATA4 F9Fh IPR1 F7Fh SPBRGH1
FFEh TOSH FDEh POSTINC2(1) FBEh LCDDATA3 F9Eh PIR1 F7Eh BAUDCON1
FFDh TOSL FDDh POSTDEC2(1) FBDh LCDDATA2 F9Dh PIE1 F7Dh LCDDATA23(3)
(1) (2)
FFCh STKPTR FDCh PREINC2 FBCh LCDDATA1 F9Ch — F7Ch LCDDATA22(3)
FFBh PCLATU FDBh PLUSW2(1) FBBh LCDDATA0 F9Bh OSCTUNE F7Bh LCDDATA21
FFAh PCLATH FDAh FSR2H FBAh LCDSE5(3) F9Ah TRISJ(3) F7Ah LCDDATA20
FF9h PCL FD9h FSR2L FB9h LCDSE4(3) F99h TRISH(3) F79h LCDDATA19
FF8h TBLPTRU FD8h STATUS FB8h LCDSE3 F98h TRISG F78h LCDDATA18
FF7h TBLPTRH FD7h TMR0H FB7h LCDSE2 F97h TRISF F77h LCDDATA17(3)
FF6h TBLPTRL FD6h TMR0L FB6h LCDSE1 F96h TRISE F76h LCDDATA16(3)
FF5h TABLAT FD5h T0CON FB5h CVRCON F95h TRISD F75h LCDDATA15
(2)
FF4h PRODH FD4h — FB4h CMCON F94h TRISC F74h LCDDATA14
FF3h PRODL FD3h OSCCON FB3h TMR3H F93h TRISB F73h LCDDATA13
FF2h INTCON FD2h LCDREG FB2h TMR3L F92h TRISA F72h LCDDATA12
FF1h INTCON2 FD1h WDTCON FB1h T3CON F91h LATJ(3) F71h LCDDATA11(3)
FF0h INTCON3 FD0h RCON FB0h —(2) F90h LATH(3) F70h LCDDATA10(3)
FEFh INDF0(1) FCFh TMR1H FAFh SPBRG1 F8Fh LATG F6Fh LCDDATA9
FEEh POSTINC0(1) FCEh TMR1L FAEh RCREG1 F8Eh LATF F6Eh LCDDATA8
FEDh POSTDEC0(1) FCDh T1CON FADh TXREG1 F8Dh LATE F6Dh LCDDATA7
FECh PREINC0(1) FCCh TMR2 FACh TXSTA1 F8Ch LATD F6Ch LCDDATA6
FEBh PLUSW0(1) FCBh PR2 FABh RCSTA1 F8Bh LATC F6Bh LCDDATA5(3)
FEAh FSR0H FCAh T2CON FAAh LCDPS F8Ah LATB F6Ah CCPR1H
FE9h FSR0L FC9h SSPBUF FA9h LCDSE0 F89h LATA F69h CCPR1L
(3)
FE8h WREG FC8h SSPADD FA8h LCDCON F88h PORTJ F68h CCP1CON
FE7h INDF1(1) FC7h SSPSTAT FA7h EECON2 F87h PORTH(3) F67h CCPR2H
FE6h POSTINC1(1) FC6h SSPCON1 FA6h EECON1 F86h PORTG F66h CCPR2L
FE5h POSTDEC1(1) FC5h SSPCON2 FA5h IPR3 F85h PORTF F65h CCP2CON
FE4h PREINC1(1) FC4h ADRESH FA4h PIR3 F84h PORTE F64h SPBRG2
FE3h PLUSW1(1) FC3h ADRESL FA3h PIE3 F83h PORTD F63h RCREG2
FE2h FSR1H FC2h ADCON0 FA2h IPR2 F82h PORTC F62h TXREG2
FE1h FSR1L FC1h ADCON1 FA1h PIR2 F81h PORTB F61h TXSTA2
FE0h BSR FC0h ADCON2 FA0h PIE2 F80h PORTA F60h RCSTA2
PORTJ(2) RJ7 RJ6 RJ5 RJ4 RJ3 RJ2 RJ1 RJ0 xxxx xxxx 54, 130
PORTH(2) RH7 RH6 RH5 RH4 RH3 RH2 RH1 RH0 xxxx xxxx 54, 128
PORTG RDPU REPU RJPU(2) RG4 RG3 RG2 RG1 RG0 000x xxxx 54, 126
PORTF RF7 RF6 RF5 RF4 RF3 RF2 RF1 — xxxx xxx- 54, 124
PORTE RE7 RE6 RE5 RE4 RE3 — RE1 RE0 xxxx x-xx 55, 121
PORTD RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 xxxx xxxx 55, 119
PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx 55, 117
PORTB RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 xxxx xxxx 55, 114
PORTA RA7(5) RA6(5) RA5 RA4 RA3 RA2 RA1 RA0 xx0x 0000 55, 111
SPBRGH1 EUSART Baud Rate Generator High Byte 0000 0000 55, 233
BAUDCON1 ABDOVF RCMT — SCKP BRG16 — WUE ABDEN 01-0 0-00 55, 232
LCDDATA23(2) S47C3 S46C3 S45C3 S44C3 S43C3 S42C3 S41C3 S40C3 xxxx xxxx 55, 161
LCDDATA22 S39C3(2) S38C3(2) S37C3(2) S36C3(2) S35C3(2) S34C3(2) S33C3(2) S32C3 xxxx xxxx 55, 161
LCDDATA21 S31C3 S30C3 S29C3 S28C3 S27C3 S26C3 S25C3 S24C3 xxxx xxxx 55, 161
LCDDATA20 S23C3 S22C3 S21C3 S20C3 S19C3 S18C3 S17C3 S16C3 xxxx xxxx 55, 161
LCDDATA19 S15C3 S14C3 S13C3 S12C3 S11C3 S10C3 S09C3 S08C3 xxxx xxxx 55, 161
LCDDATA18 S07C3 S06C3 S05C3 S04C3 S03C3 S02C3 S01C3 S00C3 xxxx xxxx 55, 161
LCDDATA17(2) S47C2 S46C2 S45C2 S44C2 S43C2 S42C2 S41C2 S40C2 xxxx xxxx 55, 161
LCDDATA16 S39C2(2) S38C2(2) S37C2(2) S36C2(2) S35C2(2) S34C2(2) S33C2(2) S32C2 xxxx xxxx 55, 161
LCDDATA15 S31C2 S30C2 S29C2 S28C2 S27C2 S26C2 S25C2 S24C2 xxxx xxxx 55, 161
LCDDATA14 S23C2 S22C2 S21C2 S20C2 S19C2 S18C2 S17C2 S16C2 xxxx xxxx 55, 161
LCDDATA13 S15C2 S14C2 S13C2 S12C2 S11C2 S10C2 S09C2 S08C2 xxxx xxxx 55, 161
LCDDATA12 S07C2 S06C2 S05C2 S04C2 S03C2 S02C2 S01C2 S00C2 xxxx xxxx 55, 161
LCDDATA11(2) S47C1 S46C1 S45C1 S44C1 S43C1 S42C1 S41C1 S40C1 xxxx xxxx 55, 161
LCDDATA10 S39C1(2) S38C1(2) S37C1(2) S36C1(2) S35C1(2) S34C1(2) S33C1(2) S32C1 xxxx xxxx 55, 161
LCDDATA9 S31C1 S30C1 S29C1 S28C1 S27C1 S26C1 S25C1 S24C1 xxxx xxxx 55, 161
LCDDATA8 S23C1 S22C1 S21C1 S20C1 S19C1 S18C1 S17C1 S16C1 xxxx xxxx 55, 161
LCDDATA7 S15C1 S14C1 S13C1 S12C1 S11C1 S10C1 S09C1 S08C1 xxxx xxxx 55, 161
LCDDATA6 S07C1 S06C1 S05C1 S04C1 S03C1 S02C1 S01C1 S00C1 xxxx xxxx 55, 161
LCDDATA5(2) S47C0 S46C0 S45C0 S44C0 S43C0 S42C0 S41C0 S40C0 xxxx xxxx 55, 161
CCPR1H Capture/Compare/PWM Register 1 High Byte xxxx xxxx 55, 148
CCPR1L Capture/Compare/PWM Register 1 Low Byte xxxx xxxx 55, 148
CCP1CON — — DC1B1 DC1B0 CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 55, 147
CCPR2H Capture/Compare/PWM Register 2 High Byte xxxx xxxx 55, 148
CCPR2L Capture/Compare/PWM Register 2 Low Byte xxxx xxxx 56, 148
CCP2CON — — DC2B1 DC2B0 CCP2M3 CCP2M2 CCP2M1 CCP2M0 --00 0000 56, 147
SPBRG2 AUSART Baud Rate Generator Register 0000 0000 56, 252
RCREG2 AUSART Receive Register 0000 0000 56, 257
TXREG2 AUSART Transmit Register 0000 0000 56, 255
TXSTA2 CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 56, 250
RCSTA2 SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 56, 251
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition, r = reserved, do not modify
Note 1: Bit 21 of the PC is only available in Test mode and Serial Programming modes.
2: These registers and/or bits are available only on 80-pin devices; otherwise they are unimplemented and read as ‘0’. Reset states shown are
for 80-pin devices.
3: Alternate names and definitions for these bits when the MSSP module is operating in I2C™ Slave mode. See Section 16.4.3.2 “Address
Masking” for details.
4: The PLLEN bit is only available in specific oscillator configurations; otherwise it is disabled and reads as ‘0’. See Section 2.4.3 “PLL
Frequency Multiplier” for details.
5: RA6/RA7 and their associated latch and direction bits are configured as port pins only when the internal oscillator is selected as the default
clock source (FOSC2 Configuration bit = 0); otherwise, they are disabled and these bits read as ‘0’.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: For borrow, the polarity is reversed. A subtraction is executed by adding the 2’s complement of the second
operand. For rotate (RRF, RLF) instructions, this bit is loaded with either bit 4 or bit 3 of the source register.
2: For borrow, the polarity is reversed. A subtraction is executed by adding the 2’s complement of the second
operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high or low-order bit of the
source register.
000h
When a = 0 and f ≥ 60h:
The instruction executes in 060h
Direct Forced mode. ‘f’ is Bank 0
interpreted as a location in the 100h
Access RAM between 060h 00h
and FFFh. This is the same as Bank 1 60h
locations F60h to FFFh through
Bank 14 Valid range
(Bank 15) of data memory. for ‘f’
Locations below 060h are not FFh
F00h Access RAM
available in this addressing
Bank 15
mode.
F40h
SFRs
FFFh
Data Memory
BSR
When a = 1 (all values of f): 000h 00000000
Bank 0
The instruction executes in
060h
Direct mode (also known as
Direct Long mode). ‘f’ is 100h
interpreted as a location in
one of the 16 banks of the data Bank 1 001001da ffffffff
memory space. The bank is through
Bank 14
designated by the Bank Select
Register (BSR). The address
can be in any implemented F00h
bank in the data memory Bank 15
space. F40h
SFRs
FFFh
Data Memory
Example Situation:
ADDWF f, d, a 000h
Not Accessible
FSR2H:FSR2L = 120h 05Fh
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 WREN bit, when set, will allow a write operation.
On power-up, the WREN bit is clear. The WRERR bit is
Several control registers are used in conjunction with set in hardware when the WR bit is set and cleared
the TBLRD and TBLWT instructions. These include the: when the internal programming timer expires and the
• EECON1 register write operation is complete.
• EECON2 register Note: During normal operation, the WRERR is
• TABLAT register read as ‘1’. This can indicate that a write
• TBLPTR registers operation was prematurely terminated by
a Reset, or a write operation was
6.2.1 EECON1 AND EECON2 REGISTERS attempted improperly.
The EECON1 register (Register 6-1) is the control
The WR control bit initiates write operations. The bit
register for memory accesses. The EECON2 register is
cannot be cleared, only set, in software. It is cleared in
not a physical register; it is used exclusively in the
hardware at the completion of the write operation.
memory write and erase sequences. Reading
EECON2 will read all ‘0’s.
The FREE bit, when set, will allow a program memory
erase operation. When FREE is set, the erase
operation is initiated on the next WR command. When
FREE is clear, only writes are enabled.
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+*
ERASE: TBLPTR<21:10>
Program Memory
TABLAT
Write Register
8 8 8 8
Program Memory
TMR0IF Wake-up if in
TMR0IE Idle or Sleep modes
TMR0IP
RBIF
RBIE
RBIP
INT0IF
INT0IE
INT1IF
INT1IE Interrupt to CPU
INT1IP Vector to Location
INT2IF
INT2IE 0008h
PIR1<6:3,1:0>
PIE1<6:3,1:0> INT2IP
IPR1<6:3,1:0> INT3IF
INT3IE
INT3IP
GIE/GIEH
PIR2<7:6,3:1>
PIE2<7:6 3:1>
IPR2<7:6,3:1> IPEN
PIR3<6:4,2:1> IPEN
PIE3<6:4,2:1> PEIE/GIEL
IPR3<6:4,2:1>
IPEN
PIR1<6:3,1:0>
PIE1<6:3,1:0>
IPR1<6:3,1:0>
PIR2<7:6,3:1>
PIE2<7:6,3:1>
IPR2<7:6,3:1> Interrupt to CPU
TMR0IF Vector to Location
TMR0IE IPEN
PIR3<6:4,2:1> 0018h
PIE3<6:4,2:1> TMR0IP
IPR3<6:4,2:1>
RBIF
RBIE
RBIP GIE/GIEH
PEIE/GIEL
INT1IF
INT1IE
INT1IP
INT2IF
INT2IE
INT2IP
INT3IF
INT3IE
INT3IP
Legend:
R = Readable bit W = 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
Legend:
R = Readable bit W = 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
3.3V
VDD TXX 5V
(at logic ‘1’)
Note: These pins are configured as digital inputs RE7 can also be configured as the alternate peripheral
on any device Reset. pin for the CCP2 module. This is done by clearing the
CCP2MX Configuration bit.
Each of the PORTE pins has a weak internal pull-up. A
single control bit can turn off all the pull-ups. This is EXAMPLE 9-5: INITIALIZING PORTE
performed by setting bit, REPU (PORTG<6>). The
CLRF PORTE ; Initialize PORTE by
weak pull-up is automatically turned off when the port
; clearing output
pin is configured as an output. The pull-ups are ; data latches
disabled on any device Reset. CLRF LATE ; Alternate method
Pins RE6:RE3 are multiplexed with the LCD common ; to clear output
; data latches
drives. I/O port functions are only available on those MOVLW 03h ; Value used to
PORTE pins depending on which commons are active. ; initialize data
The configuration is determined by the LMUX1:LMUX0 ; direction
control bits (LCDCON<1:0>). The availability is MOVWF TRISE ; Set RE<1:0> as inputs
summarized in Table 9-11. ; RE<7:2> 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
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 TMR0
1 TMR0L High Byte TMR0IF
Programmable 0 Clocks on Overflow
T0CKI pin 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
T1OSO/T13CKI 1
Prescaler Synchronize
FOSC/4 0
1, 2, 4, 8 Detect
Internal
Clock 0
T1OSI 2
Sleep Input
T1OSCEN(1) TMR1CS Timer1
On/Off
T1CKPS1:T1CKPS0
T1SYNC
TMR1ON
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
8
Read TMR1L
Write TMR1L
8
8
TMR1H
8
8
Internal Data Bus
Note 1: When enable bit, T1OSCEN, is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
XTAL
32.768 kHz
T1OSO
C2
27 pF
The module is controlled through the T2CON register The TMR2 and PR2 registers are both directly readable
(Register 12-1) which enables or disables the timer and and writable. The TMR2 register is cleared on any
configures the prescaler and postscaler. Timer2 can be device Reset, while the PR2 register initializes at FFh.
shut off by clearing control bit, TMR2ON (T2CON<2>), Both the prescaler and postscaler counters are cleared
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 12-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: CCPxM3:CCPxM0 = 1011 will only reset timer and not start A/D conversion on CCP1 match.
Timer1 is used for all Capture Timer1 is used for Capture Timer3 is used for all Capture
and Compare operations for and Compare operations for and Compare operations for
all CCP modules. Timer2 is CCP1 and Timer 3 is used for all CCP modules. Timer2 is
used for PWM operations for CCP2. used for PWM operations for
all CCP modules. Modules Both the modules use Timer2 all CCP modules. Modules
may share either timer as a common time base if they may share either timer
resource as a common time are in PWM modes. resource as a common time
base. base.
4 TMR1H TMR1L
CCP1CON<3:0> Set CCP2IF
4
Q1:Q4
4
CCP2CON<3:0>
T3CCP1 TMR3H TMR3L
T3CCP2
TMR3
Enable
CCP2 pin
Prescaler and CCPR2H CCPR2L
÷ 1, 4, 16 Edge Detect
TMR1
Enable
T3CCP2
TMR1H TMR1L
T3CCP1
Note: Clearing the CCP2CON register will force The Special Event Trigger for CCP2 can also start an
the RC1 or RE7 compare output latch A/D conversion. In order to do this, the A/D converter
(depending on device configuration) to the must already be enabled.
default low level. This is not the PORTC or Note: The Special Event Trigger of CCP1 only
PORTE I/O data latch. resets Timer1/Timer3 and cannot start an
A/D conversion even when the A/D
14.3.2 TIMER1/TIMER3 MODE SELECTION converter is enabled.
Timer1 and/or Timer3 must be running in Timer mode,
or Synchronized Counter mode, if the CCP module is
using the compare feature. In Asynchronous Counter
mode, the compare operation may not work.
Compare Output S Q
Comparator
Match Logic
R
TRIS
4 Output Enable
CCP1CON<3:0>
0 TMR1H TMR1L 0
Compare Output S Q
Comparator
Match Logic
R
TRIS
4 Output Enable
CCPR2H CCPR2L
CCP2CON<3:0>
CCPR1L
EQUATION 14-1:
PWM Period = (PR2) + 1] • 4 • TOSC •
(TMR2 Prescale Value)
Data Bus
LCD DATA
24 x 8 (= 4 x 48)
LCDDATA23 192
48
LCDDATA22 to
.
. 48
. SEG<47:0>
LCDDATA1 MUX
8 LCDDATA0
Bias
Voltage To I/O Pins
Timing Control
LCDCON 4
LCDPS
LCDSEx
COM3:COM0
FOSC/4
T13CKI LCD Clock LCD
INTRC Oscillator Source Select Charge Pump
INTOSC Oscillator
Legend:
R = Readable bit W = 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
TABLE 15-2: LCDDATA REGISTERS AND BITS FOR SEGMENT AND COM COMBINATIONS
COM Lines
Segments
0 1 2 3
LCDDATA0 LCDDATA6 LCDDATA12 LCDDATA18
0 through 7
S00C0:S07C0 S00C1:S07C1 S00C2:S07C2 S00C3:S07C3
LCDDATA1 LCDDATA7 LCDDATA13 LCDDATA19
8 through 15
S08C0:S15C0 S08C1:S15C1 S08C2:S15C2 S08C0:S15C3
LCDDATA2 LCDDATA8 LCDDATA14 LCDDATA20
16 through 23
S16C0:S23C0 S16C1:S23C1 S16C2:S23C2 S16C3:S23C3
LCDDATA3 LCDDATA9 LCDDATA15 LCDDATA21
24 through 31
S24C0:S31C0 S24C1:S31C1 S24C2:S31C2 S24C3:S31C3
LCDDATA4(1) LCDDATA10(1) LCDDATA16(1) LCDDATA22(1)
32 through 39
S32C0:S39C0 S32C1:S39C1 S32C2:S39C2 S32C3:S39C3
LCDDATA5(2) LCDDATA11(2) LCDDATA17(2) LCDDATA23(2)
40 through 47
S40C0:S47C0 S40C1:S47C1 S40C2:S47C2 S40C3:S47C3
Note 1: Bits<7:1> of these registers are not implemented in 64-pin devices. Bit 0 of these registers (SEG32Cy) is
always implemented.
2: These registers are not implemented on 64-pin devices.
2
LCDCON<3:2>
LCDPS<3:0>
÷4 00 4
System Clock (FOSC/4) 00
÷2 01 1:1 to 1:16 ÷32 COM0
÷1, 2, 3, 4 COM1
Timer1 Oscillator 01 Programmable or COM2
10 Prescaler ÷8192 Ring Counter
COM3
Internal 31 kHz Source 1x
11
2
LCDCON<1:0>
2
LCDREG<1:0>
11
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
VDD VDD
PIC18F85J90
AVDD
VLCAP1
CFLY CFLY
0.047 μF(1) 0.047 μF(1)
VLCAP2
VDD
LCDBIAS3
C3
0.047 μF(1)
LCDBIAS2
C2 C2
0.047 μF(1) 0.047 μF(1)
LCDBIAS1
C1 C1
0.047 μF(1) 0.047 μF(1)
LCDBIAS0
C0 C0
0.047 μF(1) 0.047 μF(1)
Mode 0 Mode 1
(VBIAS up to 3.6V) (VBIAS ≤ VDD)
Note 1: These values are provided for design guidance only; they should be optimized for the application by the designer
based on the actual LCD specifications.
PIC18F85J90
VDD
AVDD
LCDBIAS3
10 kΩ(1) 10 kΩ(1)
LCDBIAS2
10 kΩ(1)
LCDBIAS1
10 kΩ(1) 10 kΩ(1)
LCDBIAS0
Bias Type
Bias Level at Pin
1/2 Bias 1/3 Bias
Note 1: These values are provided for design guidance only; they should be optimized for the application by the designer
based on the actual LCD specifications.
PIC18F85J90
VDD
AVDD
(2)
LCDBIAS3
10 kΩ(1) 10 kΩ(1)
LCDBIAS2
10 kΩ(1)
LCDBIAS1
10 kΩ(1) 10 kΩ(1)
LCDBIAS0
Bias Type
Bias Level at Pin
Static 1/2 Bias 1/3 Bias
Note 1: These values are provided for design guidance only; they should be optimized for the application by the
designer based on the actual LCD specifications.
2: Potentiometer for manual contrast adjustment is optional; it may be omitted entirely.
V1
COM0
COM0 V0
V1
SEG0
V0
V1
SEG1
V0
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
SEG0
V1
COM0-SEG0 V0
-V1
COM0-SEG1 V0
1 Frame
V2
COM0 V1
V0
COM1
V2
COM0
COM1 V1
V0
V2
SEG0 V1
V0
V2
SEG3
SEG2
SEG1
SEG0
SEG1 V1
V0
V2
V1
COM0-SEG0 V0
-V1
-V2
V2
V1
COM0-SEG1 V0
-V1
-V2
1 Frame
V2
COM0 V1
COM1
V0
COM0
V2
COM1 V1
V0
V2
SEG0
V1
V0
V2
SEG1
SEG3
SEG2
SEG1
SEG0
V1
V0
V2
V1
COM0-SEG0 V0
-V1
-V2
V2
V1
COM0-SEG1 V0
-V1
-V2
2 Frames
V3
V2
COM0
V1
COM1
V0
V3
COM0
V2
COM1
V1
V0
V3
V2
SEG0
V1
V0
V3
V2
SEG1
SEG3
SEG2
SEG1
SEG0
V1
V0
V3
V2
V1
COM0-SEG0 V0
-V1
-V2
-V3
V3
V2
V1
COM0-SEG1 V0
-V1
-V2
1 Frame
-V3
V3
V2
COM0
V1
COM1
V0
V3
COM0
V2
COM1
V1
V0
V3
V2
SEG0
V1
V0
V3
V2
SEG1
SEG3
SEG2
SEG1
SEG0
V1
V0
V3
V2
V1
COM0-SEG0 V0
-V1
-V2
-V3
V3
V2
V1
COM0-SEG1 V0
-V1
-V2
2 Frames
-V3
V2
COM0
V1
V0
COM2 V2
COM1 V1
COM1 V0
COM0
V2
COM2 V1
V0
V2
SEG0
V1
SEG2
V0
SEG2
SEG1
SEG0
V2
SEG1 V1
V0
V2
V1
COM0-SEG0 V0
-V1
-V2
V2
V1
COM0-SEG1 V0
-V1
-V2
1 Frame
V2
COM0
V1
V0
COM2
V2
COM1
V1
COM1
V0
COM0
V2
COM2
V1
V0
V2
SEG0
V1
V0
SEG2
SEG1
SEG0
V2
SEG1
V1
V0
V2
V1
COM0-SEG0 V0
-V1
-V2
V2
V1
COM0-SEG1 V0
-V1
-V2
2 Frames
V3
V2
COM0
V1
V0
COM2 V3
V2
COM1
V1
COM1
V0
COM0
V3
V2
COM2
V1
V0
V3
V2
SEG0
SEG2 V1
V0
SEG2
SEG1
SEG0
V3
V2
SEG1
V1
V0
V3
V2
V1
COM0-SEG0 V0
-V1
-V2
-V3
V3
V2
V1
COM0-SEG1 V0
-V1
-V2
-V3
1 Frame
V3
V2
COM0
V1
V0
COM2 V3
V2
COM1
V1
COM1
V0
COM0
V3
V2
COM2
V1
V0
V3
V2
SEG0
V1
V0
SEG2
SEG1
SEG0
V3
V2
SEG1
V1
V0
V3
V2
V1
COM0-SEG0 V0
-V1
-V2
-V3
V3
V2
V1
COM0-SEG1 V0
-V1
-V2
-V3
2 Frames
COM3
V3
COM2 V2
COM0 V1
V0
V3
COM1 V2
COM1 V1
COM0 V0
V3
V2
COM2 V1
V0
V3
V2
COM3 V1
V0
V3
V2
SEG0 V1
V0
SEG1
SEG0
V3
V2
SEG1 V1
V0
V3
V2
V1
COM0-SEG0 V0
-V1
-V2
-V3
V3
V2
V1
COM0-SEG1 V0
-V1
-V2
-V3
1 Frame
COM3
V3
COM2 V2
COM0 V1
V0
V3
COM1 V2
COM1 V1
COM0 V0
V3
V2
COM2 V1
V0
V3
V2
COM3 V1
V0
V3
V2
SEG0 V1
V0
SEG1
SEG0
V3
V2
SEG1 V1
V0
V3
V2
V1
COM0-SEG0 V0
-V1
-V2
-V3
V3
V2
V1
COM0-SEG1 V0
-V1
-V2
-V3
2 Frames
V3
V2
COM1 V1
V0
V3
V2
COM2 V1
V0
COM3 V3
V2
V1
V0
2 Frames
TFINT
TFWR Frame
Frame Frame
Boundary Boundary Boundary
V2
V1
COM0 V0
V3
V2
V1
COM1 V0
V3
V2
V1
COM2 V0
V3
V2
V1
SEG0 V0
2 Frames
• Serial Peripheral Interface (SPI) Figure 16-1 shows the block diagram of the MSSP
module when operating in SPI mode.
• Inter-Integrated Circuit (I2C™)
- Full Master mode
FIGURE 16-1: MSSP BLOCK DIAGRAM
- Slave mode (with general address call)
(SPI MODE)
The I2C interface supports the following modes in
hardware: Internal
Data Bus
• Master mode
Read Write
• Multi-Master mode
• Slave mode
SSPBUF reg
Edge
Select
2
Clock Select
SSPM3:SSPM0
SMP:CKE
SCK 2
4 (
TMR2 Output
2
)
Edge
Select Prescaler TOSC
4, 16, 64
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: In Master mode, the overflow bit is not set since each new reception (and transmission) is initiated by
writing to the SSPBUF register.
2: When enabled, these pins must be properly configured as input or output.
3: Bit combinations not specifically listed here are either reserved or implemented in I2C™ mode only.
SDO SDI
Write to
SSPBUF
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
4 Clock
SCK Modes
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Input
Sample
(SMP = 1)
SSPIF
Next Q4 Cycle
SSPSR to after Q2↓
SSPBUF
SS
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI bit 0
(SMP = 0)
bit 7 bit 7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
SSPSR to after Q2↓
SSPBUF
SS
Optional
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI
(SMP = 0)
bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
SSPSR to after Q2↓
SSPBUF
SS
Not Optional
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Write to
SSPBUF
SDI
(SMP = 0)
bit 7 bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
after Q2↓
SSPSR to
SSPBUF
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: When enabled, the SDA and SCL pins must be configured as inputs.
Legend:
R = Readable bit W = 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: If the I2C module is active, these bits may not be set (no spooling) and the SSPBUF may not be written (or
writes to the SSPBUF are disabled).
Legend:
R = Readable bit W = 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 I2C module is active, this bit may not be set (no spooling) and the SSPBUF may not be written (or
writes to the SSPBUF are disabled).
DS39770B-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 (PIR1<3>)
Bus master
PIC18F85J90 FAMILY
terminates
transfer
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
Preliminary
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)
SDA A7 A6 A5 X A3 X X ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SSPIF (PIR1<3>)
Bus master
terminates
transfer
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
(RECEPTION, 7-BIT ADDRESS)
SSPOV (SSPCON1<6>)
Preliminary
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
CKP
(CKP does not reset to ‘0’ when SEN = 0)
Note 1: x = Don’t care (i.e., address bit can be either a ‘1’ or a ‘0’).
2: In this example, an address equal to A7.A6.A5.X.A3.X.X will be Acknowledged and cause an interrupt.
I2C™ SLAVE MODE TIMING WITH SEN = 0 AND ADMSK<5:1> = 01011
DS39770B-page 203
PIC18F85J90 FAMILY
FIGURE 16-10:
DS39770B-page 204
Receiving Address R/W = 0 Transmitting Data Transmitting Data
ACK 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
Data in SCL held low P
sampled while CPU
responds to SSPIF
SSPIF (PIR1<3>)
PIC18F85J90 FAMILY
BF (SSPSTAT<0>)
Cleared in software Cleared in software
From SSPIF ISR From SSPIF ISR
Preliminary
SSPBUF is written in software SSPBUF is written in software
CKP
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
Bus master
terminates
SSPIF (PIR1<3>) transfer
BF (SSPSTAT<0>)
Preliminary
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
CKP
(CKP does not reset to ‘0’ when SEN = 0)
I2C™ SLAVE MODE TIMING WITH SEN = 0 (RECEPTION, 10-BIT ADDRESS)
DS39770B-page 205
PIC18F85J90 FAMILY
Clock is held low until Clock is held low until
FIGURE 16-12:
DS39770B-page 206
taken place taken place
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
Bus master
terminates
SSPIF (PIR1<3>) transfer
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
Preliminary
still full. ACK is not sent.
UA (SSPSTAT<1>)
Note 1: x = Don’t care (i.e., address bit can be either a ‘1’ or a ‘0’).
2: In this example, an address equal to A9.A8.A7.A6.A5.X.A3.A2.X.X will be Acknowledged and cause an interrupt.
3: Note that the Most Significant bits of the address are not affected by the bit masking.
I2C™ SLAVE MODE TIMING WITH SEN = 0 AND ADMSK<5:1> = 01001
Bus master
terminates
Clock is held low until Clock is held low until transfer
update of SSPADD has update of SSPADD has Clock is held low until
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S Sr P
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
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
DS39770B-page 207
PIC18F85J90 FAMILY
PIC18F85J90 FAMILY
16.4.4 CLOCK STRETCHING 16.4.4.3 Clock Stretching for 7-Bit Slave
Both 7-Bit and 10-Bit Slave modes implement Transmit Mode
automatic clock stretching during a transmit sequence. The 7-Bit Slave Transmit mode implements clock
The SEN bit (SSPCON2<0>) allows clock stretching to stretching by clearing the CKP bit after the falling edge
be enabled during receives. Setting SEN will cause of the ninth clock if the BF bit is clear. This occurs
the SCL pin to be held low at the end of each data regardless 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
16.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 16-10).
ninth clock at the end of the ACK sequence, if the BF Note 1: If the user loads the contents of SSPBUF,
bit is set, the CKP bit in the SSPCON1 register is setting the BF bit before the falling edge of
automatically cleared, forcing the SCL output to be the ninth clock, the CKP bit will not be
held low. The CKP being cleared to ‘0’ will assert the cleared and clock stretching will not occur.
SCL line low. The CKP bit must be set in the user’s
ISR before reception is allowed to continue. By holding 2: The CKP bit can be set in software
the SCL line low, the user has time to service the ISR regardless of the state of the BF bit.
and read the contents of the SSPBUF before the
master device can initiate another receive sequence. 16.4.4.4 Clock Stretching for 10-Bit Slave
This will prevent buffer overruns from occurring (see Transmit Mode
Figure 16-15). In 10-Bit Slave Transmit mode, clock stretching is con-
Note 1: If the user reads the contents of the trolled during the first two address sequences by the
SSPBUF before the falling edge of the state of the UA bit, just as it is in 10-Bit Slave Receive
ninth clock, thus clearing the BF bit, the mode. The first two addresses are followed by a third
CKP bit will not be cleared and clock address sequence which contains the high-order bits
stretching will not occur. of the 10-bit address and the R/W bit set to ‘1’. After
the third address sequence is performed, the UA bit is
2: The CKP bit can be set in software
not set, the module is now configured in Transmit
regardless of the state of the BF bit. The
mode and clock stretching is controlled by the BF flag
user should be careful to clear the BF bit
as in 7-Bit Slave Transmit mode (see Figure 16-13).
in the ISR before the next receive
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
DS39770B-page 210
Clock is not held low
because buffer full bit is
clear prior to falling edge Clock is held low until Clock is not held low
of 9th clock CKP is set to ‘1’ because ACK = 1
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF (PIR1<3>)
Bus master
terminates
PIC18F85J90 FAMILY
transfer
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
Preliminary
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
CKP
CKP
If BF is cleared written
prior to the falling to ‘1’ in
edge of the 9th clock, software
CKP will not be reset BF is set after falling
to ‘0’ and no clock edge of the 9th clock,
stretching will occur CKP is reset to ‘0’ and
clock stretching occurs
I2C™ SLAVE MODE TIMING WITH SEN = 1 (RECEPTION, 7-BIT ADDRESS)
SSPIF (PIR1<3>)
Bus master
terminates
Cleared in software Cleared in software Cleared in software transfer
Cleared in software
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
Preliminary
UA (SSPSTAT<1>)
DS39770B-page 211
PIC18F85J90 FAMILY
PIC18F85J90 FAMILY
16.4.5 GENERAL CALL ADDRESS If the general call address matches, the SSPSR is
SUPPORT transferred to the SSPBUF, the BF flag bit is set (eighth
bit) and on the falling edge of the ninth bit (ACK bit), the
The addressing procedure for the I2C bus is such that
SSPIF interrupt flag bit is set.
the first byte after the Start condition usually
determines which device will be the slave addressed by When the interrupt is serviced, the source for the
the master. The exception is the general call address interrupt can be checked by reading the contents of the
which can address all devices. When this address is SSPBUF. The value can be used to determine if the
used, all devices should, in theory, respond with an address was device specific or a general call address.
Acknowledge. In 10-bit mode, the SSPADD is required to be updated
The general call address is one of eight addresses for the second half of the address to match and the UA
reserved for specific purposes by the I2C protocol. It bit is set (SSPSTAT<1>). If the general call address is
consists of all ‘0’s with R/W = 0. sampled when the GCEN bit is set, while the slave is
configured in 10-Bit Address mode, then the second
The general call address is recognized when the
half of the address is not necessary, the UA bit will not
General Call Enable bit, GCEN, is enabled
be set and the slave will begin receiving data after the
(SSPCON2<7> set). Following a Start bit detect, 8 bits
Acknowledge (Figure 16-17).
are shifted into the SSPSR and the address is
compared against the SSPADD. It is also compared to
the general call address and fixed in hardware.
SCL
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
SSPIF
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
SSPOV (SSPCON1<6>) ‘0’
GCEN (SSPCON2<7>)
‘1’
Internal SSPM3:SSPM0
Data Bus SSPADD<6:0>
Read Write
SSPBUF Baud
Rate
Generator
SDA Shift
Clock Arbitrate/WCOL Detect
SDA In Clock
SSPSR
(hold off clock source)
MSb LSb
Receive Enable
Acknowledge
Generate
SCL
SSPM3:SSPM0 SSPADD<6:0>
SDA DX DX – 1
BRG decrements on
Q2 and Q4 cycles
BRG
03h 02h 01h 00h (hold off) 03h 02h
Value
SCL
TBRG
S
Sr = Repeated Start
DS39770B-page 220
Write SSPCON2<0> (SEN = 1), ACKSTAT in
Start condition begins SSPCON2 = 1
From slave, clear ACKSTAT bit (SSPCON2<6>)
SEN = 0
Transmitting Data or Second Half
Transmit Address to Slave R/W = 0 ACK
of 10-bit Address
SDA A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
Preliminary
BF (SSPSTAT<0>)
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
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
Data shifted in on falling edge of CLK Set SSPIF at end
of receive Set SSPIF interrupt
Set SSPIF interrupt at end of Acknowledge
Set SSPIF interrupt sequence
at end of receive
at end of Acknowledge
SSPIF sequence
Set P bit
Cleared in software Cleared in software Cleared in software Cleared in software (SSPSTAT<4>)
SDA = 0, SCL = 1 Cleared in
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)
DS39770B-page 221
PIC18F85J90 FAMILY
PIC18F85J90 FAMILY
16.4.12 ACKNOWLEDGE SEQUENCE 16.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
(SSPCON2<4>). When this bit is set, the SCL pin is receive/transmit, the SCL line is held low after the fall-
pulled low and the contents of the Acknowledge data bit ing edge of the ninth clock. When the PEN bit is set, the
are presented on the SDA pin. If the user wishes to gen- master will assert the SDA line low. When the SDA line
erate an Acknowledge, then the ACKDT bit should be is sampled low, the Baud Rate Generator is reloaded
cleared. If not, the user should set the ACKDT bit before and 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 16-26).
cleared, the Baud Rate Generator is turned off and the
MSSP module then goes into Idle mode (Figure 16-25). 16.4.13.1 WCOL Status Flag
If the user writes the SSPBUF when a Stop sequence
16.4.12.1 WCOL Status Flag is in progress, then the WCOL bit is set and the
If the user writes the SSPBUF when an Acknowledge contents of the buffer are unchanged (the write doesn’t
sequence is in progress, then WCOL is set and the occur).
contents of the buffer are unchanged (the write doesn’t
occur).
SCL 8 9
SSPIF
Cleared in
SSPIF set at software
Cleared in
the end of receive software SSPIF set at the end
of Acknowledge sequence
Note: TBRG = one Baud Rate Generator period.
SDA ACK
P
TBRG TBRG TBRG
SCL brought high after TBRG
SDA asserted low before rising edge of clock
to setup Stop condition
SDA
BCLIF
SDA
SCL
Set SEN, enable Start SEN cleared automatically because of bus collision.
condition if SDA = 1, SCL = 1 MSSP module reset into Idle state.
SEN
SDA sampled low before
Start condition. Set BCLIF.
S bit and SSPIF set because
BCLIF SDA = 0, SCL = 1.
SSPIF and BCLIF are
cleared in software
SSPIF
SDA = 0, SCL = 1
TBRG TBRG
SDA
FIGURE 16-30: BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
SDA = 0, SCL = 1
Set S Set SSPIF
Less than TBRG TBRG
SCL S
SCL pulled low after BRG
time-out
SEN
Set SEN, enable Start
sequence if SDA = 1, SCL = 1
BCLIF ‘0’
SSPIF
SDA = 0, SCL = 1, Interrupts cleared
set SSPIF in software
SDA
SCL
RSEN
BCLIF
Cleared in software
S ‘0’
SSPIF ‘0’
TBRG TBRG
SDA
SCL
S ‘0’
SSPIF
PEN
BCLIF
P ‘0’
SSPIF ‘0’
SDA
PEN
BCLIF
P ‘0’
SSPIF ‘0’
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
0.3 — — — — — — — — — — — —
1.2 — — — 1.221 1.73 255 1.202 0.16 129 1.201 -0.16 103
2.4 2.441 1.73 255 2.404 0.16 129 2.404 0.16 64 2.403 -0.16 51
9.6 9.615 0.16 64 9.766 1.73 31 9.766 1.73 15 9.615 -0.16 12
19.2 19.531 1.73 31 19.531 1.73 15 19.531 1.73 7 — — —
57.6 56.818 -1.36 10 62.500 8.51 4 52.083 -9.58 2 — — —
115.2 125.000 8.51 4 104.167 -9.58 2 78.125 -32.18 1 — — —
0.3 — — — — — — — — — — — —
1.2 — — — — — — — — — — — —
2.4 — — — — — — 2.441 1.73 255 2.403 -0.16 207
9.6 9.766 1.73 255 9.615 0.16 129 9.615 0.16 64 9.615 -0.16 51
19.2 19.231 0.16 129 19.231 0.16 64 19.531 1.73 31 19.230 -0.16 25
57.6 58.140 0.94 42 56.818 -1.36 21 56.818 -1.36 10 55.555 3.55 8
115.2 113.636 -1.36 21 113.636 -1.36 10 125.000 8.51 4 — — —
0.3 0.300 0.00 8332 0.300 0.02 4165 0.300 0.02 2082 0.300 -0.04 1665
1.2 1.200 0.02 2082 1.200 -0.03 1041 1.200 -0.03 520 1.201 -0.16 415
2.4 2.402 0.06 1040 2.399 -0.03 520 2.404 0.16 259 2.403 -0.16 207
9.6 9.615 0.16 259 9.615 0.16 129 9.615 0.16 64 9.615 -0.16 51
19.2 19.231 0.16 129 19.231 0.16 64 19.531 1.73 31 19.230 -0.16 25
57.6 58.140 0.94 42 56.818 -1.36 21 56.818 -1.36 10 55.555 3.55 8
115.2 113.636 -1.36 21 113.636 -1.36 10 125.000 8.51 4 — — —
0.3 0.300 0.04 832 0.300 -0.16 415 0.300 -0.16 207
1.2 1.202 0.16 207 1.201 -0.16 103 1.201 -0.16 51
2.4 2.404 0.16 103 2.403 -0.16 51 2.403 -0.16 25
9.6 9.615 0.16 25 9.615 -0.16 12 — — —
19.2 19.231 0.16 12 — — — — — —
57.6 62.500 8.51 3 — — — — — —
115.2 125.000 8.51 1 — — — — — —
0.3 0.300 0.00 33332 0.300 0.00 16665 0.300 0.00 8332 0.300 -0.01 6665
1.2 1.200 0.00 8332 1.200 0.02 4165 1.200 0.02 2082 1.200 -0.04 1665
2.4 2.400 0.02 4165 2.400 0.02 2082 2.402 0.06 1040 2.400 -0.04 832
9.6 9.606 0.06 1040 9.596 -0.03 520 9.615 0.16 259 9.615 -0.16 207
19.2 19.193 -0.03 520 19.231 0.16 259 19.231 0.16 129 19.230 -0.16 103
57.6 57.803 0.35 172 57.471 -0.22 86 58.140 0.94 42 57.142 0.79 34
115.2 114.943 -0.22 86 116.279 0.94 42 113.636 -1.36 21 117.647 -2.12 16
0.3 0.300 0.01 3332 0.300 -0.04 1665 0.300 -0.04 832
1.2 1.200 0.04 832 1.201 -0.16 415 1.201 -0.16 207
2.4 2.404 0.16 415 2.403 -0.16 207 2.403 -0.16 103
9.6 9.615 0.16 103 9.615 -0.16 51 9.615 -0.16 25
19.2 19.231 0.16 51 19.230 -0.16 25 19.230 -0.16 12
57.6 58.824 2.12 16 55.555 3.55 8 — — —
115.2 111.111 -3.55 8 — — — — — —
In the Auto-Baud Rate Detect (ABD) mode, the clock to 2: It is up to the user to determine that the
the BRG is reversed. Rather than the BRG clocking the incoming character baud rate is within the
incoming RX1 signal, the RX1 signal is timing the BRG. range of the selected BRG clock source.
In ABD mode, the internal Baud Rate Generator is Some combinations of oscillator frequency
used as a counter to time the bit period of the incoming and EUSART baud rates are not possible
serial byte stream. due to bit error rates. Overall system
timing and communication baud rates
Once the ABDEN bit is set, the state machine will clear must be taken into consideration when
the BRG and look for a Start bit. The Auto-Baud Rate using the Auto-Baud Rate Detection
Detect must receive a byte with the value, 55h (ASCII feature.
“U”, which is also the LIN bus Sync character), in order
to calculate the proper bit rate. The measurement is
taken over both a low and a high bit time in order to TABLE 17-4: BRG COUNTER CLOCK
minimize any effects caused by asymmetry of the RATES
incoming signal. After a Start bit, the SPBRG1 begins
counting up, using the preselected clock source on the BRG16 BRGH BRG Counter Clock
first rising edge of RX1. After eight bits on the RX1 pin 0 0 FOSC/512
or the fifth rising edge, an accumulated value totalling
0 1 FOSC/128
the proper BRG period is left in the
SPBRGH1:SPBRG1 register pair. Once the 5th edge is 1 0 FOSC/128
seen (this should correspond to the Stop bit), the 1 1 FOSC/32
ABDEN bit is automatically cleared. Note: During the ABD sequence, SPBRG1 and
If a rollover of the BRG occurs (an overflow from FFFFh SPBRGH1 are both used as a 16-bit
to 0000h), the event is trapped by the ABDOVF status bit counter, independent of the BRG16 setting.
(BAUDCON1<7>). It is set in hardware by BRG rollovers
and can be set or cleared by the user in software. ABD
17.2.3.1 ABD and EUSART Transmission
mode remains active after rollover events and the
ABDEN bit remains set (Figure 17-2). Since the BRG clock is reversed during ABD acquisi-
tion, the EUSART transmitter cannot be used during
While calibrating the baud rate period, the BRG regis-
ABD. This means that whenever the ABDEN bit is set,
ters are clocked at 1/8th the preconfigured clock rate.
TXREG1 cannot be written to. Users should also
Note that the BRG clock will be configured by the
ensure that ABDEN does not become set during a
BRG16 and BRGH bits. Independent of the BRG16 bit
transmit sequence. Failing to do this may result in
setting, both the SPBRG1 and SPBRGH1 will be used
unpredictable EUSART operation.
as a 16-bit counter. This allows the user to verify that
no carry occurred for 8-bit modes by checking for 00h
in the SPBRGH1 register. Refer to Table 17-4 for
counter clock rates to the BRG.
BRG Clock
RC1IF bit
(Interrupt)
Read
RCREG1
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 SPBRGH1 SPBRG1
TX9
Baud Rate Generator TX9D
Write to TXREG1
Word 1
BRG Output
(Shift Clock)
TX1 (pin) Start bit bit 0 bit 1 bit 7/8 Stop bit
Word 1
TX1IF bit
(Transmit Buffer 1 TCY
Reg. Empty Flag)
Word 1
TRMT bit
Transmit Shift Reg
(Transmit Shift
Reg. Empty Flag)
Write to TXREG1
Word 1 Word 2
BRG Output
(Shift Clock)
TX1 (pin)
Start bit bit 0 bit 1 bit 7/8 Stop bit Start bit bit 0
RX9
SPEN
8
RC1IF
(Interrupt Flag)
OERR bit
CREN bit
Note: This timing diagram shows three words appearing on the RX1 input. The RCREG1 (Receive Buffer register) is read after the third word
causing the OERR (Overrun) bit to be set.
RX1/DT1 Line
RC1IF
Cleared due to user read of RCREG1
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 TXREG1
Dummy Write
BRG Output
(Shift Clock)
Break
TX1IF bit
(Transmit Buffer
Reg. Empty Flag)
TRMT bit
(Transmit Shift
Reg. Empty Flag)
SENDB sampled here Auto-Cleared
SENDB
(Transmit Shift
Reg. Empty Flag)
RC7/RX1/DT1
pin bit 0 bit 1 bit 2 bit 7 bit 0 bit 1 bit 7
Word 1 Word 2
RC6/TX1/CK1 pin
(SCKP = 0)
RC6/TX1/CK1 pin
(SCKP = 1)
Write to
TXREG1 Reg
Write Word 1 Write Word 2
TX1IF bit
(Interrupt Flag)
TRMT bit
Note: Sync Master mode, SPBRG1 = 0; continuous transmission of two 8-bit words.
RC6/TX1/CK1 pin
Write to
TXREG1 Reg
TX1IF bit
TRMT bit
TXEN bit
RC7/RX1/DT1
pin bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
RC6/TX1/CK1 pin
(SCKP = 0)
RC6/TX1/CK1 pin
(SCKP = 1)
Write to
SREN bit
SREN bit
CREN bit ‘0’ ‘0’
RC1IF bit
(Interrupt)
Read
RCREG1
Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
Synchronous Slave mode is entered by clearing bit 1. Enable the synchronous slave serial port by
CSRC (TXSTA<7>). This mode differs from the setting bits SYNC and SPEN and clearing bit
Synchronous Master mode in that the shift clock is CSRC.
supplied externally at the CK1 pin (instead of being 2. Clear bits CREN and SREN.
supplied internally in Master mode). This allows the 3. If interrupts are desired, set enable bit, TX1IE.
device to transfer or receive data while in any 4. If 9-bit transmission is desired, set bit, TX9.
low-power mode. 5. Enable the transmission by setting enable bit,
TXEN.
17.5.1 EUSART SYNCHRONOUS SLAVE
6. If 9-bit transmission is selected, the ninth bit
TRANSMIT
should be loaded in bit TX9D.
The operation of the Synchronous Master and Slave 7. Start transmission by loading data to the
modes are identical except in the case of the Sleep TXREG1 register.
mode.
8. If using interrupts, ensure that the GIE and PEIE
If two words are written to the TXREG1 and then the bits in the INTCON register (INTCON<7:6>) are
SLEEP instruction is executed, the following will occur: set.
a) The first word will immediately transfer to the
TSR register and transmit.
b) The second word will remain in the TXREG1
register.
c) Flag bit, TX1IF, will not be set.
d) When the first word has been shifted out of TSR,
the TXREG1 register will transfer the second
word to the TSR and flag bit, TX1IF, will now be
set.
e) If enable bit, TX1IE, is set, the interrupt will wake
the chip from Sleep. If the global interrupt is
enabled, the program will branch to the interrupt
vector.
Legend:
R = Readable bit W = 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 — — —
BRGH = 0
FOSC = 4.000 MHz FOSC = 2.000 MHz FOSC = 1.000 MHz
BAUD Actual SPBRG Actual SPBRG Actual SPBRG
% % %
RATE Rate value Rate value Rate value
Error Error Error
(K) (K) (decimal) (K) (decimal) (K) (decimal)
BRGH = 1
BAUD
FOSC = 40.000 MHz FOSC = 20.000 MHz FOSC = 10.000 MHz FOSC = 8.000 MHz
RATE
(K) Actual SPBRG Actual SPBRG Actual SPBRG Actual SPBRG
% % % %
Rate value Rate value Rate value Rate value
Error Error Error Error
(K) (decimal) (K) (decimal) (K) (decimal) (K) (decimal)
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 — — —
BRGH = 1
BAUD
FOSC = 4.000 MHz FOSC = 2.000 MHz FOSC = 1.000 MHz
RATE
(K) Actual SPBRG Actual SPBRG Actual SPBRG
% % %
Rate value Rate value Rate value
Error Error Error
(K) (decimal) (K) (decimal) (K) (decimal)
TRMT SPEN
SPBRG2
TX9
Baud Rate Generator
TX9D
Write to TXREG2
Word 1
BRG Output
(Shift Clock)
TX2 (pin)
Start bit bit 0 bit 1 bit 7/8 Stop bit
Word 1
TX2IF bit
(Transmit Buffer 1 TCY
Reg. Empty Flag)
Word 1
TRMT bit
Transmit Shift Reg
(Transmit Shift
Reg. Empty Flag)
Write to TXREG2
Word 1 Word 2
BRG Output
(Shift Clock)
TX2 (pin)
Start bit bit 0 bit 1 bit 7/8 Stop bit Start bit bit 0
RX9
SPEN
8
RC2IF
(Interrupt Flag)
OERR bit
CREN
Note: This timing diagram shows three words appearing on the RX2 input. The RCREG2 (Receive Buffer register) is read after the third
word causing the OERR (Overrun) bit to be set.
RX2/DT2 pin
bit 0 bit 1 bit 2 bit 7 bit 0 bit 1 bit 7
Word 1 Word 2
TX2/CK2 pin
Write to
TXREG2 Reg
Write Word 1 Write Word 2
TX2IF bit
(Interrupt Flag)
TRMT bit
Note: Sync Master mode, SPBRG2 = 0; continuous transmission of two 8-bit words.
TX2/CK2 pin
Write to
TXREG2 Reg
TX2IF bit
TRMT bit
TXEN bit
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 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
RX2/DT2 pin bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
TX2/CK2 pin
Write to
bit SREN
SREN bit
CREN bit ‘0’ ‘0’
RC2IF bit
(Interrupt)
Read
RCREG2
Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
Synchronous Slave mode is entered by clearing bit, 1. Enable the synchronous slave serial port by
CSRC (TXSTA2<7>). This mode differs from the setting bits, SYNC and SPEN, and clearing bit,
Synchronous Master mode in that the shift clock is CSRC.
supplied externally at the CK2 pin (instead of being 2. Clear bits, CREN and SREN.
supplied internally in Master mode). This allows the 3. If interrupts are desired, set enable bit, TX2IE.
device to transfer or receive data while in any 4. If 9-bit transmission is desired, set bit, TX9.
low-power mode. 5. Enable the transmission by setting enable bit,
TXEN.
18.5.1 AUSART SYNCHRONOUS
6. If 9-bit transmission is selected, the ninth bit
SLAVE TRANSMIT
should be loaded in bit TX9D.
The operation of the Synchronous Master and Slave 7. Start transmission by loading data to the
modes are identical except in the case of the Sleep TXREG2 register.
mode.
8. If using interrupts, ensure that the GIE and PEIE
If two words are written to the TXREG2 and then the bits in the INTCON register (INTCON<7:6>) are
SLEEP instruction is executed, the following will occur: set.
a) The first word will immediately transfer to the
TSR register and transmit.
b) The second word will remain in TXREG2
register.
c) Flag bit, TX2IF, will not be set.
d) When the first word has been shifted out of TSR,
the TXREG2 register will transfer the second
word to the TSR and flag bit, TX2IF, will now be
set.
e) If enable bit, TX2IE, is set, the interrupt will wake
the chip from Sleep. If the global interrupt is
enabled, the program will branch to the interrupt
vector.
Legend:
R = Readable bit W = 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
PCFG3:
AN11 AN10 AN9 AN8 AN7 AN6 AN5 AN4 AN3 AN2 AN1 AN0
PCFG0
0000 A A A A A A A A A A A A
0001 A A A A A A A A A A A A
0010 A A A A A A A A A A A A
0011 A A A A A A A A A A A A
0100 D A A A A A A A A A A A
0101 D D A A A A A A A A A A
0110 D D D A A A A A A A A A
0111 D D D D A A A A A A A A
1000 D D D D D A A A A A A A
1001 D D D D D D A A A A A A
1010 D D D D D D D A A A A A
1011 D D D D D D D D A A A A
1100 D D D D D D D D D A A A
1101 D D D D D D D D D D A A
1110 D D D D D D D D D D D A
1111 D D D D D D D D D D D D
A = Analog input D = Digital I/O
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
CHS3:CHS0
1011
AN11
1010
AN10
1001
AN9
1000
AN8
0111
AN7
0110
AN6
0101
AN5
0100
AN4
VAIN
(Input Voltage) 0011
10-Bit AN3
Converter
A/D 0010
AN2
0001
VCFG1:VCFG0 AN1
0000
VDD AN0
VREF+
Reference
Voltage
VREF-
VSS
Note 1: Channels AN15 through AN12 are not available on 64-pin devices.
2: I/O pins have diode protection to VDD and VSS.
VSS
Conversion starts
Holding capacitor is disconnected from analog input (typically 100 ns)
FIGURE 19-4: A/D CONVERSION TAD CYCLES (ACQT2:ACQT0 = 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
Two Common Reference Comparators Two Common Reference Comparators with Outputs
CM2:CM0 = 100 CM2:CM0 = 101
RF6/AN11/ A VIN- RF6/AN11/ A VIN-
SEG24 SEG24
VIN+ C1 C1OUT VIN+ C1 C1OUT
RF5/AN10/ A RF5/AN10/ A
CVREF/SEG23 CVREF/SEG23
RF2/AN7/C1OUT*/
SEG20
RF4/AN9/ A VIN-
SEG22 RF4/AN9/ A VIN-
D VIN+ C2 C2OUT SEG22
RF3/AN8/
SEG21 RF3/AN8/ D VIN+ C2 C2OUT
SEG21
RF1/AN6/C2OUT*/SEG19
One Independent Comparator with Output Four Inputs Multiplexed to Two Comparators
CM2:CM0 = 001 CM2:CM0 = 110
RF6/AN11/ A
RF6/AN11/ A VIN-
SEG24 CIS = 0 VIN-
SEG24
VIN+ C1 C1OUT RF5/AN10/ A CIS = 1
RF5/AN10/ A CVREF/SEG23 VIN+ C1 C1OUT
CVREF/SEG23
RF2/AN7/C1OUT*/SEG20 RF4/AN9/ A
SEG22 CIS = 0 VIN-
RF3/AN8/ A CIS = 1
RF4/AN9/ D VIN- VIN+ C2 C2OUT
SEG21
SEG22
D VIN+ C2 Off (Read as ‘0’)
RF3/AN8/ CVREF
SEG21 From VREF module
A = Analog Input, port reads zeros always D = Digital Input CIS (CMCON<3>) is the Comparator Input Switch
* Setting the TRISF<2:1> bits will disable the comparator outputs by configuring the pins as inputs.
MULTIPLEX
+
Port pins
To RF1 or
-
RF2 pin
D Q Bus
CxINV Data
Read CMCON EN
D Q Set
CMIF
bit
EN CL
From
Other
Reset Comparator
VDD
VT = 0.6V RIC
RS < 10k
Comparator
AIN Input
CPIN ILEAKAGE
VA VT = 0.6V ±500 nA
5 pF
VSS
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
CVRSS = 1
VREF+
VDD
CVRSS = 0 8R
CVR3:CVR0
CVREN R
16-to-1 MUX
R
16 Steps
CVREF
R
R
R
CVRR 8R
CVRSS = 1
VREF-
CVRSS = 0
PIC18F85J90
CVREF
R(1)
Module
+
Voltage RF5 CVREF Output
–
Reference
Output
Impedance
Note 1: R is dependent upon the Comparator Voltage Reference bits, CVRCON<5> and CVRCON<3:0>.
Legend:
R = Readable bit WO = Write-Once bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed ‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit WO = Write-Once bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed ‘1’ = Bit is set ‘0’ = Bit is cleared
Note 1: The value of these bits in program memory should always be ‘1’. This ensures that the location is
executed as a NOP if it is accidentally executed.
2: This bit should always be maintained as ‘0’.
Legend:
R = Readable bit WO = Write-Once bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed ‘1’ = Bit is set ‘0’ = Bit is cleared
Legend:
R = Readable bit WO = Write-Once bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed ‘1’ = Bit is set ‘0’ = Bit is cleared
Note 1: The value of these bits in program memory should always be ‘1’. This ensures that the location is
executed as a NOP if it is accidentally executed.
Legend:
R = Readable bit WO = Write-Once bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed ‘1’ = Bit is set ‘0’ = Bit is cleared
Note 1: The value of these bits in program memory should always be ‘1’. This ensures that the location is
executed as a NOP if it is accidentally executed.
Legend:
R = Read-only bit
Legend:
R = Read-only bit
Note 1: The values for DEV10:DEV3 may be shared with other device families. 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
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
INTRC
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 PC + 6
Counter
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
INTRC
÷ 64 C Q
Source
Clock
Failure
Detected
Sample Clock
Device Oscillator
Clock Failure
Output
CM Output
(Q)
Failure
Detected
OSCFIF
Note: The device clock is normally at a much higher frequency than the sample clock. The relative frequencies in
this example have been chosen for clarity.
Literal operations
15 8 7 0
OPCODE k (literal) MOVLW 7Fh
Control operations
CALL, GOTO and Branch operations
15 8 7 0
OPCODE n<7:0> (literal) GOTO Label
15 12 11 0
1111 n<19:8> (literal)
15 8 7 0
OPCODE S n<7:0> (literal) CALL MYFUNC
15 12 11 0
1111 n<19:8> (literal)
S = Fast bit
15 11 10 0
OPCODE n<10:0> (literal) BRA MYFUNC
15 8 7 0
OPCODE n<7:0> (literal) BC MYFUNC
BYTE-ORIENTED OPERATIONS
ADDWF f, d, a Add WREG and f 1 0010 01da ffff ffff C, DC, Z, OV, N 1, 2
ADDWFC f, d, a Add WREG and Carry bit to f 1 0010 00da ffff ffff C, DC, Z, OV, N 1, 2
ANDWF f, d, a AND WREG with f 1 0001 01da ffff ffff Z, N 1,2
CLRF f, a Clear f 1 0110 101a ffff ffff Z 2
COMF f, d, a Complement f 1 0001 11da ffff ffff Z, N 1, 2
CPFSEQ f, a Compare f with WREG, skip = 1 (2 or 3) 0110 001a ffff ffff None 4
CPFSGT f, a Compare f with WREG, skip > 1 (2 or 3) 0110 010a ffff ffff None 4
CPFSLT f, a Compare f with WREG, skip < 1 (2 or 3) 0110 000a ffff ffff None 1, 2
DECF f, d, a Decrement f 1 0000 01da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
DECFSZ f, d, a Decrement f, Skip if 0 1 (2 or 3) 0010 11da ffff ffff None 1, 2, 3, 4
DCFSNZ f, d, a Decrement f, Skip if Not 0 1 (2 or 3) 0100 11da ffff ffff None 1, 2
INCF f, d, a Increment f 1 0010 10da ffff ffff C, DC, Z, OV, N 1, 2, 3, 4
INCFSZ f, d, a Increment f, Skip if 0 1 (2 or 3) 0011 11da ffff ffff None 4
INFSNZ f, d, a Increment f, Skip if Not 0 1 (2 or 3) 0100 10da ffff ffff None 1, 2
IORWF f, d, a Inclusive OR WREG with f 1 0001 00da ffff ffff Z, N 1, 2
MOVF f, d, a Move f 1 0101 00da ffff ffff Z, N 1
MOVFF fs, fd Move fs (source) to 1st word 2 1100 ffff ffff ffff None
fd (destination) 2nd word 1111 ffff ffff ffff
MOVWF f, a Move WREG to f 1 0110 111a ffff ffff None
MULWF f, a Multiply WREG with f 1 0000 001a ffff ffff None 1, 2
NEGF f, a Negate f 1 0110 110a ffff ffff C, DC, Z, OV, N
RLCF f, d, a Rotate Left f through Carry 1 0011 01da ffff ffff C, Z, N 1, 2
RLNCF f, d, a Rotate Left f (No Carry) 1 0100 01da ffff ffff Z, N
RRCF f, d, a Rotate Right f through Carry 1 0011 00da ffff ffff C, Z, N
RRNCF f, d, a Rotate Right f (No Carry) 1 0100 00da ffff ffff Z, N
SETF f, a Set f 1 0110 100a ffff ffff None 1, 2
SUBFWB f, d, a Subtract f from WREG with 1 0101 01da ffff ffff C, DC, Z, OV, N
borrow
SUBWF f, d, a Subtract WREG from f 1 0101 11da ffff ffff C, DC, Z, OV, N 1, 2
SUBWFB f, d, a Subtract WREG from f with 1 0101 10da ffff ffff C, DC, Z, OV, N
borrow
SWAPF f, d, a Swap nibbles in f 1 0011 10da ffff ffff None 4
TSTFSZ f, a Test f, skip if 0 1 (2 or 3) 0110 011a ffff ffff None 1, 2
XORWF f, d, a Exclusive OR WREG with f 1 0001 10da ffff ffff Z, N
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared
if assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second
cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16-bits. This ensures that all
program memory locations have a valid instruction.
BIT-ORIENTED OPERATIONS
BCF f, b, a Bit Clear f 1 1001 bbba ffff ffff None 1, 2
BSF f, b, a Bit Set f 1 1000 bbba ffff ffff None 1, 2
BTFSC f, b, a Bit Test f, Skip if Clear 1 (2 or 3) 1011 bbba ffff ffff None 3, 4
BTFSS f, b, a Bit Test f, Skip if Set 1 (2 or 3) 1010 bbba ffff ffff None 3, 4
BTG f, b, a Bit Toggle f 1 0111 bbba ffff ffff None 1, 2
CONTROL OPERATIONS
BC n Branch if Carry 1 (2) 1110 0010 nnnn nnnn None
BN n Branch if Negative 1 (2) 1110 0110 nnnn nnnn None
BNC n Branch if Not Carry 1 (2) 1110 0011 nnnn nnnn None
BNN n Branch if Not Negative 1 (2) 1110 0111 nnnn nnnn None
BNOV n Branch if Not Overflow 1 (2) 1110 0101 nnnn nnnn None
BNZ n Branch if Not Zero 1 (2) 1110 0001 nnnn nnnn None
BOV n Branch if Overflow 1 (2) 1110 0100 nnnn nnnn None
BRA n Branch Unconditionally 2 1101 0nnn nnnn nnnn None
BZ n Branch if Zero 1 (2) 1110 0000 nnnn nnnn None
CALL n, s Call subroutine 1st word 2 1110 110s kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
CLRWDT — Clear Watchdog Timer 1 0000 0000 0000 0100 TO, PD
DAW — Decimal Adjust WREG 1 0000 0000 0000 0111 C
GOTO n Go to address 1st word 2 1110 1111 kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
NOP — No Operation 1 0000 0000 0000 0000 None
NOP — No Operation 1 1111 xxxx xxxx xxxx None 4
POP — Pop top of return stack (TOS) 1 0000 0000 0000 0110 None
PUSH — Push top of return stack (TOS) 1 0000 0000 0000 0101 None
RCALL n Relative Call 2 1101 1nnn nnnn nnnn None
RESET Software device Reset 1 0000 0000 1111 1111 All
RETFIE s Return from interrupt enable 2 0000 0000 0001 000s GIE/GIEH,
PEIE/GIEL
RETLW k Return with literal in WREG 2 0000 1100 kkkk kkkk None
RETURN s Return from Subroutine 2 0000 0000 0001 001s None
SLEEP — Go into Standby mode 1 0000 0000 0000 0011 TO, PD
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared
if assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second
cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16-bits. This ensures that all
program memory locations have a valid instruction.
LITERAL OPERATIONS
ADDLW k Add literal and WREG 1 0000 1111 kkkk kkkk C, DC, Z, OV, N
ANDLW k AND literal with WREG 1 0000 1011 kkkk kkkk Z, N
IORLW k Inclusive OR literal with WREG 1 0000 1001 kkkk kkkk Z, N
LFSR f, k Move literal (12-bit) 2nd word 2 1110 1110 00ff kkkk None
to FSR(f) 1st word 1111 0000 kkkk kkkk
MOVLB k Move literal to BSR<3:0> 1 0000 0001 0000 kkkk None
MOVLW k Move literal to WREG 1 0000 1110 kkkk kkkk None
MULLW k Multiply literal with WREG 1 0000 1101 kkkk kkkk None
RETLW k Return with literal in WREG 2 0000 1100 kkkk kkkk None
SUBLW k Subtract WREG from literal 1 0000 1000 kkkk kkkk C, DC, Z, OV, N
XORLW k Exclusive OR literal with WREG 1 0000 1010 kkkk kkkk Z, N
DATA MEMORY ↔ PROGRAM MEMORY OPERATIONS
TBLRD* Table Read 2 0000 0000 0000 1000 None
TBLRD*+ Table Read with post-increment 0000 0000 0000 1001 None
TBLRD*- Table Read with post-decrement 0000 0000 0000 1010 None
TBLRD+* Table Read with pre-increment 0000 0000 0000 1011 None
TBLWT* Table Write 2 0000 0000 0000 1100 None
TBLWT*+ Table Write with post-increment 0000 0000 0000 1101 None
TBLWT*- Table Write with post-decrement 0000 0000 0000 1110 None
TBLWT+* Table Write with pre-increment 0000 0000 0000 1111 None
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared
if assigned.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second
cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16-bits. This ensures that all
program memory locations have a valid instruction.
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).
Words: 1
Cycles: 1
Q Cycle Activity:
Q1 Q2 Q3 Q4
Decode Read Process Write to
register ‘f’ Data destination
Cycles: 1 No No No No
operation operation operation operation
Q Cycle Activity:
If No Jump:
Q1 Q2 Q3 Q4
Q1 Q2 Q3 Q4
Decode Read Process Write to
Decode Read literal Process No
register ‘f’ Data destination
‘n’ Data operation
Description: Clears the contents of the specified Encoding: 0000 0000 0000 0100
register. Description: CLRWDT instruction resets the
If ‘a’ is ‘0’, the Access Bank is selected. Watchdog Timer. It also resets the
If ‘a’ is ‘1’, the BSR is used to select the postscaler of the WDT. Status bits, TO
and PD, are set.
GPR bank (default).
If ‘a’ is ‘0’ and the extended instruction Words: 1
set is enabled, this instruction operates Cycles: 1
in Indexed Literal Offset Addressing
Q Cycle Activity:
mode whenever f ≤ 95 (5Fh). See
Section 23.2.3 “Byte-Oriented and Q1 Q2 Q3 Q4
Bit-Oriented Instructions in Indexed Decode No Process No
Literal Offset Mode” for details. operation Data operation
Words: 1
Example: CLRWDT
Cycles: 1
Before Instruction
Q Cycle Activity:
WDT Counter = ?
Q1 Q2 Q3 Q4 After Instruction
Decode Read Process Write WDT Counter = 00h
register ‘f’ Data register ‘f’ WDT Postscaler = 0
TO = 1
Example: CLRF FLAG_REG,1 PD = 1
Before Instruction
FLAG_REG = 5Ah
After Instruction
FLAG_REG = 00h
Q1 Q2 Q3 Q4 Q Cycle Activity:
Decode Read Process Write to Q1 Q2 Q3 Q4
register ‘f’ Data destination Decode Read Process Write to
If skip: register ‘f’ Data destination
Q1 Q2 Q3 Q4 If skip:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
If skip and followed by 2-word instruction: operation operation operation operation
Q1 Q2 Q3 Q4 If skip and followed by 2-word instruction:
No No No No Q1 Q2 Q3 Q4
operation operation operation operation No No No No
No No No No operation operation operation operation
operation operation operation operation No No No No
operation operation operation operation
Example: HERE DECFSZ CNT, 1, 1
GOTO LOOP Example: HERE DCFSNZ TEMP, 1, 0
CONTINUE ZERO :
NZERO :
Before Instruction
PC = Address (HERE) Before Instruction
After Instruction TEMP = ?
CNT = CNT – 1 After Instruction
If CNT = 0; TEMP = TEMP – 1,
PC = Address (CONTINUE) If TEMP = 0;
If CNT ≠ 0; PC = Address (ZERO)
PC = Address (HERE + 2) If TEMP ≠ 0;
PC = Address (NZERO)
Words: 1 C register f
Cycles: 1
Words: 1
Q Cycle Activity:
Cycles: 1
Q1 Q2 Q3 Q4
Decode Read Process Write to Q Cycle Activity:
register ‘f’ Data destination Q1 Q2 Q3 Q4
Decode Read Process Write to
Example: RLNCF REG, 1, 0 register ‘f’ Data destination
Before Instruction
REG = 1010 1011 Example: RRCF REG, 0, 0
After Instruction Before Instruction
REG = 0101 0111 REG = 1110 0110
C = 0
After Instruction
REG = 1110 0110
W = 0111 0011
C = 0
ADDFSR Add Literal to FSR ADDULNK Add Literal to FSR2 and Return
Syntax: ADDFSR f, k Syntax: ADDULNK k
Operands: 0 ≤ k ≤ 63 Operands: 0 ≤ k ≤ 63
f ∈ [ 0, 1, 2 ] Operation: FSR2 + k → FSR2,
Operation: FSR(f) + k → FSR(f) (TOS) → PC
Status Affected: None Status Affected: None
Encoding: 1110 1000 ffkk kkkk Encoding: 1110 1000 11kk kkkk
Description: The 6-bit literal ‘k’ is added to the Description: The 6-bit literal ‘k’ is added to the
contents of the FSR specified by ‘f’. contents of FSR2. A RETURN is then
Words: 1 executed by loading the PC with the
TOS.
Cycles: 1
Q Cycle Activity: The instruction takes two cycles to
execute; a NOP is performed during
Q1 Q2 Q3 Q4
the second cycle.
Decode Read Process Write to
literal ‘k’ Data FSR This may be thought of as a special
case of the ADDFSR instruction,
where f = 3 (binary ‘11’); it operates
Example: ADDFSR 2, 23h only on FSR2.
Words: 1
Before Instruction
FSR2 = 03FFh Cycles: 2
After Instruction Q Cycle Activity:
FSR2 = 0422h Q1 Q2 Q3 Q4
Decode Read Process Write to
literal ‘k’ Data FSR
No No No No
Operation Operation Operation Operation
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction format then becomes: {label} instruction argument(s).
MOVSS Move Indexed to Indexed PUSHL Store Literal at FSR2, Decrement FSR2
Syntax: MOVSS [zs], [zd] Syntax: PUSHL k
Operands: 0 ≤ zs ≤ 127 Operands: 0 ≤ k ≤ 255
0 ≤ zd ≤ 127
Operation: k → (FSR2),
Operation: ((FSR2) + zs) → ((FSR2) + zd) FSR2 – 1 → FSR2
Status Affected: None
Status Affected: None
Encoding:
Encoding: 1111 1010 kkkk kkkk
1st word (source) 1110 1011 1zzz zzzzs
2nd word (dest.) 1111 xxxx xzzz zzzzd Description: The 8-bit literal ‘k’ is written to the data
Description The contents of the source register are memory address specified by FSR2.
FSR2 is decremented by 1 after the
moved to the destination register. The
addresses of the source and destination operation.
registers are determined by adding the This instruction allows users to push
7-bit literal offsets, ‘zs’ or ‘zd’, values onto a software stack.
respectively, to the value of FSR2. Both
Words: 1
registers can be located anywhere in
the 4096-byte data memory space Cycles: 1
(000h to FFFh). Q Cycle Activity:
The MOVSS instruction cannot use the Q1 Q2 Q3 Q4
PCL, TOSU, TOSH or TOSL as the Decode Read ‘k’ Process Write to
destination register. data destination
If the resultant source address points to
an Indirect Addressing register, the
value returned will be 00h. If the Example: PUSHL 08h
resultant destination address points to Before Instruction
an Indirect Addressing register, the FSR2H:FSR2L = 01ECh
instruction will execute as a NOP. Memory (01ECh) = 00h
Words: 2
After Instruction
Cycles: 2 FSR2H:FSR2L = 01EBh
Q Cycle Activity: Memory (01ECh) = 08h
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
Cycles: 1 The instruction takes two cycles to
execute; a NOP is performed during the
Q Cycle Activity:
second cycle.
Q1 Q2 Q3 Q4
This may be thought of as a special case
Decode Read Process Write to
of the SUBFSR instruction, where f = 3
register ‘f’ Data destination
(binary ‘11’); it operates only on FSR2.
Words: 1
Example: SUBFSR 2, 23h Cycles: 2
Before Instruction Q Cycle Activity:
FSR2 = 03FFh Q1 Q2 Q3 Q4
After Instruction Decode Read Process Write to
FSR2 = 03DCh register ‘f’ Data destination
No No No No
Operation Operation Operation Operation
† NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
4.0V
3.6V
3.5V
3.0V PIC18F6XJ90/8XJ90
Voltage (VDD)
2.5V
2.35V
2.0V
Note 1: When the on-chip regulator is enabled, its BOR circuit will automatically trigger a device Reset
before VDD reaches a level at which full-speed operation is not possible.
3.00V
2.75V
2.7V
2.50V
Voltage (VDDCORE)
PIC18F6XJ90/8XJ90
2.35V
2.25V
2.00V
8 MHz 40 MHz
Frequency
Note 1: For frequencies between 4 MHz and 40 MHz, FMAX = (51.42 MHz/V) * (VDDCORE – 2V) + 4 MHz.
2: When the on-chip voltage regulator is disabled, VDD and VDDCORE must be maintained so that
VDDCORE ≤ VDD ≤ 3.6V.
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
Symbol Characteristic Min Max Units Conditions
No.
VIL Input Low Voltage
All I/O ports:
D030 with TTL buffer VSS 0.15 VDD V
D031 with Schmitt Trigger buffer VSS 0.2 VDD V
D032 MCLR VSS 0.2 VDD V
D033 OSC1 VSS 0.3 VDD V HS, HSPLL modes
D033A OSC1 VSS 0.2 VDD V EC, ECPLL modes
D034 T13CKI VSS 0.3 V
VIH Input High Voltage
I/O ports with analog functions:
D040 with TTL buffer 0.25 VDD + 0.8V VDD V VDD < 3.3V
D041 with Schmitt Trigger buffer 0.8 VDD VDD V
Digital-only I/O ports:
with TTL buffer 0.25 VDD + 0.8V 5.5 V VDD < 3.3V
2.0 5.5 V 3.3V ≤ VDD ≤ 3.6V
with Schmitt Trigger buffer 0.8 VDD 5.5 V
D042 MCLR 0.8 VDD VDD V
D043 OSC1 0.7 VDD VDD V HS, HSPLL modes
D043A OSC1 0.8 VDD VDD V EC, ECPLL modes
D044 T13CKI 1.6 VDD V
IIL Input Leakage Current(1)
D060 I/O ports — ±1 μA VSS ≤ VPIN ≤ VDD,
Pin at high-impedance
D061 MCLR — ±1 μA Vss ≤ VPIN ≤ VDD
D063 OSC1 — ±5 μA Vss ≤ VPIN ≤ VDD
IPU Weak Pull-up Current
D070 IPURB PORTB weak pull-up current 30 240 μA VDD = 3.3V, VPIN = VSS
Note 1: Negative current is defined as current sourced by the pin.
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 — AVDD – 1.5 V
D302 CMRR Common Mode Rejection Ratio* 55 — — dB
300 TRESP Response Time(1)* — 150 400 ns
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 (AVDD – 1.5)/2, while the other input transitions
from VSS to VDD.
Param
Sym Characteristics Min Typ Max Units Comments
No.
D310 VRES Resolution VDD/24 — VDD/32 LSb
D311 VRAA Absolute Accuracy — — 1/2 LSb
D312 VRUR Unit Resistor Value (R) — 2k — Ω
310 TSET Settling Time(1) — — 10 μs
Note 1: Settling time measured while CVRR = 1 and CVR3:CVR0 transitions from ‘0000’ to ‘1111’.
Param
Sym Characteristics Min Typ Max Units Comments
No.
VRGOUT Regulator Output Voltage* — 2.5 — V
CEFC External Filter Capacitor Value* 4.7 10 — μF Capacitor must be low ESR
* These parameters are characterized but not tested. Parameter numbers not yet assigned for these
specifications.
Param
Sym Characteristics Min Typ Max Units Comments
No.
CFLY Fly Back Capacitor 0.47 4.7 µF Capacitor must be low ESR
VBIAS VPK-PK between LCDBIAS0 & 3.40 3.6 V BIAS2:BIAS0 = 111
LCDBIAS3 3.27 V BIAS2:BIAS0 = 110
3.14 V BIAS2:BIAS0 = 101
3.01 V BIAS2:BIAS0 = 100
2.88 V BIAS2:BIAS0 = 011
2.75 V BIAS2:BIAS0 = 010
2.62 V BIAS2:BIAS0 = 001
2.49 V BIAS2:BIAS0 = 000
VDD/2
RL
CL Pin CL
Pin
VSS VSS
RL = 464Ω
CL = 50 pF for all pins except OSC2/CLKO/RA6
and including D and E outputs as ports
CL = 15 pF for OSC2/CLKO/RA6
OSC1
1 3 3 4 4
2
CLKO
OSC1
10 11
CLKO
13 12
14 19 18
16
I/O pin
(Input)
17 15
20, 21
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
Oscillator
Time-out
Internal
Reset
Watchdog
Timer
Reset
31
34 34
I/O pins
TABLE 25-11: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET REQUIREMENTS
Param.
Symbol Characteristic Min Typ Max Units Conditions
No.
T0CKI
40 41
42
T1OSO/T13CKI
45 46
47 48
TMR0 or
TMR1
CCPx
(Capture Mode)
50 51
52
CCPx
(Compare or PWM Mode)
53 54
SS
70
SCK
(CKP = 0)
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76
74
73
SS
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)
79 78
80
75, 76 77
TABLE 25-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 25-3 for load conditions.
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
91 92
SDA
In
110
109 109
SDA
Out
91 THD:STA Start Condition Hold Time 100 kHz mode 4.0 — μs After this period, the first clock
400 kHz mode 0.6 — μs pulse is generated
SCL
91 93
90 92
SDA
Start Stop
Condition Condition
SDA
Out
TXx/CKx
pin
121 121
RXx/DTx
pin
120
122
Note: Refer to Figure 25-3 for load conditions.
TXx/CKx
pin 125
RXx/DTx
pin
126
BSF ADCON0, GO
(Note 2)
131
Q4
130
A/D CLK 132
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.
XXXXXXXXXX 18F65J90
XXXXXXXXXX -I/PT e3
XXXXXXXXXX 0610017
YYWWNNN
XXXXXXXXXXXX PIC18F85J90
XXXXXXXXXXXX -I/PT e3
YYWWNNN 0610017
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.
64-Lead Plastic Thin Quad Flatpack (PT) – 10x10x1 mm Body, 2.00 mm Footprint [TQFP]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
D
D1
E
e
E1
N
b
β A1
L L1
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Number of Leads N 64
Lead Pitch e 0.50 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.17 0.22 0.27
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-085B
80-Lead Plastic Thin Quad Flatpack (PT) – 12x12x1 mm Body, 2.00 mm Footprint [TQFP]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
D
D1
E
e
E1
b N
NOTE 1
12 3 NOTE 2 α
A
c
φ
β A1 A2
L L1
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Number of Leads N 80
Lead Pitch e 0.50 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 14.00 BSC
Overall Length D 14.00 BSC
Molded Package Width E1 12.00 BSC
Molded Package Length D1 12.00 BSC
Lead Thickness c 0.09 – 0.20
Lead Width b 0.17 0.22 0.27
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-092B
V
VDDCORE/VCAP Pin ........................................................... 290
Voltage Reference Specifications .................................... 364
Voltage Regulator (On-Chip) ............................................ 290
Brown-out Reset (BOR) ........................................... 291
Low-Voltage Detection (LVD) .................................. 290
Operation in Sleep Mode ......................................... 291
Power-up Requirements .......................................... 291
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?
Device PIC18F63J90/64J90/65J90(1),
PIC18F83J90/84J90/85J90(1),
PIC18F63J90/64J90/65J90T(2),
PIC18F83J90/84J90/85J90T(2)
12/08/06