Pic18F6390/6490/8390/8490 Data Sheet: 64/80-Pin Flash Microcontrollers With LCD Driver and Nanowatt Technology
Pic18F6390/6490/8390/8490 Data Sheet: 64/80-Pin Flash Microcontrollers With LCD Driver and Nanowatt Technology
Pic18F6390/6490/8390/8490 Data Sheet: 64/80-Pin Flash Microcontrollers With LCD Driver and Nanowatt Technology
Data Sheet
64/80-Pin Flash 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.
Data
EUSART/
64-Pin TQFP
RE7/CCP2(1)/SEG31
RE4/COM1
RE5/COM2
RE6/COM3
RD0/SEG0
RD1/SEG1
RD2/SEG2
RD3/SEG3
RD4/SEG4
RD5/SEG5
RD6/SEG6
RD7/SEG7
LCDBIAS3
COM0
VDD
VSS
64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49
LCDBIAS2 1 48 RB0/INT0
LCDBIAS1 2 47 RB1/INT1/SEG8
RG0/SEG30 3 46 RB2/INT2/SEG9
RG1/TX2/CK2/SEG29 4 45 RB3/INT3/SEG10
RG2/RX2/DT2/SEG28 5 44 RB4/KBI0/SEG11
RG3/SEG27 6 43 RB5/KBI1
MCLR/VPP/RG5 RB6/KBI2/PGC
7 PIC18F6390 42
RG4/SEG26 8 41 VSS
VSS 9
PIC18F6490 40 OSC2/CLKO/RA6
VDD 10 39 OSC1/CLKI/RA7
RF7/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
RF3/AN8/SEG21 15 34 RC3/SCK/SCL
RF2/AN7/C1OUT/SEG20 33 RC2/CCP1/SEG13
16
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
RF1/AN6/C2OUT/SEG19
RF0/AN5/SEG18
RA3/AN3/VREF+/SEG17
RA2/AN2/VREF-/SEG16
RA5/AN4/HLVDIN/SEG15
RC0/T1OSO/T13CKI
RC6/TX1/CK1
RC7/RX1/DT1
AVSS
VSS
AVDD
RA1/AN1
RA0/AN0
VDD
RA4/T0CKI/SEG14
RC1/T1OSI/CCP2(1)
80-Pin TQFP
RE7/CCP2(1)/SEG31
RH0/SEG47
RH1/SEG46
RJ0/SEG32
RJ1/SEG33
RE4/COM1
RE5/COM2
RE6/COM3
RD0/SEG0
RD1/SEG1
RD2/SEG2
RD3/SEG3
RD4/SEG4
RD5/SEG5
RD6/SEG6
RD7/SEG7
LCDBIAS3
COM0
VDD
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
LCDBIAS2 3 58 RB0/INT0
LCDBIAS1 4 57 RB1/INT1/SEG8
RG0/SEG30 5 56 RB2/INT2/SEG9
RG1/TX2/CK2/SEG29 6 55 RB3/INT3/SEG10
RG2/RX2/DT2/SEG28 7 54 RB4/KBI0/SEG11
RG3/SEG27 8 53 RB5/KBI1
MCLR/VPP/RG5 9 52 RB6/KBI2/PGC
RG4/SEG26 PIC18F8390 51 VSS
10
VSS 11 PIC18F8490 50 OSC2/CLKO/RA6
VDD 12 49 OSC1/CLKI/RA7
RF7/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
RF3/AN8/SEG21 17 44 RC3/SCK/SCL
RF2/AN7/C1OUT/SEG20 43 RC2/CCP1/SEG13
18
RH7/SEG43 19 42 RJ7/SEG36
RH6/SEG42 41 RJ6/SEG37
20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
RF1/AN6/C2OUT/SEG19
RF0/AN5/SEG18
RJ4/SEG39
RJ5/SEG38
RC1/T1OSI/CCP2(1)
RA3/AN3/VREF+/SEG17
RA2/AN2/VREF-/SEG16
RA5/AN4/HLVDIN/SEG15
RC6/TX1/CK1
RC7/RX1/DT1
RC0/T1OSO/T13CKI
RH5/SEG41
RH4/SEG40
AVSS
VSS
AVDD
RA1/AN1
RA0/AN0
VDD
RA4/T0CKI/SEG14
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)
• The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include
literature number) you are using.
This family offers the advantages of all PIC18 • Four Crystal modes using crystals or ceramic
microcontrollers – namely, high computational resonators.
performance at an economical price. In addition to • Two External Clock modes offering the option of
these features, the PIC18F6390/6490/8390/8490 using two pins (oscillator input and a divide-by-4
family introduces design enhancements that make clock output) or one pin (oscillator input, with the
these microcontrollers a logical choice for many second pin reassigned as general I/O).
high-performance, power-sensitive applications. • Two External RC Oscillator modes with the same
pin options as the External Clock modes.
1.1 New Core Features • An internal oscillator block which provides an
8 MHz clock (±2% accuracy) and an INTRC
1.1.1 nanoWatt TECHNOLOGY source (approximately 31 kHz, stable over
All of the devices in the PIC18F6390/6490/8390/8490 temperature and VDD), as well as a range of six
family incorporate a range of features that can user-selectable clock frequencies between
significantly reduce power consumption during 125 kHz to 4 MHz for a total of eight clock
operation. Key items include: frequencies. This option frees the two oscillator
pins for use as additional general purpose I/O.
• Alternate Run Modes: By clocking the controller
• A Phase Lock Loop (PLL) frequency multiplier,
from the Timer1 source or the internal oscillator
available to both the High-Speed Crystal and
block, power consumption during code execution
Internal Oscillator modes, which allows clock
can be reduced by as much as 90%.
speeds of up to 40 MHz. Used with the internal
• Multiple Idle Modes: The controller can also run oscillator, the PLL gives users a complete
with its CPU core disabled, but the peripherals still selection of clock speeds from 31 kHz to
active. In these states, power consumption can be 32 MHz – all without using an external crystal or
reduced even further – to as little as 4% of normal clock circuit.
operation requirements.
Besides its availability as a clock source, the internal
• On-the-Fly Mode Switching: The
oscillator block provides a stable reference source that
power-managed modes are invoked by user code
gives the family additional features for robust
during operation, allowing the user to incorporate
operation:
power-saving ideas into their application’s
software design. • Fail-Safe Clock Monitor: This option constantly
• Lower Consumption in Key Modules: The monitors the main clock source against a
power requirements for both Timer1 and the reference signal provided by the internal
Watchdog Timer have been reduced by up to oscillator. If a clock failure occurs, the controller is
80%, with typical values of 1.1 μA and 2.1 μA, switched to the internal oscillator block, allowing
respectively. for continued low-speed operation or a safe
application shutdown.
• Two-Speed Start-up: This option allows the
internal oscillator to serve as the clock source
from Power-on Reset or wake-up from Sleep
mode until the primary clock source is available.
inc/dec PORTC
8 logic
Table Latch RC0/T1OSO/T13CKI
RC1/T1OSI/CCP2(1)
RC2/CCP1/SEG13
ROM Latch
Address RC3/SCK/SCL
Instruction Bus <16> Decode RC4/SDI/SDA
RC5/SDO/SEG12
IR RC6/TX1/CK1
RC7/RX1/DT1
8 PORTD
Instruction State Machine
Decode and Control Signals
Control RD7/SEG7:RD0/SEG0
PRODH PRODL
8 x 8 Multiply
3
8 PORTE
LCDBIAS1
BITOP W LCDBIAS2
8 8
8 LCDBIAS3
Internal COM0
OSC1(3) Power-up 8 RE4/COM1
Oscillator 8
Block Timer RE5/COM2
(3) Oscillator RE6/COM3
OSC2 ALU<8>
INTRC Start-up Timer RE7/CCP2(1)/SEG31
T1OSI Oscillator Power-on 8
Reset PORTF
8 MHz RF0/AN5/SEG18
T1OSO Oscillator Watchdog RF1/AN6/C2OUT/SEG19
Timer
Precision RF2/AN7/C1OUT/SEG20
Single-Supply Brown-out Band Gap RF3/AN8/SEG21
MCLR(2)
Programming Reset Reference RF4/AN9/SEG22
In-Circuit Fail-Safe RF5/AN10/CVREF/SEG23
VDD, VSS Debugger Clock Monitor RF6/AN11/SEG24
RF7/SS/SEG25
PORTG
BOR ADC
Timer0 Timer1 Timer2 Timer3 RG0/SEG30
HLVD 10-Bit RG1/TX2/CK2/SEG29
RG2/RX2/DT2/SEG28
RG3/SEG27
RG4/SEG26
MCLR/VPP/RG5(2)
Note 1: CCP2 is multiplexed with RC1 when Configuration bit, CCP2MX, is set, or RE7 when CCP2MX is not set.
2: RG5 is only available when MCLR functionality is disabled.
3: OSC1/CLKI and OSC2/CLKO are only available in select oscillator modes and when these pins are not being used as digital I/O.
Refer to Section 2.0 “Oscillator Configurations” for additional information.
8 RD7/SEG7:RD0/SEG0
Instruction State Machine
Decode and Control Signals
Control PRODH PRODL PORTE
LCDBIAS1
LCDBIAS2
8 x 8 Multiply LCDBIAS3
3 8
COM0
BITOP W RE4/COM1
8 8 8 RE5/COM2
RE6/COM3
OSC1(3) Internal RE7/CCP2(1)/SEG31
Oscillator Power-up 8
Timer 8
Block PORTF
(3) Oscillator RF0/AN5/SEG18
OSC2 ALU<8>
INTRC Start-up Timer RF1/AN6/C2OUT/SEG19
Oscillator Power-on 8 RF2/AN7/C1OUT/SEG20
T1OSI
Reset RF3/AN8/SEG21
8 MHz RF4/AN9/SEG22
T1OSO Oscillator Watchdog
Timer RF5/AN10/CVREF/SEG23
Precision RF6/AN11/SEG24
Single-Supply Brown-out Band Gap
MCLR(2) RF7/SS/SEG25
Programming Reset Reference
In-Circuit Fail-Safe PORTG
VDD, VSS Debugger Clock Monitor RG0/SEG30
RG1/TX2/CK2/SEG29
RG2/RX2/DT2/SEG28
RG3/SEG27
RG4/SEG26
MCLR/VPP/RG5(2)
PORTH
BOR ADC
10-Bit Timer0 Timer1 Timer2 Timer3 RH3/SEG47:RH0/SEG44
HLVD
RH7/SEG40:RH4/SEG43
PORTJ
RJ3/SEG35:RJ0/SEG32
CCP2 LCD MSSP RJ7/SEG36:RJ4/SEG39
Comparators CCP1 EUSART1 AUSART2
Driver
Note 1: CCP2 is multiplexed with RC1 when Configuration bit, CCP2MX, is set and RE7 when CCP2MX is not set.
2: RG5 is only available when MCLR functionality is disabled.
3: OSC1/CLKI and OSC2/CLKO are only available in select oscillator modes and when these pins are not being used as digital I/O.
Refer to Section 2.0 “Oscillator Configurations” for additional information.
HS 4 MHz 27 pF 27 pF
8 MHz 22 pF 22 pF
20 MHz 15 pF 15 pF 2.3 External Clock Input
Capacitor values are for design guidance only. The EC and ECIO Oscillator modes require an external
These capacitors were tested with the crystals listed clock source to be connected to the OSC1 pin. There is
below for basic start-up and operation. These values no oscillator start-up time required after a Power-on
are not optimized. Reset or after an exit from Sleep mode.
Different capacitor values may be required to produce In the EC Oscillator mode, the oscillator frequency
acceptable oscillator operation. The user should test divided by 4 is available on the OSC2 pin. This signal
the performance of the oscillator over the expected may be used for test purposes or to synchronize other
VDD and temperature range for the application. logic. Figure 2-3 shows the pin connections for the EC
Oscillator mode.
See the notes following this table for additional
information.
FIGURE 2-3: EXTERNAL CLOCK
Crystals Used: INPUT OPERATION
32 kHz 4 MHz (EC CONFIGURATION)
200 kHz 8 MHz
1 MHz 20 MHz Clock from OSC1/CLKI
Ext. System PIC18FXXXX
FOSC/4 OSC2/CLKO
Note 1: Higher capacitance increases the stability
of oscillator, but also increases the
start-up time.
The ECIO Oscillator mode functions like the EC mode,
2: When operating below 3V VDD, or when except that the OSC2 pin becomes an additional gen-
using certain ceramic resonators at any eral purpose I/O pin. The I/O pin becomes bit 6 of
voltage, it may be necessary to use the PORTA (RA6). Figure 2-4 shows the pin connections
HS mode or switch to a crystal oscillator. for the ECIO Oscillator mode.
3: Since each resonator/crystal has its own
characteristics, the user should consult FIGURE 2-4: EXTERNAL CLOCK
the resonator/crystal manufacturer for INPUT OPERATION
appropriate values of external (ECIO CONFIGURATION)
components.
4: Rs may be required to avoid overdriving
crystals with low drive level specification. Clock from OSC1/CLKI
Ext. System PIC18FXXXX
5: Always verify oscillator performance over
the VDD and temperature range that is RA6 I/O (OSC2)
expected for the application.
OSC2
FIGURE 2-5: RC OSCILLATOR MODE Phase
HS Mode FIN Comparator
VDD
OSC1 Crystal FOUT
Oscillator
REXT
OSC1 Internal Loop
Clock Filter
CEXT
PIC18FXXXX
VSS
÷4 VCO
OSC2/CLKO SYSCLK
FOSC/4
MUX
Recommended values: 3 kΩ ≤ REXT ≤ 100 kΩ
CEXT > 20 pF
CEXT
PIC18FXXXX
VSS
RA6 I/O (OSC2)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Available only in certain oscillator configurations; otherwise, this bit is unavailable and read as ‘0’. See
Section 2.6.4 “PLL in INTOSC Modes” for details.
PIC18F6X90/8X90
Primary Oscillator LP, XT, HS, RC, EC
OSC2
T1OSO
T1OSCEN
Enable
T1OSI Oscillator OSCCON<6:4> Internal Oscillator
OSCCON<6:4> 8 MHz CPU
111
4 MHz
Internal 110
Oscillator 2 MHz IDLEN
Block 101
Clock
Postscaler
1 MHz
8 MHz 100 Control
MUX
OSCTUNE<7>
WDT, PWRT, FSCM
and Two-Speed Start-up
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
T1OSI 1 2 3 n-1 n
Clock Transition
OSC1
CPU
Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
FIGURE 3-2: TRANSITION TIMING FROM SEC_RUN MODE TO PRI_RUN MODE (HSPLL)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3
T1OSI
OSC1
TOST(1) TPLL(1)
PLL Clock
Output 1 2
n-1 n
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.
INTRC 1 2 3 n-1 n
Clock Transition
OSC1
CPU
Clock
Peripheral
Clock
Program
Counter PC PC + 2 PC + 4
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
SCS1:SCS0 bits Changed OSTS bit Set
Note 1: TOST = 1024 TOSC; TPLL = 2 ms (approx). These intervals are not shown to scale.
OSC1
CPU
Clock
Peripheral
Clock
Sleep
Program
Counter PC PC + 2
OSC1
TOST(1) TPLL(1)
PLL Clock
Output
CPU Clock
Peripheral
Clock
Program
PC PC + 2 PC + 4 PC + 6
Counter
Wake Event OSTS bit Set
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
MCLRE
MCLR ( )_IDLE
Sleep
WDT
Time-out
OST/PWRT
OST 1024 Cycles
Chip_Reset
10-Bit Ripple Counter R Q
OSC1
32 μs
PWRT 65.5 ms
INTRC(1) 11-Bit Ripple Counter
Enable PWRT
Enable OST(2)
Note 1: This is the INTRC source from the internal oscillator block and is separate from the RC oscillator of the CLKI pin.
2: See Table 4-2 for time-out situations.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: It is recommended that the POR bit be set after a Power-on Reset has been detected, so that subsequent
Power-on Resets may be detected.
2: Brown-out Reset is said to have occurred when BOR is ‘0’ and POR is ‘1’ (assuming that POR was set to
‘1’ by software immediately after a Power-on Reset).
4.5.2 OSCILLATOR START-UP Since the time-outs occur from the POR pulse, if MCLR
is kept low long enough, all time-outs will expire.
TIMER (OST)
Bringing MCLR high will begin execution immediately
The Oscillator Start-up Timer (OST) provides a (Figure 4-5). This is useful for testing purposes, or to
1024 oscillator cycle (from OSC1 input) delay after the synchronize more than one PIC18FXXXX device
PWRT delay is over (parameter 33). This ensures that operating in parallel.
the crystal oscillator or resonator has started and is
stabilized.
The OST time-out is invoked only for XT, LP, HS and
HSPLL modes and only on Power-on Reset, or on exit
from most power-managed modes.
HSPLL 66 ms(1) + 1024 TOSC + 2 ms(2) 1024 TOSC + 2 ms(2) 1024 TOSC + 2 ms(2)
HS, XT, LP 66 ms(1) + 1024 TOSC 1024 TOSC 1024 TOSC
EC, ECIO 66 ms(1) — —
RC, RCIO 66 ms(1) — —
INTIO1, INTIO2 66 ms(1) — —
Note 1: 66 ms (65.5 ms) is the nominal Power-up Timer (PWRT) delay.
2: 2 ms is the nominal time required for the PLL to lock.
VDD
MCLR
INTERNAL POR
TPWRT
OST TIME-OUT
INTERNAL RESET
FIGURE 4-4: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 1
VDD
MCLR
INTERNAL POR
TPWRT
OST TIME-OUT
INTERNAL RESET
FIGURE 4-5: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 2
VDD
MCLR
INTERNAL POR
TPWRT
OST TIME-OUT
INTERNAL RESET
MCLR
INTERNAL POR
TPWRT
PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-7: TIME-OUT SEQUENCE ON POR w/PLL ENABLED (MCLR TIED TO VDD)
VDD
MCLR
INTERNAL POR
TPWRT
PLL TIME-OUT
INTERNAL RESET
TABLE 4-3: STATUS BITS, THEIR SIGNIFICANCE AND THE INITIALIZATION CONDITION FOR
RCON REGISTER
Program RCON Register STKPTR Register
Condition
Counter SBOREN RI TO PD POR BOR STKFUL STKUNF
Power-on Reset 0000h 1 1 1 1 0 0 0 0
RESET Instruction 0000h u(2) 0 u u u u u u
Brown-out Reset 0000h u(2) 1 1 1 u 0 u u
MCLR Reset during 0000h u(2) u 1 u u u u u
power-managed Run modes
MCLR Reset during 0000h u(2) u 1 0 u u u u
power-managed Idle modes and
Sleep
WDT time-out during full power 0000h u(2) u 0 u u u u u
or power-managed Run modes
MCLR during full-power 0000h u(2) u u u u u u u
execution
Stack Full Reset (STVREN = 1) 0000h u(2) u u u u u 1 u
Stack Underflow Reset 0000h u(2) u u u u u u 1
(STVREN = 1)
Stack Underflow Error (not an 0000h u(2) u u u u u u 1
actual Reset, STVREN = 0)
WDT time-out during PC + 2(1) u(2) u 0 0 u u u u
power-managed Idle or
Sleep modes
Interrupt exit from PC + 2(1) u(2) u u 0 u u u u
power-managed modes
Legend: u = unchanged
Note 1: When the wake-up is due to an interrupt and the GIEH or GIEL bits are set, the PC is loaded with the
interrupt vector (008h or 0018h).
2: Reset state is ‘1’ for POR and unchanged for all other Resets when software BOR is enabled
(BOREN1:BOREN0 Configuration bits = 01 and SBOREN = 1); otherwise, the Reset state is ‘0’.
FIGURE 5-1: PROGRAM MEMORY MAP AND STACK FOR PIC18F6390/6490/8390/8490 DEVICES
PIC18F6390/8390 PIC18F6490/8490
PC<20:0> PC<20:0>
CALL,RCALL,RETURN 21 CALL,RCALL,RETURN 21
RETFIE,RETLW RETFIE,RETLW
Stack Level 1 Stack Level 1
• •
• •
• •
On-Chip
Program Memory On-Chip
1FFFh Program Memory
2000h
3FFFh
4000h
User Memory Space
1FFFFFh 1FFFFFh
11111
11110
Top-of-Stack Registers 11101 Stack Pointer
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
Q1
Q2 Internal
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.
Figure 5-4 shows an example of how instruction words The use of ‘1111’ in the 4 MSbs of an instruction
are stored in the program memory. specifies a special form of NOP. If the instruction is
executed in proper sequence – immediately after the
The CALL and GOTO instructions have the absolute pro- first word – the data in the second word is accessed
gram memory address embedded into the instruction. and used by the instruction sequence. If the first word
Since instructions are always stored on word bound- is skipped for some reason and the second word is
aries, the data contained in the instruction is a word executed by itself, a NOP is executed instead. This is
address. The word address is written to PC<20:1>, necessary for cases when the two-word instruction is
which accesses the desired byte address in program preceded by a conditional instruction that changes the
memory. Instruction #2 in Figure 5-4 shows how the PC. Example 5-4 shows how this works.
instruction, GOTO 0006h, is encoded in the program
memory. Program branch instructions, which encode a Note: See Section 5.5 “Program Memory and
relative address offset, operate in the same manner. The the Extended Instruction Set” for
offset value stored in a branch instruction represents the information on two-word instructions in the
extended instruction set.
= 0011
Bank 3
Access Bank
00h
Access RAM Low
5Fh
Access RAM High 60h
(SFRs) FFh
Unused
to Read as 00h
= 1110
Bank 14
EFFh
00h Unimplemented F00h
= 1111 F58h
Bank 15 F60h Banked SFRs
FFh SFR
FFFh
BSR(1)
Data Memory From Opcode(2)
7 0 000h 00h 7 0
0 0 0 0 0 0 1 0 Bank 0 11 11 11 11 11 1 1 1
FFh
100h 00h
Bank 1
Bank Select(2) 200h FFh
00h
Bank 2
300h FFh
00h
Bank 3
through
Bank 13
FFh
E00h
00h
Bank 14
F00h FFh
00h
Bank 15
FFFh FFh
Note 1: The Access RAM bit of the instruction can be used to force an override of the selected bank (BSR<3:0>) to
the registers of the Access Bank.
2: The MOVFF instruction embeds the entire 12-bit address in the instruction.
5.3.2 ACCESS BANK Using this “forced” addressing allows the instruction to
operate on a data address in a single cycle without
While the use of the BSR with an embedded 8-bit
updating the BSR first. For 8-bit addresses of 80h and
address allows users to address the entire range of
above, this means that users can evaluate and operate
data memory, it also means that the user must always
on SFRs more efficiently. The Access RAM below 60h
ensure that the correct bank is selected. Otherwise,
is a good place for data values that the user might need
data may be read from or written to the wrong location.
to access rapidly, such as immediate computational
This can be disastrous if a GPR is the intended target
results or common program variables. Access RAM
of an operation but an SFR is written to instead.
also allows for faster and more code efficient context
Verifying and/or changing the BSR for each read or
saving and switching of variables.
write to data memory can become very inefficient.
The mapping of the Access Bank is slightly different
To streamline access for the most commonly used data
when the extended instruction set is enabled (XINST
memory locations, the data memory is configured with
Configuration bit = 1). This is discussed in more detail
an Access Bank, which allows users to access a
in Section 5.6.3 “Mapping the Access Bank in
mapped block of memory without specifying a BSR.
Indexed Literal Offset Mode”.
The Access Bank consists of the first 96 bytes of
memory (00h-5Fh) in Bank 0 and the last 160 bytes of
5.3.3 GENERAL PURPOSE
memory (60h-FFh) in Block 15. The lower half is known
REGISTER FILE
as the “Access RAM” and is composed of GPRs. This
upper half is where the device’s SFRs are mapped. PIC18 devices may have banked memory in the GPR
These two areas are mapped contiguously in the area. This is data RAM, which is available for use by all
Access Bank and can be addressed in a linear fashion instructions. GPRs start at the bottom of Bank 0
by an 8-bit address (Figure 5-5). (address 000h) and grow upwards towards the bottom
of the SFR area. GPRs are not initialized by a
The Access Bank is used by core PIC18 instructions
Power-on Reset and are unchanged on all other
that include the Access RAM bit (the ‘a’ parameter in
Resets.
the instruction). When ‘a’ is equal to ‘1’, the instruction
uses the BSR and the 8-bit address included in the
opcode for the data memory address. When ‘a’ is ‘0’,
however, the instruction is forced to use the Access
Bank address map; the current value of the BSR is
ignored entirely.
SPBRG1 EUSART1 Baud Rate Generator Register Low Byte 0000 0000 61, 201
RCREG1 EUSART1 Receive Register 0000 0000 61, 208
TXREG1 EUSART1 Transmit Register 0000 0000 61, 206
TXSTA1 CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 61, 198
RCSTA1 SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 61, 199
IPR3 — LCDIP RC2IP TX2IP — — — — -111 ---- 61, 106
PIR3 — LCDIF RC2IF TX2IF — — — — -000 ---- 61, 100
PIE3 — LCDIE RC2IE TX2IE — — — — -000 ---- 61, 103
IPR2 OSCFIP CMIP — — BCLIP HLVDIP TMR3IP CCP2IP 11-- 1111 61, 105
PIR2 OSCFIF CMIF — — BCLIF HLVDIF TMR3IF CCP2IF 00-- 0000 61, 99
PIE2 OSCFIE CMIE — — BCLIE HLVDIE TMR3IE CCP2IE 00-- 0000 61, 102
IPR1 — ADIP RC1IP TX1IP SSPIP CCP1IP TMR2IP TMR1IP -111 1111 61, 104
PIR1 — ADIF RC1IF TX1IF SSPIF CCP1IF TMR2IF TMR1IF -000 0000 61, 98
PIE1 — ADIE RC1IE TX1IE SSPIE CCP1IE TMR2IE TMR1IE -000 0000 61, 101
OSCTUNE INTSRC PLLEN(3) — TUN4 TUN3 TUN2 TUN1 TUN0 00-0 0000 35, 61
TRISJ(2) PORTJ Data Direction Register 1111 1111 62, 130
TRISH(2) PORTH Data Direction Register 1111 1111 62, 128
TRISG — — — PORTG Data Direction Register ---1 1111 62, 126
TRISF PORTF Data Direction Register 1111 1111 62, 124
TRISE PORTE Data Direction Register — — — — 1111 ---- 62, 121
TRISD PORTD Data Direction Register 1111 1111 62, 119
TRISC PORTC Data Direction Register 1111 1111 62, 117
TRISB PORTB Data Direction Register 1111 1111 62, 114
TRISA TRISA7(5) TRISA6(5) PORTA Data Direction Register 1111 1111 62, 111
LATJ(2) LATJ Data Output Register xxxx xxxx 62, 130
LATH(2) LATH Data Output Register xxxx xxxx 62, 128
LATG — — — LATG Data Output Register ---x xxxx 62, 126
LATF LATF Data Output Register xxxx xxxx 62, 124
LATE LATE Data Output Register — — — — xxxx ---- 62, 121
LATD LATD Data Output Register xxxx xxxx 62, 119
LATC LATC Data Output Register xxxx xxxx 62, 117
LATB LATB Data Output Register xxxx xxxx 62, 114
LATA LATA7(5) LATA6(5) LATA Data Output Register xxxx xxxx 62, 111
PORTJ(2) Read PORTJ pins, Write PORTJ Data Latch xxxx xxxx 62, 130
PORTH(2) Read PORTH pins, Write PORTH Data Latch xxxx xxxx 62, 128
PORTG — — RG5(4) Read PORTG pins <4:0>, Write PORTG Data Latch <4:0> --xx xxxx 62, 126
PORTF Read PORTF pins, Write PORTF Data Latch xxxx xxxx 62, 124
PORTE Read PORTE pins, Write PORTE Data Latch — — — — xxxx ---- 62, 121
PORTD Read PORTD pins, Write PORTD Data Latch xxxx xxxx 62, 119
PORTC Read PORTC pins, Write PORTC Data Latch xxxx xxxx 62, 117
PORTB Read PORTB pins, Write PORTB Data Latch xxxx xxxx 62, 114
PORTA RA7(5) RA6(5) Read PORTA pins, Write PORTA Data Latch xx0x 0000 62, 111
Legend: x = unknown, u = unchanged, – = unimplemented, q = value depends on condition
Note 1: The SBOREN bit is only available when the BOREN1:BOREN0 Configuration bits = 01; otherwise it is disabled and reads as ‘0’. See
Section 4.4 “Brown-out Reset (BOR)”.
2: These registers and/or bits are not implemented on 64-pin devices; read as ‘0’.
3: The PLLEN bit is only available in specific oscillator configurations; otherwise, it is disabled and reads as ‘0’. See Section 2.6.4 “PLL in
INTOSC Modes”.
4: The RG5 bit is only available when Master Clear is disabled (MCLRE Configuration bit = 0); otherwise, RG5 reads as ‘0’. This bit is
read-only.
5: RA6/RA7 and their associated latch and direction bits are individually configured as port pins based on various primary oscillator modes.
When disabled, these bits read as ‘0’.
6: These registers are implemented but unused in 64-pin devices and may be used as general-purpose data RAM if required.
SPBRGH1 EUSART1 Baud Rate Generator Register High Byte 0000 0000 62, 201
BAUDCON1 ABDOVF RCIDL — SCKP BRG16 — WUE ABDEN 01-0 0-00 62, 200
LCDDATA23(6) S47C3 S46C3 S45C3 S44C3 S43C3 S42C3 S41C3 S40C3 xxxx xxxx 63, 261
LCDDATA22(6) S39C3 S38C3 S37C3 S36C3 S35C3 S34C3 S33C3 S32C3 xxxx xxxx 63, 261
LCDDATA21 S31C3 S30C3 S29C3 S28C3 S27C3 S26C3 S25C3 S24C3 xxxx xxxx 63, 261
LCDDATA20 S23C3 S22C3 S21C3 S20C3 S19C3 S18C3 S17C3 S16C3 xxxx xxxx 63, 261
LCDDATA19 S15C3 S14C3 S13C3 S12C3 S11C3 S10C3 S09C3 S08C3 xxxx xxxx 63, 261
LCDDATA18 S07C3 S06C3 S05C3 S04C3 S03C3 S02C3 S01C3 S00C3 xxxx xxxx 63, 261
LCDDATA17(6) S47C2 S46C2 S45C2 S44C2 S43C2 S42C2 S41C2 S40C2 xxxx xxxx 63, 261
LCDDATA16(6) S39C2 S38C2 S37C2 S36C2 S35C2 S34C2 S33C2 S32C2 xxxx xxxx 63, 261
LCDDATA15 S31C2 S30C2 S29C2 S28C2 S27C2 S26C2 S25C2 S24C2 xxxx xxxx 63, 261
LCDDATA14 S23C2 S22C2 S21C2 S20C2 S19C2 S18C2 S17C2 S16C2 xxxx xxxx 63, 261
LCDDATA13 S15C2 S14C2 S13C2 S12C2 S11C2 S10C2 S09C2 S08C2 xxxx xxxx 63, 261
LCDDATA12 S07C2 S06C2 S05C2 S04C2 S03C2 S02C2 S01C2 S00C2 xxxx xxxx 63, 261
LCDDATA11(6) S47C1 S46C1 S45C1 S44C1 S43C1 S42C1 S41C1 S40C1 xxxx xxxx 63, 261
SPBRG2 AUSART2 Baud Rate Generator Register 0000 0000 63, 220
RCREG2 AUSART2 Receive Register 0000 0000 63, 224
TXREG2 AUSART2 Transmit Register 0000 0000 63, 222
TXSTA2 CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 63, 218
RCSTA2 SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 63, 219
LCDDATA10(6) S39C1 S38C1 S37C1 S36C1 S35C1 S34C1 S33C1 S32C1 xxxx xxxx 63, 261
LCDDATA9 S31C1 S30C1 S29C1 S28C1 S27C1 S26C1 S25C1 S24C1 xxxx xxxx 63, 261
LCDDATA8 S23C1 S22C1 S21C1 S20C1 S19C1 S18C1 S17C1 S16C1 xxxx xxxx 63, 261
LCDDATA7 S15C1 S14C1 S13C1 S12C1 S11C1 S10C1 S09C1 S08C1 xxxx xxxx 63, 261
LCDDATA6 S07C1 S06C1 S05C1 S04C1 S03C1 S02C1 S01C1 S00C1 xxxx xxxx 63, 261
LCDDATA5(6) S47C0 S46C0 S45C0 S44C0 S43C0 S42C0 S41C0 S40C0 xxxx xxxx 63, 261
LCDDATA4(6) S39C0 S38C0 S37C0 S36C0 S35C0 S34C0 S33C0 S32C0 xxxx xxxx 63, 261
LCDDATA3 S31C0 S30C0 S29C0 S28C0 S27C0 S26C0 S25C0 S24C0 xxxx xxxx 63, 261
LCDDATA2 S23C0 S22C0 S21C0 S20C0 S19C0 S18C0 S17C0 S16C0 xxxx xxxx 63, 261
LCDDATA1 S15C0 S14C0 S13C0 S12C0 S11C0 S10C0 S09C0 S08C0 xxxx xxxx 63, 261
LCDDATA0 S07C0 S06C0 S05C0 S04C0 S03C0 S02C0 S01C0 S00C0 xxxx xxxx 63, 261
LCDSE5(2) SE47 SE46 SE45 SE44 SE43 SE42 SE41 SE40 0000 0000 64, 261
LCDSE4(2) SE39 SE38 SE37 SE36 SE35 SE34 SE33 SE32 0000 0000 64, 260
LCDSE3 SE31 SE30 SE29 SE28 SE27 SE26 SE25 SE24 0000 0000 64, 260
LCDSE2 SE23 SE22 SE21 SE20 SE19 SE18 SE17 SE16 0000 0000 64, 260
LCDSE1 SE15 SE14 SE13 SE12 SE11 SE10 SE9 SE8 0000 0000 64, 260
LCDSE0 SE7 SE6 SE5 SE4 SE3 SE2 SE1 SE0 0000 0000 64, 260
LCDCON LCDEN SLPEN WERR — CS1 CS0 LMUX1 LMUX0 000- 0000 64, 258
LCDPS WFT BIASMD LCDA WA LP3 LP2 LP1 LP0 0000 0000 64, 259
Legend: x = unknown, u = unchanged, – = unimplemented, q = value depends on condition
Note 1: The SBOREN bit is only available when the BOREN1:BOREN0 Configuration bits = 01; otherwise it is disabled and reads as ‘0’. See
Section 4.4 “Brown-out Reset (BOR)”.
2: These registers and/or bits are not implemented on 64-pin devices; read as ‘0’.
3: The PLLEN bit is only available in specific oscillator configurations; otherwise, it is disabled and reads as ‘0’. See Section 2.6.4 “PLL in
INTOSC Modes”.
4: The RG5 bit is only available when Master Clear is disabled (MCLRE Configuration bit = 0); otherwise, RG5 reads as ‘0’. This bit is
read-only.
5: RA6/RA7 and their associated latch and direction bits are individually configured as port pins based on various primary oscillator modes.
When disabled, these bits read as ‘0’.
6: These registers are implemented but unused in 64-pin devices and may be used as general-purpose data RAM if required.
Legend:
R = Readable bit W = 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
Bank 1
and FFFh. This is the same as through 60h
locations F60h to FFFh 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
Instruction: TBLRD*
Program Memory
Table Pointer(1)
Table Latch (8-bit)
TBLPTRU TBLPTRH TBLPTRL
TABLAT
Program Memory
(TBLPTR)
Program Memory
7.2 Operation
Example 7-1 shows the instruction sequence for an
8 x 8 unsigned multiplication. Only one instruction is
required when one of the arguments is already loaded
in the WREG register.
Example 7-2 shows the sequence to do an 8 x 8 signed
multiplication. To account for the signed bits of the
arguments, each argument’s Most Significant bit (MSb)
is tested and the appropriate subtractions are done.
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:0>
PIE1<6:0> INT2IP
IPR1<6:0> INT3IF
INT3IE
INT3IP
PIR2<7:6, 3:0> GIE/GIEH
PIE2<7:6, 3:0>
IPR2<7:6, 3:0> IPEN
PIR3<6:4> IPEN
PIE3<6:4>
IPR3<6:4> PEIE/GIEL
IPEN
PIR1<6:0>
PIE1<6:0>
IPR1<6:0>
PIR2<7:6, 3:0>
PIE2<7:6, 3:0>
IPR2<7:6, 3:0> Interrupt to CPU
TMR0IF Vector to Location
TMR0IE IPEN
PIR3<6:4> 0018h
PIE3<6:4> TMR0IP
IPR3<6:4>
RBIF
RBIE
RBIP GIEH/GIE
GIEL/PEIE
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
• TRIS register (data direction register) Reading the PORTA register reads the status of the
pins, whereas writing to it will write to the port latch.
• PORT register (reads the levels on the pins of the
device) The Data Latch register (LATA) is also memory mapped.
• LAT register (output latch) Read-modify-write operations on the LATA register read
and write the latched output value for PORTA.
The Data Latch (LAT register) is useful for
read-modify-write operations on the value that the I/O The RA4 pin is multiplexed with the Timer0 module
pins are driving. clock input and the LCD segment drive to become the
RA4/T0CKI/SEG14 pin. Pins RA6 and RA7 are
A simplified model of a generic I/O port, without the multiplexed with the main oscillator pins; they are
interfaces to other peripherals, is shown in Figure 9-1. enabled as oscillator or I/O pins by the selection of the
main oscillator in the Configuration register (see
FIGURE 9-1: GENERIC I/O PORT Section 23.1 “Configuration Bits” for details). When
OPERATION they are not used as port pins, RA6 and RA7 and their
associated TRIS and LAT bits are read as ‘0’.
The other PORTA pins are multiplexed with analog
RD LAT
inputs and the analog VREF+ and VREF- inputs. The
Data operation of pins RA3:RA0 and RA5 as A/D converter
Bus D Q inputs is selected by clearing or setting the control bits
WR LAT I/O pin(1)
in the ADCON1 register (A/D Control Register 1).
or PORT
CK The RA4/T0CKI/SEG14 pin is a Schmitt Trigger input
Data Latch and an open-drain output. All other PORTA pins have
TTL input levels and full CMOS output drivers.
D Q
The TRISA register controls the direction of the PORTA
WR TRIS pins, even when they are being used as analog inputs.
CK
The user must ensure the bits in the TRISA register are
TRIS Latch Input maintained set when using them as analog inputs.
Buffer
RA5:RA2 are also multiplexed with LCD segment
RD TRIS
drives controlled by bits in the LCDSE1 and
LCDSE2 registers. I/O port functions are only
Q D available when the segments are disabled.
RA0/AN0 RA0 0 O DIG LATA<0> data output. Not affected by analog pin setting.
1 I TTL PORTA<0> data input. Reads ‘0’ on POR.
AN0 1 I ANA A/D input channel 0. Default configuration on POR.
RA1/AN1 RA1 0 O DIG LATA<1> data output. Not affected by analog pin setting.
1 I TTL PORTA<1> data input. Reads ‘0’ on POR.
AN1 1 I ANA A/D input channel 1. Default configuration on POR.
RA2/AN2/VREF-/ RA2 0 O DIG LATA<2> data output. Not affected by analog pin setting; disabled
SEG16 when LCD segment enabled.
1 I TTL PORTA<2> data input. Reads ‘0’ on POR.
AN2 1 I ANA A/D input channel 2. Default configuration on POR.
VREF- 1 I ANA A/D low reference voltage input.
SEG16 x O ANA Segment 16 analog output for LCD.
RA3/AN3/VREF+/ RA3 0 O DIG LATA<3> data output. Output is unaffected by analog pin setting;
SEG17 disabled when LCD segment enabled.
1 I TTL PORTA<3> data input. Reads ‘0’ on POR.
AN3 1 I ANA A/D input channel 3. Default configuration on POR.
VREF+ 1 I ANA A/D high reference voltage input.
SEG17 x O ANA Segment 17 analog output for LCD. Disables all other digital outputs.
RA4/T0CKI/ RA4 0 O DIG LATA<4> data output; disabled when LCD segment enabled.
SEG14 1 I ST PORTA<4> data input.
T0CKI I ST Timer0 clock input.
SEG14 x O ANA Segment 14 analog output for LCD.
RA5/AN4/ RA5 0 O DIG LATA<5> data output. Not affected by analog pin setting; disabled
HLVDIN/SEG15 when LCD segment enabled.
1 I TTL PORTA<5> data input. Reads ‘0’ on POR.
AN4 1 I ANA A/D input channel 5. Default configuration on POR.
HLVDIN 1 I ANA High/Low-Voltage Detect external trip point input.
SEG15 x O ANA Segment 15 analog output for LCD.
OSC2/CLKO/RA6 OSC2 x O ANA Main oscillator feedback output connection (XT, HS and LP modes).
CLKO x O DIG System cycle clock output (FOSC/4) in all oscillator modes except
RCIO, INTIO2 and ECIO.
RA6 0 O DIG LATA<6> data output. Enabled in RCIO, INTIO2 and ECIO modes only.
1 I TTL PORTA<6> data input. Enabled in RCIO, INTIO2 and ECIO modes only.
OSC1/CLKI/RA7 OSC1 x I ANA Main oscillator input connection, all modes except INTIO.
CLKI x I ANA Main clock input connection, all modes except INTIO.
RA7 0 O DIG LATA<7> data output. Available only in INTIO modes; otherwise reads
as ‘0’.
1 I TTL PORTA<7> data input. Available only in INTIO modes; otherwise reads
as ‘0’.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Buffer Input, TTL = TTL Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
RD0/SEG0 RD0 0 O DIG LATD<0> data output; disabled when LCD segment enabled.
1 I ST PORTD<0> data input.
SEG0 x O ANA Segment 0 analog output for LCD.
RD1/SEG1 RD1 0 O DIG LATD<1> data output; disabled when LCD segment enabled.
1 I ST PORTD<1> data input.
SEG1 x O ANA Segment 1 analog output for LCD.
RD2/SEG2 RD2 0 O DIG LATD<2> data output; disabled when LCD segment enabled.
1 I ST PORTD<2> data input.
SEG2 x O ANA Segment 2 analog output for LCD.
RD3/SEG3 RD3 0 O DIG LATD<3> data output; disabled when LCD segment enabled.
1 I ST PORTD<3> data input.
SEG3 x O ANA Segment 3 analog output for LCD.
RD4/SEG4 RD4 0 O DIG LATD<4> data output; disabled when LCD segment enabled.
1 I ST PORTD<4> data input.
SEG4 x O ANA Segment 4 analog output for LCD module.
RD5/SEG5 RD5 0 O DIG LATD<5> data output; disabled when LCD segment enabled.
1 I ST PORTD<5> data input.
SEG5 x O ANA Segment 5 analog output for LCD.
RD6/SEG6 RD6 0 O DIG LATD<6> data output; disabled when LCD segment enabled.
1 I ST PORTD<6> data input.
SEG6 x O ANA Segment 6 analog output for LCD.
RD7/SEG7 RD7 0 O DIG LATD<7> data output; disabled when LCD segment enabled.
1 I ST PORTD<7> data input.
SEG7 x O ANA Segment 7 analog output for LCD.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Buffer Input, TTL = TTL Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
RE4/COM1 RE4 0 O DIG LATE<4> data output; disabled when LCD common enabled.
1 I ST PORTE<4> data input.
COM1 x O ANA Common 1 analog output for LCD.
RE5/COM2 RE5 0 O DIG LATE<5> data output; disabled when LCD common enabled.
1 I ST PORTE<5> data input.
COM2 x O ANA Common 2 analog output for LCD.
RE6/COM3 RE6 0 O DIG LATE<6> data output; disabled when LCD segment enabled.
1 I ST PORTE<6> data input.
COM3 x O ANA Common 3 analog output for LCD.
RE7/CCP2/ RE7 0 O DIG LATE<7> data output; disabled when LCD segment enabled.
SEG31 1 I ST PORTE<7> data input.
CCP2(1) 0 O DIG CCP2 compare output and CCP2 PWM output; takes priority over port data.
1 I ST CCP2 capture input.
SEG31 x O ANA Segment 31 analog output for LCD.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Buffer Input, TTL = TTL Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
Note 1: Alternate assignment for CCP2 when the CCP2MX Configuration bit = 0.
RF0/AN5/ RF0 0 O DIG LATF<0> data output. Output is unaffected by analog input; disabled
SEG18 when LCD segment is enabled.
1 I ST PORTF<0> data input. Reads ‘0’ on POR.
AN5 1 I ANA A/D input channel 5. Default configuration on POR.
SEG18 x O ANA Segment 18 analog output for LCD.
RF1/AN6/ RF1 0 O DIG LATF<1> data output. Output is unaffected by analog input; disabled
C2OUT/SEG19 when LCD segment is enabled.
1 I ST PORTF<1> data input. Reads ‘0’ on POR.
AN6 1 I ANA A/D input channel 6. Default configuration on POR.
C2OUT 0 O DIG Comparator 2 output; takes priority over port data.
SEG19 x O ANA Segment 19 analog output for LCD.
RF2/AN7/ RF2 0 O DIG LATF<2> data output. Output is unaffected by analog input; disabled
C1OUT/SEG20 when LCD segment is enabled.
1 I ST PORTF<2> data input. Reads ‘0’ on POR.
AN7 1 I ANA A/D input channel 7. Default configuration on POR.
C1OUT 0 O TTL Comparator 1 output; takes priority over port data.
SEG20 x O ANA Segment 20 analog output for LCD.
RF3/AN8/ RF3 0 O DIG LATF<3> data output. Output is unaffected by analog input; disabled
SEG21 when LCD segment is enabled.
1 I ST PORTF<3> data input. Reads ‘0’ on POR.
AN8 1 I ANA A/D input channel 8 and Comparator C2+ input. Default input
configuration on POR; not affected by analog output.
SEG21 x O ANA Segment 21 analog output for LCD.
RF4/AN9/ RF4 0 O DIG LATF<4> data output. Output is unaffected by analog input; disabled
SEG22 when LCD segment is enabled.
1 I ST PORTF<4> data input. Reads ‘0’ on POR.
AN9 1 I ANA A/D input channel 9 and Comparator C2- input. Default input
configuration on POR; does not affect digital output.
SEG22 x O ANA Segment 22 analog output for LCD.
RF5/AN10/ RF5 0 O DIG LATF<5> data output. Output unaffected by analog input; disabled
CVREF/SEG23 when either LCD segment or CVREF is enabled.
1 I ST PORTF<5> data input. Reads ‘0’ on POR.
AN10 1 I ANA A/D input channel 10 and Comparator C1+ input. Default input
configuration on POR.
CVREF 0 O ANA Comparator voltage reference output. Enabling this feature disables
digital I/O.
SEG23 x O ANA Segment 23 analog output for LCD.
RF6/AN11/ RF6 0 O DIG LATF<6> data output. Output is unaffected by analog input; disabled
SEG24 when LCD segment is enabled.
1 I ST PORTF<6> data input. Reads ‘0’ on POR.
AN11 1 I ANA A/D input channel 11 and Comparator C1- input. Default input
configuration on POR; does not affect digital output.
SEG24 x O ANA Segment 24 analog output for LCD.
RF7/SS/SEG25 RF7 0 O DIG LATF<7> data output; disabled when LCD segment is enabled.
1 I ST PORTF<7> data input.
SS 1 I TTL Slave select input for MSSP module.
SEG25 x O ANA Segment 25 analog output for LCD.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Buffer Input, TTL = TTL Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
RG0/SEG30 RG0 0 O DIG LATG<0> data output; disabled when LCD segment enabled.
1 I ST PORTG<0> data input.
SEG30 x O ANA Segment 30 analog output for LCD.
RG1/TX2/CK2/ RG1 0 O DIG LATG<1> data output; disabled when LCD segment enabled.
SEG29 1 I ST PORTG<1> data input.
TX2 1 O DIG Synchronous serial data output (AUSART module); takes priority over
port data.
CK2 1 O DIG Synchronous serial data input (AUSART module). User must configure
as an input.
1 I ST Synchronous serial clock input (AUSART module).
SEG29 x O ANA Segment 29 analog output for LCD.
RG2/RX2/DT2/ RG2 0 O DIG LATG<2> data output; disabled when LCD segment enabled.
SEG28 1 I ST PORTG<2> data input.
RX2 1 I ST Asynchronous serial receive data input (AUSART module).
DT2 1 O DIG Synchronous serial data output (AUSART module); takes priority over
port data.
1 I ST Synchronous serial data input (AUSART module). User must configure
as an input.
SEG28 x O ANA Segment 28 analog output for LCD.
RG3/SEG27 RG3 0 O DIG LATG<3> data output; disabled when LCD segment enabled.
1 I ST PORTG<3> data input.
SEG27 0 O ANA Segment 27 analog output for LCD.
RG4/SEG26 RG4 0 O DIG LATG<4> data output; disabled when LCD segment enabled.
1 I ST PORTG<4> data input.
SEG26 x O ANA Segment 26 analog output for LCD.
MCLR/VPP/RG5 MCLR —(1) I ST External Master Clear input; enabled when MCLRE Configuration bit is set.
VPP —(1) I ANA High-voltage detection; used for ICSP™ mode entry detection. Always
available, regardless of pin mode.
RG5 —(1) I ST PORTG<5> data input; enabled when MCLRE Configuration bit is clear.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Buffer Input, TTL = TTL Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
Note 1: RG5 does not have a corresponding TRISG bit.
RH0/SEG47 RH0 0 O DIG-4 LATH<0> data output; disabled when LCD segment enabled.
1 I ST PORTH<0> data input.
SEG47 x O ANA Segment 47 analog output for LCD.
RH1/SEG46 RH1 0 O DIG LATH<1> data output; disabled when LCD segment enabled.
1 I ST PORTH<1> data input.
SEG46 x O ANA Segment 46 analog output for LCD.
RH2/SEG45 RH2 0 O DIG LATH<2> data output; disabled when LCD segment enabled.
1 I ST PORTH<2> data input.
SEG45 x O ANA Segment 45 analog output for LCD.
RH3/SEG44 RH3 0 O DIG LATH<3> data output; disabled when LCD segment enabled.
1 I ST PORTH<3> data input.
SEG44 x O ANA Segment 44 analog output for LCD.
RH4/SEG40 RH4 0 O DIG LATH<4> data output; disabled when LCD segment enabled.
1 I ST PORTH<4> data input.
SEG40 x O ANA Segment 40 analog output for LCD
RH5/SEG41 RH5 0 O DIG LATH<5> data output; disabled when LCD segment enabled.
1 I ST PORTH<5> data input.
SEG41 x O ANA Segment 41 analog output for LCD.
RH6/SEG42 RH6 0 O DIG LATH<6> data output; disabled when LCD segment enabled.
1 I ST PORTH<6> data input.
SEG42 x O ANA Segment 42 analog output for LCD.
RH7/SEG43 RH7 0 O DIG LATH<7> data output; disabled when LCD segment enabled.
1 I ST PORTH<7> data input.
SEG43 x O ANA Segment 43 analog output for LCD.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Buffer Input, TTL = TTL Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
RJ0/SEG32 RJ0 0 O DIG LATJ<0> data output; disabled when LCD segment enabled.
1 I ST PORTJ<0> data input.
SEG32 x O ANA Segment 32 analog output for LCD.
RJ1/SEG33 RJ1 0 O DIG LATJ<1> data output; disabled when LCD segment enabled.
1 I ST PORTJ<1> data input.
SEG33 x O ANA Segment 33 analog output for LCD.
RJ2/SEG34 RJ2 0 O DIG LATJ<2> data output; disabled when LCD segment enabled.
1 I ST PORTJ<2> data input.
SEG34 x O ANA Segment 34 analog output for LCD.
RJ3/SEG35 RJ3 0 O DIG LATJ<3> data output; disabled when LCD segment enabled.
1 I ST PORTJ<3> data input.
SEG35 x O ANA Segment 35 analog output for LCD.
RJ4/SEG39 RJ4 0 O DIG LATJ<4> data output; disabled when LCD segment enabled.
1 I ST PORTJ<4> data input.
SEG39 x O ANA Segment 39 analog output for LCD.
RJ5/SEG38 RJ5 0 O DIG LATJ<5> data output; disabled when LCD segment enabled.
1 I ST PORTJ<5> data input.
SEG38 x O ANA Segment 38 analog output for LCD.
RJ6/SEG37 RJ6 0 O DIG LATJ<6> data output; disabled when LCD segment enabled.
1 I ST PORTJ<6> data input.
SEG37 x O ANA Segment 37 analog output for LCD.
RJ7/SEG36 RJ7 0 O DIG LATJ<7> data output; disabled when LCD segment enabled.
1 I ST PORTJ<7> data input.
SEG36 x O ANA Segment 36 analog output for LCD.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Buffer Input, TTL = TTL Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
FOSC/4 0
1 Sync with Set
1 Internal TMR0L TMR0IF
T0CKI pin Programmable Clocks on Overflow
0
Prescaler
T0SE (2 TCY Delay)
3 8
T0CS
T0PS2:T0PS0 8
Internal Data Bus
PSA
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI maximum prescale.
FOSC/4 0
1 Sync with TMR0 Set
1 Internal TMR0L High Byte TMR0IF
T0CKI pin Programmable Clocks on Overflow
Prescaler 0 8
T0SE (2 TCY Delay)
T0CS 3 Read TMR0L
T0PS2:T0PS0
Write TMR0L
PSA 8
8
TMR0H
8
8
Internal Data Bus
Note: Upon Reset, Timer0 is enabled in 8-bit mode with clock input from T0CKI maximum 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
TMR1 Set
Clear TMR1 TMR1L TMR1IF
High Byte
(CCP Special Event Trigger) on Overflow
Note 1: When 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 T1OSCEN is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
C1
PIC18FXXXX
11.3.2 LOW-POWER TIMER1 OPTION
33 pF
The Timer1 oscillator can operate at two distinct levels
T1OSI
of power consumption based on device configuration.
When the LPT1OSC Configuration bit is set, the Timer1
XTAL
32.768 kHz oscillator operates in a low-power mode. When
LPT1OSC is not set, Timer1 operates at a higher power
T1OSO level. Power consumption for a particular mode is
C2 relatively constant, regardless of the device’s operating
33 pF mode. The default Timer1 configuration is the higher
power mode.
Note: See the Notes with Table 11-1 for additional
information about capacitor selection. As the Low-Power Timer1 mode tends to be more
sensitive to interference, high noise environments may
cause some oscillator instability. The low-power option
is therefore best suited for low noise applications where
power conservation is an important design
consideration.
Legend:
R = Readable bit W = 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 T1OSCEN is cleared, the inverter and feedback resistor are turned off to eliminate power drain.
Read TMR3L
Write TMR3L
8
8
TMR3H
8
8
Internal Data Bus
Note 1: When 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 the timer and not start the A/D conversion on the CCPx 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>
Edge
Select
2
Clock Select
SSPM3:SSPM0
RC3/SCK/
SCL
SMP:CKE 4
2 2
(
TMR2 Output )
Edge
Select Prescaler TOSC
4, 16, 64
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: In Master mode, the overflow bit is not set, since each new reception (and transmission) is initiated by
writing to the SSPBUF register.
2: When enabled, these pins must be properly configured as inputs or outputs.
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
If the Sleep mode is selected, all module clocks are There is also an SMP bit which controls when the data
halted and the transmission/reception will remain in is sampled.
that state until the devices wakes. After the device
returns to Run mode, the module will resume
transmitting and receiving data.
In SPI Slave mode, the SPI Transmit/Receive Shift
register operates asynchronously to the device. This
allows the device to be placed in any power-managed
mode and data to be shifted into the SPI Transmit/
Receive Shift register. When all 8 bits have been
received, the MSSP interrupt flag bit will be set and if
enabled, will wake the device.
Legend:
R = Readable bit W = 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.
2: Bit combinations not specifically listed here are either reserved or implemented in SPI mode only.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Value that will be transmitted when the user initiates an Acknowledge sequence at the end of a receive.
2: If the I2C module is not in the Idle mode, these bits may not be set (no spooling) and the SSPBUF may not
be written (or writes to the SSPBUF are disabled).
DS39629C-page 172
Receiving Address R/W = 0 Receiving Data ACK Receiving Data ACK
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF (PIR1<3>)
Bus master
terminates
transfer
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
PIC18F6390/6490/8390/8490
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
CKP (SSPCON1<4>)
(CKP does not reset to ‘0’ when SEN = 0)
I2C™ SLAVE MODE TIMING WITH SEN = 0 (RECEPTION, 7-BIT ADDRESS)
SCL
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
Data in SCL held low P
sampled while CPU
responds to SSPIF
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
Cleared in software Cleared in software
From SSPIF ISR From SSPIF ISR
SSPBUF is written in software SSPBUF is written in software
Clear by reading
CKP (SSPCON1<4>)
DS39629C-page 173
FIGURE 15-10:
DS39629C-page 174
Clock is held low until Clock is held low until
update of SSPADD has update of SSPADD has
taken place taken place
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte Receive Data Byte
R/W = 0 ACK
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
Bus master
terminates
SSPIF (PIR1<3>) transfer
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
PIC18F6390/6490/8390/8490
UA (SSPSTAT<1>)
Bus master
terminates
Clock is held low until Clock is held low until transfer
update of SSPADD has update of SSPADD has Clock is held low until
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S Sr P
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
DS39629C-page 175
PIC18F6390/6490/8390/8490
15.4.4 CLOCK STRETCHING 15.4.4.3 Clock Stretching for 7-Bit Slave
Both 7 and 10-Bit Slave modes implement automatic Transmit Mode
clock stretching during a transmit sequence. 7-Bit Slave Transmit mode implements clock stretching
The SEN bit (SSPCON2<0>) allows clock stretching to by clearing the CKP bit after the falling edge of the ninth
be enabled during receives. Setting SEN will cause clock, if the BF bit is clear. This occurs regardless of the
the SCL pin to be held low at the end of each data 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
15.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 15-9).
ninth clock at the end of the ACK sequence, if the BF Note 1: If the user loads the contents of SSPBUF,
bit is set, the CKP bit in the SSPCON1 register is setting the BF bit before the falling edge of
automatically cleared, forcing the SCL output to be the ninth clock, the CKP bit will not be
held low. The CKP being cleared to ‘0’ will assert the cleared and clock stretching will not occur.
SCL line low. The CKP bit must be set in the user’s
ISR before reception is allowed to continue. By holding 2: The CKP bit can be set in software
the SCL line low, the user has time to service the ISR regardless of the state of the BF bit.
and read the contents of the SSPBUF before the
15.4.4.4 Clock Stretching for 10-Bit Slave
master device can initiate another receive sequence.
This will prevent buffer overruns from occurring (see Transmit Mode
Figure 15-13). In 10-Bit Slave Transmit mode, clock stretching is
controlled during the first two address sequences by
Note 1: If the user reads the contents of the
the state of the UA bit, just as it is in 10-Bit Slave
SSPBUF before the falling edge of the
Receive mode. The first two addresses are followed
ninth clock, thus clearing the BF bit, the
by a third address sequence which contains the high-
CKP bit will not be cleared and clock
order bits of the 10-bit address and the R/W bit set to
stretching will not occur.
‘1’. After the third address sequence is performed, the
2: The CKP bit can be set in software UA bit is not set, the module is now configured in
regardless of the state of the BF bit. The Transmit mode and clock stretching is controlled by
user should be careful to clear the BF bit the BF flag as in 7-Bit Slave Transmit mode (see
in the ISR before the next receive Figure 15-11).
sequence in order to prevent an overflow
condition.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
SDA DX DX – 1
SCL
Master device
CKP asserts clock
Master device
deasserts clock
WR
SSPCON
DS39629C-page 178
Clock is not held low
because buffer full bit is
clear prior to falling edge Clock is held low until Clock is not held low
of 9th clock CKP is set to ‘1’ because ACK = 1
SDA A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF (PIR1<3>)
Bus master
terminates
transfer
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
PIC18F6390/6490/8390/8490
SSPOV (SSPCON1<6>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
CKP (SSPON1<4>)
CKP
If BF is cleared written
prior to the falling to ‘1’ in
edge of the 9th clock, software
CKP will not be reset BF is set after falling
to ‘0’ and no clock edge of the 9th clock,
stretching will occur CKP is reset to ‘0’ and
clock stretching occurs
I2C™ SLAVE MODE TIMING WITH SEN = 1 (RECEPTION, 7-BIT ADDRESS)
SSPIF (PIR1<3>)
Bus master
terminates
Cleared in software Cleared in software Cleared in software transfer
Cleared in software
BF (SSPSTAT<0>)
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
UA (SSPSTAT<1>)
DS39629C-page 179
PIC18F6390/6490/8390/8490
15.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 deter-
mines which device will be the slave addressed by the When the interrupt is serviced, the source for the inter-
master. The exception is the general call address which rupt can be checked by reading the contents of the
can address all devices. When this address is used, all SSPBUF. The value can be used to determine if the
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 Addressing mode, then the second
The general call address is recognized when the
half of the address is not necessary, the UA bit will not
General Call Enable bit (GCEN) is enabled
be set and the slave will begin receiving data after the
(SSPCON2<7> set). Following a Start bit detect, 8 bits
Acknowledge (Figure 15-15).
are shifted into the SSPSR and the address is
compared against the SSPADD. It is also compared to
the general call address and fixed in hardware.
SCL
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
SSPIF
BF (SSPSTAT<0>)
Cleared in software
SSPBUF is read
SSPOV (SSPCON1<6>) ‘0’
GCEN (SSPCON2<7>)
‘1’
Internal SSPM3:SSPM0
Data Bus SSPADD<6:0>
Read Write
SSPBUF Baud
Rate
Generator
SDA Shift
Clock Arbitrate/WCOL Detect
SDA In Clock
SSPSR
(hold off clock source)
MSb LSb
Receive Enable
Acknowledge
Generate
SCL
SSPM3:SSPM0 SSPADD<6:0>
SDA DX DX – 1
BRG decrements on
Q2 and Q4 cycles
BRG
03h 02h 01h 00h (hold off) 03h 02h
Value
SCL
TBRG
S
Set S (SSPSTAT<3>)
Write to SSPCON2
SDA = 1,
occurs here. At completion of Start bit,
SDA = 1, SCL = 1
hardware clears RSEN bit
SCL (no change). and sets SSPIF
Sr = Repeated Start
DS39629C-page 188
Write SSPCON2<0> SEN = 1 ACKSTAT in
Start condition begins SSPCON2 = 1
From slave, clear ACKSTAT bit SSPCON2<6>
SEN = 0
Transmitting Data or Second Half
Transmit Address to Slave R/W = 0 of 10-bit Address ACK
SDA A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
BF (SSPSTAT<0>)
SEN
PEN
R/W
I 2C™ MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
Write to SSPCON2<4>
to start Acknowledge sequence
SDA = ACKDT (SSPCON2<5>) = 0
Write to SSPCON2<0> (SEN = 1),
begin Start Condition ACK from Master Set ACKEN, start Acknowledge sequence
Master configured as a receiver SDA = ACKDT = 0 SDA = ACKDT = 1
SEN = 0 by programming SSPCON2<3> (RCEN = 1)
Bus master
ACK is not sent terminates
transfer
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SCL S P
Data shifted in on falling edge of CLK Set SSPIF at end
of receive Set SSPIF interrupt
Set SSPIF interrupt at end of Acknow-
Set SSPIF interrupt ledge sequence
at end of receive
at end of Acknowledge
SSPIF sequence
Set P bit
Cleared in software Cleared in software Cleared in software Cleared in software (SSPSTAT<4>)
SDA = 0, SCL = 1 Cleared in
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)
PIC18F6390/6490/8390/8490
DS39629C-page 189
PIC18F6390/6490/8390/8490
15.4.12 ACKNOWLEDGE SEQUENCE 15.4.13 STOP CONDITION TIMING
TIMING A Stop bit is asserted on the SDA pin at the end of a
An Acknowledge sequence is enabled by setting the receive/transmit by setting the Stop Sequence Enable
Acknowledge Sequence Enable bit, ACKEN bit, PEN (SSPCON2<2>). At the end of a receive/
(SSPCON2<4>). When this bit is set, the SCL pin is transmit, the SCL line is held low after the falling edge
pulled low and the contents of the Acknowledge data bit of the ninth clock. When the PEN bit is set, the master
are presented on the SDA pin. If the user wishes to gen- will assert the SDA line low. When the SDA line is
erate an Acknowledge, then the ACKDT bit should be sampled low, the Baud Rate Generator is reloaded and
cleared. If not, the user should set the ACKDT bit before counts down to ‘0’. When the Baud Rate Generator
starting an Acknowledge sequence. The Baud Rate times out, the SCL pin will be brought high and one
Generator then counts for one rollover period (TBRG) TBRG (Baud Rate Generator rollover count) later, the
and the SCL pin is deasserted (pulled high). When the SDA pin will be deasserted. When the SDA pin is sam-
SCL pin is sampled high (clock arbitration), the Baud pled high while SCL is high, the P bit (SSPSTAT<4>) is
Rate Generator counts for TBRG. The SCL pin is then set. A TBRG later, the PEN bit is cleared and the SSPIF
pulled low. Following this, the ACKEN bit is automatically bit is set (Figure 15-24).
cleared, the Baud Rate Generator is turned off and the
MSSP module then goes into Idle mode (Figure 15-23). 15.4.13.1 WCOL Status Flag
If the user writes the SSPBUF when a Stop sequence
15.4.12.1 WCOL Status Flag is in progress, then the WCOL bit is set and the
If the user writes the SSPBUF when an Acknowledge contents of the buffer are unchanged (the write doesn’t
sequence is in progress, then WCOL is set and the occur).
contents of the buffer are unchanged (the write doesn’t
occur).
SCL 8 9
SSPIF
Cleared in
Set SSPIF at the end software
of receive Cleared in
software Set SSPIF at the end
of Acknowledge sequence
Note: TBRG = one Baud Rate Generator period.
SDA ACK
P
TBRG TBRG TBRG
SCL brought high after TBRG
SDA asserted low before rising edge of clock
to setup Stop condition
SDA
BCLIF
SDA
SCL
Set SEN, enable Start SEN cleared automatically because of bus collision.
condition if SDA = 1, SCL = 1 MSSP module reset into Idle state.
SEN
SDA sampled low before
Start condition. Set BCLIF.
S bit and SSPIF set because
BCLIF SDA = 0, SCL = 1.
SSPIF and BCLIF are
cleared in software
SSPIF
TBRG TBRG
SDA
FIGURE 15-28: BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
SDA = 0, SCL = 1
Set S Set SSPIF
Less than TBRG TBRG
SCL S
SCL pulled low after BRG
time-out
SEN
Set SEN, enable START
sequence if SDA = 1, SCL = 1
BCLIF ‘0’
SSPIF
SDA = 0, SCL = 1, Interrupts cleared
set SSPIF 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
The SPBRGH1:SPBRG1 register pair controls the period 16.1.1 OPERATION IN POWER-MANAGED
of a free-running timer. In Asynchronous mode, the MODES
BRGH (TXSTA1<2>) and BRG16 (BAUDCON1<3>) bits
also control the baud rate. In Synchronous mode, BRGH The device clock is used to generate the desired baud
is ignored. Table 16-1 shows the formula for computation rate. When one of the power-managed modes is
of the baud rate for different EUSART modes that only entered, the new clock source may be operating at a
apply in Master mode (internally generated clock). different frequency. This may require an adjustment to
the value in the SPBRG1 register pair.
Given the desired baud rate and FOSC, the nearest
integer value for the SPBRGH1:SPBRG1 registers can 16.1.2 SAMPLING
be calculated using the formulas in Table 16-1. From
this, the error in baud rate can be determined. An exam- The data on the RX1 pin is sampled three times by a
ple calculation is shown in Example 16-1. Typical baud majority detect circuit to determine if a high or a low
rates and error values for the various Asynchronous level is present at the RX1 pin.
modes are shown in Table 16-3. It may be advanta-
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: 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 SREN bit = 1 and BRGH bit = 0.
Synchronous Slave mode is entered by clearing bit, 1. Enable the synchronous slave serial port by
CSRC (TXSTA1<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.
16.4.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
BRGH = 0
FOSC = 4.000 MHz FOSC = 2.000 MHz FOSC = 1.000 MHz
BAUD Actual SPBRG Actual SPBRG Actual SPBRG
% % %
RATE Rate (K) value Rate (K) value Rate (K) value
Error Error Error
(K) (decimal) (decimal) (decimal)
0.3 0.300 0.16 207 0.300 -0.16 103 0.300 -0.16 51
1.2 1.202 0.16 51 1.201 -0.16 25 1.201 -0.16 12
2.4 2.404 0.16 25 2.403 -0.16 12 — — —
9.6 8.929 -6.99 6 — — — — — —
19.2 20.833 8.51 2 — — — — — —
57.6 62.500 8.51 0 — — — — — —
115.2 62.500 -45.75 0 — — — — — —
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 (K) value Rate (K) value Rate (K) value Rate (K) value
Error Error Error Error
(decimal) (decimal) (decimal) (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 (K) value Rate (K) value Rate (K) value
Error Error Error
(decimal) (decimal) (decimal)
0.3 — — — — — — 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 — — — — — —
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
SREN bit
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.
17.4.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 the 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
Note 1: Performing a conversion on unimplemented channels will return a floating input measurement.
Legend:
R = Readable bit W = 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:
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
Note 1: If the A/D FRC clock source is selected, a delay of one TCY (instruction cycle) is added before the A/D
clock starts. This allows the SLEEP instruction to be executed before starting a conversion.
CHS3:CHS0
1011
AN11
1010
AN10
1001
AN9
1000
AN8
0111
AN7
0110
AN6
0101
AN5
0100
AN4
VAIN
(Input Voltage) 0011
10-Bit AN3
A/D
Converter 0010
AN2
0001
VCFG1:VCFG0 AN1
AVDD(1) 0000
AN0
X0
VREF+ X1
Reference 1X
Voltage VREF- 0X
AVSS(1)
1022 LSB
1022.5 LSB
1023 LSB
1023.5 LSB
• Set GIE bit
3. Wait the required acquisition time (if required).
4. Start conversion:
Analog Input Voltage
• Set GO/DONE bit (ADCON0<1>)
VSS
FIGURE 18-5: A/D CONVERSION TAD CYCLES (ACQT<2:0> = 010, TACQ = 4 TAD)
1 2 3 4 1 2 3 4 5 6 7 8 9 10 11 TAD1
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Automatic
Acquisition Conversion starts Discharge
Time (Holding capacitor is disconnected)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
RF1/AN6/C2OUT*/SEG19
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
RF5/AN10/ A VIN+ C1 C1OUT A VIN+ C1 C1OUT
RF5/AN10/
CVREF/SEG23 CVREF/SEG23
RF2/AN7/C1OUT*/SEG20
RF4/AN9/ A VIN-
SEG22 RF4/AN9/
RF3/AN8/ C2 C2OUT A VIN-
D VIN+ SEG22
SEG21 RF3/AN8/ C2 C2OUT
D VIN+
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 VIN- RF6/AN11/ A
SEG24 SEG24 CIS = 0 VIN-
RF5/AN10/ A VIN+ C1 C1OUT RF5/AN10/ A CIS = 1
VIN+ C1 C1OUT
CVREF/SEG23 CVREF/SEG23
RF2/AN7/C1OUT*/SEG20 RF4/AN9/ A
SEG22 CIS = 0 VIN-
RF3/AN8/ A CIS = 1
RF4/AN9/ D VIN- SEG21 VIN+ C2 C2OUT
SEG22
RF3/AN8/ D VIN+ C2 Off (Read as ‘0’)
SEG21 CVREF
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.
VIN+
19.5 Comparator Outputs
+
Output The comparator outputs are read through the CMCON
VIN- –
register. These bits are read-only. The comparator
outputs may also be directly output to the RF2 and RF1
I/O pins. When enabled, multiplexers in the output path
of the RF2 and RF1 pins will switch and the output of
each pin will be the unsynchronized output of the
comparator. The uncertainty of each of the
VIN- comparators is related to the input offset voltage and
the response time given in the specifications.
VIN+ Figure 19-3 shows the comparator output block
diagram.
The TRISF bits will still function as an output enable/
Output disable for the RF2 and RF1 pins while in this mode.
The polarity of the comparator outputs can be changed
using the C2INV and C1INV bits (CMCON<5:4>).
19.3.1 EXTERNAL REFERENCE SIGNAL Note 1: When reading the PORT register, all pins
When external voltage references are used, the configured as analog inputs will read as a
comparator module can be configured to have the com- ‘0’. Pins configured as digital inputs will
parators operate from the same, or different reference convert an analog input according to the
sources. However, threshold detector applications may Schmitt Trigger input specification.
require the same reference. The reference signal must 2: Analog levels on any pin defined as a
be between VSS and VDD and can be applied to either digital input may cause the input buffer to
pin of the comparator(s). consume more current than is specified.
MULTIPLEX
+
Port pins
To RF2 or
RF1 pin
- D Q Bus
CxINV Data
Read CMCON EN
D Q Set
CMIF
bit
EN CL
From
Other
Reset Comparator
VDD
VT = 0.6V RIC
RS < 10k
Comparator
AIN Input
CPIN ILEAKAGE
VA VT = 0.6V ±500 nA
5 pF
VSS
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: CVROE overrides the TRISF<5> bit setting if enabled for output; RF5 must also be configured as an input
by setting TRISF<5> to ‘1’.
CVRSS = 1
VREF+
VDD
CVRSS = 0 8R
CVR3:CVR0
CVREN R
16-to-1 MUX
16 Steps
CVREF
R
R
R
CVRR 8R
CVRSS = 1
VREF-
CVRSS = 0
PIC18FXXXX
CVREF
R(1)
Module
+
Voltage RF5 CVREF Output
–
Reference
Output
Impedance
Note 1: R is dependent upon the voltage reference configuration bits, CVRCON<3:0> and CVRCON<5>.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: HLVDL3:HLVDL0 modes that result in a trip point below the valid operating voltage of the device are not
tested.
Set
HLVDIF
HLVDEN
Internal Voltage
BOREN Reference
VDD
VLVD
HLVDIF
Enable HLVD
TIRVST
IRVST
HLVDIF cleared in software
Internal Reference is stable
CASE 2:
VDD
VLVD
HLVDIF
Enable HLVD
TIRVST
IRVST
Internal Reference is stable
HLVDIF cleared in software
VLVD
VDD
HLVDIF
Enable HLVD
IRVST TIRVST
CASE 2:
VLVD
VDD
HLVDIF
Enable HLVD
IRVST TIRVST
LCDDATAx SE<47:0>
Data Bus Registers 192-to-48
24 x 8 MUX To I/O Pads
(= 4 x 48)
Timing Control
LCDCON COM3:COM0
To I/O Pads
LCDPS
LCDSEx
FOSC/4
Maximum Maximum
Number of Number of
LMUX1:LMUX0 Multiplex Bias
Pixels Pixels
(PIC18F6X90) (PIC18F8X90)
00 Static (COM0) 32 48 Static
01 1/2 (COM1:COM0) 64 96 1/2 or 1/3
10 1/3 (COM2:COM0) 96 144 1/2 or 1/3
11 1/4 (COM3:COM0) 128 192 1/3
Legend:
R = Readable bit W = 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
COM0
COM1
COM2
COM3
System Clock
(FOSC/4) ÷8192
÷4 STAT
TMR1 32 kHz ÷32 ÷1, 2, 3, 4
Crystal Oscillator ÷2 DUP 4-Bit Prog Prescaler
Ring Counter
TRIP
Internal RC Oscillator QUAD
÷32
Nom FRC = 31.25 kHz LP3:LP0
LMUX1:LMUX0
(LCDPS<3:0>)
(LCDCON<1:0>)
CS1:CS0 LMUX1:LMUX0
(LCDCON<3:2>) (LCDCON<1:0>)
Static
1/2 Bias 1/3 Bias
Bias
VLCD 0 AVSS AVSS AVSS
VLCD 3 To VLCD 1 — 1/2 AVDD 1/3 AVDD
VLCD 2 LCD
VLCD 2 — 1/2 AVDD 2/3 AVDD
VLCD 1 Driver
VLCD 0 VLCD 3 AVDD AVDD AVDD
LCD Bias 3 LCD Bias 2 LCD Bias 1 Connections for External R-ladder
1/2 Bias
AVDD* 10 kΩ* 10 kΩ*
AVSS
* These values are provided for design guidance only and should be optimized for the application by the designer.
Any LCD pixel location not being used for display can The COM signal represents the time slice for each
be used as general purpose RAM. common, while the SEG contains the pixel data.
The pixel signal (COM-SEG) will have no DC com-
22.7 LCD Frame Frequency ponent and it can take only one of the two rms values.
The higher rms value will create a dark pixel and a
The rate at which the COM and SEG outputs changes lower rms value will create a clear pixel.
is called the LCD frame frequency
As the number of commons increases, the delta
between the two rms values decreases. The delta
TABLE 22-4: FRAME FREQUENCY represents the maximum contrast that the display can
FORMULAS have.
Multiplex Frame Frequency = The LCDs can be driven by two types of waveform:
Static Clock Source/(4 x 1 x (LP3:LP0 + 1)) Type-A and Type-B. In Type-A waveform, the phase
changes within each common type, whereas in Type-B
1/2 Clock Source/(2 x 2 x (LP3:LP0 + 1)) waveform, the phase changes on each frame
1/3 Clock Source/(1 x 3 x (LP3:LP0 + 1)) boundary. Thus, Type-A waveform maintains 0 VDC
1/4 Clock Source/(1 x 4 x (LP3:LP0 + 1)) over a single frame, whereas Type-B waveform takes
two frames.
Note: Clock source is (FOSC/4)/8192,
Timer1 Osc/32 or INTRC/32. Note 1: If Sleep has to be executed with LCD
Sleep enabled (LCDCON<SLPEN> is
TABLE 22-5: APPROXIMATE FRAME ‘1’), then care must be taken to execute
FREQUENCY (IN Hz) USING Sleep only when VDC on all the pixels is
FOSC @ 32 MHz, ‘0’.
TIMER1 @ 32.768 kHz OR 2: When the LCD clock source is
INTRC OSCILLATOR (FOSC/4)/8192, if Sleep is executed
irrespective of the LCDCON<SLPEN>
LP3:LP0 Static 1/2 1/3 1/4 setting, the LCD goes into Sleep. Thus,
1 125 125 167 125 take care to see that VDC on all pixels is ‘0’
when Sleep is executed.
2 83 83 111 83
3 62 62 83 62 Figure 22-4 through Figure 22-14 provide waveforms
for static, half-multiplex, one-third-multiplex and
4 50 50 67 50 quarter-multiplex drives for Type-A and Type-B
5 42 42 56 42 waveforms.
6 36 36 48 36
7 31 31 42 31
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
300001h CONFIG1H IESO FCMEN — — FOSC3 FOSC2 FOSC1 FOSC0 00-- 0111
300002h CONFIG2L — — — BORV1 BORV0 BOREN1 BOREN0 PWRTEN ---1 1111
300003h CONFIG2H — — — WDTPS3 WDTPS2 WDTPS1 WDTPS0 WDTEN ---1 1111
300005h CONFIG3H MCLRE — — — — LPT1OSC — CCP2MX 1--- -0-1
300006h CONFIG4L DEBUG XINST — — — — — STVREN 10-- ---1
300008h CONFIG5L — — — — — — — CP ---- ---1
3FFFFEh DEVID1 DEV2 DEV1 DEV0 REV4 REV3 REV2 REV1 REV0 xxxx xxxx(1)
3FFFFFh DEVID2 DEV10 DEV9 DEV8 DEV7 DEV6 DEV5 DEV4 DEV3 0000 xxxx(1)
Legend: x = unknown, u = unchanged, - = unimplemented, q = value depends on condition.
Shaded cells are unimplemented, read as ‘0’.
Note 1: See Register 23-7 for DEVID values. DEVID registers are read-only and cannot be programmed by the user.
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Note 1: The Power-up Timer is decoupled from Brown-out Reset, allowing these features to be independently
controlled.
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit C = Clearable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as ‘0’
-n = Value when device is unprogrammed u = Unchanged from programmed state
Note 1: These values for DEV10:DEV3 may be shared with other devices. The specific device is always identified
by using the entire DEV10:DEV0 bit sequence.
Sleep
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This bit has no effect if the Configuration bit, WDTEN, is enabled.
OSC1
TOST(1) TPLL(1)
1 2 n-1 n
PLL Clock
Output
Clock
Transition
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.
Sample Clock
Device Oscillator
Clock Failure
Output
CM Output
(Q)
Failure
Detected
OSCFIF
Unimplemented Unimplemented
Read ‘0’s Read ‘0’s (Unimplemented Memory Space)
1FFFFFh 1FFFFFh
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 an input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared
if assigned.
3: If the Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The
second cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all
program memory locations have a valid instruction.
5: If the table write starts the write cycle to internal memory, the write will continue until terminated.
BIT-ORIENTED OPERATIONS
BCF f, b, a Bit Clear f 1 1001 bbba ffff ffff None 1, 2
BSF f, b, a Bit Set f 1 1000 bbba ffff ffff None 1, 2
BTFSC f, b, a Bit Test f, Skip if Clear 1 (2 or 3) 1011 bbba ffff ffff None 3, 4
BTFSS f, b, a Bit Test f, Skip if Set 1 (2 or 3) 1010 bbba ffff ffff None 3, 4
BTG f, d, a Bit Toggle f 1 0111 bbba ffff ffff None 1, 2
CONTROL OPERATIONS
BC n Branch if Carry 1 (2) 1110 0010 nnnn nnnn None
BN n Branch if Negative 1 (2) 1110 0110 nnnn nnnn None
BNC n Branch if Not Carry 1 (2) 1110 0011 nnnn nnnn None
BNN n Branch if Not Negative 1 (2) 1110 0111 nnnn nnnn None
BNOV n Branch if Not Overflow 1 (2) 1110 0101 nnnn nnnn None
BNZ n Branch if Not Zero 1 (2) 1110 0001 nnnn nnnn None
BOV n Branch if Overflow 1 (2) 1110 0100 nnnn nnnn None
BRA n Branch Unconditionally 2 1101 0nnn nnnn nnnn None
BZ n Branch if Zero 1 (2) 1110 0000 nnnn nnnn None
CALL n, s Call Subroutine 1st word 2 1110 110s kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
CLRWDT — Clear Watchdog Timer 1 0000 0000 0000 0100 TO, PD
DAW — Decimal Adjust WREG 1 0000 0000 0000 0111 C
GOTO n Go to Address 1st word 2 1110 1111 kkkk kkkk None
2nd word 1111 kkkk kkkk kkkk
NOP — No Operation 1 0000 0000 0000 0000 None
NOP — No Operation 1 1111 xxxx xxxx xxxx None 4
POP — Pop Top of Return Stack (TOS) 1 0000 0000 0000 0110 None
PUSH — Push Top of Return Stack (TOS) 1 0000 0000 0000 0101 None
RCALL n Relative Call 2 1101 1nnn nnnn nnnn None
RESET Software Device Reset 1 0000 0000 1111 1111 All
RETFIE s Return from Interrupt Enable 2 0000 0000 0001 000s GIE/GIEH,
PEIE/GIEL
RETLW k Return with Literal in WREG 2 0000 1100 kkkk kkkk None
RETURN s Return from Subroutine 2 0000 0000 0001 001s None
SLEEP — Go into Standby mode 1 0000 0000 0000 0011 TO, PD
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as an input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared
if assigned.
3: If the Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The
second cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all
program memory locations have a valid instruction.
5: If the table write starts the write cycle to internal memory, the write will continue until terminated.
LITERAL OPERATIONS
ADDLW k Add Literal and WREG 1 0000 1111 kkkk kkkk C, DC, Z, OV, N
ANDLW k AND Literal with WREG 1 0000 1011 kkkk kkkk Z, N
IORLW k Inclusive OR Literal with WREG 1 0000 1001 kkkk kkkk Z, N
LFSR f, k Move Literal (12-bit) 2nd word 2 1110 1110 00ff kkkk None
to FSR(f) 1st word 1111 0000 kkkk kkkk
MOVLB k Move Literal to BSR<3:0> 1 0000 0001 0000 kkkk None
MOVLW k Move Literal to WREG 1 0000 1110 kkkk kkkk None
MULLW k Multiply Literal with WREG 1 0000 1101 kkkk kkkk None
RETLW k Return with Literal in WREG 2 0000 1100 kkkk kkkk None
SUBLW k Subtract WREG from Literal 1 0000 1000 kkkk kkkk C, DC, Z, OV, N
XORLW k Exclusive OR Literal with WREG 1 0000 1010 kkkk kkkk Z, N
DATA MEMORY ↔ PROGRAM MEMORY OPERATIONS
TBLRD* Table Read 2 0000 0000 0000 1000 None
TBLRD*+ Table Read with Post-Increment 0000 0000 0000 1001 None
TBLRD*- Table Read with Post-Decrement 0000 0000 0000 1010 None
TBLRD+* Table Read with Pre-Increment 0000 0000 0000 1011 None
TBLWT* Table Write 2 0000 0000 0000 1100 None 5
TBLWT*+ Table Write with Post-Increment 0000 0000 0000 1101 None 5
TBLWT*- Table Write with Post-Decrement 0000 0000 0000 1110 None 5
TBLWT+* Table Write with Pre-Increment 0000 0000 0000 1111 None 5
Note 1: When a PORT register is modified as a function of itself (e.g., MOVF PORTB, 1, 0), the value used will be that
value present on the pins themselves. For example, if the data latch is ‘1’ for a pin configured as an input and is
driven low by an external device, the data will be written back with a ‘0’.
2: If this instruction is executed on the TMR0 register (and where applicable, ‘d’ = 1), the prescaler will be cleared
if assigned.
3: If the Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The
second cycle is executed as a NOP.
4: Some instructions are two-word instructions. The second word of these instructions will be executed as a NOP
unless the first word of the instruction retrieves the information embedded in these 16 bits. This ensures that all
program memory locations have a valid instruction.
5: If the table write starts the write cycle to internal memory, the write will continue until terminated.
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction format then becomes: {label} instruction argument(s).
Cycles: 1 Q1 Q2 Q3 Q4
Decode Read literal Process Write to PC
Q Cycle Activity:
‘n’ Data
Q1 Q2 Q3 Q4 No No No No
Decode Read Process Write operation operation operation operation
register ‘f’ Data register ‘f’ If No Jump:
Q1 Q2 Q3 Q4
Example: BCF FLAG_REG, 7, 0 Decode Read literal Process No
Before Instruction ‘n’ Data operation
FLAG_REG = C7h
After Instruction Example: HERE BN Jump
FLAG_REG = 47h
Before Instruction
PC = address (HERE)
After Instruction
If Negative = 1;
PC = address (Jump)
If Negative = 0;
PC = address (HERE + 2)
Before Instruction
FLAG_REG = 5Ah
After Instruction
FLAG_REG = 00h
Q1 Q2 Q3 Q4 Cycles: 1
Decode Read Process Write Q Cycle Activity:
register W Data W Q1 Q2 Q3 Q4
Example 1: Decode Read Process Write to
DAW register ‘f’ Data destination
Before Instruction
W = A5h Example: DECF CNT, 1, 0
C = 0
DC = 0 Before Instruction
After Instruction CNT = 01h
W = 05h Z = 0
C = 1 After Instruction
DC = 0 CNT = 00h
Example 2: Z = 1
Before Instruction
W = CEh
C = 0
DC = 0
After Instruction
W = 34h
C = 1
DC = 0
Words: 1 C register f
Cycles: 1
Words: 1
Q Cycle Activity:
Cycles: 1
Q1 Q2 Q3 Q4
Decode Read Process Write to Q Cycle Activity:
register ‘f’ Data destination Q1 Q2 Q3 Q4
Decode Read Process Write to
Example: RLNCF REG, 1, 0 register ‘f’ Data destination
Before Instruction
REG = 1010 1011 Example: RRCF REG, 0, 0
After Instruction Before Instruction
REG = 0101 0111 REG = 1110 0110
C = 0
After Instruction
REG = 1110 0110
W = 0111 0011
C = 0
ADDFSR Add Literal to FSR ADDULNK Add Literal to FSR2 and Return
Syntax: ADDFSR f, k Syntax: ADDULNK k
Operands: 0 ≤ k ≤ 63 Operands: 0 ≤ k ≤ 63
f ∈ [ 0, 1, 2 ] Operation: FSR2 + k → FSR2,
Operation: FSR(f) + k → FSR(f) PC = (TOS)
Status Affected: None Status Affected: None
Encoding: 1110 1000 ffkk kkkk Encoding: 1110 1000 11kk kkkk
Description: The 6-bit literal ‘k’ is added to the Description: The 6-bit literal ‘k’ is added to the
contents of the FSR specified by ‘f’. contents of FSR2. A RETURN is then
Words: 1 executed by loading the PC with the
Cycles: 1 TOS.
Q Cycle Activity: The instruction takes two cycles to
execute; a NOP is performed during the
Q1 Q2 Q3 Q4
second cycle.
Decode Read Process Write to
This may be thought of as a special case
literal ‘k’ Data FSR
of the ADDFSR instruction, where f = 3
(binary ‘11’); it operates only on FSR2.
Words: 1
Example: ADDFSR 2, 23h
Cycles: 2
Before Instruction
FSR2 = 03FFh
Q Cycle Activity:
After Instruction
FSR2 = 0422h Q1 Q2 Q3 Q4
Decode Read Process Write to
literal ‘k’ Data FSR
No No No No
Operation Operation Operation Operation
Note: All PIC18 instructions may take an optional label argument preceding the instruction mnemonic for use in
symbolic addressing. If a label is used, the instruction syntax then becomes: {label} instruction argument(s).
MOVSS Move Indexed to Indexed PUSHL Store Literal at FSR2, Decrement FSR2
Syntax: MOVSS [zs], [zd] Syntax: PUSHL k
Operands: 0 ≤ zs ≤ 127 Operands: 0 ≤ k ≤ 255
0 ≤ zd ≤ 127
Operation: k → (FSR2),
Operation: ((FSR2) + zs) → ((FSR2) + zd) FSR2 – 1→ FSR2
Status Affected: None
Status Affected: None
Encoding:
Encoding: 1111 1010 kkkk kkkk
1st word (source) 1110 1011 1zzz zzzzs
1111 xxxx xzzz zzzzd Description: The 8-bit literal ‘k’ is written to the data
2nd word (dest.)
memory address specified by FSR2. FSR2 is
Description The contents of the source register are decremented by 1 after the operation.
moved to the destination register. The
This instruction allows users to push values
addresses of the source and destination
onto a software stack.
registers are determined by adding the
7-bit literal offsets ‘zs’ or ‘zd’, Words: 1
respectively, to the value of FSR2. Both Cycles: 1
registers can be located anywhere in
Q Cycle Activity:
the 4096-byte data memory space
(000h to FFFh). Q1 Q2 Q3 Q4
The MOVSS instruction cannot use the Decode Read ‘k’ Process Write to
PCL, TOSU, TOSH or TOSL as the data destination
destination register.
If the resultant source address points to
an Indirect Addressing register, the Example: PUSHL 08h
value returned will be 00h. If the Before Instruction
resultant destination address points to FSR2H:FSR2L = 01ECh
an Indirect Addressing register, the Memory (01ECh) = 00h
instruction will execute as a NOP.
After Instruction
Words: 2
FSR2H:FSR2L = 01EBh
Cycles: 2 Memory (01ECh) = 08h
Q Cycle Activity:
Q1 Q2 Q3 Q4
Decode Determine Determine Read
source addr source addr source reg
Decode Determine Determine Write
dest addr dest addr to dest reg
SUBFSR Subtract Literal from FSR SUBULNK Subtract Literal from FSR2 and Return
Syntax: SUBFSR f, k Syntax: SUBULNK k
Operands: 0 ≤ k ≤ 63 Operands: 0 ≤ k ≤ 63
f ∈ [ 0, 1, 2 ] Operation: FSR2 – k → FSR2,
Operation: FSRf – k → FSRf (TOS) → PC
Status Affected: None Status Affected: None
Encoding: 1110 1001 ffkk kkkk Encoding: 1110 1001 11kk kkkk
Description: The 6-bit literal ‘k’ is subtracted from Description: The 6-bit literal ‘k’ is subtracted from the
the contents of the FSR specified contents of the FSR2. A RETURN is then
by ‘f’. executed by loading the PC with the TOS.
Words: 1 The instruction takes two cycles to execute;
Cycles: 1 a NOP is performed during the second cycle.
Q Cycle Activity: This may be thought of as a special case of
the SUBFSR instruction, where f = 3 (binary
Q1 Q2 Q3 Q4
‘11’); it operates only on FSR2.
Decode Read Process Write to
Words: 1
register ‘f’ Data destination
Cycles: 2
Q Cycle Activity:
Example: SUBFSR 2, 23h Q1 Q2 Q3 Q4
Before Instruction Decode Read Process Write to
FSR2 = 03FFh register ‘f’ Data destination
After Instruction No No No No
FSR2 = 03DCh Operation Operation Operation Operation
† NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
6.0V
5.5V
5.0V PIC18FX390/X490
4.5V
Voltage
4.2V
4.0V
3.5V
3.0V
2.5V
2.0V
40 MHz
Frequency
6.0V
5.5V
5.0V
4.5V PIC18LFX390/X490
Voltage
4.2V
4.0V
3.5V
3.0V
2.5V
2.0V
4 MHz 40 MHz
Frequency
FMAX = (16.36 MHz/V) (VDDAPPMIN – 2.0V) + 4 MHz
Note: VDDAPPMIN is the minimum voltage of the PIC® device in the application.
Param
Sym Characteristics Min Typ Max Units Comments
No.
D300 VIOFF Input Offset Voltage — ±5.0 ±10 mV
D301 VICM Input Common Mode Voltage* 0 — VDD – 1.5 V
D302 CMRR Common Mode Rejection Ratio* 55 — — dB
300 TRESP Response Time*(1) — 150 400 ns PIC18FXXXX
300A — 150 600 ns PIC18LFXXXX,
VDD = 2.0V
301 TMC2OV Comparator Mode Change to — — 10 μs
Output Valid*
* These parameters are characterized but not tested.
Note 1: Response time measured with one comparator input at (VDD – 1.5)/2, while the other input transitions
from VSS to VDD.
Param
Sym Characteristics Min Typ Max Units Comments
No.
D310 VRES Resolution VDD/24 — VDD/32 LSb
D311 VRAA Absolute Accuracy — — 1/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’.
VHLVD
VHLVD
HLVDIF
Param
Sym Characteristic Min Typ† Max Units Conditions
No.
D420 HLVD Voltage on VDD HLVDL<3:0> = 0000 2.06 2.17 2.28 V
Transition High-to-Low HLVDL<3:0> = 0001 2.12 2.23 2.34 V
HLVDL<3:0> = 0010 2.24 2.36 2.48 V
HLVDL<3:0> = 0011 2.32 2.44 2.56 V
HLVDL<3:0> = 0100 2.47 2.60 2.73 V
HLVDL<3:0> = 0101 2.65 2.79 2.93 V
HLVDL<3:0> = 0110 2.74 2.89 3.04 V
HLVDL<3:0> = 0111 2.96 3.12 3.28 V
HLVDL<3:0> = 1000 3.22 3.39 3.56 V
HLVDL<3:0> = 1001 3.37 3.55 3.73 V
HLVDL<3:0> = 1010 3.52 3.71 3.90 V
HLVDL<3:0> = 1011 3.70 3.90 4.10 V
HLVDL<3:0> = 1100 3.90 4.11 4.32 V
HLVDL<3:0> = 1101 4.11 4.33 4.55 V
HLVDL<3:0> = 1110 4.36 4.59 4.82 V
D423 VBG Band Gap Reference HLVDL<3:0> = 1111 — 1.2 — V HLVD input external.
Voltage Value
† Production tested at TAMB = 25°C. Specifications over temperature limits ensured by characterization.
VDD/2
RL Pin CL
VSS
CL
Pin
RL = 464Ω
VSS CL = 50 pF for all pins except OSC2/CLKO
and including D and E outputs as ports
OSC1
1 3 3 4 4
2
CLKO
Param
Device Min Typ Max Units Conditions
No.
INTOSC Accuracy @ Freq = 8 MHz, 4 MHz, 2 MHz, 1 MHz, 500 kHz, 250 kHz, 125 kHz(1)
PIC18LF6390/6490/8390/8490 -2 +/-1 2 % +25°C VDD = 2.7-3.3V
-5 — 5 % -10°C to +85°C VDD = 2.7-3.3V
-10 +/-1 10 % -40°C to +85°C VDD = 2.7-3.3V
PIC18F6390/6490/8390/8490 -2 +/-1 2 % +25°C VDD = 4.5-5.5V
-5 — 5 % -10°C to +85°C VDD = 4.5-5.5V
-10 +/-1 10 % -40°C to +85°C VDD = 4.5-5.5V
INTRC Accuracy @ Freq = 31 kHz(2)
PIC18LF6390/6490/8390/8490 26.562 — 35.938 kHz -40°C to +85°C VDD = 2.7-3.3V
PIC18F6390/6490/8390/8490 26.562 — 35.938 kHz -40°C to +85°C VDD = 4.5-5.5V
Legend: Shading of rows is to assist in readability of the table.
Note 1: Frequency calibrated at 25°C. OSCTUNE register can be used to compensate for temperature drift.
2: INTRC frequency after calibration.
OSC1
10 11
CLKO
13 12
14 19 18
16
I/O pin
(Input)
17 15
20, 21
Note: Refer to Figure 26-4 for load conditions.
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
Oscillator
Time-out
Internal
Reset
Watchdog
Timer
Reset
31
34 34
I/O pins
BVDD
VDD 35
VBGAP = 1.2V
VIRVST
Enable Internal
Reference Voltage
Internal Reference 36
Voltage Stable
TABLE 26-10: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET REQUIREMENTS
Param.
Symbol Characteristic Min Typ Max Units Conditions
No.
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
SS
81
SCK
(CKP = 0)
71 72
79
73
SCK
(CKP = 1)
80
78
75, 76
74
Note: Refer to Figure 26-4 for load conditions.
SS
70
SCK
(CKP = 0) 83
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76 77
TABLE 26-15: 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 26-4 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
RC6/TX1/CK1
pin
121 121
RC7/RX1/DT1
pin
120
122
Note: Refer to Figure 26-4 for load conditions.
RC6/TX1/CK1
pin 125
RC7/RX1/DT1
pin
126
BSF ADCON0, GO
(Note 2)
131
Q4
130
A/D CLK 132
ADIF TCY
GO DONE
SAMPLING STOPPED
SAMPLE
Note 1: If the A/D clock source is selected as RC, a time of TCY is added before the A/D clock starts. This allows the SLEEP instruction
to be executed.
2: This is a minimal RC delay (typically 100 ns), which also disconnects the holding capacitor from the analog input.
XXXXXXXXXX PIC18F6490
XXXXXXXXXX -I/PT e3
XXXXXXXXXX 0710017
YYWWNNN
XXXXXXXXXXXX PIC18F8490-E
XXXXXXXXXXXX /PT e3
YYWWNNN 0710017
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.
/HDG3ODVWLF7KLQ4XDG)ODWSDFN 37 ±[[PP%RG\PP>74)3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D
D1
E
e
E1
N
b
β A1
L L1
8QLWV 0,//,0(7(56
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI/HDGV 1
/HDG3LWFK H %6&
2YHUDOO+HLJKW $ ± ±
0ROGHG3DFNDJH7KLFNQHVV $
6WDQGRII $ ±
)RRW/HQJWK /
)RRWSULQW / 5()
)RRW$QJOH
2YHUDOO:LGWK ( %6&
2YHUDOO/HQJWK ' %6&
0ROGHG3DFNDJH:LGWK ( %6&
0ROGHG3DFNDJH/HQJWK ' %6&
/HDG7KLFNQHVV F ±
/HDG:LGWK E
0ROG'UDIW$QJOH7RS
0ROG'UDIW$QJOH%RWWRP
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
&KDPIHUVDWFRUQHUVDUHRSWLRQDOVL]HPD\YDU\
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGPPSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
/HDG3ODVWLF7KLQ4XDG)ODWSDFN 37 ±[[PP%RG\PP>74)3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
/HDG3ODVWLF7KLQ4XDG)ODWSDFN 37 ±[[PP%RG\PP>74)3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D
D1
E
e
E1
b N
NOTE 1
12 3 NOTE 2 α
A
c
φ
β A2
A1
L L1
8QLWV 0,//,0(7(56
'LPHQVLRQ/LPLWV 0,1 120 0$;
1XPEHURI/HDGV 1
/HDG3LWFK H %6&
2YHUDOO+HLJKW $ ± ±
0ROGHG3DFNDJH7KLFNQHVV $
6WDQGRII $ ±
)RRW/HQJWK /
)RRWSULQW / 5()
)RRW$QJOH
2YHUDOO:LGWK ( %6&
2YHUDOO/HQJWK ' %6&
0ROGHG3DFNDJH:LGWK ( %6&
0ROGHG3DFNDJH/HQJWK ' %6&
/HDG7KLFNQHVV F ±
/HDG:LGWK E
0ROG'UDIW$QJOH7RS
0ROG'UDIW$QJOH%RWWRP
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
&KDPIHUVDWFRUQHUVDUHRSWLRQDOVL]HPD\YDU\
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGPPSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
/HDG3ODVWLF7KLQ4XDG)ODWSDFN 37 ±[[PP%RG\PP>74)3@
1RWH )RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
L N
LCD NEGF ............................................................................... 323
Associated Registers ............................................... 279 NOP ................................................................................. 323
Bias Types ............................................................... 263
Clock Source Selection ............................................ 262 O
Configuring the Module ............................................ 278 Opcode Field Descriptions ............................................... 296
Frame Frequency ..................................................... 264 Oscillator Configuration ..................................................... 31
Interrupts .................................................................. 276 EC .............................................................................. 31
LCDCON Register ................................................... 258 ECIO .......................................................................... 31
LCDDATA Register .................................................. 258 HS .............................................................................. 31
LCDPS Register ....................................................... 258 HSPLL ....................................................................... 31
LCDSE Register ....................................................... 258 Internal Oscillator Block ............................................. 34
Multiplex Types ........................................................ 263 INTIO1 ....................................................................... 31
Operation During Sleep ........................................... 277 INTIO2 ....................................................................... 31
Pixel Control ............................................................. 264 LP .............................................................................. 31
Prescaler .................................................................. 262 RC ............................................................................. 31
Segment Enables ..................................................... 263 RCIO .......................................................................... 31
Waveform Generation .............................................. 264 XT .............................................................................. 31
LCDCON Register ........................................................... 258 Oscillator Selection .......................................................... 281
LCDDATA Register .......................................................... 258 Oscillator Start-up Timer (OST) ........................... 39, 55, 281
LCDPS Register ............................................................... 258 Oscillator Switching ........................................................... 36
LP3:LP0 Bits ............................................................ 262 Oscillator Transitions ......................................................... 37
LCDSE Register ............................................................... 258 Oscillator, Timer1 ..................................................... 135, 145
LFSR ................................................................................ 319 Oscillator, Timer3 ............................................................. 143
Liquid Crystal Display (LCD) Driver ................................. 257
Look-up Tables .................................................................. 68
P
Packaging ........................................................................ 389
M Details ...................................................................... 390
Master Clear (MCLR) ......................................................... 53 Marking .................................................................... 389
Master Synchronous Serial Port (MSSP). See MSSP. PICSTART Plus Development Programmer .................... 348
Memory Organization ......................................................... 65 PIE Registers ................................................................... 101
Data Memory ............................................................. 71 Pin Functions
Program Memory ....................................................... 65 AVDD .......................................................................... 29
Memory Programming Requirements .............................. 364 AVDD .......................................................................... 19
Microchip Internet Web Site ............................................. 409 AVSS .......................................................................... 29
Migration from Baseline to Enhanced Devices ................ 396 AVSS .......................................................................... 19
Migration from High-End to Enhanced Devices ............... 397 COM0 .................................................................. 17, 25
Migration from Mid-Range to Enhanced Devices ............ 397 LCDBIAS1 ........................................................... 17, 25
MOVF ............................................................................... 319 LCDBIAS2 ........................................................... 17, 25
MOVFF ............................................................................ 320 LCDBIAS3 ........................................................... 17, 25
MOVLB ............................................................................ 320 MCLR/VPP/RG5 ................................................... 12, 20
MOVLW ........................................................................... 321 OSC1/CLKI/RA7 .................................................. 12, 20
MOVSF ............................................................................ 339 OSC2/CLKO/RA6 ................................................ 12, 20
MOVSS ............................................................................ 340 RA0/AN0 .............................................................. 13, 21
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?
10/05/07