Pic 16F690
Pic 16F690
Low-Power Features
Standby Current:
- 50 nA @ 2.0V, typical
Operating Current:
- 11 A @ 32 kHz, 2.0V, typical
- 220 A @ 4 MHz, 2.0V, typical
Watchdog Timer Current:
- <1 A @ 2.0V, typical
Peripheral Features
Special Microcontroller Features
Precision Internal Oscillator:
- Factory calibrated to 1%
- Software selectable frequency range of
8 MHz to 32 kHz
- Software tunable
- Two-Speed Start-up mode
- Crystal fail detect for critical applications
- Clock mode switching during operation for
power savings
Power-Saving Sleep mode
Wide Operating Voltage Range (2.0V-5.5V)
Industrial and Extended Temperature Range
Power-on Reset (POR)
Power-up Timer (PWRTE) and Oscillator Start-up
Timer (OST)
Brown-out Reset (BOR) with Software Control
Option
Enhanced Low-Current Watchdog Timer (WDT)
with On-Chip Oscillator (Software selectable
nominal 268 Seconds with Full Prescaler) with
Software Enable
Multiplexed Master Clear/Input Pin
Programmable Code Protection
High Endurance Flash/EEPROM Cell:
- 100,000 write Flash endurance
- 1,000,000 write EEPROM endurance
- Flash/Data EEPROM retention: > 40 years
Enhanced USART Module:
- Supports RS-485, RS-232 and LIN 2.0
- Auto-Baud Detect
- Auto-wake-up on Start bit
DS40001262F-page 1
PIC16F631/677/685/687/689/690
Program
Memory
Data Memory
Flash
(words)
SRAM EEPROM
(bytes) (bytes)
Device
I/O
PIC16F631
PIC16F677
PIC16F685
PIC16F687
PIC16F689
PIC16F690
1024
2048
4096
2048
4096
4096
64
128
256
128
256
256
128
256
256
256
256
256
10-bit A/D
Comparators
(ch)
18
18
18
18
18
18
12
12
12
12
12
2
2
2
2
2
2
Timers
8/16-bit
1/1
1/1
2/1
1/1
1/1
2/1
No
Yes
No
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
No
Yes
Yes
Yes
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5
RC4/C2OUT
RC3/C12IN3RC6
RC7
RB7
TABLE 1:
1
2
3
4
5
6
7
8
9
10
PIC16F631
VSS
RA0/C1IN+/ICSPDAT/ULPWU
RA1/C12IN0-/ICSPCLK
RA2/T0CKI/INT/C1OUT
RC0/C2IN+
RC1/C12IN1RC2/C12IN2RB4
RB5
RB6
I/O
Pin
Analog
Comparators
Timers
Interrupt
Pull-up
Basic
RA0
19
AN0/ULPWU
C1IN+
IOC
ICSPDAT
RA1
18
AN1
C12IN0-
IOC
ICSPCLK
RA2
17
C1OUT
T0CKI
IOC/INT
MCLR/VPP
RA3
IOC
Y(1)
RA4
T1G
IOC
OSC2/CLKOUT
RA5
T1CKI
IOC
OSC1/CLKIN
RB4
13
IOC
RB5
12
IOC
RB6
11
IOC
RB7
10
IOC
RC0
16
AN4
C2IN+
RC1
15
AN5
C12IN1-
RC2
14
AN6
C12IN2-
RC3
AN7
C12IN3-
RC4
C2OUT
RC5
RC6
RC7
VDD
20
VSS
Note 1:
DS40001262F-page 2
PIC16F631/677/685/687/689/690
PIC16F677 Pin Diagram
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/AN3/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5
RC4/C2OUT
RC3/AN7C12IN3RC6/AN8/SS
RC7/AN9/SDO
RB7
TABLE 2:
I/O
1
2
3
4
5
6
7
8
9
10
PIC16F677
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RC0/AN4/C2IN+
RC1/AN5/C12IN1RC2/AN6/C12IN2RB4/AN10/SDI/SDA
RB5/AN11
RB6/SCK/SCL
Pin
Analog
Comparators
Timers
Interrupt
Pull-up
Basic
RA0
19
AN0/ULPWU
C1IN+
IOC
ICSPDAT
RA1
18
AN1
C12IN0-
IOC
ICSPCLK
RA2
17
C1OUT
T0CKI
IOC/INT
RA3
IOC
Y(1)
MCLR/VPP
RA4
T1G
IOC
OSC2/CLKOUT
RA5
T1CKI
IOC
OSC1/CLKIN
RB4
13
IOC
RB5
12
IOC
RB6
11
IOC
RB7
10
IOC
RC0
16
AN4
C2IN+
RC1
15
AN5
C12IN1-
RC2
14
AN6
C12IN2-
RC3
AN7
C12IN3-
RC4
C2OUT
RC5
RC6
RC7
VDD
20
VSS
Note 1:
DS40001262F-page 3
PIC16F631/677/685/687/689/690
PIC16F685 Pin Diagram
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/AN3/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5/CCP1/P1A
RC4/C2OUT/P1B
RC3/AN7/C12IN3-/P1C
RC6/AN8
RC7/AN9
RB7
TABLE 3:
1
2
3
4
5
6
7
8
9
10
PIC16F685
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RC0/AN4/C2IN+
RC1/AN5/C12IN1RC2/AN6/C12IN2-/P1D
RB4/AN10
RB5/AN11
RB6
I/O
Pin
Analog
Comparators
Timers
ECCP
Interrupt
Pull-up
Basic
RA0
19
AN0/ULPWU
C1IN+
IOC
ICSPDAT
RA1
18
AN1/VREF
C12IN0-
IOC
ICSPCLK
RA2
17
AN2
C1OUT
T0CKI
IOC/INT
RA3
(1)
IOC
RA4
AN3
RA5
T1G
IOC
OSC2/CLKOUT
T1CKI
IOC
OSC1/CLKIN
RB4
13
AN10
IOC
RB5
12
AN11
IOC
MCLR/VPP
RB6
11
IOC
RB7
10
IOC
RC0
16
AN4
C2IN+
RC1
15
AN5
C12IN1-
RC2
14
AN6
C12IN2-
P1D
RC3
AN7
C12IN3-
P1C
RC4
C2OUT
P1B
RC5
CCP1/P1A
RC6
AN8
RC7
AN9
VDD
20
VSS
Note 1:
DS40001262F-page 4
PIC16F631/677/685/687/689/690
PIC16F687/689 Pin Diagram
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/AN3/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5
RC4/C2OUT
RC3/AN7/C12IN3RC6/AN8/SS
RC7/AN9/SDO
RB7/TX/CK
TABLE 4:
1
2
3
4
5
6
7
8
9
10
PIC16F687/689
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RC0/AN4/C2IN+
RC1/AN5/C12IN1RC2/AN6/C12IN2RB4/AN10/SDI/SDA
RB5/AN11/RX/DT
RB6/SCK/SCL
I/O
Pin
Analog
Comparators
Timers
EUSART
SSP
RA0
19
AN0/ULPWU
C1IN+
RA1
18
AN1/VREF
C12IN0-
RA2
17
AN2
C1OUT
T0CKI
RA3
RA4
AN3
Interrupt Pull-up
Basic
IOC
ICSPDAT
IOC
ICSPCLK
IOC/INT
IOC
Y(1)
MCLR/VPP
T1G
IOC
OSC2/CLKOUT
RA5
T1CKI
IOC
OSC1/CLKIN
RB4
13
AN10
SDI/SDA
IOC
RB5
12
AN11
RX/DT
IOC
RB6
11
SCL/SCK
IOC
RB7
10
TX/CK
IOC
RC0
16
AN4
C2IN+
RC1
15
AN5
C12IN1-
RC2
14
AN6
C12IN2-
RC3
AN7
C12IN3-
RC4
C2OUT
RC5
RC6
AN8
SS
RC7
AN9
SDO
VDD
20
VSS
DS40001262F-page 5
PIC16F631/677/685/687/689/690
PIC16F690 Pin Diagram (PDIP, SOIC, SSOP)
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/AN3/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5/CCP1/P1A
RC4/C2OUT/P1B
RC3/AN7/C12IN3-/P1C
RC6/AN8/SS
RC7/AN9/SDO
RB7/TX/CK
TABLE 5:
I/O
1
2
3
4
5
6
7
8
9
10
PIC16F690
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RC0/AN4/C2IN+
RC1/AN5/C12IN1RC2/AN6/C12IN2-/P1D
RB4/AN10/SDI/SDA
RB5/AN11/RX/DT
RB6/SCK/SCL
Pin
Analog
Comparators Timers
ECCP
EUSART
SSP
Interrupt
Pull-up
Basic
RA0
19
AN0/ULPWU
C1IN+
IOC
ICSPDAT
RA1
18
AN1/VREF
C12IN0-
IOC
ICSPCLK
RA2
17
AN2
C1OUT
T0CKI
IOC/INT
RA3
IOC
Y(1)
MCLR/VPP
RA4
AN3
T1G
IOC
OSC2/CLKOUT
RA5
T1CKI
IOC
OSC1/CLKIN
RB4
13
AN10
SDI/SDA
IOC
RB5
12
AN11
RX/DT
IOC
RB6
11
SCL/SCK
IOC
RB7
10
IOC
TX/CK
RC0
16
AN4
C2IN+
RC1
15
AN5
C12IN1-
RC2
14
AN6
C12IN2-
P1D
RC3
AN7
C12IN3-
P1C
RC4
C2OUT
P1B
RC5
CCP1/P1A
RC6
AN8
SS
RC7
AN9
SDO
VDD
20
VSS
DS40001262F-page 6
PIC16F631/677/685/687/689/690
PIC16F631/677/685/687/689/690 Pin Diagram (QFN)
RA3/MCLR/VPP
(1)
RC5/CCP1/P1A
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
VDD
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
20
19
18
17
16
20-pin QFN
PIC16F631/677/
685/687/689/690
15
RA1/AN1/C12IN0-/VREF/ICSPCLK
14
RA2/AN2/T0CKI/INT/C1OUT
13
RC0/AN4/C2IN+
11
RC2/AN6/C12IN2-/P1D(1)
RB4/AN10/SDI/SDA(2)
RB7/TX/CK
(3)
6
RC7/AN9/SDO(2)
Note 1:
RC6/AN8/SS
10
RC1/AN5/C12IN1-
RB5/AN11/RX/DT(3)
12
(2)
RC3/AN7/C12IN3-/P1C(1)
RC4/C2OUT/P1B
RB6/SCK/SCL(2)
(1)
2:
3:
DS40001262F-page 7
PIC16F631/677/685/687/689/690
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 9
2.0 Memory Organization ................................................................................................................................................................. 24
3.0 Oscillator Module (With Fail-Safe Clock Monitor)....................................................................................................................... 45
4.0 I/O Ports ..................................................................................................................................................................................... 57
5.0 Timer0 Module ........................................................................................................................................................................... 79
6.0 Timer1 Module with Gate Control............................................................................................................................................... 82
7.0 Timer2 Module ........................................................................................................................................................................... 89
8.0 Comparator Module.................................................................................................................................................................... 91
9.0 Analog-to-Digital Converter (ADC) Module .............................................................................................................................. 105
10.0 Data EEPROM and Flash Program Memory Control ............................................................................................................... 117
11.0 Enhanced Capture/Compare/PWM Module ............................................................................................................................. 125
12.0 Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART) ............................................................... 148
13.0 SSP Module Overview ............................................................................................................................................................. 175
14.0 Special Features of the CPU .................................................................................................................................................... 193
15.0 Instruction Set Summary .......................................................................................................................................................... 212
16.0 Development Support............................................................................................................................................................... 221
17.0 Electrical Specifications............................................................................................................................................................ 225
18.0 DC and AC Characteristics Graphs and Tables ....................................................................................................................... 258
19.0 Packaging Information.............................................................................................................................................................. 285
The Microchip Web Site ..................................................................................................................................................................... 295
Customer Change Notification Service .............................................................................................................................................. 295
Customer Support .............................................................................................................................................................................. 295
Product Identification System............................................................................................................................................................. 296
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:
Microchips Worldwide Web site; http://www.microchip.com
Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
DS40001262F-page 8
PIC16F631/677/685/687/689/690
1.0
DEVICE OVERVIEW
FIGURE 1-1:
Data Bus
PORTA
Program Counter
RA0
RA1
RA2
RA3
RA4
RA5
Flash
1K x 14
Program
RAM
64 bytes
File
Registers
Memory
Program 14
Bus
RAM Addr
9
PORTB
Addr MUX
Instruction Reg
7
Direct Addr
RB4
RB5
RB6
RB7
Indirect
Addr
FSR Reg
STATUS Reg
8
PORTC
3
Power-up
Timer
Instruction
Decode and
Control
OSC1/CLKI
Oscillator
Start-up Timer
ALU
Power-on
Reset
OSC2/CLKO
Timing
Generation
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
MUX
Watchdog
Timer
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
ULPWU
Ultra Low-Power
Wake-up
T0CKI
VSS
T1G
T1CKI
Timer0
Timer1
EEADR
2
Analog Comparators
and Reference
DS40001262F-page 9
PIC16F631/677/685/687/689/690
FIGURE 1-2:
Data Bus
PORTA
Program Counter
Flash
RA0
RA1
RA2
RA3
RA4
RA5
2K x 14
Program
RAM
128 bytes
File
Registers
Memory
Program 14
Bus
RAM Addr
9
PORTB
Addr MUX
Instruction Reg
7
Direct Addr
Indirect
Addr
RB4
RB5
RB6
RB7
FSR Reg
STATUS Reg
8
PORTC
3
Power-up
Timer
Instruction
Decode and
Control
Oscillator
Start-up Timer
OSC1/CLKI
ALU
Power-on
Reset
OSC2/CLKO
Timing
Generation
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
MUX
Watchdog
Timer
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
ULPWU
T0CKI
Ultra Low-Power
Wake-up
Timer0
VSS
T1G
SDI/ SCK/
SDO SDA SCL SS
T1CKI
Synchronous
Serial Port
Timer1
Analog-to-Digital Converter
2
Analog Comparators
and Reference
256 Bytes
Data
EEPROM
EEADR
VREF AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C1IN- C1IN+ C1OUT C2IN- C2IN+ C2OUT
DS40001262F-page 10
PIC16F631/677/685/687/689/690
FIGURE 1-3:
Data Bus
PORTA
Program Counter
Flash
RA0
RA1
RA2
RA3
RA4
RA5
4K x 14
Program
RAM
256 bytes
File
Registers
Memory
Program 14
Bus
RAM Addr
9
PORTB
Addr MUX
Instruction Reg
7
Direct Addr
Indirect
Addr
RB4
RB5
RB6
RB7
FSR Reg
STATUS Reg
8
PORTC
3
Power-up
Timer
Instruction
Decode and
Control
Oscillator
Start-up Timer
OSC1/CLKI
ALU
Power-on
Reset
OSC2/CLKO
Timing
Generation
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
MUX
Watchdog
Timer
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
ULPWU
T0CKI
Ultra Low-Power
Wake-up
Timer0
VSS
T1G
CCP1/
P1A P1B P1C P1D
T1CKI
Timer1
Timer2
ECCP+
Analog-to-Digital Converter
2
Analog Comparators
and Reference
256 Bytes
Data
EEPROM
EEADR
VREF AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C1IN- C1IN+ C1OUT C2IN- C2IN+ C2OUT
DS40001262F-page 11
PIC16F631/677/685/687/689/690
FIGURE 1-4:
Data Bus
PORTA
Program Counter
Flash
RA0
RA1
RA2
RA3
RA4
RA5
2K(1)/4K x 14
Program
RAM
128(1)/256 bytes
File
Registers
Memory
Program 14
Bus
RAM Addr
9
PORTB
Addr MUX
Instruction Reg
Indirect
Addr
Direct Addr
RB4
RB5
RB6
RB7
FSR Reg
STATUS Reg
8
PORTC
3
Power-up
Timer
Instruction
Decode and
Control
Oscillator
Start-up Timer
OSC1/CLKI
ALU
Power-on
Reset
Timing
Generation
OSC2/CLKO
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
MUX
Watchdog
Timer
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
ULPWU
T0CKI
Ultra Low-Power
Wake-up
Timer0
VSS
T1G
T1CKI
Timer1
TX/CK
SDI/ SCK/
SDO SDA SCL SS
RX/DT
Synchronous
Serial Port
EUSART
Analog-to-Digital Converter
2
Analog Comparators
and Reference
256 Bytes
Data
EEPROM
EEADR
VREF AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C1IN- C1IN+ C1OUT C2IN- C2IN+ C2OUT
Note
1:
PIC16F687 only.
DS40001262F-page 12
PIC16F631/677/685/687/689/690
FIGURE 1-5:
Data Bus
PORTA
Program Counter
Flash
RA0
RA1
RA2
RA3
RA4
RA5
4k x 14
Program
RAM
256 bytes
File
Registers
Memory
Program 14
Bus
RAM Addr
9
PORTB
Addr MUX
Instruction Reg
Direct Addr
7
8
Indirect
Addr
RB4
RB5
RB6
RB7
FSR Reg
STATUS Reg
8
PORTC
3
Power-up
Timer
Instruction
Decode and
Control
Oscillator
Start-up Timer
OSC1/CLKI
OSC2/CLKO
Power-on
Reset
Timing
Generation
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
MUX
ALU
8
Watchdog
Timer
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
ULPWU
T0CKI
Ultra Low-Power
Wake-up
Timer0
T1G
VSS
TX/CK RX/DT
T1CKI
Timer1
Timer2
CCP1/
P1A
EUSART
ECCP+
SDI/ SCK/
SDO SDA SCL SS
Synchronous
Serial Port
Analog-to-Digital Converter
2
Analog Comparators
and Reference
256 Bytes
Data
EEPROM
EEADR
VREF AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C1IN- C1IN+ C1OUT C2IN- C2IN+ C2OUT
DS40001262F-page 13
PIC16F631/677/685/687/689/690
TABLE 1-1:
Name
RA0/C1IN+/ICSPDAT/ULPWU
RA1/C12IN0-/ICSPCLK
RA2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
Function
Input
Type
RA0
TTL
C1IN+
AN
ICSPDAT
ST
ULPWU
AN
RA1
TTL
Output
Type
Description
C12IN0-
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
T0CKI
ST
INT
ST
C1OUT
RA3
TTL
MCLR
ST
Programming voltage.
VPP
HV
RA4
TTL
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
RA5
TTL
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
CLKIN
ST
RB4
RB4
TTL
RB5
RB5
TTL
RB6
RB6
TTL
RB7
RB7
TTL
RC0/C2IN+
RC1/C12IN1RC2/C12IN2RC3/C12IN3RC4/C2OUT
RC5
Legend:
RC0
ST
C2IN+
AN
RC1
ST
C12IN1-
AN
RC2
ST
C12IN2-
AN
RC3
ST
C12IN3-
AN
RC4
ST
C2OUT
RC5
ST
DS40001262F-page 14
PIC16F631/677/685/687/689/690
TABLE 1-1:
Input
Type
RC6
RC6
ST
RC7
RC7
ST
VSS
VSS
Power
Ground reference.
VDD
VDD
Power
Positive supply.
Name
Legend:
Output
Type
Description
DS40001262F-page 15
PIC16F631/677/685/687/689/690
TABLE 1-2:
Name
RA0/AN0/C1IN+/ICSPDAT/
ULPWU
RA1/AN1/C12IN0-/VREF/
ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
RB4/AN10/SDI/SDA
RB5/AN11
RB6/SCK/SCL
Legend:
Function
Input
Type
RA0
TTL
Description
AN0
AN
C1IN+
AN
ICSPDAT
ST
ULPWU
AN
RA1
TTL
AN1
AN
C12IN0-
AN
VREF
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
AN2
AN
T0CKI
ST
INT
ST
C1OUT
RA3
TTL
MCLR
ST
VPP
HV
Programming voltage.
RA4
TTL
AN3
AN
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
RA5
TTL
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
CLKIN
ST
RB4
TTL
AN10
AN
SDI
ST
SDA
ST
OD
RB5
TTL
AN11
AN
RB6
TTL
SCK
ST
SCL
ST
DS40001262F-page 16
Output
Type
OD
I2C clock.
PIC16F631/677/685/687/689/690
TABLE 1-2:
Input
Type
RB7
RB7
TTL
RC0/AN4/C2IN+
RC0
ST
AN4
AN
C2IN+
AN
RC1
ST
Name
RC1/AN5/C12IN1-
RC2/AN6/C12IN2-
RC3/AN7/C12IN3-
RC4/C2OUT
Output
Type
Description
AN5
AN
C12IN1-
AN
RC2
ST
AN6
AN
C12IN2-
AN
RC3
ST
AN7
AN
C12IN3-
AN
RC4
ST
C2OUT
RC5
RC5
ST
RC6/AN8/SS
RC6
ST
AN8
AN
SS
ST
RC7/AN9/SDO
VSS
VDD
Legend:
RC7
ST
AN9
AN
SDO
VSS
Power
Ground reference.
VDD
Power
Positive supply.
DS40001262F-page 17
PIC16F631/677/685/687/689/690
TABLE 1-3:
RA0/AN0/C1IN+/ICSPDAT/
ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
RB4/AN10
RB5/AN11
Function
Input
Type
RA0
TTL
Output
Type
Description
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN0
AN
C1IN+
AN
ICSPDAT
TTL
ULPWU
AN
RA1
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN1
AN
C12IN0-
AN
VREF
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
AN2
AN
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
T0CKI
ST
INT
ST
C1OUT
RA3
TTL
MCLR
ST
VPP
HV
Programming voltage.
RA4
TTL
AN3
AN
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
RA5
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
CLKIN
ST
RB4
TTL
AN10
AN
RB5
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN11
AN
RB6
RB6
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
RB7
RB7
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
RC0/AN4/C2IN+
RC0
ST
Legend:
AN4
AN
C2IN+
AN
DS40001262F-page 18
PIC16F631/677/685/687/689/690
TABLE 1-3:
Function
Input
Type
RC1
ST
RC1/AN5/C12IN1-
Output
Type
Description
AN5
AN
C12IN1-
AN
RC2/AN6/C12IN2-/P1D
RC2
ST
AN6
AN
C12IN2-
AN
P1D
RC3
ST
AN7
AN
C12IN3-
AN
P1C
RC4
ST
C2OUT
RC3/AN7/C12IN3-/P1C
RC4/C2OUT/P1B
RC5/CCP1/P1A
P1B
RC5
ST
CCP1
ST
P1A
ST
RC6
ST
AN8
AN
RC7
ST
AN9
AN
VSS
VSS
Power
Ground reference.
VDD
VDD
Power
Positive supply.
RC6/AN8
RC7/AN9
Legend:
DS40001262F-page 19
PIC16F631/677/685/687/689/690
TABLE 1-4:
RA0/AN0/C1IN+/ICSPDAT/
ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
RB4/AN10/SDI/SDA
RB5/AN11/RX/DT
Function
Input
Type
RA0
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN0
AN
AN
ICSPDAT
TTL
ULPWU
AN
RA1
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN1
AN
C12IN0-
AN
VREF
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
AN2
AN
T0CKI
ST
INT
ST
External Interrupt.
C1OUT
RA3
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
MCLR
ST
VPP
HV
Programming voltage.
RA4
TTL
AN3
AN
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
RA5
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
CLKIN
ST
RB4
TTL
AN10
AN
SDI
ST
SDA
ST
OD
RB5
TTL
AN11
AN
RX
ST
DS40001262F-page 20
Description
C1IN+
DT
Legend:
Output
Type
ST
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
Open Drain
PIC16F631/677/685/687/689/690
TABLE 1-4:
Function
Input
Type
RB6
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
SCK
ST
SCL
ST
RB7
TTL
TX
RB6/SCK/SCL
RB7/TX/CK
RC0/AN4/C2IN+
Output
Type
OD
Description
I2C clock.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS EUSART asynchronous output.
CK
ST
RC0
ST
AN4
AN
C2IN+
AN
RC1/AN5/C12IN1-
RC1
ST
AN5
AN
C12IN1-
AN
RC2
ST
RC2/AN6/C12IN2-
AN6
AN
C12IN2-
AN
RC3/AN7/C12IN3-
RC3
ST
AN7
AN
C12IN3-
AN
RC4
ST
RC4/C2OUT
C2OUT
RC5
RC5
ST
RC6/AN8/SS
RC6
ST
AN8
AN
SS
ST
RC7
ST
RC7/AN9/SDO
AN9
AN
SDO
VSS
VSS
Power
Ground reference.
VDD
VDD
Power
Positive supply.
Legend:
Open Drain
DS40001262F-page 21
PIC16F631/677/685/687/689/690
TABLE 1-5:
RA0/AN0/C1IN+/ICSPDAT/
ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
RB4/AN10/SDI/SDA
RB5/AN11/RX/DT
Function
Input
Type
RA0
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN0
AN
AN
ICSPDAT
TTL
ULPWU
AN
RA1
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN1
AN
C12IN0-
AN
VREF
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
AN2
AN
T0CKI
ST
INT
ST
External interrupt.
C1OUT
RA3
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
MCLR
ST
VPP
HV
Programming voltage.
RA4
TTL
AN3
AN
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
RA5
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
CLKIN
ST
RB4
TTL
AN10
AN
SDI
ST
SDA
ST
OD
RB5
TTL
AN11
AN
RX
ST
DS40001262F-page 22
Description
C1IN+
DT
Legend:
Output
Type
ST
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
Open Drain
PIC16F631/677/685/687/689/690
TABLE 1-5:
Function
Input
Type
RB6
TTL
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
SCK
ST
SCL
ST
RB7
TTL
TX
RB6/SCK/SCL
RB7/TX/CK
RC0/AN4/C2IN+
OD
Description
I2C clock.
CMOS General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
CMOS EUSART asynchronous output.
CK
ST
RC0
ST
AN4
AN
C2IN+
AN
RC1/AN5/C12IN1-
RC1
ST
AN5
AN
C12IN1-
AN
RC2
ST
RC2/AN6/C12IN2-/P1D
AN6
AN
C12IN2-
AN
RC3/AN7/C12IN3-/P1C
P1D
RC3
ST
AN7
AN
C12IN3-
AN
P1C
RC4
ST
C2OUT
P1B
RC5
ST
CCP1
ST
RC4/C2OUT/P1B
RC5/CCP1/P1A
RC6/AN8/SS
RC7/AN9/SDO
P1A
ST
RC6
ST
AN8
AN
SS
ST
RC7
ST
AN9
AN
SDO
VSS
Power
Ground reference.
Power
Positive supply.
VSS
VDD
VDD
Legend:
Output
Type
Open Drain
DS40001262F-page 23
PIC16F631/677/685/687/689/690
2.0
MEMORY ORGANIZATION
2.1
FIGURE 2-1:
FIGURE 2-2:
CALL, RETURN
RETFIE, RETLW
13
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
0000h
Interrupt Vector
0004h
0005h
On-Chip
Program
Memory
PC<12:0>
CALL, RETURN
RETFIE, RETLW
13
Page 0
07FFh
0800h
Page 1
0FFFh
1000h
Stack Level 1
Access 0-FFFh
Stack Level 2
1FFFh
Stack Level 8
Reset Vector
Interrupt Vector
0000h
FIGURE 2-3:
0004h
0005h
On-Chip
Page 0
Memory
03FFh
0400h
PC<12:0>
CALL, RETURN
RETFIE, RETLW
Access 0-3FFh
1FFFh
13
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
Interrupt Vector
On-Chip
Memory
0000h
0004h
0005h
Page 0
07FFh
0800h
Access 0-7FFh
1FFFh
DS40001262F-page 24
PIC16F631/677/685/687/689/690
2.2
RP0
Bank 0 is selected
Bank 1 is selected
Bank 2 is selected
Bank 3 is selected
2.2.1
2.2.2
DS40001262F-page 25
PIC16F631/677/685/687/689/690
FIGURE 2-4:
PCLATH
INTCON
PIR1
PIR2
TMR1L
TMR1H
T1CON
General
Purpose
Registers
64 Bytes
00h
01h
02h
03h
04h
05h
06h
07h
08h
09h
0Ah
0Bh
0Ch
0Dh
0Eh
0Fh
10h
11h
12h
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
20h
PIE2
PCON
OSCCON
OSCTUNE
PCLATH
INTCON
PIE1
WPUA
IOCA
WDTCON
File
Address
80h
81h
82h
83h
84h
85h
86h
87h
88h
89h
8Ah
8Bh
8Ch
8Dh
8Eh
8Fh
90h
91h
92h
93h
94h
95h
96h
97h
98h
99h
9Ah
9Bh
9Ch
9Dh
9Eh
9Fh
A0h
EEADR
PCLATH
INTCON
EEDAT
WPUB
IOCB
VRCON
CM1CON0
CM2CON0
CM2CON1
ANSEL
File
Address
100h
101h
102h
103h
104h
105h
106h
107h
108h
109h
10Ah
10Bh
10Ch
10Dh
10Eh
10Fh
110h
111h
112h
113h
114h
115h
116h
117h
118h
119h
11Ah
11Bh
11Ch
11Dh
11Eh
11Fh
120h
EECON2(1)
PCLATH
INTCON
EECON1
SRCON
180h
181h
182h
183h
184h
185h
186h
187h
188h
189h
18Ah
18Bh
18Ch
18Dh
18Eh
18Fh
190h
191h
192h
193h
194h
195h
196h
197h
198h
199h
19Ah
19Bh
19Ch
19Dh
19Eh
19Fh
1A0h
3Fh
40h
6Fh
70h
7Fh
Bank 0
Note 1:
File
Address
accesses
70h-7Fh
Bank 1
EFh
F0h
FFh
accesses
70h-7Fh
Bank 2
16Fh
170h
17Fh
accesses
70h-7Fh
1EFh
1F0h
1FFh
Bank 3
DS40001262F-page 26
PIC16F631/677/685/687/689/690
FIGURE 2-5:
PCLATH
INTCON
PIR1
PIR2
TMR1L
TMR1H
T1CON
SSPBUF
SSPCON
ADRESH
ADCON0
File
Address
00h
01h
02h
03h
04h
05h
06h
07h
08h
09h
0Ah
0Bh
0Ch
0Dh
0Eh
0Fh
10h
11h
12h
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
20h
PIE2
PCON
OSCCON
OSCTUNE
General
Purpose
Register
PCLATH
INTCON
PIE1
SSPADD(2)
SSPSTAT
WPUA
IOCA
WDTCON
ADRESL
ADCON1
General
Purpose
Register
32 Bytes
96 Bytes
7Fh
Bank 0
Note 1:
2:
accesses
70h-7Fh
Bank 1
File
Address
80h
81h
82h
83h
84h
85h
86h
87h
88h
89h
8Ah
8Bh
8Ch
8Dh
8Eh
8Fh
90h
91h
92h
93h
94h
95h
96h
97h
98h
99h
9Ah
9Bh
9Ch
9Dh
9Eh
9Fh
A0h
EEADR
PCLATH
INTCON
EEDAT
WPUB
IOCB
VRCON
CM1CON0
CM2CON0
CM2CON1
ANSEL
ANSELH
File
Address
100h
101h
102h
103h
104h
105h
106h
107h
108h
109h
10Ah
10Bh
10Ch
10Dh
10Eh
10Fh
110h
111h
112h
113h
114h
115h
116h
117h
118h
119h
11Ah
11Bh
11Ch
11Dh
11Eh
11Fh
120h
EECON2(1)
PCLATH
INTCON
EECON1
SRCON
180h
181h
182h
183h
184h
185h
186h
187h
188h
189h
18Ah
18Bh
18Ch
18Dh
18Eh
18Fh
190h
191h
192h
193h
194h
195h
196h
197h
198h
199h
19Ah
19Bh
19Ch
19Dh
19Eh
19Fh
1A0h
BFh
C0h
EFh
F0h
FFh
accesses
70h-7Fh
Bank 2
16Fh
170h
17Fh
accesses
70h-7Fh
1EFh
1F0h
1FFh
Bank 3
DS40001262F-page 27
PIC16F631/677/685/687/689/690
FIGURE 2-6:
PCLATH
INTCON
PIR1
PIR2
TMR1L
TMR1H
T1CON
TMR2
T2CON
CCPR1L
CCPR1H
CCP1CON
PWM1CON
ECCPAS
ADRESH
ADCON0
File
Address
00h
01h
02h
03h
04h
05h
06h
07h
08h
09h
0Ah
0Bh
0Ch
0Dh
0Eh
0Fh
10h
11h
12h
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
20h
PIE2
PCON
OSCCON
OSCTUNE
General
Purpose
Register
PCLATH
INTCON
PIE1
PR2
WPUA
IOCA
WDTCON
ADRESL
ADCON1
Bank 0
Note 1:
80h
81h
82h
83h
84h
85h
86h
87h
88h
89h
8Ah
8Bh
8Ch
8Dh
8Eh
8Fh
90h
91h
92h
93h
94h
95h
96h
97h
98h
99h
9Ah
9Bh
9Ch
9Dh
9Eh
9Fh
A0h
EEADR
EEDATH
EEADRH
PCLATH
INTCON
EEDAT
WPUB
IOCB
VRCON
CM1CON0
CM2CON0
CM2CON1
ANSEL
ANSELH
General
Purpose
Register
General
Purpose
Register
80 Bytes
80 Bytes
96 Bytes
7Fh
File
Address
accesses
70h-7Fh
Bank 1
EFh
F0h
FFh
accesses
70h-7Fh
Bank 2
File
Address
100h
101h
102h
103h
104h
105h
106h
107h
108h
109h
10Ah
10Bh
10Ch
10Dh
10Eh
10Fh
110h
111h
112h
113h
114h
115h
116h
117h
118h
119h
11Ah
11Bh
11Ch
11Dh
11Eh
11Fh
120h
EECON2(1)
16Fh
170h
17Fh
PCLATH
INTCON
EECON1
PSTRCON
SRCON
accesses
70h-7Fh
180h
181h
182h
183h
184h
185h
186h
187h
188h
189h
18Ah
18Bh
18Ch
18Dh
18Eh
18Fh
190h
191h
192h
193h
194h
195h
196h
197h
198h
199h
19Ah
19Bh
19Ch
19Dh
19Eh
19Fh
1A0h
1F0h
1FFh
Bank 3
DS40001262F-page 28
PIC16F631/677/685/687/689/690
FIGURE 2-7:
File
Address
Indirect addr. (1)
OPTION_REG
PCL
STATUS
FSR
TRISA
TRISB
TRISC
PCLATH
INTCON
PIR1
00h
01h
02h
03h
04h
05h
06h
07h
08h
09h
0Ah
0Bh
0Ch
PIR2
0Dh
TMR1L
PCLATH
INTCON
PIE1
80h
81h
82h
83h
84h
85h
86h
87h
88h
89h
8Ah
8Bh
8Ch
PIE2
0Eh
PCON
PCLATH
INTCON
EEDAT
PCLATH
INTCON
EECON1
180h
181h
182h
183h
184h
185h
186h
187h
188h
189h
18Ah
18Bh
18Ch
8Dh
EEADR
10Dh
EECON2(1)
18Dh
8Eh
EEDATH(3)
10Eh
18Eh
(3)
10Fh
110h
111h
112h
18Fh
190h
191h
192h
113h
114h
115h
116h
117h
118h
119h
11Ah
11Bh
11Ch
11Dh
11Eh
11Fh
120h
193h
194h
195h
196h
197h
198h
199h
19Ah
19Bh
19Ch
19Dh
19Eh
19Fh
1A0h
0Fh
10h
11h
12h
OSCCON
OSCTUNE
8Fh
90h
91h
92h
SSPBUF
SSPCON
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
20h
SSPADD(2)
SSPSTAT
WPUA
IOCA
WDTCON
TXSTA
SPBRG
SPBRGH
BAUDCTL
93h
94h
95h
96h
97h
98h
99h
9Ah
9Bh
9Ch
9Dh
9Eh
9Fh
A0h
ADRESH
ADCON0
General
Purpose
Register
96 Bytes
7Fh
Bank 0
Note 1:
2:
3:
ADRESL
ADCON1
General
Purpose
Register
32 Bytes
48 Bytes
(PIC16F689
only)
accesses
70h-7Fh
Bank 1
File
Address
100h
101h
102h
103h
104h
105h
106h
107h
108h
109h
10Ah
10Bh
10Ch
TMR1H
T1CON
RCSTA
TXREG
RCREG
File
Address
BFh
C0h
EFh
F0h
FFh
EEADRH
WPUB
IOCB
VRCON
CM1CON0
CM2CON0
CM2CON1
ANSEL
ANSELH
SRCON
General
Purpose
Register
80 Bytes
(PIC16F689
only)
accesses
70h-7Fh
Bank 2
170h
17Fh
accesses
70h-7Fh
1F0h
1FFh
Bank 3
DS40001262F-page 29
PIC16F631/677/685/687/689/690
FIGURE 2-8:
File
Address
Indirect addr. (1)
OPTION_REG
PCL
STATUS
FSR
TRISA
TRISB
TRISC
PCLATH
INTCON
PIR1
00h
01h
02h
03h
04h
05h
06h
07h
08h
09h
0Ah
0Bh
0Ch
PIR2
TMR1L
TMR1H
T1CON
TMR2
T2CON
0Dh
0Eh
0Fh
10h
11h
12h
PIE2
PCON
OSCCON
OSCTUNE
SSPBUF
SSPCON
CCPR1L
CCPR1H
CCP1CON
RCSTA
TXREG
RCREG
13h
14h
15h
16h
17h
18h
19h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
20h
SSPADD(2)
SSPSTAT
WPUA
IOCA
WDTCON
TXSTA
SPBRG
SPBRGH
BAUDCTL
PWM1CON
ECCPAS
ADRESH
ADCON0
PCLATH
INTCON
PIE1
PR2
ADRESL
ADCON1
80h
81h
82h
83h
84h
85h
86h
87h
88h
89h
8Ah
8Bh
8Ch
8Dh
8Eh
8Fh
90h
91h
92h
EEADR
EEDATH
EEADRH
93h
94h
95h
96h
97h
98h
99h
9Ah
9Bh
9Ch
9Dh
9Eh
9Fh
A0h
General
Purpose
Register
General
Purpose
Register
7Fh
Bank 0
Note 1:
2:
accesses
70h-7Fh
Bank 1
PCLATH
INTCON
EEDAT
WPUB
IOCB
VRCON
CM1CON0
CM2CON0
CM2CON1
ANSEL
ANSELH
File
Address
100h
101h
102h
103h
104h
105h
106h
107h
108h
109h
10Ah
10Bh
10Ch
10Dh
10Eh
10Fh
110h
111h
112h
EECON2(1)
113h
114h
115h
116h
117h
118h
119h
11Ah
11Bh
11Ch
11Dh
11Eh
11Fh
120h
PCLATH
INTCON
EECON1
PSTRCON
SRCON
180h
181h
182h
183h
184h
185h
186h
187h
188h
189h
18Ah
18Bh
18Ch
18Dh
18Eh
18Fh
190h
191h
192h
193h
194h
195h
196h
197h
198h
199h
19Ah
19Bh
19Ch
19Dh
19Eh
19Fh
1A0h
General
Purpose
Register
80 Bytes
96 Bytes
File
Address
80 Bytes
EFh
F0h
FFh
accesses
70h-7Fh
Bank 2
16Fh
170h
17Fh
accesses
70h-7Fh
1F0h
1FFh
Bank 3
DS40001262F-page 30
PIC16F631/677/685/687/689/690
TABLE 2-1:
Addr
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Page
Bank 0
00h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical register)
xxxx xxxx
43,200
01h
TMR0
xxxx xxxx
79,200
02h
PCL
0000 0000
43,200
03h
STATUS
0001 1xxx
35,200
xxxx xxxx
43,200
IRP
RP1
RP0
TO
PD
DC
04h
FSR
05h
PORTA(7)
RA5
RA4
RA3
RA2
RA1
RA0
--xx xxxx
57,200
06h
PORTB(7)
RB7
RB6
RB5
RB4
xxxx ----
67,200
07h
PORTC(7)
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
xxxx xxxx
74,200
08h
Unimplemented
09h
Unimplemented
0Ah
PCLATH
---0 0000
43,200
0Bh
INTCON
GIE
PEIE
T0IE
INTE
RABIE
RABIF(1)
0000 000x
37,200
0Ch
PIR1
ADIF(4)
RCIF(2)
TXIF(2)
SSPIF(5)
TMR1IF
-000 0000
40,200
0Dh
PIR2
OSFIF
C2IF
C1IF
EEIF
0000 ----
41,200
0Eh
TMR1L
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
85,200
0Fh
TMR1H
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
85,200
10h
T1CON
87,200
11h
TMR2(3)
12h
T2CON(3)
13h
SSPBUF(5)
14h
SSPCON(5, 6)
15h
CCPR1L(3)
16h
CCPR1H
(3)
17h
CCP1CON(3)
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CCP1M2
CCP1M1
CCP1M0
0000 0000
125,200
18h
RCSTA(2)
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
0000 000x
158,200
19h
TXREG(2)
0000 0000
150
1Ah
(2)
RCREG
0000 0000
155
1Bh
1Ch
PWM1CON(3)
1Dh
ECCPAS(3)
ECCPASE ECCPAS2
1Eh
ADRESH(4)
1Fh
ADCON0(4)
Legend:
Note 1:
2:
3:
4:
5:
6:
7:
T1GINV
TMR1GE
T1CKPS1
T1CKPS0
T1OSCEN
T0IF
INTF
CCP1IF(3) TMR2IF(3)
T1SYNC
TMR1CS
TOUTPS3
TOUTPS2
TOUTPS1
TOUTPS0
TMR2ON
T2CKPS1
SSPM2
SSPM1
0000 0000
89,200
90,200
SSPOV
SSPEN
CKP
SSPM3
SSPM0
Unimplemented
PRSEN
ADFM
PDC6
VCFG
xxxx xxxx
178,200
0000 0000
177,200
xxxx xxxx
126,200
xxxx xxxx
126,200
PDC5
PDC4
PDC3
PDC2
PDC1
PDC0
0000 0000
143,200
ECCPAS1
ECCPAS0
PSSAC1
PSSAC0
PSSBD1
PSSBD0
0000 0000
140,200
xxxx xxxx
113,200
0000 0000
111,200
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
MCLR and WDT Reset do not affect the previous value data latch. The RABIF bit will be cleared upon Reset but will set again if the
mismatch exists.
PIC16F687/PIC16F689/PIC16F690 only.
PIC16F685/PIC16F690 only.
PIC16F677/PIC16F685/PIC16F687/PIC16F689/PIC16F690 only.
PIC16F677/PIC16F687/PIC16F689/PIC16F690 only.
When SSPCON register bits SSPM<3:0> = 1001, any reads or writes to the SSPADD SFR address are accessed through the SSPMSK
register. See Registers 13-2 and 13-3 for more detail.
Port pins with analog functions controlled by the ANSEL and ANSELH registers will read 0 immediately after a Reset even though the
data latches are either undefined (POR) or unchanged (other Resets).
DS40001262F-page 31
PIC16F631/677/685/687/689/690
TABLE 2-2:
Addr
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Page
xxxx xxxx
43,200
Bank 1
80h
INDF
81h
OPTION_REG
Addressing this location uses contents of FSR to address data memory (not a physical register)
82h
PCL
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
83h
STATUS
84h
FSR
IRP
RP1
RP0
TO
PD
DC
1111 1111
36,200
0000 0000
43,200
0001 1xxx
35,200
xxxx xxxx
43,200
57,200
85h
TRISA
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
--11 1111
86h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
68,201
87h
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
74,200
88h
Unimplemented
89h
Unimplemented
8Ah
PCLATH
---0 0000
43,200
8Bh
INTCON
GIE
PEIE
0000 000x
37,200
(4)
T0IE
INTE
RABIE
PIE1
OSFIE
8Eh
PCON
8Fh
OSCCON
IRCF2
IRCF1
IRCF0
90h
OSCTUNE
TUN4
TUN3
EEIE
ULPWUE SBOREN
SSPIE
(5)
PIE2
C1IE
TXIE
(2)
8Ch
C2IE
RCIE
(2)
8Dh
91h
ADIE
T0IF
TMR2IE
(3)
TMR1IE
-000 0000
38,201
0000 ----
39,201
POR
BOR
--01 --qq
42,201
OSTS
HTS
LTS
SCS
-110 q000
46,201
TUN2
TUN1
TUN0
---0 0000
50,201
CCP1IE
RABIF(1)
INTF
(3)
Unimplemented
92h
PR2(3)
93h
SSPADD(5, 7)
93h
SSPMSK(5, 7)
MSK7
MSK6
94h
SSPSTAT(5)
SMP
CKE
D/A
R/W
95h
WPUA(6)
WPUA5
WPUA4
WPUA2
96h
IOCA
IOCA5
IOCA4
IOCA3
IOCA2
97h
WDTCON
WDTPS3
WDTPS2
98h
TXSTA(2)
CSRC
TX9
TXEN
SYNC
SENDB
99h
SPBRG(2)
BRG7
BRG6
BRG5
BRG4
BRG15
BRG14
BRG13
ABDOVF
RCIDL
(2)
9Ah
SPBRGH
9Bh
BAUDCTL(2)
MSK5
1111 1111
89,201
0000 0000
184,201
MSK0
1111 1111
187,201
UA
BF
0000 0000
176,201
WPUA1
WPUA0
--11 -111
60,201
IOCA1
IOCA0
--00 0000
60,201
WDTPS1
WDTPS0
SWDTEN
---0 1000
208,201
BRGH
TRMT
TX9D
0000 0010
157,201
BRG3
BRG2
BRG1
BRG0
0000 0000
160,201
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
160,201
SCKP
BRG16
WUE
ABDEN
01-0 0-00
159,201
MSK4
MSK3
MSK2
MSK1
9Ch
Unimplemented
9Dh
Unimplemented
xxxx xxxx
113,201
-000 ----
112,201
9Eh
ADRESL(4)
9Fh
ADCON1(4)
Legend:
Note 1:
2:
3:
4:
5:
6:
7:
ADCS2
ADCS1
ADCS0
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
MCLR and WDT Reset do not affect the previous value data latch. The RABIF bit will be cleared upon Reset but will set again if the
mismatch exists.
PIC16F687/PIC16F689/PIC16F690 only.
PIC16F685/PIC16F690 only.
PIC16F677/PIC16F685/PIC16F687/PIC16F689/PIC16F690 only.
PIC16F677/PIC16F687/PIC16F689/PIC16F690 only.
RA3 pull-up is enabled when pin is configured as MCLR in Configuration Word.
Accessible only when SSPCON register bits SSPM<3:0> = 1001.
DS40001262F-page 32
PIC16F631/677/685/687/689/690
TABLE 2-3:
Addr
Name
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Page
Bank 2
100h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical register)
xxxx xxxx
43,200
101h
TMR0
xxxx xxxx
79,200
102h
PCL
0000 0000
43,200
103h
STATUS
0001 1xxx
35,200
104h
FSR
105h
PORTA(4)
106h
PORTB(4)
RB7
RB6
RB5
RB4
107h
PORTC(4)
RC7
RC6
RC5
RC4
RC3
RC2
IRP
RP1
RP0
TO
PD
DC
RA5
RA4
RA3
RA2
xxxx xxxx
43,200
RA0
--xx xxxx
57,200
xxxx ----
67,200
RC1
RC0
xxxx xxxx
74,200
RA1
108h
Unimplemented
109h
Unimplemented
---0 0000
43,200
10Ah PCLATH
10Bh INTCON
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF(1)
0000 000x
37,200
10Ch EEDAT
EEDAT7
EEDAT6
EEDAT5
EEDAT4
EEDAT3
EEDAT2
EEDAT1
EEDAT0
0000 0000
118,201
10Dh EEADR
EEADR5
EEADR4
EEADR3
EEADR2
EEADR1
EEADR0
0000 0000
118,201
EEDATH3
EEDATH2
EEDATH1
118,201
118,201
EEADR7(3)
EEADR6
EEDATH(2)
10Fh EEADRH(2)
10Eh
EEDATH5 EEDATH4
110h
Unimplemented
111h
Unimplemented
112h
Unimplemented
113h
Unimplemented
114h
Unimplemented
115h
WPUB
116h
IOCB
117h
118h
VRCON
119h
11Ah
11Bh
WPUB7
WPUB6
WPUB5
WPUB4
1111 ----
68,201
IOCB7
IOCB6
IOCB5
IOCB4
0000 ----
68,201
Unimplemented
C1VREN
C2VREN
VRR
VP6EN
VR3
VR2
VR1
VR0
0000 0000
103,201
CM1CON0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C1CH0
0000 -000
96,201
CM2CON0
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
C2CH0
0000 -000
97,201
CM2CON1
MC1OUT
MC2OUT
T1GSS
C2SYNC
00-- --10
99,201
11Ch
Unimplemented
11Dh
Unimplemented
11Eh
ANSEL
11Fh
ANSELH(3)
Legend:
Note 1:
2:
3:
4:
ANS7
ANS6
ANS5
ANS4
ANS3(3)
ANS2(3)
ANS1
ANS0
1111 1111
59,201
ANS11
ANS10
ANS9
ANS8
---- 1111
113,201
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
MCLR and WDT Reset does not affect the previous value data latch. The RABIF bit will be cleared upon Reset but will set again if the
mismatch exists.
PIC16F685/PIC16F689/PIC16F690 only.
PIC16F677/PIC16F685/PIC16F687/PIC16F689/PIC16F690 only.
Port pins with analog functions controlled by the ANSEL and ANSELH registers will read 0 immediately after a Reset even though the
data latches are either undefined (POR) or unchanged (other Resets).
DS40001262F-page 33
PIC16F631/677/685/687/689/690
TABLE 2-4:
Addr
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Page
Bank 3
180h
INDF
181h
OPTION_REG
Addressing this location uses contents of FSR to address data memory (not a physical register) xxxx xxxx
182h
PCL
183h
STATUS
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
RP1
1111 1111
43,200
36,200
0000 0000
43,200
35,200
TO
PD
DC
0001 1xxx
xxxx xxxx
43,200
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
--11 1111
57,200
RP0
184h
FSR
185h
TRISA
186h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
68,201
187h
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
74,201
TRISA5
188h
Unimplemented
189h
Unimplemented
18Ah
PCLATH
---0 0000
43,200
18Bh
INTCON
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF(1)
0000 000x
37,200
18Ch
EECON1
EEPGD(2)
WRERR
WREN
WR
RD
x--- x000
119,201
18Dh
EECON2
---- ----
117,201
18Eh
Unimplemented
18Fh
Unimplemented
190h
Unimplemented
191h
Unimplemented
192h
Unimplemented
193h
Unimplemented
194h
Unimplemented
195h
Unimplemented
196h
Unimplemented
197h
Unimplemented
198h
Unimplemented
199h
Unimplemented
19Ah
Unimplemented
19Bh
Unimplemented
19Ch
Unimplemented
19Dh
PSTRCON(2)
19Eh
SRCON
19Fh
Legend:
Note 1:
2:
STRSYNC
STRD
STRC
STRB
STRA
---0 0001
144,201
SR1
SR0
C1SEN
C2REN
PULSS
PULSR
0000 00--
101,201
Unimplemented
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
MCLR and WDT Reset does not affect the previous value data latch. The RABIF bit will be cleared upon Reset but will set again if the
mismatch exists.
PIC16F685/PIC16F690 only.
DS40001262F-page 34
PIC16F631/677/685/687/689/690
2.2.2.1
STATUS Register
REGISTER 2-1:
R/W-0
IRP
RP1
R/W-0
RP0
R-1
TO
R-1
PD
R/W-x
R/W-x
R/W-x
DC(1)
C(1)
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6-5
bit 4
bit 3
bit 2
Z: Zero bit
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero
bit 1
bit 0
Note 1:
For Borrow, the polarity is reversed. A subtraction is executed by adding the twos complement of the
second operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high-order or low-order
bit of the source register.
DS40001262F-page 35
PIC16F631/677/685/687/689/690
2.2.2.2
OPTION Register
Note:
Timer0/WDT prescaler
External RA2/INT interrupt
Timer0
Weak pull-ups on PORTA/PORTB
REGISTER 2-2:
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2-0
DS40001262F-page 36
Bit Value
Timer0 Rate
WDT Rate
000
001
010
011
100
101
110
111
1:2
1:4
1:8
1 : 16
1 : 32
1 : 64
1 : 128
1 : 256
1:1
1:2
1:4
1:8
1 : 16
1 : 32
1 : 64
1 : 128
PIC16F631/677/685/687/689/690
2.2.2.3
INTCON Register
Note:
REGISTER 2-3:
R/W-0
GIE
PEIE
R/W-0
T0IE
R/W-0
R/W-0
(1,3)
INTE
RABIE
R/W-0
R/W-0
R/W-x
T0IF(2)
INTF
RABIF
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
Note 1:
2:
3:
DS40001262F-page 37
PIC16F631/677/685/687/689/690
2.2.2.4
PIE1 Register
REGISTER 2-4:
Note:
U-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
ADIE(5)
RCIE(3)
TXIE(3)
SSPIE(4)
CCP1IE(2)
TMR2IE(1)
TMR1IE
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7
Unimplemented: Read as 0
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
Note 1:
2:
3:
4:
5:
x = Bit is unknown
PIC16F685/PIC16F690 only.
PIC16F685/PIC16F689/PIC16F690 only.
PIC16F687/PIC16F689/PIC16F690 only.
PIC16F677/PIC16F687/PIC16F689/PIC16F690 only.
PIC16F677/PIC16F685/PIC16F687/PIC16F689/PIC16F690 only.
DS40001262F-page 38
PIC16F631/677/685/687/689/690
2.2.2.5
PIE2 Register
REGISTER 2-5:
Note:
R/W-0
R/W-0
R/W-0
R/W-0
U-0
U-0
U-0
U-0
OSFIE
C2IE
C1IE
EEIE
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7
bit 6
bit 5
bit 4
bit 3-0
Unimplemented: Read as 0
x = Bit is unknown
DS40001262F-page 39
PIC16F631/677/685/687/689/690
2.2.2.6
PIR1 Register
REGISTER 2-6:
Note:
U-0
R/W-0
R-0
R-0
R/W-0
R/W-0
R/W-0
R/W-0
ADIF(5)
RCIF(3)
TXIF(3)
SSPIF(4)
CCP1IF(2)
TMR2IF(1)
TMR1IF
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
Unimplemented: Read as 0
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
Note 1:
2:
3:
4:
5:
PIC16F685/PIC16F690 only.
PIC16F685/PIC16F689/PIC16F690 only.
PIC16F687/PIC16F689/PIC16F690 only.
PIC16F677/PIC16F687/PIC16F689/PIC16F690 only.
PIC16F677/PIC16F685/PIC16F687/PIC16F689/PIC16F690 only.
DS40001262F-page 40
PIC16F631/677/685/687/689/690
2.2.2.7
PIR2 Register
REGISTER 2-7:
Note:
R/W-0
R/W-0
R/W-0
R/W-0
U-0
U-0
U-0
U-0
OSFIF
C2IF
C1IF
EEIF
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3-0
Unimplemented: Read as 0
DS40001262F-page 41
PIC16F631/677/685/687/689/690
2.2.2.8
PCON Register
REGISTER 2-8:
U-0
U-0
R/W-0
R/W-1
U-0
U-0
R/W-0
R/W-x
ULPWUE
SBOREN(1)
POR
BOR
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-6
Unimplemented: Read as 0
bit 5
bit 4
bit 3-2
Unimplemented: Read as 0
bit 1
bit 0
Note 1:
BOREN<1:0> = 01 in the Configuration Word register for this bit to control the BOR.
DS40001262F-page 42
PIC16F631/677/685/687/689/690
2.3
2.3.2
FIGURE 2-9:
LOADING OF PC IN
DIFFERENT SITUATIONS
PCH
PCL
12
PC
PCLATH<4:0>
Instruction with
PCL as
Destination
ALU Result
PCLATH
PCH
12
11 10
PCL
8
PC
GOTO, CALL
2
PCLATH<4:3>
11
OPCODE<10:0>
PCLATH
2.3.1
STACK
MODIFYING PCL
2.4
EXAMPLE 2-1:
MOVLW
MOVWF
NEXT
CLRF
INCF
BTFSS
GOTO
CONTINUE
INDIRECT ADDRESSING
0x20
FSR
INDF
FSR
FSR,4
NEXT
;initialize pointer
;to RAM
;clear INDF register
;inc pointer
;all done?
;no clear next
;yes continue
DS40001262F-page 43
PIC16F631/677/685/687/689/690
FIGURE 2-10:
Direct Addressing
RP1 RP0
Bank Select
From Opcode
Indirect Addressing
0
IRP
Bank Select
Location Select
00
01
10
Location Select
11
00h
180h
Data
Memory
7Fh
1FFh
Bank 0
Bank 1
Bank 2
Bank 3
For memory map detail, see Figures 2-6, 2-7 and 2-8.
DS40001262F-page 44
PIC16F631/677/685/687/689/690
3.0
3.1
Overview
1.
2.
3.
4.
5.
6.
7.
8.
FIGURE 3-1:
External Oscillator
OSC2
Sleep
MUX
OSC1
IRCF<2:0>
(OSCCON Register)
8 MHz
Internal Oscillator
4 MHz
System Clock
(CPU and Peripherals)
INTOSC
111
110
101
1 MHz
100
500 kHz
250 kHz
125 kHz
LFINTOSC
31 kHz
31 kHz
011
MUX
HFINTOSC
8 MHz
Postscaler
2 MHz
010
001
000
DS40001262F-page 45
PIC16F631/677/685/687/689/690
3.2
Oscillator Control
REGISTER 3-1:
U-0
R/W-1
R/W-1
R/W-0
R-1
R-0
R-0
R/W-0
IRCF2
IRCF1
IRCF0
OSTS(1)
HTS
LTS
SCS
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
Unimplemented: Read as 0
bit 6-4
bit 3
bit 2
bit 1
bit 0
Note 1:
Bit resets to 0 with Two-Speed Start-up and LP, XT or HS selected as the Oscillator mode or Fail-Safe
mode is enabled.
DS40001262F-page 46
PIC16F631/677/685/687/689/690
3.3
TABLE 3-1:
3.4
3.4.1
Switch From
Switch To
Frequency
Oscillator Delay
Sleep/POR
LFINTOSC
HFINTOSC
31 kHz
125 kHz to 8 MHz
Sleep/POR
EC, RC
DC 20 MHz
2 cycles
EC, RC
DC 20 MHz
1 cycle of each
Sleep/POR
LP, XT, HS
32 kHz to 20 MHz
HFINTOSC
1 s (approx.)
3.4.2
EC MODE
FIGURE 3-2:
Clock from
Ext. System
PIC MCU
I/O
Note 1:
OSC2/CLKOUT(1)
DS40001262F-page 47
PIC16F631/677/685/687/689/690
3.4.3
FIGURE 3-3:
QUARTZ CRYSTAL
OPERATION (LP, XT OR
HS MODE)
PIC MCU
OSC1/CLKIN
C1
To Internal
Logic
Quartz
Crystal
RF(2)
OSC2/CLKOUT
RS(1)
C2
Sleep
Note 1:
2:
FIGURE 3-4:
CERAMIC RESONATOR
OPERATION
(XT OR HS MODE)
PIC MCU
OSC1/CLKIN
C1
To Internal
Logic
RP(3)
RF(2)
Sleep
DS40001262F-page 48
C2 Ceramic
RS(1)
Resonator
Note 1:
OSC2/CLKOUT
PIC16F631/677/685/687/689/690
3.4.4
EXTERNAL RC MODES
3.5
FIGURE 3-5:
VDD
EXTERNAL RC MODES
PIC MCU
REXT
OSC1/CLKIN
Internal
Clock
CEXT
2.
3.5.1
VSS
FOSC/4 or
I/O(2)
OSC2/CLKOUT
(1)
3.5.2
HFINTOSC
DS40001262F-page 49
PIC16F631/677/685/687/689/690
3.5.2.1
OSCTUNE Register
REGISTER 3-2:
U-0
U-0
U-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
TUN4
TUN3
TUN2
TUN1
TUN0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-5
Unimplemented: Read as 0
bit 4-0
00001 =
00000 = Oscillator module is running at the factory-calibrated frequency.
11111 =
DS40001262F-page 50
PIC16F631/677/685/687/689/690
3.5.3
LFINTOSC
3.5.4
8 MHz
4 MHz (Default after Reset)
2 MHz
1 MHz
500 kHz
250 kHz
125 kHz
31 kHz (LFINTOSC)
Note:
3.5.5
6.
DS40001262F-page 51
PIC16F631/677/685/687/689/690
FIGURE 3-6:
HFINTOSC
HFINTOSC
Start-up Time
2-cycle Sync
Running
LFINTOSC
0
IRCF <2:0>
System Clock
HFINTOSC
HFINTOSC
2-cycle Sync
Running
LFINTOSC
IRCF <2:0>
System Clock
LFINTOSC
HFINTOSC
LFINTOSC turns off unless WDT or FSCM is enabled
LFINTOSC
Start-up Time
2-cycle Sync
Running
HFINTOSC
IRCF <2:0>
=0
System Clock
DS40001262F-page 52
PIC16F631/677/685/687/689/690
3.6
Clock Switching
3.6.1
3.6.2
3.7
3.7.1
3.7.2
1.
2.
3.
4.
5.
6.
7.
TWO-SPEED START-UP
SEQUENCE
DS40001262F-page 53
PIC16F631/677/685/687/689/690
3.7.3
FIGURE 3-7:
TWO-SPEED START-UP
HFINTOSC
TOST
OSC1
1022 1023
OSC2
Program Counter
PC - N
PC
PC + 1
System Clock
DS40001262F-page 54
PIC16F631/677/685/687/689/690
3.8
3.8.3
FIGURE 3-8:
External
Clock
LFINTOSC
Oscillator
64
31 kHz
(~32 s)
488 Hz
(~2 ms)
3.8.4
3.8.1
Clock
Failure
Detected
FAIL-SAFE DETECTION
3.8.2
Sample Clock
FAIL-SAFE OPERATION
DS40001262F-page 55
PIC16F631/677/685/687/689/690
FIGURE 3-9:
Sample Clock
Oscillator
Failure
System
Clock
Output
Clock Monitor Output
(Q)
Failure
Detected
OSCFIF
Test
Note:
TABLE 3-2:
Name
Test
Test
The system clock is normally at a much higher frequency than the sample clock. The relative frequencies in
this example have been chosen for clarity.
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets(1)
CONFIG(2)
CPD
CP
MCLRE
PWRTE
WDTE
FOSC2
FOSC1
FOSC0
OSCCON
IRCF2
IRCF1
IRCF0
OSTS
HTS
LTS
SCS
-110 x000
-110 x000
OSCTUNE
TUN4
TUN3
TUN2
TUN1
TUN0
---0 0000
---u uuuu
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
Legend:
Note 1:
2:
x = unknown, u = unchanged, = unimplemented locations read as 0. Shaded cells are not used by oscillators.
Other (non Power-up) Resets include MCLR Reset and Watchdog Timer Reset during normal operation.
See Configuration Word register (Register 14-1) for operation of all register bits.
DS40001262F-page 56
PIC16F631/677/685/687/689/690
4.0
I/O PORTS
4.1
Note:
EXAMPLE 4-1:
BCF
BCF
CLRF
BSF
CLRF
BSF
BCF
MOVLW
MOVWF
BCF
REGISTER 4-1:
INITIALIZING PORTA
STATUS,RP0;Bank 0
STATUS,RP1;
PORTA
;Init PORTA
STATUS,RP1;Bank 2
ANSEL
;digital I/O
STATUS,RP0;Bank 1
STATUS,RP1;
0Ch
;Set RA<3:2> as inputs
TRISA
;and set RA<5:4,1:0>
;as outputs
STATUS,RP0;Bank 0
U-0
U-0
R/W-x
R/W-x
R-x
R/W-x
R/W-x
R/W-x
RA5
RA4
RA3
RA2
RA1
RA0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-6
Unimplemented: Read as 0
bit 5-0
REGISTER 4-2:
x = Bit is unknown
U-0
U-0
R/W-1
R/W-1
R-1
R/W-1
R/W-1
R/W-1
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-6
Unimplemented: Read as 0
bit 5-0
Note 1:
2:
x = Bit is unknown
DS40001262F-page 57
PIC16F631/677/685/687/689/690
4.2
4.2.3
INTERRUPT-ON-CHANGE
Every PORTA pin on this device family has an interrupton-change option and a weak pull-up option. RA0 also
has an Ultra Low-Power Wake-up option. The next
three sections describe these functions.
4.2.1
4.2.2
WEAK PULL-UPS
DS40001262F-page 58
PIC16F631/677/685/687/689/690
REGISTER 4-3:
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-0
x = Bit is unknown
Note 1:
Setting a pin to an analog input automatically disables the digital input circuitry, weak pull-ups and
interrupt-on-change if available. The corresponding TRIS bit must be set to Input mode in order to allow
external control of the voltage on the pin.
REGISTER 4-4:
U-0
U-0
U-0
U-0
R/W-1
R/W-1
R/W-1
R/W-1
ANS11
ANS10
ANS9
ANS8
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-4
Unimplemented: Read as 0
bit 3-0
Note 1:
2:
Setting a pin to an analog input automatically disables the digital input circuitry, weak pull-ups and
interrupt-on-change if available. The corresponding TRIS bit must be set to Input mode in order to allow
external control of the voltage on the pin.
PIC16F677/PIC16F685/PIC16F687/PIC16F689/PIC16F690 only.
DS40001262F-page 59
PIC16F631/677/685/687/689/690
REGISTER 4-5:
U-0
U-0
R/W-1
R/W-1
U-0
R/W-1
R/W-1
R/W-1
WPUA5
WPUA4
WPUA2
WPUA1
WPUA0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-6
Unimplemented: Read as 0
bit 5-4
bit 3
Unimplemented: Read as 0
bit 2-0
Note 1:
2:
3:
4:
x = Bit is unknown
Global RABPU bit of the OPTION register must be enabled for individual pull-ups to be enabled.
The weak pull-up device is automatically disabled if the pin is in Output mode (TRISA = 0).
The RA3 pull-up is enabled when configured as MCLR and disabled as an I/O in the Configuration Word.
WPUA<5:4> always reads 1 in XT, HS and LP Oscillator modes.
REGISTER 4-6:
U-0
U-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
IOCA5
IOCA4
IOCA3
IOCA2
IOCA1
IOCA0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-6
Unimplemented: Read as 0
bit 5-0
Note 1:
2:
x = Bit is unknown
Global Interrupt Enable (GIE) must be enabled for individual interrupts to be recognized.
IOCA<5:4> always reads 1 in XT, HS and LP Oscillator modes.
DS40001262F-page 60
PIC16F631/677/685/687/689/690
4.2.4
EXAMPLE 4-2:
BCF
BCF
BSF
BSF
BCF
BSF
BCF
BCF
CALL
BSF
BSF
BSF
MOVLW
MOVWF
BCF
SLEEP
NOP
ULTRA LOW-POWER
WAKE-UP INITIALIZATION
STATUS,RP0
STATUS,RP1
PORTA,0
STATUS,RP1
ANSEL,0
STATUS,RP0
STATUS,RP1
TRISA,0
CapDelay
PCON,ULPWUE
IOCA,0
TRISA,0
B10001000
INTCON
STATUS,RP0
;Bank 0
;
;Set RA0 data latch
;Bank 2
;RA0 to digital I/O
;Bank 1
;
;Output high to
;charge capacitor
;Enable ULP Wake-up
;Select RA0 IOC
;RA0 to input
;Enable interrupt
;and clear flag
;Bank 0
;Wait for IOC
;
DS40001262F-page 61
PIC16F631/677/685/687/689/690
4.2.5
4.2.5.1
Figure 4-2 shows the diagram for this pin. The RA0/
AN0/C1IN+/ICSPDAT/ULPWU pin is configurable to
function as one of the following:
FIGURE 4-1:
RA0/AN0/C1IN+/ICSPDAT/ULPWU
Analog(1)
Input Mode
VDD
Data Bus
D
Weak
CK Q
WR
WPUA
RABPU
RD
WPUA
VDD
D
WR
PORTA
Q
I/O Pin
CK Q
VSS
+
D
WR
TRISA
VT
CK Q
IULP
0
RD
TRISA
Analog(1)
Input Mode
VSS
ULPWUE
RD
PORTA
D
WR
IOCA
Q
Q
CK Q
D
EN
RD
IOCA
Q3
D
EN
Interrupt-on-Change
RD PORTA
To Comparator
To A/D Converter(2)
Note
DS40001262F-page 62
1:
2:
PIC16F631/677/685/687/689/690
4.2.5.2
RA1/AN1/C12IN0-/VREF/ICSPCLK
4.2.5.3
RA2/AN2/T0CKI/INT/C1OUT
Figure 4-2 shows the diagram for this pin. The RA1/
AN1/C12IN0-/VREF/ICSPCLK pin is configurable to
function as one of the following:
Figure 4-3 shows the diagram for this pin. The RA2/AN2/
T0CKI/INT/C1OUT pin is configurable to function as one
of the following:
FIGURE 4-2:
Data Bus
WR
WPUA
Analog(1)
Input Mode
FIGURE 4-3:
Data Bus
VDD
CK Q
WR
WPUA
Weak
CK
Analog(1)
Input Mode
VDD
Weak
RABPU
RD
WPUA
RABPU
RD
WPUA
C1OUT
Enable
D
WR
PORTA
VDD
D
WR
PORTA
CK Q
VDD
CK
C1OUT
I/O Pin
D
WR
TRISA
CK Q
VSS
Analog(1)
Input Mode
RD
TRISA
WR
TRISA
I/O Pin
CK
VSS
Analog(1)
Input Mode
RD
TRISA
RD
PORTA
RD
PORTA
D
D
Q
CK Q
WR
IOCA
D
EN
RD
IOCA
Q3
CK
WR
IOCA
EN
RD
IOCA
EN
Interrupt-onChange
Q
Q3
D
EN
Interrupt-onChange
RD PORTA
RD PORTA
To Comparator
To A/D Converter(2)
To Timer0
To INT
Note
1:
2:
To A/D Converter(2)
Note
1:
2:
DS40001262F-page 63
PIC16F631/677/685/687/689/690
4.2.5.4
4.2.5.5
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
Figure 4-4 shows the diagram for this pin. The RA3/
MCLR/VPP pin is configurable to function as one of the
following:
Figure 4-5 shows the diagram for this pin. The RA4/
AN3/T1G/OSC2/CLKOUT pin is configurable to
function as one of the following:
FIGURE 4-4:
Data Bus
MCLRE
Reset
RD
TRISA
FIGURE 4-5:
D
CK
Analog(3)
Input Mode
Data Bus
MCLRE
Input
Pin
VSS
RD
PORTA
WR
IOCA
Weak
VSS
WR
WPUA
D
CK
VDD
Weak
Q
Q
Q
EN
RD
IOCA
Interrupt-onChange
RABPU
RD
WPUA
CLK(1)
Modes
Oscillator
Circuit
Q3
OSC1
VDD
CLKOUT
Enable
D
D
EN
WR
PORTA
CK
FOSC/4
1
0
I/O Pin
Q
CLKOUT
Enable
RD PORTA
VSS
D
WR
TRISA
CK
INTOSC/
RC/EC(2)
CLKOUT
Enable
RD
TRISA
Analog
Input Mode
RD
PORTA
D
WR
IOCA
CK
Q
Q
Q
EN
RD
IOCA
Q3
D
EN
Interrupt-onChange
RD PORTA
To T1G
To A/D Converter(4)
Note 1: CLK modes are XT, HS, LP, LPTMR1 and CLKOUT
Enable.
2: With CLKOUT option.
3: ANSEL determines Analog Input mode.
4: Not implemented on PIC16F631.
DS40001262F-page 64
PIC16F631/677/685/687/689/690
4.2.5.6
RA5/T1CKI/OSC1/CLKIN
Figure 4-6 shows the diagram for this pin. The RA5/
T1CKI/OSC1/CLKIN pin is configurable to function as
one of the following:
FIGURE 4-6:
Data Bus
WR
WPUA
TMR1LPEN(1)
VDD
D
CK
Weak
Q
RABPU
RD
WPUA
Oscillator
Circuit
OSC2
WR
PORTA
VDD
D
CK
Q
I/O Pin
D
WR
TRISA
CK
VSS
INTOSC
Mode
RD
TRISA
(2)
RD
PORTA
D
WR
IOCA
CK
Q
EN
Q3
RD
IOCA
Q
D
EN
Interrupt-onChange
RD PORTA
To TMR1 or CLKGEN
Note
DS40001262F-page 65
PIC16F631/677/685/687/689/690
TABLE 4-1:
Name
ADCON0
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
ADFM
VCFG
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
0000 0000
0000 0000
1111 1111
ANSEL
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
1111 1111
CM1CON0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C1CH0
0000 -000
0000 -000
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
IOCA5
IOCA4
IOCA3
IOCA2
IOCA1
IOCA0
--00 0000
--00 0000
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
1111 1111
1111 1111
INTCON
IOCA
OPTION_REG
PORTA
SSPCON
RA5
RA4
RA3
RA2
RA1
RA0
--xx xxxx
--uu uuuu
WCOL
SSPOV
SSPEN
CKP
SSPM3
SSPM2
SSPM1
SSPM0
0000 0000
0000 0000
uuuu uuuu
T1CON
T1GINV
TMR1GE
T1SYNC
TMR1CS
TMR1ON
0000 0000
TRISA
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
--11 1111
--11 1111
WPUA
WPUA5
WPUA4
WPUA2
WPUA1
WPUA0
--11 -111
--11 -111
Legend:
x = unknown, u = unchanged, = unimplemented locations read as 0. Shaded cells are not used by PORTA.
DS40001262F-page 66
PIC16F631/677/685/687/689/690
4.3
4.4.1
WEAK PULL-UPS
4.4.2
INTERRUPT-ON-CHANGE
EXAMPLE 4-3:
This interrupt can wake the device from Sleep. The user,
in the Interrupt Service Routine, clears the interrupt by:
BCF
BCF
CLRF
BSF
MOVLW
MOVWF
BCF
STATUS,RP0
STATUS,RP1
PORTB
STATUS,RP0
FFh
TRISB
STATUS,RP0
Note:
4.4
INITIALIZING PORTB
;Bank 0
;
;Init PORTB
;Bank 1
;Set RB<7:4> as inputs
;
;Bank 0
a)
b)
REGISTER 4-7:
R/W-x
R/W-x
R/W-x
R/W-x
U-0
U-0
U-0
U-0
RB7
RB6
RB5
RB4
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-4
bit 3-0
Unimplemented: Read as 0
x = Bit is unknown
DS40001262F-page 67
PIC16F631/677/685/687/689/690
REGISTER 4-8:
R/W-1
R/W-1
R/W-1
R/W-1
U-0
U-0
U-0
U-0
TRISB7
TRISB6
TRISB5
TRISB4
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-4
bit 3-0
Unimplemented: Read as 0
REGISTER 4-9:
x = Bit is unknown
R/W-1
R/W-1
R/W-1
R/W-1
U-0
U-0
U-0
U-0
WPUB7
WPUB6
WPUB5
WPUB4
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-4
x = Bit is unknown
bit 3-0
Unimplemented: Read as 0
Note 1:
Global RABPU bit of the OPTION register must be enabled for individual pull-ups to be enabled.
2:
The weak pull-up device is automatically disabled if the pin is in Output mode (TRISB<7:4> = 0).
REGISTER 4-10:
R/W-0
R/W-0
R/W-0
R/W-0
U-0
U-0
U-0
U-0
IOCB7
IOCB6
IOCB5
IOCB4
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-4
bit 3-0
Unimplemented: Read as 0
DS40001262F-page 68
x = Bit is unknown
PIC16F631/677/685/687/689/690
4.4.3
4.4.3.1
RB4/AN10/SDI/SDA
Figure 4-7 shows the diagram for this pin. The RB4/
AN10/SDI/SDA(1) pin is configurable to function as one
of the following:
FIGURE 4-7:
Data Bus
WR
WPUB
Analog(1)
Input Mode
VDD
CK Q
Weak
RABPU
RD
WPUB
D
WR
PORTB
CK Q
SSPEN
SSPSR
0
1
VDD
1
0
D
WR
TRISB
CK
I/O Pin
From 1
0
SSP
VSS
Q
1
0
Analog(1)
Input Mode
RD
TRISB
RD
PORTB
D
Q
Q
CK Q
WR
IOCB
D
EN
RD
IOCB
Q3
D
ST
EN
Interrupt-onChange
RD PORTB
To SSPSR
To A/D Converter(2)
Available on PIC16F677/PIC16F687/PIC16F689/PIC16F690
only.
Note
1:
2:
DS40001262F-page 69
PIC16F631/677/685/687/689/690
4.4.3.2
RB5/AN11/RX/DT(1, 2)
Figure 4-8 shows the diagram for this pin. The RB5/
AN11/RX/DT pin is configurable to function as one of
the following:
FIGURE 4-8:
Data Bus
WR
WPUB
Analog(1)
Input Mode
VDD
CK Q
Weak
RABPU
RD
WPUB
SYNC
SPEN
D
WR
PORTB
CK Q
VDD
EUSART
DT 1
0
1
0
From
EUSART 1
0
CK Q
0
1
D
WR
TRISB
I/O Pin
VSS
Analog(1)
Input Mode
RD
TRISB
RD
PORTB
D
Q
Q
CK Q
WR
IOCB
D
EN
RD
IOCB
Q3
D
ST
EN
Interrupt-onChange
RD PORTB
To EUSART RX/DT
To A/D Converter(2)
DS40001262F-page 70
1:
2:
PIC16F631/677/685/687/689/690
4.4.3.3
RB6/SCK/SCL
Figure 4-9 shows the diagram for this pin. The RB6/
SCK/SCL(1) pin is configurable to function as one of the
following:
a general purpose I/O
a SPI clock
an I2C clock
Note 1: SCK and SCL are available on
PIC16F677/PIC16F687/PIC16F689/
PIC16F690 only.
FIGURE 4-9:
Data Bus
WR
WPUB
CK Q
CK Q
D
WR
TRISB
Weak
RABPU
RD
WPUB
WR
PORTB
VDD
CK
Q
Q
SSPEN
VDD
SSP
Clock 1
0
1
0
From
SSP 1
0
I/O Pin
VSS
1
0
RD
TRISB
RD
PORTB
D
WR
IOCB
Q
Q
CK Q
D
EN
RD
IOCB
Q3
D
ST
EN
Interrupt-onChange
RD PORTB
To SSP
Available on PIC16F677/PIC16F687/PIC16F689/PIC16F690
only.
DS40001262F-page 71
PIC16F631/677/685/687/689/690
4.4.3.4
RB7/TX/CK
Figure 4-10 shows the diagram for this pin. The RB7/
TX/CK(1) pin is configurable to function as one of the
following:
a general purpose I/O
an asynchronous serial output
a synchronous clock I/O
FIGURE 4-10:
Data Bus
WR
WPUB
VDD
CK Q
Weak
RABPU
RD
WPUB
SPEN
TXEN
SYNC
D
WR
PORTB
EUSART
CK 0
1
EUSART
TX
1
0
CK Q
VDD
0
1
0
1
D
WR
TRISB
I/O Pin
CK Q
0
1
VSS
1
0
RD
TRISB
RD
PORTB
D
WR
IOCB
Q
Q
CK Q
D
EN
RD
IOCB
Q3
D
EN
Interrupt-onChange
RD PORTB
Available on PIC16F687/PIC16F689/PIC16F690 only.
DS40001262F-page 72
PIC16F631/677/685/687/689/690
TABLE 4-2:
Name
IOCB
INTCON
PORTB
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
Bit 7
Bit 6
Bit 5
Bit 4
IOCB7
IOCB6
IOCB5
IOCB4
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
RB7
RB6
RB5
RB4
TRISB
WPUB
Legend: x = unknown, u = unchanged, = unimplemented read as 0. Shaded cells are not used by PORTB.
DS40001262F-page 73
PIC16F631/677/685/687/689/690
4.5
REGISTER 4-11:
Note:
EXAMPLE 4-4:
INITIALIZING PORTC
BCF
BCF
CLRF
BSF
CLRF
BSF
BCF
MOVLW
MOVWF
STATUS,RP0
STATUS,RP1
PORTC
STATUS,RP1
ANSEL
STATUS,RP0
STATUS,RP1
0Ch
TRISC
BCF
STATUS,RP0
;Bank 0
;
;Init PORTC
;Bank 2
;digital I/O
;Bank 1
;
;Set RC<3:2> as inputs
;and set RC<5:4,1:0>
;as outputs
;Bank 0
R/W-0
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-0
x = Bit is unknown
REGISTER 4-12:
R/W-1
R/W-1
R/W-1
R/W-1
R-1
R/W-1
R/W-1
R/W-1
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-0
x = Bit is unknown
DS40001262F-page 74
PIC16F631/677/685/687/689/690
4.5.1
RC0/AN4/C2IN+
4.5.3
RC2/AN6/C12IN2-/P1D
4.5.2
RC1/AN5/C12IN1-
4.5.4
FIGURE 4-11:
Data Bus
D
WR
PORTC
CK
VDD
WR
TRISC
CK
Q
Q
VSS
Analog Input
Mode(1)
RD
TRISC
Q
I/O Pin
RC3/AN7/C12IN3-/P1C
FIGURE 4-12:
Data Bus
CCP1OUT
Enable
D
WR
PORTC
RD
PORTC
CK
VDD
Q
Q
CCP1OUT
To Comparators
0
1
To A/D Converter(2)
Note
1:
2:
0
1
D
WR
TRISC
CK
I/O Pin
Q
Q
VSS
Analog Input
Mode(1)
RD
TRISC
RD
PORTC
To Comparators
To A/D Converter(2)
1:
2:
DS40001262F-page 75
PIC16F631/677/685/687/689/690
4.5.5
RC4/C2OUT/P1B
(1, 2)
The RC4/C2OUT/P1B
as one of the following:
4.5.6
is configurable to function
FIGURE 4-13:
on
RC5/CCP1/P1A
FIGURE 4-14:
Data bus
CCP1OUT
Enable
PIC16F685/
D
WR
PORTC
CK
VDD
Q
Q
CCP1OUT
0
1
1
0
C2OUT EN
CCP1OUT EN
D
WR
TRISC
C2OUT EN
C2OUT
VSS
RD
TRISC
0
1
1
0
Data Bus
WR
PORTC
CK
I/O Pin
VDD
CCP1OUT EN
CCP1OUT
on
I/O Pin
CK Q
RD
PORTC
To Enhanced CCP
VSS
Available on PIC16F685/PIC16F690 only.
D
WR
TRISC
CK Q
RD
TRISC
RD
PORTC
DS40001262F-page 76
PIC16F631/677/685/687/689/690
4.5.7
RC6/AN8/SS
The RC6/AN8/SS
of the following:
(1,2)
4.5.8
RC7/AN9/SDO
FIGURE 4-15:
FIGURE 4-16:
Data Bus
PORT/SDO
Select
D
WR
PORTC
CK
VDD
Data Bus
SDO
D
I/O Pin
D
WR
TRISC
CK
Q
Q
CK
D
WR
TRISC
CK
Q
Q
To SS Input
To A/D Converter(2)
VSS
Analog Input
Mode(1)
RD
TRISC
RD
PORTC
VDD
0
1
I/O Pin
VSS
Analog Input
Mode(1)
RD
TRISC
WR
PORTC
0
1
RD
PORTC
To A/D Converter(2)
1:
2:
1:
2:
DS40001262F-page 77
PIC16F631/677/685/687/689/690
TABLE 4-3:
Name
ANSEL
ANSELH
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
Bit 7
Bit 6
Bit 5
Bit 4
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
1111 1111
1111 1111
ANS11
ANS10
ANS9
ANS8
---- 1111
---- 1111
CCP1CON(2)
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CCP1M2
CCP1M1
CCP1M0
0000 0000
0000 0000
CM2CON0
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
C2CH0
0000 -000
0000 -000
CM2CON1
MC1OUT
MC2OUT
T1GSS
C2SYNC
00-- --10
00-- --10
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
xxxx xxxx
uuuu uuuu
STRSYNC
STRD
STRC
STRB
STRA
---0 0001
---0 0001
SR1
SR0
C1SEN
C2REN
PULSS
PULSR
0000 00--
0000 00--
PORTC
PSTRCON
SRCON
(1)
WCOL
SSPOV
SSPEN
CKP
SSPM3
SSPM2
SSPM1
SSPM0
0000 0000
0000 0000
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
VRCON
C1VREN
C2VREN
VRR
VP6EN
VR3
VR2
VR1
VR0
0000 0000
0000 0000
SSPCON
Legend:
Note 1:
2:
x = unknown, u = unchanged, = unimplemented locations read as 0. Shaded cells are not used by PORTC.
PIC16F687/PIC16F689/PIC16F690 only.
PIC16F685/PIC16F690 only.
DS40001262F-page 78
PIC16F631/677/685/687/689/690
5.0
TIMER0 MODULE
5.1
Timer0 Operation
5.1.1
5.1.2
FIGURE 5-1:
FOSC/4
Data Bus
0
8
1
Sync 2
cycles
1
T0CKI
pin
TMR0
0
0
T0SE
T0CS
8-bit
Prescaler
PSA
1
8
PSA
WDTE
SWDTEN
PS<2:0>
16-bit
Prescaler
31 kHz
INTOSC
1
WDT
Time-out
0
16
Watchdog
Timer
PSA
WDTPS<3:0>
Note
1:
2:
3:
DS40001262F-page 79
PIC16F631/677/685/687/689/690
5.1.3
SOFTWARE PROGRAMMABLE
PRESCALER
5.1.3.1
EXAMPLE 5-1:
BANKSEL TMR0
CLRWDT
CLRF
TMR0
CHANGING PRESCALER
(TIMER0 WDT)
;
;Clear WDT
;Clear TMR0 and
;prescaler
BANKSEL OPTION_REG ;
BSF
OPTION_REG,PSA;Select WDT
CLRWDT
;
;
MOVLW
b11111000 ;Mask prescaler
ANDWF
OPTION_REG,W; bits
IORLW
b00000101 ;Set WDT prescaler
MOVWF
OPTION_REG ;
to 1:32
DS40001262F-page 80
EXAMPLE 5-2:
CHANGING PRESCALER
(WDT TIMER0)
CLRWDT
5.1.4
TIMER0 INTERRUPT
5.1.5
PIC16F631/677/685/687/689/690
REGISTER 5-1:
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2-0
Note 1:
INTCON
TMR0 RATE
WDT RATE
000
001
010
011
100
101
110
111
1:2
1:4
1:8
1 : 16
1 : 32
1 : 64
1 : 128
1 : 256
1:1
1:2
1:4
1:8
1 : 16
1 : 32
1 : 64
1 : 128
A dedicated 16-bit WDT postscaler is available. See Section 14.5 Watchdog Timer (WDT) for more
information.
TABLE 5-1:
Name
BIT VALUE
Bit 6
GIE
PEIE
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
T0IE
INTE
RABIE
T0IF
INTF
T0CS
T0SE
PSA
PS2
PS1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 --11 1111 --11 1111
Legend: = Unimplemented locations, read as 0, u = unchanged, x = unknown. Shaded cells are not used by the
Timer0 module.
DS40001262F-page 81
PIC16F631/677/685/687/689/690
6.0
6.1
Timer1 Operation
6.2
Clock
Source
T1OSCEN
FOSC
Mode
TMR1CS
FOSC/4
xxx
T1CKI pin
xxx
T1LPOSC
LP or
INTOSCIO
DS40001262F-page 82
PIC16F631/677/685/687/689/690
FIGURE 6-1:
T1GINV
TMR1ON
Set flag bit
TMR1IF on
Overflow
To C2 Comparator Module
Timer1 Clock
TMR1(2)
TMR1H
TMR1L
EN
Synchronized
clock input
1
Oscillator
(1)
T1SYNC
OSC1/T1CKI
1
FOSC/4
Internal
Clock
OSC2/T1G
Prescaler
1, 2, 4, 8
Synchronize(3)
det
0
2
T1CKPS<1:0>
TMR1CS
1
INTOSC
Without CLKOUT
T1OSCEN
SYNCC2OUT(4)
0
T1GSS
Note 1:
2:
3:
4:
ST Buffer is low power type when using LP oscillator, or high speed type when using T1CKI.
Timer1 register increments on rising edge.
Synchronize does not operate while in Sleep.
SYNCC2OUT is synchronized when the C2SYNC bit of the CM2CON1 register is set.
DS40001262F-page 83
PIC16F631/677/685/687/689/690
6.2.1
6.2.2
Note:
6.5
Timer1 Prescaler
6.4
Timer1 Oscillator
DS40001262F-page 84
Timer1 Operation in
Asynchronous Counter Mode
6.5.1
6.3
6.6
Timer1 Gate
PIC16F631/677/685/687/689/690
Note:
6.7
Timer1 Interrupt
6.8
6.10
6.11
Comparator Synchronization
6.9
DS40001262F-page 85
PIC16F631/677/685/687/689/690
FIGURE 6-2:
T1CKI = 1
when TMR1
Enabled
T1CKI = 0
when TMR1
Enabled
Note 1:
2:
DS40001262F-page 86
PIC16F631/677/685/687/689/690
6.12
REGISTER 6-1:
R/W-0
R/W-0
(1)
T1GINV
TMR1GE
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
T1CKPS1
T1CKPS0
T1OSCEN
T1SYNC
TMR1CS
TMR1ON
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5-4
bit 3
bit 2
bit 1
bit 0
Note 1:
2:
DS40001262F-page 87
PIC16F631/677/685/687/689/690
TABLE 6-1:
Name
Bit 7
Bit 6
CM2CON1
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
MC1OUT
MC2OUT
T1GSS
C2SYNC
---- --10
---- --10
INTCON
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 0000
0000 0000
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
uuuu uuuu
TMR1H
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
TMR1L
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
uuuu uuuu
0000 0000
uuuu uuuu
T1CON
Legend:
T1GINV
TMR1GE
T1CKPS1
T1CKPS0
T1OSCEN
T1SYNC
TMR1CS
TMR1ON
x = unknown, u = unchanged, = unimplemented, read as 0. Shaded cells are not used by the Timer1 module.
DS40001262F-page 88
PIC16F631/677/685/687/689/690
7.0
TIMER2 MODULE
7.1
Timer2 Operation
FIGURE 7-1:
FOSC/4
Prescaler
1:1, 1:4, 1:16
2
TMR2
Sets Flag
bit TMR2IF
Reset
Comparator
EQ
Postscaler
1:1 to 1:16
T2CKPS<1:0>
PR2
4
TOUTPS<3:0>
DS40001262F-page 89
PIC16F631/677/685/687/689/690
T2CON: TIMER 2 CONTROL REGISTER(1)
REGISTER 7-1:
U-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
TOUTPS3
TOUTPS2
TOUTPS1
TOUTPS0
TMR2ON
T2CKPS1
T2CKPS0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7
Unimplemented: Read as 0
bit 6-3
bit 2
bit 1-0
Note 1:
x = Bit is unknown
PIC16F685/PIC16F690 only.
TABLE 7-1:
Name
Bit 7
INTCON
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
0000 000x
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
PR2
1111 1111
1111 1111
TMR2
0000 0000
0000 0000
-000 0000
-000 0000
T2CON
Legend:
Note 1:
x = unknown, u = unchanged, = unimplemented read as 0. Shaded cells are not used for Timer2 module.
PIC16F685/PIC16F690 only.
TOUTPS3
DS40001262F-page 90
TOUTPS2
TOUTPS1
TOUTPS0
TMR2ON
T2CKPS1
T2CKPS0
PIC16F631/677/685/687/689/690
8.0
COMPARATOR MODULE
8.1
FIGURE 8-1:
SINGLE COMPARATOR
VIN+
VIN-
Output
VINVIN+
Output
Note:
Comparator Overview
DS40001262F-page 91
PIC16F631/677/685/687/689/690
FIGURE 8-2:
C1POL
2
D
Q1
C12IN0-
C12IN1C12IN2-
1
MUX
2
C12IN3-
EN
To
Data Bus
RD_CM1CON0
Set C1IF
Q3*RD_CM1CON0
EN
CL
NRESET
C1ON(1)
To other peripherals
C1R
C1IN+
FixedRef
CVREF
0
MUX
1
0
MUX
1
C1OUT
C1POL
Note 1:
2:
3:
C1VREN
FIGURE 8-3:
C1VIN- C1VIN+ C1
+
When C1ON = 0, the C1 comparator will produce a 0 output to the XOR Gate.
Q1 and Q3 are phases of the four-phase system clock (FOSC).
Q1 is held high during Sleep mode.
EN
RD_CM2CON0
C2CH<1:0>
Set C2IF
2
C12IN1C12IN2-
1
MUX
2
C12IN3-
EN
CL
NRESET
C2VINC2VIN+
C2OUT
C2
C2SYNC
C2POL
C2R
FixedRef
CVREF
0
MUX
1
C2VREN
DS40001262F-page 92
Q3*RD_CM2CON0
C2ON(1)
C12IN0-
C2IN+
To
Data Bus
0
MUX
1
Note 1:
2:
3:
0
MUX
1
SYNCC2OUT
to Timer1 Gate, SR latch
and other peripherals
From TMR1
Clock
When C2ON = 0, the C2 comparator will produce a 0 output to the XOR Gate.
Q1 and Q3 are phases of the four-phase system clock (FOSC).
Q1 is held high during Sleep mode.
PIC16F631/677/685/687/689/690
8.2
Comparator Control
8.2.4
COMPARATOR OUTPUT
SELECTION
Enable
Input selection
Reference selection
Output selection
Output polarity
8.2.1
8.2.3
COMPARATOR ENABLE
8.2.2
COMPARATOR REFERENCE
SELECTION
8.2.5
TABLE 8-1:
COMPARATOR OUTPUT
STATE VS. INPUT CONDITIONS
Input Condition
CxPOL
CxOUT
CxVIN-
8.3
< CxVIN+
DS40001262F-page 93
PIC16F631/677/685/687/689/690
8.4
FIGURE 8-4:
COMPARATOR
INTERRUPT TIMING W/O
CMxCON0 READ
Q1
Q3
CxIN+
TRT
Cxout
Set CxIF (edge)
CxIF
reset by software
FIGURE 8-5:
COMPARATOR
INTERRUPT TIMING WITH
CMxCON0 READ
Q1
Q3
CxIN+
TRT
Cxout
Set CxIF (edge)
CxIF
cleared by CMxCON0 read
reset by software
The CxIE bit of the PIE1 register and the PEIE and GIE
bits of the INTCON register must all be set to enable
comparator interrupts. If any of these bits are cleared,
the interrupt is not enabled, although the CxIF bit of the
PIR1 register will still be set if an interrupt condition
occurs.
DS40001262F-page 94
PIC16F631/677/685/687/689/690
8.5
8.6
Effects of a Reset
DS40001262F-page 95
PIC16F631/677/685/687/689/690
REGISTER 8-1:
R/W-0
R-0
R/W-0
R/W-0
U-0
R/W-0
R/W-0
R/W-0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C1CH0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7
bit 6
bit 5
bit 4
bit 3
Unimplemented: Read as 0
bit 2
bit 1-0
Note 1:
x = Bit is unknown
Comparator output requires the following three conditions: C1OE = 1, C1ON = 1 and corresponding
PORT TRIS bit = 0.
DS40001262F-page 96
PIC16F631/677/685/687/689/690
REGISTER 8-2:
R/W-0
R-0
R/W-0
R/W-0
U-0
R/W-0
R/W-0
R/W-0
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
C2CH0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7
bit 6
bit 5
bit 4
bit 3
Unimplemented: Read as 0
bit 2
bit 1-0
Note 1:
x = Bit is unknown
Comparator output requires the following three conditions: C2OE = 1, C2ON = 1 and corresponding
PORT TRIS bit = 0.
DS40001262F-page 97
PIC16F631/677/685/687/689/690
8.7
FIGURE 8-6:
Rs < 10K
RIC
To Comparator
AIN
VA
CPIN
5 pF
VT 0.6V
ILEAKAGE(1)
Vss
Legend: CPIN
= Input Capacitance
ILEAKAGE = Leakage Current at the pin due to various junctions
= Interconnect Resistance
RIC
RS
= Source Impedance
= Analog Voltage
VA
= Threshold Voltage
VT
Note 1:
DS40001262F-page 98
PIC16F631/677/685/687/689/690
8.8
8.8.2
8.8.1
SYNCHRONIZING COMPARATOR
C2 OUTPUT TO TIMER1
8.8.3
SIMULTANEOUS COMPARATOR
OUTPUT READ
REGISTER 8-3:
R-0
R-0
U-0
U-0
U-0
U-0
R/W-1
R/W-0
MC1OUT
MC2OUT
T1GSS
C2SYNC
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7
bit 6
bit 5-2
Unimplemented: Read as 0
bit 1
bit 0
Note 1:
2:
x = Bit is unknown
DS40001262F-page 99
PIC16F631/677/685/687/689/690
8.9
8.9.2
Comparator SR Latch
8.9.1
LATCH OPERATION
FIGURE 8-7:
LATCH OUTPUT
PULSS
Pulse
Gen(2)
0
MUX
1
C1OUT pin(3)
C1SEN
SR
Latch(1)
C2OE
C2REN
PULSR
Note 1:
2:
3:
Pulse
Gen(2)
1
MUX
0
C2OUT pin(3)
SR1
If R = 1 and S = 1 simultaneously, Q = 0, Q = 1
Pulse generator causes a 1/2 Q-state (1 Tosc) pulse width.
Output shown for reference only. See I/O port pin block diagram for more detail.
DS40001262F-page 100
PIC16F631/677/685/687/689/690
REGISTER 8-4:
R/W-0
R/W-0
(2)
(2)
SR1
SR0
R/W-0
R/W-0
R/S-0
R/S-0
U-0
U-0
C1SEN
C2REN
PULSS
PULSR
bit 7
bit 0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1-0
Unimplemented: Read as 0
Note 1:
2:
The CxOUT bit in the CMxCON0 register will always reflect the actual comparator output (not the level on
the pin), regardless of the SR latch operation.
To enable an SR latch output to the pin, the appropriate CxOE and TRIS bits must be properly configured.
DS40001262F-page 101
PIC16F631/677/685/687/689/690
8.10
8.10.3
8.10.1
8.10.4
INDEPENDENT OPERATION
8.10.2
EQUATION 8-1:
V RR = 1 (low range):
CVREF = (VR<3:0>/24) V DD
V RR = 0 (high range):
CV REF = (VDD/4) + (VR<3:0> VDD/32)
The full range of VSS to VDD cannot be realized due to
the construction of the module. See Figure 8-8.
DS40001262F-page 102
PIC16F631/677/685/687/689/690
8.10.5
8.10.7
8.10.6
FIGURE 8-8:
VOLTAGE REFERENCE
SELECTION
VDD
VRR
8R
Analog
MUX
15
CVREF(1)
To Comparators
and ADC Module
0
VR<3:0>(1)
C1VREN
C2VREN
VP6EN
Sleep
HFINTOSC enable
Fixed Ref
To Comparators
and ADC Module
0.6V
EN
Fixed Voltage
Reference
Note 1:
DS40001262F-page 103
PIC16F631/677/685/687/689/690
REGISTER 8-5:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
C1VREN
C2VREN
VRR
VP6EN
VR3
VR2
VR1
VR0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3-0
VR<3:0>: Comparator Voltage Reference CVREF Value Selection bits (0 VR<3:0> 15)
When VRR = 1: CVREF = (VR<3:0>/24) * VDD
When VRR = 0: CVREF = VDD/4 + (VR<3:0>/32) * VDD
TABLE 8-2:
Name
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
ANSEL
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
1111 1111
1111 1111
CM1CON0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C1CH0
0000 -000
0000 0000
CM2CON0
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
C2CH0
0000 -000
0000 -000
CM2CON1
MC1OUT
MC2OUT
T1GSS
C2SYNC
00-- --10
00-- --10
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
PIE2
OSFIE
C2IE
C1IE
EEIE
0000 ----
0000 ----
PIR2
OSFIF
C2IF
C1IF
EEIF
0000----
0000----
PORTA
RA5
RA4
RA3
RA2
RA1
RA0
--xx xxxx
--uu uuuu
PORTC
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
xxxx xxxx
uuuu uuuu
SRCON
SR1
SR0
C1SEN
C2REN
PULSS
PULSR
0000 00--
0000 00--
INTCON
TRISA
TRISA1
TRISA0
--11 1111
--11 1111
TRISC
TRISC7
TRISC6
TRISC1
TRISC0
1111 1111
1111 1111
VRCON
C1VREN
C2VREN
VR1
VR0
0000 0000
0000 0000
Legend:
VRR
VP6EN
VR3
VR2
x = unknown, u = unchanged, = unimplemented, read as 0. Shaded cells are not used for comparator.
DS40001262F-page 104
PIC16F631/677/685/687/689/690
9.0
ANALOG-TO-DIGITAL
CONVERTER (ADC) MODULE
FIGURE 9-1:
VCFG = 1
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN0-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA4/AN3/T1G/OSC2/CLKOUT
RC0/AN4/C2IN+
RC1/AN5/C12IN1RC2/AN6/C12IN2-/P1D(1)
ADC
RC3/AN7/C12IN3-/P1C(1)
RC6/AN8/SS(2)
10
GO/DONE
RC7/AN9/SDO(2)
ADFM
RB4/AN10/SDI/SDA(2)
RB5/AN11/RX/DT(2)
0 = Left Justify
1 = Right Justify
ADON
10
CVREF
VSS
VP6 Reference
ADRESH
ADRESL
CHS
Note 1:
2:
3:
DS40001262F-page 105
PIC16F631/677/685/687/689/690
9.1
ADC Configuration
Port configuration
Channel selection
ADC voltage reference selection
ADC conversion clock source
Interrupt control
Results formatting
9.1.1
PORT CONFIGURATION
9.1.2
CHANNEL SELECTION
9.1.3
9.1.4
CONVERSION CLOCK
FOSC/2
FOSC/4
FOSC/8
FOSC/16
FOSC/32
FOSC/64
FRC (dedicated internal oscillator)
DS40001262F-page 106
PIC16F631/677/685/687/689/690
TABLE 9-1:
ADC CLOCK PERIOD (TAD) VS. DEVICE OPERATING FREQUENCIES (VDD > 3.0V,
VREF > 2.5V)
ADCS<2:0>
20 MHz
FOSC/2
000
100 ns
FOSC/4
100
200 ns(2)
001
400 ns
(2)
800 ns
(2)
FOSC/8
FOSC/16
101
FOSC/32
010
1.6 s
FOSC/64
110
3.2 s
FRC
x11
2-6 s(1,4)
Legend:
Note 1:
2:
3:
4:
8 MHz
(2)
4 MHz
1 MHz
(2)
2.0 s
1.0 s(2)
4.0 s
2.0 s
8.0 s(3)
2.0 s
4.0 s
16.0 s(3)
4.0 s
8.0 s(3)
32.0 s(3)
(3)
16.0 s
64.0 s(3)
2-6 s(1,4)
2-6 s(1,4)
250 ns
(2)
500 ns
500 ns(2)
1.0 s
(2)
8.0 s
(3)
2-6 s(1,4)
FIGURE 9-2:
TCY to TAD TAD1 TAD2 TAD3 TAD4 TAD5 TAD6 TAD7 TAD8 TAD9 TAD10 TAD11
b9
b8
b7
b6
b5
b4
b3
b2
b1
b0
Conversion Starts
Holding Capacitor is disconnected from analog input (typically 100 ns)
Set GO/DONE bit
9.1.5
INTERRUPTS
DS40001262F-page 107
PIC16F631/677/685/687/689/690
9.1.6
RESULT FORMATTING
FIGURE 9-3:
(ADFM = 0)
ADRESL
MSB
LSB
bit 7
bit 0
bit 7
Unimplemented: Read as 0
MSB
(ADFM = 1)
bit 7
Unimplemented: Read as 0
DS40001262F-page 108
bit 0
LSB
bit 0
bit 7
bit 0
10-bit A/D Result
PIC16F631/677/685/687/689/690
9.2
9.2.1
ADC Operation
STARTING A CONVERSION
9.2.5
9.2.6
9.2.2
COMPLETION OF A CONVERSION
9.2.3
Note:
9.2.4
1.
2.
3.
4.
5.
6.
TERMINATING A CONVERSION
7.
8.
Configure Port:
Disable pin output driver (See TRIS register)
Configure pin as analog
Configure the ADC module:
Select ADC conversion clock
Configure voltage reference
Select ADC input channel
Select result format
Turn on ADC module
Configure ADC interrupt (optional):
Clear ADC interrupt flag
Enable ADC interrupt
Enable peripheral interrupt
Enable global interrupt(1)
Wait the required acquisition time(2).
Start conversion by setting the GO/DONE bit.
Wait for ADC conversion to complete by one of
the following:
Polling the GO/DONE bit
Waiting for the ADC interrupt (interrupts
enabled)
Read ADC Result
Clear the ADC interrupt flag (required if interrupt
is enabled).
A/D
Acquisition
DS40001262F-page 109
PIC16F631/677/685/687/689/690
EXAMPLE 9-1:
A/D CONVERSION
9.2.7
DS40001262F-page 110
PIC16F631/677/685/687/689/690
REGISTER 9-1:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
ADFM
VCFG
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5-2
bit 1
bit 0
DS40001262F-page 111
PIC16F631/677/685/687/689/690
REGISTER 9-2:
U-0
R/W-0
R/W-0
R/W-0
U-0
U-0
U-0
U-0
ADCS2
ADCS1
ADCS0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
Unimplemented: Read as 0
bit 6-4
bit 3-0
Unimplemented: Read as 0
DS40001262F-page 112
PIC16F631/677/685/687/689/690
REGISTER 9-3:
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
ADRES9
ADRES8
ADRES7
ADRES6
ADRES5
ADRES4
ADRES3
ADRES2
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-0
x = Bit is unknown
REGISTER 9-4:
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
ADRES1
ADRES0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-6
bit 5-0
REGISTER 9-5:
x = Bit is unknown
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
ADRES9
ADRES8
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-2
bit 1-0
REGISTER 9-6:
x = Bit is unknown
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
ADRES7
ADRES6
ADRES5
ADRES4
ADRES3
ADRES2
ADRES1
ADRES0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-0
x = Bit is unknown
DS40001262F-page 113
PIC16F631/677/685/687/689/690
9.3
EQUATION 9-1:
Assumptions:
T ACQ = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient
= T AMP + T C + T COFF
= 2s + T C + Temperature - 25C 0.05s/C
The value for TC can be approximated with the following equations:
1
= V CHOLD
V AP P LI ED 1 -------------------------n+1
2
1
TC
----------
RC
V AP P LI ED 1 e = V CHOLD
Tc
---------
1
RC
;combining [1] and [2]
V AP P LI ED 1 e = V A PP LIE D 1 -------------------------n+1
2
1
T C = C HOLD R IC + R SS + R S ln(1/2047)
= 10pF 1k + 7k + 10k ln(0.0004885)
= 1.37 s
Therefore:
T ACQ = 2S + 1.37 S + 50C- 25C 0.05S /C
= 4.67 S
DS40001262F-page 114
PIC16F631/677/685/687/689/690
Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out.
2: The charge holding capacitor (CHOLD) is not discharged after each conversion.
3: The maximum recommended impedance for analog sources is 10 k. This is required to meet the pin
leakage specification.
FIGURE 9-4:
VT = 0.6V
ANx
CPIN
5 pF
VT = 0.6V
Sampling
Switch
SS Rss
RIC 1k
I LEAKAGE(1)
CHOLD = 10 pF
VSS/VREF-
6V
5V
VDD 4V
3V
2V
Legend: CPIN
= Input Capacitance
VT
= Threshold Voltage
I LEAKAGE = Leakage current at the pin due to
various junctions
RIC
= Interconnect Resistance
SS
= Sampling Switch
CHOLD
= Sample/Hold Capacitance
Note 1:
FIGURE 9-5:
RSS
5 6 7 8 9 10 11
Sampling Switch
(k)
Full-Scale Range
3FFh
3FEh
ADC Output Code
3FDh
3FCh
1 LSB ideal
3FBh
Full-Scale
Transition
004h
003h
002h
001h
000h
VSS/VREF-
Zero-Scale
Transition
VDD/VREF+
DS40001262F-page 115
PIC16F631/677/685/687/689/690
TABLE 9-2:
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
ADCON0
ADFM
VCFG
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
0000 0000
0000 0000
ADCON1
ANSEL
ANSELH
ADCS2
ADCS1
ADCS0
-000 ----
-000 ----
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
1111 1111
1111 1111
ANS11
ANS10
ANS9
ANS8
---- 1111
---- 1111
xxxx xxxx
uuuu uuuu
ADRESH
ADRESL
xxxx xxxx
uuuu uuuu
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
INTCON
PORTA
RA5
RA4
RA3
RA2
RA1
RA0
--xx xxxx
--uu uuuu
PORTB
RB7
RB6
RB5
RB4
xxxx ----
uuuu ----
PORTC
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
xxxx xxxx
uuuu uuuu
TRISA
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
--11 1111
--11 1111
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
Legend:
x = unknown, u = unchanged, = unimplemented read as 0. Shaded cells are not used for ADC module.
DS40001262F-page 116
PIC16F631/677/685/687/689/690
10.0
EECON1
EECON2
EEDAT
EEDATH (PIC16F685/PIC16F689/PIC16F690 only)
EEADR
EEADRH (PIC16F685/PIC16F689/PIC16F690 only)
10.1
10.1.1
DS40001262F-page 117
PIC16F631/677/685/687/689/690
REGISTER 10-1:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
EEDAT7
EEDAT6
EEDAT5
EEDAT4
EEDAT3
EEDAT2
EEDAT1
EEDAT0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-0
x = Bit is unknown
EEDAT<7:0>: Eight Least Significant Address bits to Write to or Read from data EEPROM or Read from program
memory
REGISTER 10-2:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
EEADR7(1)
EEADR6
EEADR5
EEADR4
EEADR3
EEADR2
EEADR1
EEADR0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
EEADR<7:0>: Eight Least Significant Address bits for EEPROM Read/Write Operation(1) or Read from program
memory
bit 7-0
Note 1:
PIC16F677/PIC16F685/PIC16F687/PIC16F689/PIC16F690 only.
REGISTER 10-3:
U-0
U-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
EEDATH5
EEDATH4
EEDATH3
EEDATH2
EEDATH1
EEDATH0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-6
Unimplemented: Read as 0
bit 5-0
Note 1:
PIC16F685/PIC16F689/PIC16F690 only.
REGISTER 10-4:
U-0
U-0
U-0
U-0
R/W-0
R/W-0
R/W-0
R/W-0
EEADRH3
EEADRH2
EEADRH1
EEADRH0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-4
Unimplemented: Read as 0
bit 3-0
EEADRH<3:0>: Specifies the four Most Significant Address bits or high bits for program memory reads
DS40001262F-page 118
PIC16F631/677/685/687/689/690
REGISTER 10-4:
Note 1:
PIC16F685/PIC16F689/PIC16F690 only.
REGISTER 10-5:
R/W-x
(1)
EEPGD
U-0
U-0
R/W-x
R/W-0
R/S-0
R/S-0
WRERR
WREN
WR
RD
bit 7
bit 0
Legend:
S = Bit can only be set
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6-4
Unimplemented: Read as 0
bit 3
bit 2
bit 1
bit 0
Note 1:
PIC16F685/PIC16F689/PIC16F690 only.
DS40001262F-page 119
PIC16F631/677/685/687/689/690
10.1.2
10.1.3
EXAMPLE 10-1:
BANKSEL EEADR
;
MOVF
DATA_EE_ADDR, W;
MOVWF
EEADR
;Data Memory
;Address to read
BANKSEL EECON1
;
BCF
EECON1, EEPGD;Point to DATA memory
BSF
EECON1, RD ;EE Read
BANKSEL EEDAT
;
MOVF
EEDAT, W
;W = EEDAT
BANKSEL PORTA
;Bank 0
EXAMPLE 10-2:
Required
Sequence
BANKSELEEADR
;
MOVFDATA_EE_ADDR, W;
MOVWFEEADR
;Data Memory Address to write
MOVFDATA_EE_DATA, W;
MOVWFEEDAT
;Data Memory Value to write
BANKSELEECON1
;
BCF EECON1, EEPGD;Point to DATA memory
BSF EECON1, WREN ;Enable writes
BCF INTCON, GIE ;Disable INTs.
BTFSCINTCON, GIE;SEE AN576
GOTO$-2
MOVLW55h
;
MOVWFEECON2
;Write 55h
MOVLWAAh
;
MOVWFEECON2
;Write AAh
BSF EECON1, WR ;Set WR bit to begin write
BSF INTCON, GIE ;Enable INTs.
SLEEP
;Wait for interrupt to signal write complete (optional)
BCF EECON1, WREN ;Disable writes
BANKSEL0x00
;Bank 0
DS40001262F-page 120
PIC16F631/677/685/687/689/690
10.1.4
Required
Sequence
EXAMPLE 10-3:
BANKSEL EEADR
MOVF
MS_PROG_EE_ADDR, W
MOVWF
EEADRH
MOVF
LS_PROG_EE_ADDR, W
MOVWF
EEADR
BANKSELEECON1
;
BSF
EECON1, EEPGD
BSF
EECON1, RD
;
;
;MS Byte of Program Address to read
;
;LS Byte of Program Address to read
NOP
NOP
;
BANKSELEEDAT
MOVF
EEDAT, W
MOVWF
LOWPMBYTE
MOVF
EEDATH, W
MOVWF
HIGHPMBYTE
BANKSEL0x00
;
;W = LS Byte of Program Memory
;
;W = MS Byte of Program EEDAT
;
;Bank 0
DS40001262F-page 121
PIC16F631/677/685/687/689/690
FIGURE 10-1:
Table 0-1:
Q
1
Q
2
Q
3
Q
4
PC
Flash ADDR
Flash Data
Q
1
Q
2
Q
3
Q
4
PC + 1
INSTR (PC)
INSTR(PC - 1)
executed here
Q
1
Q
2
Q
3
Q
4
EEADRH,EEADR
INSTR (PC + 1)
BSF EECON1,RD
executed here
Q
1
Q
2
Q
4
PC
+3
PC+3
EEDATH,EEDAT
INSTR(PC + 1)
executed here
Q
3
Q
1
Q
2
Q
3
Q
4
Forced NOP
executed here
Q
2
Q
3
Q
4
PC + 5
PC + 4
INSTR (PC + 3)
Q
1
INSTR (PC + 4)
INSTR(PC + 3)
executed here
INSTR(PC + 4)
executed here
RD bit
EEDATH
EEDAT
Register
EERHLT
DS40001262F-page 122
PIC16F631/677/685/687/689/690
10.2
Write Verify
EXAMPLE 10-4:
WRITE VERIFY
BANKSEL EEDAT
MOVF
EEDAT, W
;
;EEDAT not changed
;from previous write
BANKSEL EECON1
;
BSF
EECON1, RD ;YES, Read the
;value written
BANKSEL EEDAT
;
XORWF
EEDAT, W
;
BTFSS
STATUS, Z ;Is data the same
GOTO
WRITE_ERR ;No, handle error
:
;Yes, continue
BANKSEL 0x00
;Bank 0
10.2.1
10.3
10.4
DS40001262F-page 123
PIC16F631/677/685/687/689/690
TABLE 10-1:
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
EECON1
EEPGD(1)
WRERR
WREN
WR
RD
x--- x000
0--- q000
EECON2
EEADR
EEADR7(2) EEADR6
Name
EEADRH(1)
EEDAT
EEDATH(1)
INTCON
PIE2
PIR2
Legend:
Note
1:
2:
EEADR5
---- ----
---- ----
EEADR4
EEADR3
EEADR2
EEADR1
EEADR0
0000 0000
0000 0000
EEADRH3
EEADRH2
EEADRH1
EEADRH0
---- 0000
---- 0000
EEDAT7
EEDAT6
EEDAT5
EEDAT4
EEDAT3
EEDAT2
EEDAT1
EEDAT0
0000 0000
0000 0000
--00 0000
EEDATH5
EEDATH4
EEDATH3
EEDATH2
EEDATH1
EEDATH0
--00 0000
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 0000
0000 0000
OSFIE
C2IE
C1IE
EEIE
0000 ----
0000 ----
OSFIF
C2IF
C1IF
EEIF
0000 ----
0000 ----
DS40001262F-page 124
PIC16F631/677/685/687/689/690
11.0
ENHANCED CAPTURE/
COMPARE/PWM MODULE
REGISTER 11-1:
TABLE 11-1:
ECCP Mode
Timer Resource
Capture
Timer1
Compare
Timer1
PWM
Timer2
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CCP1M2
CCP1M1
CCP1M0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-6
bit 5-4
bit 3-0
DS40001262F-page 125
PIC16F631/677/685/687/689/690
11.1
11.1.2
Capture Mode
11.1.1
FIGURE 11-1:
Prescaler
1, 4, 16
CAPTURE MODE
OPERATION BLOCK
DIAGRAM
Set Flag bit CCP1IF
(PIR1 register)
CCP1
pin
CCPR1H
and
Edge Detect
TMR1H
11.1.3
SOFTWARE INTERRUPT
11.1.4
CCP PRESCALER
EXAMPLE 11-1:
CHANGING BETWEEN
CAPTURE PRESCALERS
BANKSEL CCP1CON
CLRF
MOVLW
CCPR1L
MOVWF
Capture
Enable
TMR1L
CCP1CON<3:0>
System Clock (FOSC)
DS40001262F-page 126
PIC16F631/677/685/687/689/690
11.2
11.2.2
Compare Mode
FIGURE 11-2:
COMPARE MODE
OPERATION BLOCK
DIAGRAM
CCP1CON<3:0>
Mode Select
S
R
Output
Logic
Match
TRIS
Output Enable
Comparator
TMR1H
TMR1L
11.2.1
11.2.4
CCP1
Pin
11.2.3
DS40001262F-page 127
PIC16F631/677/685/687/689/690
11.3
PWM Mode
PR2
T2CON
CCPR1L
CCP1CON
FIGURE 11-4:
Period
Pulse Width
TMR2 = PR2
TMR2 = CCPR1L:CCP1CON<5:4>
TMR2 = 0
FIGURE 11-3:
CCPR1H(2) (Slave)
CCP1
R
Comparator
TMR2
(1)
S
TRIS
Comparator
PR2
Note 1:
2:
Clear Timer2,
toggle CCP1 pin and
latch duty cycle
DS40001262F-page 128
PIC16F631/677/685/687/689/690
11.3.1
PWM PERIOD
EQUATION 11-2:
EQUATION 11-1:
CCPR1L:CCP1CON<5:4>
Duty Cycle Ratio = ----------------------------------------------------------------------4 PR2 + 1
TOSC = 1/FOSC
11.3.2
EQUATION 11-3:
Note:
PWM PERIOD
Note:
PULSE WIDTH
11.3.3
PWM RESOLUTION
EQUATION 11-4:
PWM RESOLUTION
log 4 PR2 + 1
Resolution = ------------------------------------------ bits
log 2
TABLE 11-2:
PWM Frequency
1.22 kHz
TABLE 11-3:
Note:
4.88 kHz
19.53 kHz
78.12 kHz
156.3 kHz
208.3 kHz
16
0xFF
0xFF
0xFF
0x3F
0x1F
0x17
10
10
10
6.6
PWM Frequency
1.22 kHz
4.90 kHz
19.61 kHz
76.92 kHz
153.85 kHz
200.0 kHz
16
0x65
0x65
0x65
0x19
0x0C
0x09
DS40001262F-page 129
PIC16F631/677/685/687/689/690
11.3.4
11.3.5
11.3.6
EFFECTS OF RESET
Any Reset will force all ports to Input mode and the
CCP registers to their Reset states.
11.3.7
4.
5.
6.
DS40001262F-page 130
11.4
Single PWM
Half-Bridge PWM
Full-Bridge PWM, Forward mode
Full-Bridge PWM, Reverse mode
PIC16F631/677/685/687/689/690
FIGURE 11-5:
DC1B<1:0>
CCP1M<3:0>
4
P1M<1:0>
2
CCPR1L
CCP1/P1A
CCP1/P1A
TRIS
CCPR1H (Slave)
P1B
R
Comparator
Output
Controller
P1B
TRIS
P1C
TMR2
(1)
TRIS
S
P1D
Comparator
Clear Timer2,
toggle PWM pin and
latch duty cycle
PR2
Note
1:
P1C
P1D
TRIS
PWM1CON
The 8-bit timer TMR2 register is concatenated with the 2-bit internal Q clock, or 2 bits of the prescaler to create the 10-bit
time base.
Note 1: The TRIS register value for each PWM output must be configured appropriately.
2: Clearing the CCP1CON register will relinquish ECCP control of all PWM output pins.
3: Any pin not used by an Enhanced PWM mode is available for alternate pin functions
TABLE 11-4:
ECCP Mode
P1M<1:0>
Single
00
Half-Bridge
10
CCP1/P1A
Yes
(1)
Yes
P1B
P1C
P1D
Yes(1)
Yes(1)
Yes(1)
Yes
No
No
Full-Bridge, Forward
01
Yes
Yes
Yes
Yes
Full-Bridge, Reverse
11
Yes
Yes
Yes
Yes
Note 1:
DS40001262F-page 131
PIC16F631/677/685/687/689/690
FIGURE 11-6:
P1M<1:0>
Signal
PR2+1
Pulse
Width
Period
00
(Single Output)
P1A Modulated
Delay(1)
Delay(1)
P1A Modulated
10
(Half-Bridge)
P1B Modulated
P1A Active
01
(Full-Bridge,
Forward)
P1B Inactive
P1C Inactive
P1D Modulated
P1A Inactive
11
(Full-Bridge,
Reverse)
P1B Modulated
P1C Active
P1D Inactive
Relationships:
Period = 4 * TOSC * (PR2 + 1) * (TMR2 Prescale Value)
Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 Prescale Value)
Delay = 4 * TOSC * (PWM1CON<6:0>)
Note 1: Dead-band delay is programmed using the PWM1CON register (Section 11.4.6 Programmable Dead-Band Delay
mode).
DS40001262F-page 132
PIC16F631/677/685/687/689/690
FIGURE 11-7:
P1M<1:0>
PR2+1
Pulse
Width
Period
00
(Single Output)
P1A Modulated
P1A Modulated
Delay(1)
10
(Half-Bridge)
Delay(1)
P1B Modulated
P1A Active
01
(Full-Bridge,
Forward)
P1B Inactive
P1C Inactive
P1D Modulated
P1A Inactive
11
(Full-Bridge,
Reverse)
P1B Modulated
P1C Active
P1D Inactive
Relationships:
Period = 4 * TOSC * (PR2 + 1) * (TMR2 Prescale Value)
Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 Prescale Value)
Delay = 4 * TOSC * (PWM1CON<6:0>)
Note
1:
Dead-band delay is programmed using the PWM1CON register (Section 11.4.6 Programmable Dead-Band Delay
mode).
DS40001262F-page 133
PIC16F631/677/685/687/689/690
11.4.1
HALF-BRIDGE MODE
FIGURE 11-8:
Period
Period
Pulse Width
P1A(2)
td
td
P1B(2)
(1)
(1)
(1)
td = Dead-Band Delay
Note 1:
2:
FIGURE 11-9:
P1A
Load
FET
Driver
P1B
FET
Driver
FET
Driver
P1A
FET
Driver
Load
FET
Driver
P1B
DS40001262F-page 134
PIC16F631/677/685/687/689/690
11.4.2
FULL-BRIDGE MODE
FIGURE 11-10:
FET
Driver
QC
QA
FET
Driver
P1A
Load
P1B
FET
Driver
P1C
FET
Driver
QD
QB
VP1D
DS40001262F-page 135
PIC16F631/677/685/687/689/690
FIGURE 11-11:
Forward Mode
Period
P1A
(2)
Pulse Width
P1B(2)
P1C(2)
P1D(2)
(1)
(1)
Reverse Mode
Period
Pulse Width
P1A(2)
P1B(2)
P1C(2)
P1D(2)
(1)
Note 1:
2:
(1)
DS40001262F-page 136
PIC16F631/677/685/687/689/690
11.4.2.1
FIGURE 11-12:
Signal
Period
P1A (Active-High)
P1B (Active-High)
Pulse Width
P1C (Active-High)
(2)
P1D (Active-High)
Pulse Width
Note 1:
2:
The direction bit P1M1 of the CCP1CON register is written any time during the PWM cycle.
When changing directions, the P1A and P1C signals switch before the end of the current PWM cycle. The
modulated P1B and P1D signals are inactive at this time. The length of this time is (1/Fosc) TMR2 prescale
value.
DS40001262F-page 137
PIC16F631/677/685/687/689/690
FIGURE 11-13:
t1
Reverse Period
P1A
P1B
PW
P1C
P1D
PW
TON
External Switch C
TOFF
External Switch D
Potential
Shoot-Through Current
Note 1:
11.4.3
T = TOFF TON
2:
3:
START-UP CONSIDERATIONS
DS40001262F-page 138
PIC16F631/677/685/687/689/690
11.4.4
FIGURE 11-14:
Drive logic 1
Drive logic 0
Tri-state (high-impedance)
ECCPAS<2:0>
PSSAC<0>
P1A_DRV
111
1
0
110
PSSAC<1>
101
100
INT
P1A
TRISx
011
From Comparator C2
010
PSSBD<0>
From Comparator C1
001
P1B_DRV
000
1
0
PRSEN
PSSBD<1>
P1B
TRISx
ECCPASE
PSSAC<0>
P1C_DRV
1
0
PSSAC<1>
P1C
TRISx
PSSBD<0>
P1D_DRV
1
0
PSSBD<1>
TRISx
P1D
DS40001262F-page 139
PIC16F631/677/685/687/689/690
REGISTER 11-2:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
ECCPASE
ECCPAS2
ECCPAS1
ECCPAS0
PSSAC1
PSSAC0
PSSBD1
PSSBD0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6-4
bit 3-2
bit 1-0
Note 1:
DS40001262F-page 140
PIC16F631/677/685/687/689/690
FIGURE 11-15:
Shutdown Event
ECCPASE bit
PWM Activity
PWM Period
Start of
PWM Period
11.4.5
ECCPASE
Cleared by
Shutdown
Shutdown Firmware PWM
Event Occurs Event Clears
Resumes
AUTO-RESTART MODE
The Enhanced PWM can be configured to automatically restart the PWM signal once the auto-shutdown
condition has been removed. Auto-restart is enabled by
setting the PRSEN bit in the PWM1CON register.
If auto-restart is enabled, the ECCPASE bit will remain
set as long as the auto-shutdown condition is active.
When the auto-shutdown condition is removed, the
ECCPASE bit will be cleared via hardware and normal
operation will resume.
FIGURE 11-16:
Shutdown Event
ECCPASE bit
PWM Activity
PWM Period
Start of
PWM Period
Shutdown
Shutdown
Event Occurs Event Clears
PWM
Resumes
DS40001262F-page 141
PIC16F631/677/685/687/689/690
11.4.6
PROGRAMMABLE DEAD-BAND
DELAY MODE
FIGURE 11-17:
Period
Period
Pulse Width
P1A(2)
td
td
P1B(2)
(1)
(1)
(1)
td = Dead-Band Delay
Note 1:
2:
In Half-Bridge mode, a digitally programmable deadband delay is available to avoid shoot-through current
from destroying the bridge power switches. The delay
occurs at the signal transition from the non-active state
to the active state. See Figure 11-8 for illustration. The
lower seven bits of the associated PWM1CON register
(Register 11-3) sets the delay period in terms of
microcontroller instruction cycles (TCY or 4 TOSC).
FIGURE 11-18:
+
V
-
P1A
Load
FET
Driver
+
V
-
P1B
V-
DS40001262F-page 142
PIC16F631/677/685/687/689/690
REGISTER 11-3:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
PRSEN
PDC6
PDC5
PDC4
PDC3
PDC2
PDC1
PDC0
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6-0
DS40001262F-page 143
PIC16F631/677/685/687/689/690
11.4.7
Note:
REGISTER 11-4:
U-0
U-0
U-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-1
STRSYNC
STRD
STRC
STRB
STRA
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-5
Unimplemented: Read as 0
bit 4
bit 3
bit 2
bit 1
bit 0
Note 1:
The PWM Steering mode is available only when the CCP1CON register bits CCP1M<3:2> = 11 and
P1M<1:0> = 00.
DS40001262F-page 144
PIC16F631/677/685/687/689/690
FIGURE 11-19:
SIMPLIFIED STEERING
BLOCK DIAGRAM
STRA
P1A Signal
CCP1M1
PORT Data
P1A pin
STRB
CCP1M0
PORT Data
TRIS
P1B pin
TRIS
STRC
CCP1M1
PORT Data
P1C pin
TRIS
STRD
CCP1M0
PORT Data
P1D pin
TRIS
Note 1:
2:
DS40001262F-page 145
PIC16F631/677/685/687/689/690
11.4.7.1
Steering Synchronization
FIGURE 11-20:
PWM
STRn
P1<D:A>
PORT Data
PORT Data
P1n = PWM
FIGURE 11-21:
PWM
STRn
P1<D:A>
PORT Data
PORT Data
P1n = PWM
DS40001262F-page 146
PIC16F631/677/685/687/689/690
TABLE 11-5:
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
CCP1CON
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CM1CON0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
T1GSS
CM2CON0
Bit 0
Value on
POR, BOR
Value on
all other
Resets
C2CH0
CM2CON1
MC1OUT MC2OUT
CCPR1L
CCPR1H
ECCPAS
PSSAC1
PSSAC0
PSSBD1
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
PSTRCON
STRSYNC
STRD
STRC
STRB
STRA
PWM1CON
PRSEN
PDC6
PDC5
PDC4
PDC3
PDC2
PDC1
PDC0
T1CON
T1GINV
INTCON
T2CON
TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
TMR1L
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
TMR1H
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
TMR2
TRISC
TRISC7
TRISC6
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
Legend: = Unimplemented locations, read as 0, u = unchanged, x = unknown. Shaded cells are not used by the Capture,
Compare and PWM.
DS40001262F-page 147
PIC16F631/677/685/687/689/690
12.0
ENHANCED UNIVERSAL
SYNCHRONOUS
ASYNCHRONOUS RECEIVER
TRANSMITTER (EUSART)
FIGURE 12-1:
TXIE
Interrupt
TXIF
TXREG Register
8
MSb
TX/CK pin
LSb
(8)
Pin Buffer
and Control
TRMT
SPEN
TXEN
Baud Rate Generator
FOSC
TX9
BRG16
+1
SPBRGH
SPBRG
DS40001262F-page 148
Multiplier
x4
x16 x64
SYNC
1 X 0 0
BRGH
X 1 1 0
BRG16
X 1 0 1
TX9D
PIC16F631/677/685/687/689/690
FIGURE 12-2:
CREN
RX/DT pin
Data
Recovery
FOSC
BRG16
SPBRGH
SPBRG
Multiplier
x4
x16 x64
SYNC
1 X 0 0
BRGH
X 1 1 0
BRG16
X 1 0 1
Stop
RCIDL
RSR Register
MSb
Pin Buffer
and Control
+1
OERR
(8)
LSb
0 START
RX9
FERR
RX9D
RCREG Register
FIFO
8
Data Bus
RCIF
RCIE
Interrupt
DS40001262F-page 149
PIC16F631/677/685/687/689/690
12.1
12.1.1
EUSART ASYNCHRONOUS
TRANSMITTER
12.1.1.1
DS40001262F-page 150
12.1.1.2
Transmitting Data
12.1.1.3
PIC16F631/677/685/687/689/690
12.1.1.4
TSR Status
12.1.1.6
12.1.1.5
1.
2.
3.
5.
6.
7.
FIGURE 12-3:
ASYNCHRONOUS TRANSMISSION
Write to TXREG
BRG Output
(Shift Clock)
Word 1
TX/CK
pin
Start bit
FIGURE 12-4:
bit 1
bit 7/8
Stop bit
Word 1
TXIF bit
(Transmit Buffer
Reg. Empty Flag)
TRMT bit
(Transmit Shift
Reg. Empty Flag)
bit 0
1 TCY
Word 1
Transmit Shift Reg
Write to TXREG
BRG Output
(Shift Clock)
Word 1
TX/CK
pin
TXIF bit
(Transmit Buffer
Reg. Empty Flag)
TRMT bit
(Transmit Shift
Reg. Empty Flag)
Note:
Word 2
Start bit
bit 0
1 TCY
bit 1
Word 1
bit 7/8
Stop bit
Start bit
bit 0
Word 2
1 TCY
Word 1
Transmit Shift Reg
Word 2
Transmit Shift Reg
DS40001262F-page 151
PIC16F631/677/685/687/689/690
TABLE 12-1:
Name
Bit 7
Bit 6
BAUDCTL
ABDOVF
GIE
INTCON
PIE1
PIR1
RCREG
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
0000 0000
0000 0000
Bit 5
Bit 4
Bit 3
RCIDL
SCKP
PEIE
T0IE
INTE
ADIE
RCIE
ADIF
RCIF
RCSTA
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
0000 000x
0000 000x
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
BRG11
BRG10
BRG9
BRG8
SPBRGH
BRG15
BRG14
BRG13
BRG12
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
TXREG
TXSTA
Legend:
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
0000 0000
0000 0000
1111 ----
1111 ----
0000 0000
0000 0000
0000 0010
0000 0010
x = unknown, = unimplemented read as 0. Shaded cells are not used for Asynchronous Transmission.
DS40001262F-page 152
PIC16F631/677/685/687/689/690
12.1.2
EUSART ASYNCHRONOUS
RECEIVER
12.1.2.1
12.1.2.2
Receiving Data
12.1.2.3
Receive Interrupts
DS40001262F-page 153
PIC16F631/677/685/687/689/690
12.1.2.4
12.1.2.5
12.1.2.7
Address Detection
12.1.2.6
DS40001262F-page 154
PIC16F631/677/685/687/689/690
12.1.2.8
1.
2.
3.
4.
5.
6.
7.
8.
9.
12.1.2.9
FIGURE 12-5:
ASYNCHRONOUS RECEPTION
Start
bit
bit 0
RX/DT pin
bit 1
Rcv Shift
Reg
Rcv Buffer Reg
RCIDL
Start
bit
Word 1
RCREG
bit 0
Start
bit
Word 2
RCREG
Read Rcv
Buffer Reg
RCREG
RCIF
(Interrupt Flag)
OERR bit
CREN
Note:
This timing diagram shows three words appearing on the RX input. The RCREG (receive buffer) is read after the third word,
causing the OERR (overrun) bit to be set.
DS40001262F-page 155
PIC16F631/677/685/687/689/690
TABLE 12-2:
Name
Bit 7
Bit 6
BAUDCTL
ABDOVF
GIE
INTCON
PIE1
PIR1
RCREG
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
0000 0000
0000 0000
Bit 5
Bit 4
Bit 3
RCIDL
SCKP
PEIE
T0IE
INTE
ADIE
RCIE
ADIF
RCIF
RCSTA
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
0000 000x
0000 000x
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
1111 ----
1111 ----
SPBRGH
BRG15
BRG14
BRG13
BRG12
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
TXREG
TXSTA
Legend:
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
0000 0000
0000 0000
0000 0010
0000 0010
x = unknown, = unimplemented read as 0. Shaded cells are not used for Asynchronous Reception.
DS40001262F-page 156
PIC16F631/677/685/687/689/690
12.2
The factory calibrates the internal oscillator block output (INTOSC). However, the INTOSC frequency may
drift as VDD or temperature changes, and this directly
affects the asynchronous baud rate. Two methods may
be used to adjust the baud rate clock, but both require
a reference clock source of some kind.
REGISTER 12-1:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R-1
R/W-0
CSRC
TX9
TXEN(1)
SYNC
SENDB
BRGH
TRMT
TX9D
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
Note 1:
DS40001262F-page 157
PIC16F631/677/685/687/689/690
RCSTA: RECEIVE STATUS AND CONTROL REGISTER(1)
REGISTER 12-2:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R-0
R-0
R-x
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
DS40001262F-page 158
PIC16F631/677/685/687/689/690
REGISTER 12-3:
R-0
R-1
U-0
R/W-0
R/W-0
U-0
R/W-0
R/W-0
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
Unimplemented: Read as 0
bit 4
bit 3
bit 2
Unimplemented: Read as 0
bit 1
bit 0
DS40001262F-page 159
PIC16F631/677/685/687/689/690
12.3
EXAMPLE 12-1:
F OS C
Desired Baud Rate = --------------------------------------------------------------------64 [SPBRGH:SPBRG] + 1
16000000
-----------------------9600
= ------------------------ 1
64
= 25.042 = 25 decimal
16000000
Calculated Baud Rate = --------------------------64 25 + 1
= 9615
TABLE 12-3:
CALCULATING BAUD
RATE ERROR
Configuration Bits
BRG/EUSART Mode
8-bit/Asynchronous
FOSC/[64 (n+1)]
8-bit/Asynchronous
16-bit/Asynchronous
16-bit/Asynchronous
8-bit/Synchronous
16-bit/Synchronous
SYNC
BRG16
BRGH
FOSC/[16 (n+1)]
1
Legend:
FOSC/[4 (n+1)]
TABLE 12-4:
Name
Bit 7
Bit 6
BAUDCTL
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
RCSTA
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
0000 000x
0000 000x
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
TXSTA
CSRC
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
0000 0010
0000 0010
Legend:
x = unknown, - = unimplemented read as 0. Shaded cells are not used for the Baud Rate Generator.
DS40001262F-page 160
PIC16F631/677/685/687/689/690
TABLE 12-5:
BAUD
RATE
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
300
1200
1221
1.73
255
1200
0.00
239
1200
0.00
143
1202
0.16
103
2400
2404
0.16
129
2400
0.00
119
2400
0.00
71
2404
0.16
51
9600
9470
-1.36
32
9600
0.00
29
9600
0.00
17
9615
0.16
12
10417
10417
0.00
29
10286
-1.26
27
10165
-2.42
16
10417
0.00
11
19.2k
19.53k
1.73
15
19.20k
0.00
14
19.20k
0.00
57.6k
57.60k
0.00
57.60k
0.00
115.2k
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
300
300
0.16
207
300
0.00
191
300
0.16
103
300
0.16
51
1200
1202
0.16
51
1200
0.00
47
1202
0.16
25
1202
0.16
12
2400
2404
0.16
25
2400
0.00
23
2404
0.16
12
9600
9600
0.00
10417
10417
0.00
10417
0.00
19.2k
19.20k
0.00
57.6k
57.60k
0.00
115.2k
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
300
1200
2400
2404
0.16
207
9600
9615
0.16
129
9600
0.00
119
9600
0.00
71
9615
0.16
51
10417
10417
0.00
119
10378
-0.37
110
10473
0.53
65
10417
0.00
47
19.2k
19.23k
0.16
64
19.20k
0.00
59
19.20k
0.00
35
19231
0.16
25
57.6k
56.82k
-1.36
21
57.60k
0.00
19
57.60k
0.00
11
55556
-3.55
115.2k
113.64k
-1.36
10
115.2k
0.00
115.2k
0.00
DS40001262F-page 161
PIC16F631/677/685/687/689/690
TABLE 12-5:
BAUD
RATE
Actual
Rate
%
Error
SPBRG
value
(decimal)
300
1200
1202
0.16
207
1200
0.00
191
1202
0.16
103
300
1202
0.16
0.16
207
51
2400
2404
0.16
103
2400
0.00
95
2404
0.16
51
2404
0.16
25
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
9600
9615
0.16
25
9600
0.00
23
9615
0.16
12
10417
10417
0.00
23
10473
0.53
21
10417
0.00
11
10417
0.00
19.2k
19.23k
0.16
12
19.2k
0.00
11
57.6k
57.60k
0.00
115.2k
115.2k
0.00
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
1666
300
300.0
-0.01
4166
300.0
0.00
3839
300.0
0.00
2303
299.9
-0.02
1200
1200
-0.03
1041
1200
0.00
959
1200
0.00
575
1199
-0.08
416
2400
2399
-0.03
520
2400
0.00
479
2400
0.00
287
2404
0.16
207
51
9600
9615
0.16
129
9600
0.00
119
9600
0.00
71
9615
0.16
10417
10417
0.00
119
10378
-0.37
110
10473
0.53
65
10417
0.00
47
19.2k
19.23k
0.16
64
19.20k
0.00
59
19.20k
0.00
35
19.23k
0.16
25
57.6k
56.818
-1.36
21
57.60k
0.00
19
57.60k
0.00
11
55556
-3.55
115.2k
113.636
-1.36
10
115.2k
0.00
115.2k
0.00
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
300
300.1
0.04
832
300.0
0.00
767
299.8
-0.108
416
300.5
0.16
207
1200
1202
0.16
207
1200
0.00
191
1202
0.16
103
1202
0.16
51
2400
2404
0.16
103
2400
0.00
95
2404
0.16
51
2404
0.16
25
9600
9615
0.16
25
9600
0.00
23
9615
0.16
12
10417
10417
0.00
23
10473
0.53
21
10417
0.00
11
10417
0.00
19.2k
19.23k
0.16
12
19.20k
0.00
11
57.6k
57.60k
0.00
115.2k
115.2k
0.00
DS40001262F-page 162
PIC16F631/677/685/687/689/690
TABLE 12-5:
BAUD
RATE
Actual
Rate
%
Error
SPBRG
value
(decimal)
300
1200
300.0
1200
0.00
-0.01
16665
4166
300.0
1200
0.00
0.00
15359
3839
300.0
1200
0.00
0.00
9215
2303
300.0
1200
0.00
-0.02
6666
1666
2400
2400
0.02
2082
2400
0.00
1919
2400
0.00
1151
2401
0.04
832
9600
9597
-0.03
520
9600
0.00
479
9600
0.00
287
9615
0.16
207
10417
10417
0.00
479
10425
0.08
441
10433
0.16
264
10417
191
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
19.2k
19.23k
0.16
259
19.20k
0.00
239
19.20k
0.00
143
19.23k
0.16
103
57.6k
57.47k
-0.22
86
57.60k
0.00
79
57.60k
0.00
47
57.14k
-0.79
34
115.2k
116.3k
0.94
42
115.2k
0.00
39
115.2k
0.00
23
117.6k
2.12
16
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
Actual
Rate
%
Error
SPBRG
value
(decimal)
832
300
300.0
0.01
3332
300.0
0.00
3071
299.9
-0.02
1666
300.1
0.04
1200
1200
0.04
832
1200
0.00
767
1199
-0.08
416
1202
0.16
207
2400
2398
0.08
416
2400
0.00
383
2404
0.16
207
2404
0.16
103
9600
9615
0.16
103
9600
0.00
95
9615
0.16
51
9615
0.16
25
10417
10417
0.00
95
10473
0.53
87
10417
0.00
47
10417
0.00
23
19.2k
19.23k
0.16
51
19.20k
0.00
47
19.23k
0.16
25
19.23k
0.16
12
57.6k
58.82k
2.12
16
57.60k
0.00
15
55.56k
-3.55
115.2k
111.1k
-3.55
115.2k
0.00
DS40001262F-page 163
PIC16F631/677/685/687/689/690
12.3.1
AUTO-BAUD DETECT
TABLE 12-6:
FIGURE 12-6:
BRG16
BRGH
BRG Base
Clock
BRG ABD
Clock
FOSC/64
FOSC/512
FOSC/16
FOSC/128
FOSC/16
FOSC/128
FOSC/4
FOSC/32
Note:
BRG Value
RX pin
0000h
001Ch
Start
Edge #1
bit 1
bit 0
Edge #2
bit 3
bit 2
Edge #3
bit 5
bit 4
Edge #4
bit 7
bit 6
Edge #5
Stop bit
BRG Clock
Auto Cleared
Set by User
ABDEN bit
RCIDL
RCIF bit
(Interrupt)
Read
RCREG
SPBRG
XXh
1Ch
SPBRGH
XXh
00h
Note 1:
The ABD sequence requires the EUSART module to be configured in Asynchronous mode
DS40001262F-page 164
PIC16F631/677/685/687/689/690
12.3.2
AUTO-WAKE-UP ON BREAK
12.3.2.1
Special Considerations
Break Character
To avoid character errors or character fragments during
a wake-up event, the wake-up character must be all
zeros.
When the wake-up is enabled the function works
independent of the low time on the data stream. If the
WUE bit is set and a valid non-zero character is
received, the low time from the Start bit to the first rising
edge will be interpreted as the wake-up event. The
remaining bits in the character will be received as a
fragmented character and subsequent characters can
result in framing or overrun errors.
Therefore, the initial character in the transmission must
be all 0s. This must be ten or more bit times, 13-bit
times recommended for LIN bus, or any number of bit
times for standard RS-232 devices.
Oscillator Startup Time
Oscillator start-up time must be considered, especially
in applications using oscillators with longer start-up
intervals (i.e., LP, XT or HS/PLL mode). The Sync
Break (or wake-up signal) character must be of
sufficient length, and be followed by a sufficient
interval, to allow enough time for the selected oscillator
to start and provide proper initialization of the EUSART.
WUE Bit
The wake-up event causes a receive interrupt by
setting the RCIF bit. The WUE bit is cleared in
hardware by a rising edge on RX/DT. The interrupt
condition is then cleared in software by reading the
RCREG register and discarding its contents.
To ensure that no actual data is lost, check the RCIDL
bit to verify that a receive operation is not in process
before setting the WUE bit. If a receive operation is not
occurring, the WUE bit may then be set just prior to
entering the Sleep mode.
FIGURE 12-7:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
Auto Cleared
Note 1:
DS40001262F-page 165
PIC16F631/677/685/687/689/690
FIGURE 12-8:
Q1
Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1Q2 Q3 Q4
OSC1
Auto Cleared
Note 1
RCIF
Sleep Command Executed
Note 1:
2:
12.3.3
If the wake-up event requires long oscillator warm-up time, the automatic clearing of the WUE bit can occur while the stposc signal is
still active. This sequence should not depend on the presence of Q clocks.
The EUSART remains in Idle while the WUE bit is set.
12.3.3.1
Sleep Ends
12.3.4
DS40001262F-page 166
PIC16F631/677/685/687/689/690
FIGURE 12-9:
Write to TXREG
BRG Output
(Shift Clock)
TX (pin)
Start bit
bit 0
bit 1
bit 11
Stop bit
Break
TXIF bit
(Transmit
Interrupt Flag)
TRMT bit
(Transmit Shift
Empty Flag)
SENDB Sampled Here
Auto Cleared
SENDB
(send Break
control bit)
DS40001262F-page 167
PIC16F631/677/685/687/689/690
12.4
12.4.1
SYNC = 1
CSRC = 1
SREN = 0 (for transmit); SREN = 1 (for receive)
CREN = 0 (for transmit); CREN = 1 (for receive)
SPEN = 1
12.4.1.1
Master Clock
DS40001262F-page 168
12.4.1.2
Clock Polarity
12.4.1.3
12.4.1.4
1.
2.
3.
4.
5.
6.
7.
8.
PIC16F631/677/685/687/689/690
FIGURE 12-10:
SYNCHRONOUS TRANSMISSION
RX/DT
pin
bit 0
bit 1
Word 1
bit 2
bit 7
bit 0
bit 1
Word 2
bit 7
TX/CK pin
(SCKP = 0)
TX/CK pin
(SCKP = 1)
Write to
TXREG Reg
Write Word 1
Write Word 2
TXIF bit
(Interrupt Flag)
TRMT bit
TXEN bit
Note:
1
Sync Master mode, SPBRG = 0, continuous transmission of two 8-bit words.
FIGURE 12-11:
bit 0
bit 2
bit 1
bit 6
bit 7
TX/CK pin
Write to
TXREG reg
TXIF bit
TRMT bit
TXEN bit
TABLE 12-7:
Name
Bit 7
Bit 6
BAUDCTL
ABDOVF
GIE
PIE1
PIR1
INTCON
RCREG
RCSTA
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
0000 0000
0000 0000
RX9D
0000 000x
0000 000x
0000 0000
Bit 5
Bit 4
Bit 3
RCIDL
SCKP
PEIE
T0IE
INTE
ADIE
RCIE
ADIF
RCIF
RX9
SREN
CREN
ADDEN
FERR
OERR
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
0000 0000
0000 0000
0000 0010
0000 0010
TXREG
TXSTA
Legend:
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
x = unknown, = unimplemented read as 0. Shaded cells are not used for Synchronous Master Transmission.
DS40001262F-page 169
PIC16F631/677/685/687/689/690
12.4.1.5
12.4.1.6
Slave Clock
12.4.1.7
12.4.1.8
12.4.1.9
1.
DS40001262F-page 170
PIC16F631/677/685/687/689/690
FIGURE 12-12:
RX/DT
pin
bit 0
bit 1
bit 2
bit 3
bit 4
bit 5
bit 6
bit 7
TX/CK pin
(SCKP = 0)
TX/CK pin
(SCKP = 1)
Write to
bit SREN
SREN bit
CREN bit 0
RCIF bit
(Interrupt)
Read
RXREG
Note:
Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
TABLE 12-8:
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
BAUDCTL
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
INTCON
PIE1
PIR1
RCREG
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
OERR
0000 0000
RX9D
0000 000x
0000 000x
RCSTA
SPEN
RX9
SREN
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
TXREG
TXSTA
Legend:
CREN
ADDEN
0000 0000
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
0000 0000
0000 0000
0000 0010
0000 0010
x = unknown, = unimplemented read as 0. Shaded cells are not used for Synchronous Master Reception.
DS40001262F-page 171
PIC16F631/677/685/687/689/690
12.4.2
SYNC = 1
CSRC = 0
SREN = 0 (for transmit); SREN = 1 (for receive)
CREN = 0 (for transmit); CREN = 1 (for receive)
SPEN = 1
1.
2.
3.
4.
12.4.2.1
5.
12.4.2.2
1.
2.
3.
4.
5.
6.
7.
TABLE 12-9:
Bit 7
Bit 6
BAUDCTL
ABDOVF
GIE
PIE1
PIR1
RCREG
Name
INTCON
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
0000 0000
0000 0000
Bit 5
Bit 4
Bit 3
RCIDL
SCKP
PEIE
T0IE
INTE
ADIE
RCIE
ADIF
RCIF
RCSTA
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
0000 000x
0000 000x
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
0000 0000
0000 0000
0000 0010
0000 0010
TRISB
TXREG
TXSTA
Legend:
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
x = unknown, = unimplemented read as 0. Shaded cells are not used for Synchronous Slave Transmission.
DS40001262F-page 172
PIC16F631/677/685/687/689/690
12.4.2.3
12.4.2.4
1.
2.
3.
4.
5.
6.
7.
8.
Bit 7
Bit 6
BAUDCTL
ABDOVF
GIE
PIE1
PIR1
INTCON
RCREG
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
Bit 5
Bit 4
Bit 3
RCIDL
SCKP
PEIE
T0IE
INTE
ADIE
RCIE
ADIF
RCIF
0000 0000
0000 0000
RCSTA
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
0000 000x
0000 000x
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
TRISB
TXREG
TXSTA
Legend:
TX9
TXEN
SYNC
SENDB
BRGH
TRMT
TX9D
0000 0000
0000 0000
0000 0010
0000 0010
x = unknown, = unimplemented read as 0. Shaded cells are not used for Synchronous Slave Reception.
DS40001262F-page 173
PIC16F631/677/685/687/689/690
12.5
12.5.1
12.5.2
SYNCHRONOUS TRANSMIT
DURING SLEEP
DS40001262F-page 174
PIC16F631/677/685/687/689/690
13.0
FIGURE 13-1:
Write
SSPBUF Reg
13.1
SPI Mode
SSPSR Reg
SDI/SDA
SDO
bit 0
Peripheral OE
SS Control
Enable
SS
Edge
Select
2
Clock Select
SSPM<3:0>
Shift
Clock
Edge
Select
SCK/
SCL
TMR2 Output
2
Prescaler TCY
4, 16, 64
TRISB<6>
DS40001262F-page 175
PIC16F631/677/685/687/689/690
SSPSTAT: SYNC SERIAL PORT STATUS REGISTER(1)
REGISTER 13-1:
R/W-0
R/W-0
R-0
R-0
R-0
R-0
R-0
R-0
SMP
CKE
D/A
R/W
UA
BF
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
Note 1:
2:
PIC16F687/PIC16F689/PIC16F690 only.
Does not update if receive was ignored.
DS40001262F-page 176
PIC16F631/677/685/687/689/690
REGISTER 13-2:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
WCOL
SSPOV
SSPEN
CKP
SSPM3(2)
SSPM2(2)
SSPM1(2)
SSPM0(2)
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7
bit 6
bit 5
bit 4
bit 3-0
Note 1:
2:
PIC16F687/PIC16F689/PIC16F690 only.
When this mode is selected, any reads or writes to the SSPADD SFR address actually accesses the SSPMSK register.
DS40001262F-page 177
PIC16F631/677/685/687/689/690
13.2
Operation
EXAMPLE 13-1:
LOOP
BSF
BCF
BTFSS
GOTO
BCF
MOVF
MOVWF
MOVF
MOVWF
STATUS,RP0
STATUS,RP1
SSPSTAT, BF
LOOP
STATUS,RP0
SSPBUF, W
RXDATA
TXDATA, W
SSPBUF
DS40001262F-page 178
;Bank 1
;
;Has data been received(transmit complete)?
;No
;Bank 0
;WREG reg = contents of SSPBUF
;Save in user RAM, if data is meaningful
;W reg = contents of TXDATA
;New data to xmit
PIC16F631/677/685/687/689/690
13.3
13.4
Typical Connection
FIGURE 13-2:
SDI
SDI
Shift Register
(SSPSR)
MSb
LSb
Shift Register
(SSPSR)
MSb
SCK
Processor 1
SDO
Serial Clock
LSb
SCK
Processor 2
DS40001262F-page 179
PIC16F631/677/685/687/689/690
13.5
Master Mode
FIGURE 13-3:
Write to
SSPBUF
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
4 Clock
Modes
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
SDO
(CKE = 0)
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
SDO
(CKE = 1)
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
SDI
(SMP = 0)
bit 0
bit 7
Input
Sample
(SMP = 0)
SDI
(SMP = 1)
bit 7
bit 0
Input
Sample
(SMP = 1)
SSPIF
SSPSR to
SSPBUF
DS40001262F-page 180
PIC16F631/677/685/687/689/690
13.6
Slave Mode
13.7
FIGURE 13-4:
SS
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDO
SDI
(SMP = 0)
bit 7
bit 6
bit 7
bit 0
bit 0
bit 7
bit 7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
SSPSR to
SSPBUF
DS40001262F-page 181
PIC16F631/677/685/687/689/690
FIGURE 13-5:
SS
Optional
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDO
bit 7
SDI
(SMP = 0)
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
bit 0
bit 7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
SSPSR to
SSPBUF
FIGURE 13-6:
SS
Not Optional
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Write to
SSPBUF
SDO
SDI
(SMP = 0)
bit 6
bit 7
bit 7
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
bit 0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
SSPSR to
SSPBUF
DS40001262F-page 182
PIC16F631/677/685/687/689/690
13.8
Sleep Operation
TABLE 13-1:
13.9
Effects of a Reset
CKP
CKE
0, 0
0, 1
1, 0
1, 1
TABLE 13-2:
Address
Name
0Bh/8Bh/
10Bh/18Bh
INTCON
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR,
BOR
Value on
all other
Resets
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
xxxx xxxx
uuuu uuuu
0Ch
PIR1
13h
SSPBUF
14h
SSPCON
WCOL
SSPOV
SSPEN
CKP
SSPM3
SSPM2
SSPM1
SSPM0
0000 0000
0000 0000
86h/186h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
87h/187h
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
94h
SSPSTAT
SMP
CKE
D/A
R/W
UA
BF
0000 0000
0000 0000
Legend:
Note
x = unknown, u = unchanged, = unimplemented, read as 0. Shaded cells are not used by the SSP in SPI mode.
1:
PIC16F677/PIC16F687/PIC16F689/PIC16F690 only.
DS40001262F-page 183
PIC16F631/677/685/687/689/690
13.11 SSP I2C Operation
The SSP module in I2C mode, fully implements all slave
functions, except general call support, and provides
interrupts on Start and Stop bits in hardware to facilitate
firmware implementations of the master functions. The
SSP module implements the Standard mode
specifications, as well as 7-bit and 10-bit addressing.
Two pins are used for data transfer. These are the RB6/
SCK/SCL pin, which is the clock (SCL), and the RB4/
AN10/SDI/SDA pin, which is the data (SDA).
The SSP module functions are enabled by setting SSP
enable bit SSPEN (SSPCON<5>).
FIGURE 13-7:
Read
RB6/
SCK/
SCL
Write
SSPBUF Reg
SSPSR Reg
Shift
Clock
RB4/
AN10/
SDI/SDA
MSb
LSb
Match Detect
Addr Match
SSPMSK Reg
SSPADD Reg
a)
Start and
Stop bit Detect
Set, Reset
S, P bits
(SSPSTAT Reg)
The SSP module has six registers for the I2C operation,
which are listed below.
DS40001262F-page 184
b)
PIC16F631/677/685/687/689/690
13.12.1
ADDRESSING
TABLE 13-3:
3.
4.
5.
6.
7.
8.
9.
SSPSR SSPBUF
Generate ACK
Pulse
BF
SSPOV
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
Yes
Note:
Shaded cells show the conditions where the user software did not properly clear the overflow condition.
DS40001262F-page 185
PIC16F631/677/685/687/689/690
13.12.2
RECEPTION
FIGURE 13-8:
R/W = 0
Receiving Address
SCL
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
Receiving Data
ACK
A7 A6 A5 A4 A3 A2 A1
SDA
ACK
D7 D6 D5 D4 D3 D2 D1 D0
8
Receiving Data
ACK
D7 D6 D5 D4 D3 D2 D1 D0
1
Cleared in software
Bus Master
terminates
transfer
SSPOV (SSPCON<6>)
Bit SSPOV is set because the SSPBUF register is still full.
ACK is not sent.
DS40001262F-page 186
PIC16F631/677/685/687/689/690
13.12.3
REGISTER 13-3:
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
MSK7
MSK6
MSK5
MSK4
MSK3
MSK2
MSK1
MSK0(2)
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 7-1
bit 0
Note 1: When SSPCON bits SSPM<3:0> = 1001, any reads or writes to the SSPADD SFR address are accessed
through the SSPMSK register. The SSPEN bit of the SSPCON register should be zero when accessing
the SSPMSK register.
2: In all other SSP modes, this bit has no effect.
DS40001262F-page 187
DS40001262F-page 188
5
6
UA is set indicating
that the SSPADD needs to
be updated
A7
UA (SSPSTAT<1>)
SSPBUF is written
with contents of SSPSR
SSPOV (SSPCON<6>)
CKP
Cleared in software
BF (SSPSTAT<0>)
(PIR1<3>)
SSPIF
SCL
SDA
2
4
Cleared in software
UA is set indicating
that SSPADD needs to
be updated
Cleared by hardware
when SSPADD is updated
with low byte of address
A6 A5 A4 A3 A2 A1 A0
ACK
5
6
Cleared in software
D7 D6 D5 D4 D3 D2 D1 D0
ACK
2
4
Cleared in software
D7 D6 D5 D4 D3 D2 D1 D0
P
Bus master
terminates
transfer
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
ACK
FIGURE 13-9:
PIC16F631/677/685/687/689/690
I2C SLAVE MODE TIMING (RECEPTION, 10-BIT ADDRESS)
PIC16F631/677/685/687/689/690
13.12.4
TRANSMISSION
FIGURE 13-10:
SDA
SCL
A7
A6
1
2
Data in
sampled
R/W = 1
A5
A4
A3
A2
A1
SSPIF (PIR1<3>)
ACK
Transmitting Data
ACK
D7
1
SCL held low
while CPU
responds to SSPIF
D6
D5
D4
D3
D2
D1
D0
Cleared in software
BF (SSPSTAT<0>)
SSPBUF is written in software
CKP (SSPCON<4>)
Set bit after writing to SSPBUF
(the SSPBUF must be written to
before the CKP bit can be set)
DS40001262F-page 189
DS40001262F-page 190
UA is set indicating
that the SSPADD needs to
be updated
UA (SSPSTAT<1>)
SSPBUF is written
with contents of SSPSR
SSPOV (SSPCON<6>)
CKP
Cleared in software
BF (SSPSTAT<0>)
(PIR1<3>)
SSPIF
2
4
Cleared in software
UA is set indicating
that SSPADD needs to
be updated
Cleared by hardware
when SSPADD is updated
with low byte of address
9
1
5
6
Cleared in software
9
1
2
4
Cleared in software
P
Bus master
terminates
transfer
SSPOV is set
because SSPBUF is
still full. ACK is not sent.
FIGURE 13-11:
SCL
SDA
PIC16F631/677/685/687/689/690
I2C SLAVE MODE TIMING (TRANSMISSION, 10-BIT ADDRESS)
PIC16F631/677/685/687/689/690
13.13 Master Mode
13.14.1
DS40001262F-page 191
PIC16F631/677/685/687/689/690
FIGURE 13-12:
Table 0-1:
Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
SDA
DX
DX-1
SCL
Master device
asserts clock
CKP
Master device
deasserts clock
WR
SSPCON
TABLE 13-4:
Addr
Value on
POR, BOR
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
0Bh/8Bh/
INTCON
10Bh/18Bh
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
0Ch
PIR1
13h
SSPBUF
14h
SSPCON
WCOL
SSPOV
SSPEN
CKP
SSPM3
SSPM2
SSPM1
SSPM0
0000 0000
0000 0000
86h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
93h
SSPMSK(2)
MSK7
MSK6
MSK5
MSK4
MSK3
MSK2
MSK1
MSK0
94h
SSPSTAT
SMP(3)
CKE(3)
D/A
R/W
UA
BF
0000 0000
0000 0000
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IF
TMR1IF
-000 0000
-000 0000
Legend:
Note 1:
2:
3:
xxxx xxxx
1111 1111
uuuu uuuu
1111 1111
= Unimplemented locations, read as 0, u = unchanged, x = unknown. Shaded cells are not used by the SSP module.
PIC16F677/PIC16F687/PIC16F689/PIC16F690 only.
SSPMSK register (Register 13-3) can be accessed by reading or writing to SSPADD register with bits SSPM<3:0> = 1001.
See Registers 13-2 and 13-3 for more details.
Maintain these bits clear.
DS40001262F-page 192
PIC16F631/677/685/687/689/690
14.0
14.1
Configuration Bits
DS40001262F-page 193
PIC16F631/677/685/687/689/690
REGISTER 14-1:
Reserved
FCMEN
IESO
BOREN1(1)
BOREN0(1)
bit 13
CPD(2
bit 7
CP(3)
MCLRE(4)
PWRTE
WDTE
FOSC2
FOSC1
bit 6
FOSC0
bit 0
Legend:
R = Readable bit
W = Writable bit
P = Programmable
U = Unimplemented
bit, read as 0
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
bit 13-12
bit 11
bit 10
bit 9-8
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2-0
Note
1:
2:
3:
4:
DS40001262F-page 194
PIC16F631/677/685/687/689/690
14.2
Reset
Power-on Reset
MCLR Reset
MCLR Reset during Sleep
WDT Reset
Brown-out Reset (BOR)
FIGURE 14-1:
MCLR/VPP pin
Sleep
WDT
Module
WDT
Time-out
Reset
VDD Rise
Detect
Power-on Reset
VDD
Brown-out(1)
Reset
BOREN
SBOREN
OST/PWRT
OST
Chip_Reset
OSC1/
CLKI pin
PWRT
LFINTOSC
Enable PWRT
Enable OST
Note
1:
DS40001262F-page 195
PIC16F631/677/685/687/689/690
14.2.1
FIGURE 14-2:
The on-chip POR circuit holds the chip in Reset until VDD
has reached a high enough level for proper operation. A
maximum rise time for VDD is required. See
Section 17.0 Electrical Specifications for details. If
the BOR is enabled, the maximum rise time specification
does not apply. The BOR circuitry will keep the device in
Reset until VDD reaches VBOR (see Section 14.2.4
Brown-out Reset (BOR)).
Note:
VDD
PIC16F685
R1
1 kor greater)
MCLR
RECOMMENDED MCLR
CIRCUIT
C1
0.1 F
(optional, not critical)
14.2.3
VDD variation
Temperature variation
Process variation
14.2.2
MCLR
DS40001262F-page 196
PIC16F631/677/685/687/689/690
14.2.4
Note:
FIGURE 14-3:
BROWN-OUT SITUATIONS
VDD
Internal
Reset
VBOR
64 ms(1)
VDD
Internal
Reset
VBOR
< 64 ms
64 ms(1)
VDD
Internal
Reset
Note 1:
VBOR
64 ms(1)
DS40001262F-page 197
PIC16F631/677/685/687/689/690
14.2.5
TIME-OUT SEQUENCE
14.2.6
TABLE 14-1:
For more information, see Section 4.2.4 Ultra LowPower Wake-up and Section 14.2.4 Brown-out
Reset (BOR).
Brown-out Reset
PWRTE = 0
PWRTE = 1
PWRTE = 0
PWRTE = 1
Wake-up from
Sleep
TPWRT +
1024 TOSC
1024 TOSC
TPWRT +
1024 TOSC
1024 TOSC
1024 TOSC
LP, T1OSCIN = 1
TPWRT
TPWRT
TPWRT
TPWRT
Oscillator Configuration
XT, HS, LP
TABLE 14-2:
POR
BOR
TO
PD
Condition
Power-on Reset
Brown-out Reset
WDT Reset
WDT Wake-up
TABLE 14-3:
Name
PCON
STATUS
Legend:
Note 1:
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
SBOREN
POR
BOR
--01 --qq
--0u --uu
TO
PD
DC
0001 1xxx
000q quuu
Bit 6
Bit 5
Bit 4
ULPWUE
IRP
RP1
RPO
u = unchanged, x = unknown, = unimplemented bit, reads as 0, q = value depends on condition. Shaded cells are not used by BOR.
Other (non Power-up) Resets include MCLR Reset and Watchdog Timer Reset during normal operation.
DS40001262F-page 198
PIC16F631/677/685/687/689/690
FIGURE 14-4:
VDD
MCLR
Internal POR
TPWRT
PWRT Time-out
TOST
OST Time-out
Internal Reset
FIGURE 14-5:
VDD
MCLR
Internal POR
TPWRT
PWRT Time-out
TOST
OST Time-out
Internal Reset
FIGURE 14-6:
MCLR
Internal POR
TPWRT
PWRT Time-out
TOST
OST Time-out
Internal Reset
DS40001262F-page 199
PIC16F631/677/685/687/689/690
TABLE 14-4:
Register
Address
Power-on Reset
MCLR Reset
WDT Reset
Brown-out Reset(1)
xxxx xxxx
uuuu uuuu
uuuu uuuu
INDF
00h/80h/
100h/180h
xxxx xxxx
xxxx xxxx
uuuu uuuu
TMR0
01h/101h
xxxx xxxx
uuuu uuuu
uuuu uuuu
PCL
02h/82h/
102h/182h
0000 0000
0000 0000
PC + 1(3)
STATUS
03h/83h/
103h/183h
0001 1xxx
000q quuu(4)
uuuq quuu(4)
FSR
04h/84h/
104h184h
xxxx xxxx
uuuu uuuu
uuuu uuuu
PORTA
05h/105h
--xx xxxx
--uu uuuu
--uu uuuu
PORTB
06h/106h
xxxx ----
uuuu ----
uuuu ----
PORTC
07h/107h
xxxx xxxx
uuuu uuuu
uuuu uuuu
PCLATH
0Ah/8Ah/
10Ah/18Ah
---0 0000
---0 0000
---u uuuu
INTCON
0Bh/8Bh/
10Bh/18Bh
0000 000x
0000 000u
uuuu uuuu(2)
PIR1
0Ch
-000 0000
-000 0000
-uuu uuuu(2)
PIR2
0Dh
0000 ----
0000 ----
uuuu ----(2)
TMR1L
0Eh
xxxx xxxx
uuuu uuuu
uuuu uuuu
TMR1H
0Fh
xxxx xxxx
uuuu uuuu
uuuu uuuu
T1CON
10h
0000 0000
uuuu uuuu
uuuu uuuu
TMR2
11h
0000 0000
0000 0000
uuuu uuuu
T2CON
12h
-000 0000
-000 0000
-uuu uuuu
SSPBUF
13h
xxxx xxxx
uuuu uuuu
uuuu uuuu
SSPCON
14h
0000 0000
0000 0000
uuuu uuuu
CCPR1L
15h
xxxx xxxx
uuuu uuuu
uuuu uuuu
CCPR1H
16h
xxxx xxxx
uuuu uuuu
uuuu uuuu
CCP1CON
17h
0000 0000
0000 0000
uuuu uuuu
RCSTA
18h
0000 000x
0000 000x
uuuu uuuu
TXREG
19h
0000 0000
0000 0000
uuuu uuuu
RCREG
1Ah
0000 0000
0000 0000
uuuu uuuu
PWM1CON
1Ch
0000 0000
0000 0000
uuuu uuuu
ECCPAS
1Dh
0000 0000
0000 0000
uuuu uuuu
ADRESH
1Eh
xxxx xxxx
uuuu uuuu
uuuu uuuu
ADCON0
1Fh
0000 0000
0000 0000
uuuu uuuu
OPTION_REG
81h/181h
1111 1111
1111 1111
uuuu uuuu
TRISA
85h/185h
--11 1111
--11 1111
--uu uuuu
Legend:
Note 1:
2:
3:
4:
5:
6:
DS40001262F-page 200
PIC16F631/677/685/687/689/690
TABLE 14-4:
Address
Power-on Reset
MCLR Reset
WDT Reset (Continued)
Brown-out Reset(1)
TRISB
86h/186h
1111 ----
1111 ----
uuuu ----
TRISC
Register
87h/187h
1111 1111
1111 1111
uuuu uuuu
PIE1
8Ch
-000 0000
-000 0000
-uuu uuuu
PIE2
8Dh
0000 ----
0000 ----
uuuu uuuu
1, 5)
PCON
8Eh
--01 --0x
OSCCON
8Fh
-110 q000
-110 q000
-uuu uuuu
OSCTUNE
90h
---0 0000
---u uuuu
---u uuuu
PR2
92h
1111 1111
1111 1111
uuuu uuuu
SSPADD
93h
0000 0000
1111 1111
uuuu uuuu
(6)
--0u --uq
--uu --uu
93h
---- ----
1111 1111
uuuu uuuu
SSPSTAT
94h
0000 0000
1111 1111
uuuu uuuu
WPUA
95h
--11 -111
--11 -111
uuuu uuuu
IOCA
96h
--00 0000
--00 0000
--uu uuuu
WDTCON
97h
---0 1000
---0 1000
---u uuuu
TXSTA
98h
0000 0010
0000 0010
uuuu uuuu
SPBRG
99h
0000 0000
0000 0000
uuuu uuuu
SPBRGH
9Ah
0000 0000
0000 0000
uuuu uuuu
BAUDCTL
9Bh
01-0 0-00
01-0 0-00
uu-u u-uu
ADRESL
9Eh
xxxx xxxx
uuuu uuuu
uuuu uuuu
ADCON1
9Fh
-000 ----
-000 ----
-uuu ----
EEDAT
10Ch
0000 0000
0000 0000
uuuu uuuu
EEADR
10Dh
0000 0000
0000 0000
uuuu uuuu
EEDATH
10Eh
--00 0000
--00 0000
--uu uuuu
EEADRH
10Fh
---- 0000
---- 0000
---- uuuu
WPUB
115h
1111 ----
1111 ----
uuuu ----
IOCB
116h
0000 ----
0000 ----
uuuu ----
VRCON
118h
0000 0000
0000 0000
uuuu uuuu
CM1CON0
119h
0000 -000
0000 -000
uuuu -uuu
CM2CON0
11Ah
0000 -000
0000 -000
uuuu -uuu
CM2CON1
11Bh
00-- --00
00-- --10
uu-- --uu
ANSEL
11Eh
1111 1111
1111 1111
uuuu uuuu
ANSELH
11Fh
---- 1111
---- 1111
---- uuuu
EECON1
18Ch
x--- x000
u--- q000
---- uuuu
EECON2
18Dh
---- ----
---- ----
---- ----
PSTRCON
19Dh
---0 0001
---0 0001
---u uuuu
SRCON
19EH
0000 00--
0000 00--
uuuu uu--
SSPMSK
Legend:
Note 1:
2:
3:
4:
5:
6:
TABLE 14-5:
DS40001262F-page 201
PIC16F631/677/685/687/689/690
Program
Counter
Status
Register
PCON
Register
Power-on Reset
000h
0001 1xxx
--01 --0x
000h
000u uuuu
--0u --uu
000h
0001 0uuu
--0u --uu
000h
0000 uuuu
--0u --uu
PC + 1
uuu0 0uuu
--uu --uu
Condition
WDT Reset
WDT Wake-up
Brown-out Reset
Interrupt Wake-up from Sleep
000h
0001 1uuu
--01 --u0
PC + 1(1)
uuu1 0uuu
--uu --uu
DS40001262F-page 202
PIC16F631/677/685/687/689/690
14.3
Interrupts
A/D Interrupt
EUSART Receive and Transmit Interrupts
Timer1 Overflow Interrupt
Synchronous Serial Port (SSP) Interrupt
Enhanced CCP1 Interrupt
Timer1 Overflow Interrupt
Timer2 Match Interrupt
14.3.1
RA2/INT INTERRUPT
DS40001262F-page 203
PIC16F631/677/685/687/689/690
14.3.2
TIMER0 INTERRUPT
14.3.3
PORTA/PORTB INTERRUPT
FIGURE 14-7:
INTERRUPT LOGIC
IOC-RA0
IOCA0
IOC-RA1
IOCA1
IOC-RA2
IOCA2
IOC-RA3
IOCA3
IOC-RA4
IOCA4
IOC-RA5
IOCA5
IOC-RB4
IOCB4
IOC-RB5
IOCB5
IOC-RB6
IOCB6
IOC-RB7
IOCB7
SSPIF
SSPIE
TXIF
TXIE
RCIF
RCIE
TMR2IF
TMR2IE
TMR1IF
TMR1IE
Interrupt to CPU
INTF
INTE
RABIF
RABIE
C1IF
C1IE
PEIE
C2IF
C2IE
GIE
ADIF
ADIE
EEIF
EEIE
Note 1:
OSFIF
OSFIE
CCP1IF
CCP1IE
DS40001262F-page 204
PIC16F631/677/685/687/689/690
FIGURE 14-8:
Q2
Q3
Q4
Q1
Q2
Q3
Q4
Q1
Q2
Q3
Q4
Q1
Q2
Q3
Q4
Q1
Q2
Q3
Q4
OSC1
CLKOUT (3)
(4)
INT pin
(1)
(1)
INTF flag
(INTCON<1>)
(5)
GIE bit
(INTCON<7>)
INSTRUCTION FLOW
PC
Instruction
Fetched
INTCON
Inst (0004h)
Inst (0005h)
Dummy Cycle
Inst (0004h)
Dummy Cycle
Inst (PC)
0005h
2:
Asynchronous interrupt latency = 3-4 TCY. Synchronous latency = 3 TCY, where TCY = instruction cycle time. Latency
is the same whether Inst (PC) is a single cycle or a 2-cycle instruction.
3:
4:
For minimum width of INT pulse, refer to AC specifications in Section 17.0 Electrical Specifications.
5:
TABLE 14-6:
Name
Inst (PC + 1)
Inst (PC 1)
0004h
PC + 1
PC + 1
Inst (PC)
Instruction
Executed
Note 1:
PC
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
PIE2
OSFIE
C2IE
C1IE
EEIE
0000 ----
0000 ----
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
PIR2
OSFIF
C2IF
C1IF
EEIF
0000 ----
0000 ----
Legend:
DS40001262F-page 205
PIC16F631/677/685/687/689/690
14.4
The
PIC16F631/677/685/687/689/690
normally does not require saving the
PCLATH. However, if computed GOTOs
are used in the ISR and the main code,
the PCLATH must be saved and restored
in the ISR.
EXAMPLE 14-1:
MOVWF
SWAPF
CLRF
MOVWF
W_TEMP
STATUS,W
STATUS
STATUS_TEMP
;Copy
;Swap
;bank
;Save
W to TEMP register
status to be saved into W
0, regardless of current bank, Clears IRP,RP1,RP0
status to bank zero STATUS_TEMP register
:(ISR)
:
SWAPF STATUS_TEMP,W
MOVWF
SWAPF
SWAPF
DS40001262F-page 206
PIC16F631/677/685/687/689/690
14.5
14.5.2
14.5.1
WDT OSCILLATOR
WDT CONTROL
FIGURE 14-9:
0
Prescaler(1)
1
8
PSA
31 kHz
LFINTOSC Clock
PS<2:0>
WDTPS<3:0>
To TMR0
0
1
PSA
Note
1:
TABLE 14-7:
This is the shared Timer0/WDT prescaler. See Section 5.4 Prescaler for more information.
WDT STATUS
Conditions
WDTE = 0
WDT
Cleared
CLRWDT Command
Oscillator Fail Detected
Exit Sleep + System Clock = T1OSC, EXTRC, INTOSC, EXTCLK
Exit Sleep + System Clock = XT, HS, LP
DS40001262F-page 207
PIC16F631/677/685/687/689/690
REGISTER 14-2:
U-0
U-0
U-0
R/W-0
R/W-1
R/W-0
R/W-0
R/W-0
WDTPS3
WDTPS2
WDTPS1
WDTPS0
SWDTEN(1)
bit 7
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
bit 7-5
Unimplemented: Read as 0
bit 4-1
bit 0
x = Bit is unknown
Note 1: If WDTE Configuration bit = 1, then WDT is always enabled, irrespective of this control bit. If WDTE
Configuration bit = 0, then it is possible to turn WDT on/off with this control bit.
TABLE 14-8:
Value on
all other
Resets
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
CONFIG(1)
CPD
CP
MCLRE
PWRTE
WDTE
FOSC2
FOSC1
FOSC0
PS0
1111 1111
1111 1111
---0 1000
T0CS
T0SE
PSA
PS2
PS1
DS40001262F-page 208
PIC16F631/677/685/687/689/690
14.6
14.6.1
The first event will cause a device Reset. The two latter
events are considered a continuation of program execution. The TO and PD bits in the STATUS register can
be used to determine the cause of device Reset. The
PD bit, which is set on power-up, is cleared when Sleep
is invoked. TO bit is cleared if WDT Wake-up occurred.
The following peripheral interrupts can wake the device
from Sleep:
1.
2.
3.
4.
5.
6.
7.
8.
14.6.2
DS40001262F-page 209
PIC16F631/677/685/687/689/690
FIGURE 14-10:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
TOST(2)
CLKOUT(4)
INT pin
INTF flag
(INTCON<1>)
GIE bit
(INTCON<7>)
Instruction Flow
PC
Instruction
Fetched
Instruction
Executed
Note
14.7
Processor in
Sleep
PC
Inst(PC) = Sleep
Inst(PC 1)
PC + 1
PC + 2
Inst(PC + 1)
Inst(PC + 2)
Sleep
Inst(PC + 1)
14.8
Dummy Cycle
0004h
0005h
Inst(0004h)
Inst(0005h)
Dummy Cycle
Inst(0004h)
2:
TOST = 1024 TOSC (drawing not to scale). This delay does not apply to EC and RC Oscillator modes.
3:
GIE = 1 assumed. In this case after wake-up, the processor jumps to 0004h. If GIE = 0, execution will continue in-line.
4:
CLKOUT is not available in XT, HS, LP or EC Oscillator modes, but shown here for timing reference.
Code Protection
ID Locations
14.9
PC + 2
1:
PC + 2
power
ground
programming voltage
DS40001262F-page 210
PIC16F631/677/685/687/689/690
FIGURE 14-11:
TYPICAL IN-CIRCUIT
SERIAL PROGRAMMING
CONNECTION
To Normal
Connections
External
Connector
Signals
PIC16F631/677/
685/687/689/690
+5V
VDD
0V
VSS
VPP
RA3/MCLR/VPP
CLK
RA1
Data I/O
RA0
To Normal
Connections
*
DS40001262F-page 211
PIC16F631/677/685/687/689/690
15.0
TABLE 15-1:
Field
Description
Register file address (0x00 to 0x7F)
f
W
OPCODE FIELD
DESCRIPTIONS
PC
Program Counter
TO
Time-out bit
Carry bit
C
DC
Z
PD
Power-down bit
FIGURE 15-1:
d = 0 for destination W
d = 1 for destination f
f = 7-bit file register address
Bit-oriented file register operations
13
10 9
7 6
OPCODE
b (BIT #)
f (FILE #)
15.1
Read-Modify-Write Operations
13
OPCODE
DS40001262F-page 212
0
k (literal)
11
OPCODE
10
0
k (literal)
PIC16F631/677/685/687/689/690
TABLE 15-2:
Mnemonic,
Operands
Description
Cycles
MSb
LSb
Status
Affected
Notes
f, d
f, d
f
f, d
f, d
f, d
f, d
f, d
f, d
f, d
f
f, d
f, d
f, d
f, d
f, d
Add W and f
AND W with f
Clear f
Clear W
Complement f
Decrement f
Decrement f, Skip if 0
Increment f
Increment f, Skip if 0
Inclusive OR W with f
Move f
Move W to f
No Operation
Rotate Left f through Carry
Rotate Right f through Carry
Subtract W from f
Swap nibbles in f
Exclusive OR W with f
BCF
BSF
BTFSC
BTFSS
f, b
f, b
f, b
f, b
Bit Clear f
Bit Set f
Bit Test f, Skip if Clear
Bit Test f, Skip if Set
1
1
1
1
1
1
1(2)
1
1(2)
1
1
1
1
1
1
1
1
1
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
dfff
dfff
lfff
0xxx
dfff
dfff
dfff
dfff
dfff
dfff
dfff
lfff
0xx0
dfff
dfff
dfff
dfff
dfff
ffff
ffff
ffff
xxxx
ffff
ffff
ffff
ffff
ffff
ffff
ffff
ffff
0000
ffff
ffff
ffff
ffff
ffff
00bb
01bb
10bb
11bb
bfff
bfff
bfff
bfff
ffff
ffff
ffff
ffff
111x
1001
0kkk
0000
1kkk
1000
00xx
0000
01xx
0000
0000
110x
1010
kkkk
kkkk
kkkk
0110
kkkk
kkkk
kkkk
0000
kkkk
0000
0110
kkkk
kkkk
kkkk
kkkk
kkkk
0100
kkkk
kkkk
kkkk
1001
kkkk
1000
0011
kkkk
kkkk
0111
0101
0001
0001
1001
0011
1011
1010
1111
0100
1000
0000
0000
1101
1100
0010
1110
0110
C, DC, Z
Z
Z
Z
Z
Z
Z
Z
Z
C
C
C, DC, Z
Z
1, 2
1, 2
2
1, 2
1, 2
1, 2, 3
1, 2
1, 2, 3
1, 2
1, 2
1, 2
1, 2
1, 2
1, 2
1, 2
01
01
01
01
1, 2
1, 2
3
3
2:
3:
k
k
k
k
k
k
k
k
1
1
2
1
2
1
1
2
2
2
1
1
1
11
11
10
00
10
11
11
00
11
00
00
11
11
C, DC, Z
Z
TO, PD
Z
TO, PD
C, DC, Z
Z
When an I/O register is modified as a function of itself (e.g., MOVF GPIO, 1), the value used will be that value present
on the pins themselves. For example, if the data latch is 1 for a pin configured as input and is driven low by an external
device, the data will be written back with a 0.
If this instruction is executed on the TMR0 register (and where applicable, d = 1), the prescaler will be cleared if
assigned to the Timer0 module.
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.
DS40001262F-page 213
PIC16F631/677/685/687/689/690
15.2
Instruction Descriptions
ADDLW
Syntax:
[ label ] ADDLW
Operands:
0 k 255
Operation:
(W) + k (W)
Status Affected:
C, DC, Z
Description:
BCF
Bit Clear f
Syntax:
[ label ] BCF
Operands:
0 f 127
0b7
Operation:
0 (f<b>)
Status Affected:
None
Description:
BSF
Bit Set f
Syntax:
[ label ] BSF
f,b
ADDWF
Add W and f
Syntax:
[ label ] ADDWF
Operands:
0 f 127
d 0,1
Operands:
0 f 127
0b7
Operation:
Operation:
1 (f<b>)
Status Affected:
C, DC, Z
Status Affected:
None
Description:
Description:
ANDLW
BTFSC
Syntax:
[ label ] ANDLW
Syntax:
Operands:
0 k 255
Operands:
Operation:
0 f 127
0b7
Status Affected:
Operation:
skip if (f<b>) = 0
Description:
Status Affected:
None
Description:
ANDWF
f,d
AND W with f
Syntax:
[ label ] ANDWF
Operands:
0 f 127
d 0,1
Operation:
f,d
Status Affected:
Description:
DS40001262F-page 214
f,b
PIC16F631/677/685/687/689/690
BTFSS
CLRWDT
Syntax:
Syntax:
[ label ] CLRWDT
Operands:
0 f 127
0b<7
Operands:
None
Operation:
00h WDT
0 WDT prescaler,
1 TO
1 PD
Status Affected:
TO, PD
Description:
Operation:
skip if (f<b>) = 1
Status Affected:
None
Description:
CALL
Call Subroutine
COMF
Complement f
Syntax:
[ label ] CALL k
Syntax:
[ label ] COMF
Operands:
0 k 2047
Operands:
Operation:
(PC)+ 1 TOS,
k PC<10:0>,
(PCLATH<4:3>) PC<12:11>
0 f 127
d [0,1]
f,d
Operation:
(f) (destination)
Status Affected:
Description:
DECF
Decrement f
Syntax:
Status Affected:
None
Description:
CLRF
Clear f
Syntax:
[ label ] CLRF
Operands:
0 f 127
Operands:
Operation:
00h (f)
1Z
0 f 127
d [0,1]
Operation:
(f) - 1 (destination)
Status Affected:
Status Affected:
Description:
Description:
Decrement register f. If d is 0,
the result is stored in the W
register. If d is 1, the result is
stored back in register f.
CLRW
Clear W
Syntax:
[ label ] CLRW
Operands:
None
Operation:
00h (W)
1Z
Status Affected:
Description:
DS40001262F-page 215
PIC16F631/677/685/687/689/690
DECFSZ
Decrement f, Skip if 0
INCFSZ
Increment f, Skip if 0
Syntax:
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operands:
0 f 127
d [0,1]
Operation:
(f) - 1 (destination);
skip if result = 0
Operation:
(f) + 1 (destination),
skip if result = 0
Status Affected:
None
Status Affected:
None
Description:
Description:
GOTO
Unconditional Branch
IORLW
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 k 2047
Operands:
0 k 255
Operation:
k PC<10:0>
PCLATH<4:3> PC<12:11>
Operation:
Status Affected:
Status Affected:
None
Description:
Description:
INCF
Increment f
IORWF
Inclusive OR W with f
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operands:
0 f 127
d [0,1]
Operation:
(f) + 1 (destination)
Operation:
Status Affected:
Status Affected:
Description:
Description:
DS40001262F-page 216
GOTO k
INCF f,d
INCFSZ f,d
IORWF
f,d
PIC16F631/677/685/687/689/690
MOVF
Move f
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
MOVF f,d
MOVWF
Move W to f
Syntax:
[ label ]
MOVWF
Operands:
0 f 127
Operation:
(W) (f)
Operation:
(f) (dest)
Status Affected:
None
Status Affected:
Description:
Description:
Words:
Cycles:
Words:
Cycles:
Example:
MOVF
Example:
MOVW
F
OPTION
Before Instruction
OPTION =
W
=
After Instruction
OPTION =
W
=
FSR, 0
0xFF
0x4F
0x4F
0x4F
After Instruction
W =
value in FSR
register
Z = 1
MOVLW
Move literal to W
NOP
No Operation
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 k 255
Operands:
None
Operation:
k (W)
Operation:
No operation
Status Affected:
None
Status Affected:
None
Description:
Description:
No operation.
Words:
Cycles:
Words:
Cycles:
Example:
MOVLW k
Example:
MOVLW
NOP
NOP
0x5A
After Instruction
W =
0x5A
DS40001262F-page 217
PIC16F631/677/685/687/689/690
RETFIE
RETLW
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
None
Operands:
0 k 255
Operation:
TOS PC,
1 GIE
Operation:
k (W);
TOS PC
Status Affected:
None
Status Affected:
None
Description:
Description:
Words:
Cycles:
Example:
RETFIE
Words:
Cycles:
Example:
RETFIE
After Interrupt
PC =
GIE =
TABLE
TOS
1
RETLW k
;W now has
;table value
DS40001262F-page 218
RETURN
Syntax:
[ label ]
Operands:
None
Operation:
TOS PC
Status Affected:
None
Description:
RETURN
PIC16F631/677/685/687/689/690
RLF
SLEEP
Syntax:
[ label ]
Syntax:
[ label ] SLEEP
Operands:
0 f 127
d [0,1]
Operands:
None
Operation:
Operation:
Status Affected:
Description:
00h WDT,
0 WDT prescaler,
1 TO,
0 PD
RLF
f,d
Words:
Cycles:
Example:
Status Affected:
TO, PD
Description:
Register f
RLF
REG1,0
Before Instruction
REG1
C
=
=
1110 0110
0
=
=
=
1110 0110
1100 1100
1
After Instruction
REG1
W
C
RRF
SUBLW
Syntax:
[ label ]
Syntax:
[ label ] SUBLW k
Operands:
0 f 127
d [0,1]
Operands:
0 k 255
Operation:
k - (W) W)
Operation:
Status Affected:
Description:
Description:
RRF f,d
Register f
Wk
C=1
Wk
DC = 0
W<3:0> k<3:0>
DC = 1
W<3:0> k<3:0>
DS40001262F-page 219
PIC16F631/677/685/687/689/690
SUBWF
Subtract W from f
XORLW
Syntax:
Syntax:
[ label ] XORLW k
Operands:
0 f 127
d [0,1]
Operands:
0 k 255
Operation:
Operation:
(W) .XOR. k W)
Status Affected:
Description:
Wf
C=1
Wf
DC = 0
W<3:0> f<3:0>
DC = 1
W<3:0> f<3:0>
SWAPF
Swap Nibbles in f
XORWF
Syntax:
Syntax:
[ label ] XORWF
Operands:
0 f 127
d [0,1]
Operands:
0 f 127
d [0,1]
Operation:
(f<3:0>) (destination<7:4>),
(f<7:4>) (destination<3:0>)
Operation:
Status Affected:
Status Affected:
None
Description:
Description:
DS40001262F-page 220
Exclusive OR W with f
f,d
PIC16F631/677/685/687/689/690
16.0
DEVELOPMENT SUPPORT
16.1
Multiple projects
Multiple tools
Multiple configurations
Simultaneous debugging sessions
DS40001262F-page 221
PIC16F631/677/685/687/689/690
16.2
MPLAB XC Compilers
16.3
MPASM Assembler
16.4
16.5
DS40001262F-page 222
PIC16F631/677/685/687/689/690
16.6
16.7
16.8
16.9
The MPLAB PICkit 3 allows debugging and programming of PIC and dsPIC Flash microcontrollers at a most
affordable price point using the powerful graphical user
interface of the MPLAB IDE. The MPLAB PICkit 3 is
connected to the design engineers PC using a fullspeed USB interface and can be connected to the target via a Microchip debug (RJ-11) connector (compatible with MPLAB ICD 3 and MPLAB REAL ICE). The
connector uses two device I/O pins and the Reset line
to implement in-circuit debugging and In-Circuit Serial
Programming (ICSP).
DS40001262F-page 223
PIC16F631/677/685/687/689/690
16.11 Demonstration/Development
Boards, Evaluation Kits, and
Starter Kits
A wide variety of demonstration, development and
evaluation boards for various PIC MCUs and dsPIC
DSCs allows quick application development on fully
functional systems. Most boards include prototyping
areas for adding custom circuitry and provide application firmware and source code for examination and
modification.
The boards support a variety of features, including LEDs,
temperature sensors, switches, speakers, RS-232
interfaces, LCD displays, potentiometers and additional
EEPROM memory.
DS40001262F-page 224
PIC16F631/677/685/687/689/690
17.0
ELECTRICAL SPECIFICATIONS
Power dissipation is calculated as follows: PDIS = VDD x {IDD - IOH} + {(VDD - VOH) x IOH} + (VOL x IOL).
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.
Note:
Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up.
Thus, a series resistor of 50-100 should be used when applying a low level to the MCLR pin, rather
than pulling this pin directly to VSS.
DS40001262F-page 225
PIC16F631/677/685/687/689/690
FIGURE 17-1:
5.5
5.0
VDD (V)
4.5
4.0
3.5
3.0
2.5
2.0
0
10
20
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
FIGURE 17-2:
125
5%
Temperature (C)
85
2%
60
1%
25
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 226
PIC16F631/677/685/687/689/690
17.1
DC CHARACTERISTICS
Param
No.
Sym
Characteristic
Conditions
VDD
Supply Voltage
2.0
2.0
3.0
4.5
5.5
5.5
5.5
5.5
V
V
V
V
D002*
VDR
1.5
D003
VPOR
VSS
D004*
SVDD
0.05
D001
D001C
D001D
DS40001262F-page 227
PIC16F631/677/685/687/689/690
17.2
DC CHARACTERISTICS
Conditions
Param
No.
Device Characteristics
Min.
Typ
Max.
Units
VDD
D010
D011*
D012
D013*
D014
D015
D016*
D017
D018
D019
Note 1:
2:
3:
4:
5:
(1, 2)
13
19
2.0
22
30
3.0
33
60
5.0
140
240
2.0
220
380
3.0
380
550
5.0
260
360
2.0
420
650
3.0
0.8
1.1
mA
5.0
130
220
2.0
215
360
3.0
360
520
5.0
220
340
2.0
375
550
3.0
0.65
1.0
mA
5.0
20
2.0
16
40
3.0
31
65
5.0
340
450
2.0
500
700
3.0
0.8
1.2
mA
5.0
410
650
2.0
700
950
3.0
1.30
1.65
mA
5.0
230
400
2.0
400
680
3.0
0.63
1.1
mA
5.0
3.8
5.0
mA
4.5
4.0
5.45
mA
5.0
Note
FOSC = 32 kHz
LP Oscillator mode
FOSC = 1 MHz
XT Oscillator mode
FOSC = 4 MHz
XT Oscillator mode
FOSC = 1 MHz
EC Oscillator mode
FOSC = 4 MHz
EC Oscillator mode
FOSC = 31 kHz
LFINTOSC mode
FOSC = 4 MHz
HFINTOSC mode
FOSC = 8 MHz
HFINTOSC mode
FOSC = 4 MHz
EXTRC mode(3)
FOSC = 20 MHz
HS Oscillator mode
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance only and are
not tested.
The test conditions for all IDD measurements in Active Operation mode are: OSC1 = external square wave, from
rail-to-rail; all I/O pins tri-stated, pulled to VDD; MCLR = VDD; WDT disabled.
The supply current is mainly a function of the operating voltage and frequency. Other factors, such as I/O pin loading
and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact on the current
consumption.
For RC oscillator configurations, current through REXT is not included. The current through the resistor can be extended
by the formula IR = VDD/2REXT (mA) with REXT in k.
The peripheral current is the sum of the base IDD or IPD and the additional current consumed when this peripheral is
enabled. The peripheral current can be determined by subtracting the base IDD or IPD current from this limit. Max
values should be used when calculating total current consumption.
The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD.
DS40001262F-page 228
PIC16F631/677/685/687/689/690
17.2
DC CHARACTERISTICS
Param
No.
Device Characteristics
Min.
Typ
Max.
Units
VDD
D020
Power-down Base
Current(IPD)(2)
0.05
1.2
2.0
0.15
1.5
3.0
0.35
1.8
5.0
Note
WDT, BOR, Comparators, VREF and
T1OSC disabled
90
500
nA
3.0
-40C TA +25C
1.0
2.2
2.0
WDT Current(1)
2.0
4.0
3.0
3.0
7.0
5.0
D022
42
60
3.0
85
122
5.0
D023
32
45
2.0
60
78
3.0
D021
D024
D024a*
D025
D026
D027
Note 1:
2:
3:
4:
5:
BOR Current(1)
Comparator Current(1), both
comparators enabled
120
160
5.0
30
36
2.0
45
55
3.0
75
95
5.0
39
47
2.0
59
72
3.0
98
124
5.0
2.0
5.0
2.0
2.5
5.5
3.0
3.0
7.0
5.0
0.30
1.6
3.0
0.36
1.9
5.0
90
125
3.0
VP6 Current
125
162
5.0
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance only and are
not tested.
The test conditions for all IDD measurements in Active Operation mode are: OSC1 = external square wave, from
rail-to-rail; all I/O pins tri-stated, pulled to VDD; MCLR = VDD; WDT disabled.
The supply current is mainly a function of the operating voltage and frequency. Other factors, such as I/O pin loading
and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact on the current
consumption.
For RC oscillator configurations, current through REXT is not included. The current through the resistor can be extended
by the formula IR = VDD/2REXT (mA) with REXT in k.
The peripheral current is the sum of the base IDD or IPD and the additional current consumed when this peripheral is
enabled. The peripheral current can be determined by subtracting the base IDD or IPD current from this limit. Max
values should be used when calculating total current consumption.
The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD.
DS40001262F-page 229
PIC16F631/677/685/687/689/690
17.3
DC CHARACTERISTICS
Param
No.
Device Characteristics
Min.
Typ
Max.
Units
0.05
2.0
0.15
11
3.0
0.35
15
5.0
90
500
nA
3.0
-40C TA +25C
1.0
17.5
2.0
WDT Current(1)
2.0
19
3.0
3.0
22
5.0
42
65
3.0
85
127
5.0
32
45
2.0
3.0
Note
VDD
D020E
Power-down Base
Current(IPD)(2)
D021E
D022E
D023E
D024E
D024AE*
60
78
120
160
5.0
30
70
2.0
45
90
3.0
75
120
5.0
39
91
2.0
59
117
3.0
BOR Current(1)
Comparator Current(1), both
comparators enabled
CVREF Current(1) (high range)
98
156
5.0
2.0
18
2.0
2.5
21
3.0
3.0
24
5.0
D026E
0.30
12
3.0
0.36
16
5.0
D027E
90
130
3.0
VP6 Current
125
170
5.0
D025E
Note 1:
2:
3:
4:
5:
T1OSC Current
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance only and are
not tested.
The test conditions for all IDD measurements in Active Operation mode are: OSC1 = external square wave, from
rail-to-rail; all I/O pins tri-stated, pulled to VDD; MCLR = VDD; WDT disabled.
The supply current is mainly a function of the operating voltage and frequency. Other factors, such as I/O pin loading
and switching rate, oscillator type, internal code execution pattern and temperature, also have an impact on the current
consumption.
For RC oscillator configurations, current through REXT is not included. The current through the resistor can be extended
by the formula IR = VDD/2REXT (mA) with REXT in k.
The peripheral current is the sum of the base IDD or IPD and the additional current consumed when this peripheral is
enabled. The peripheral current can be determined by subtracting the base IDD or IPD current from this limit. Max
values should be used when calculating total current consumption.
The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
the part in Sleep mode, with all I/O pins in high-impedance state and tied to VDD.
DS40001262F-page 230
PIC16F631/677/685/687/689/690
17.4
DC Characteristics:
PIC16F631/677/685/687/689/690-I (Industrial)
PIC16F631/677/685/687/689/690-E (Extended)
Standard Operating Conditions (unless otherwise stated)
Operating temperature
-40C TA +85C for industrial
-40C TA +125C for extended
DC CHARACTERISTICS
Param
No.
Sym.
VIL
Characteristic
Min.
Typ
Max.
Units
Vss
Vss
Conditions
0.8
0.15 VDD
Vss
0.2 VDD
0.2 VDD
D030
D030A
D031
D032
VSS
D033
VSS
0.3
D033A
VSS
0.3 VDD
VIH
D040
D040A
D041
2.0
VDD
VDD
0.8 VDD
VDD
0.8 VDD
VDD
D042
MCLR
D043
1.6
VDD
D043A
0.7 VDD
VDD
D043B
0.9 VDD
VDD
(Note 1)
IIL
D060
I/O ports
0.1
D061
MCLR(3)
0.1
D063
OSC1
0.1
50
250
400
0.6
VDD 0.7
200
nA
D070*
IPUR
VOL
D080
(5)
I/O ports
VOH
D090
I/O ports
D100
IULP
Note 1:
2:
3:
4:
5:
DS40001262F-page 231
PIC16F631/677/685/687/689/690
17.4
DC Characteristics:
PIC16F631/677/685/687/689/690-I (Industrial)
PIC16F631/677/685/687/689/690-E (Extended) (Continued)
Standard Operating Conditions (unless otherwise stated)
Operating temperature
-40C TA +85C for industrial
-40C TA +125C for extended
DC CHARACTERISTICS
Param
No.
Sym.
D101*
COSC2
D101A* CIO
Characteristic
Min.
Typ
Max.
Units
OSC2 pin
15
pF
50
pF
Conditions
In XT, HS and LP modes when
external clock is used to drive
OSC1
ED
Byte Endurance
100K
1M
E/W
-40C TA +85C
D120A
ED
Byte Endurance
10K
100K
E/W
+85C TA +125C
D121
VDRW
VMIN
5.5
D122
TDEW
D123
TRETD
Characteristic Retention
40
D124
TREF
1M
10M
E/W
-40C TA +85C
D130
EP
Cell Endurance
10K
100K
E/W
-40C TA +85C
D130A
ED
Cell Endurance
1K
10K
E/W
D131
VPR
VMIN
5.5
D132
VPEW
4.5
5.5
D133
TPEW
2.5
ms
D134
TRETD
Characteristic Retention
40
ms
Note 1:
2:
3:
4:
5:
+85C TA +125C
VMIN = Minimum operating
voltage
DS40001262F-page 232
PIC16F631/677/685/687/689/690
17.5
Thermal Considerations
TH02
TH03
TH04
TH05
TH06
TH07
Note 1:
2:
3:
Sym.
JA
Characteristic
Thermal Resistance
Junction to Ambient
Typ.
Units
62.4
85.2
108.1
40
28.1
24.2
32.2
2.5
150
C/W
C/W
C/W
C/W
C/W
C/W
C/W
C/W
C
W
W
Conditions
W
PI/O = (IOL * VOL) + (IOH * (VDD - VOH))
PDER
Derated Power
W
PDER = PDMAX (TDIE - TA)/JA
(Note 2, 3)
IDD is current to run the chip alone without driving any load on the output pins.
TA = Ambient Temperature.
Maximum allowable power dissipation is the lower value of either the absolute maximum total power
dissipation or derated power.
DS40001262F-page 233
PIC16F631/677/685/687/689/690
17.6
FIGURE 17-3:
Time
osc
rd
rw
sc
ss
t0
t1
wr
OSC1
RD
RD or WR
SCK
SS
T0CKI
T1CKI
WR
P
R
V
Z
Period
Rise
Valid
High-impedance
LOAD CONDITIONS
Load Condition
Pin
CL
VSS
DS40001262F-page 234
PIC16F631/677/685/687/689/690
17.7
FIGURE 17-4:
CLOCK TIMING
Q4
Q1
Q2
Q3
Q4
Q1
OSC1/CLKIN
OS02
OS04
OS04
OS03
OSC2/CLKOUT
(LP,XT,HS Modes)
OSC2/CLKOUT
(CLKOUT Mode)
TABLE 17-1:
Sym.
OS01
FOSC
Characteristic
External CLKIN Frequency(1)
(1)
Oscillator Frequency
OS02
TOSC
Oscillator Period(1)
OS03
TCY
OS04*
TOSH,
TOSL
TOSR,
TOSF
OS05*
Note 1:
Min.
Typ
Max.
Units
Conditions
DC
37
kHz
DC
MHz
XT Oscillator mode
DC
20
MHz
HS Oscillator mode
DC
20
MHz
EC Oscillator mode
LP Oscillator mode
32.768
kHz
LP Oscillator mode
0.1
MHz
XT Oscillator mode
20
MHz
HS Oscillator mode
DC
MHz
RC Oscillator mode
27
LP Oscillator mode
250
ns
XT Oscillator mode
50
ns
HS Oscillator mode
50
ns
EC Oscillator mode
30.5
LP Oscillator mode
250
10,000
ns
XT Oscillator mode
50
1,000
ns
HS Oscillator mode
250
ns
RC Oscillator mode
200
TCY
DC
ns
TCY = 4/FOSC
LP oscillator
100
ns
XT oscillator
20
ns
HS oscillator
ns
LP oscillator
ns
XT oscillator
ns
HS oscillator
DS40001262F-page 235
PIC16F631/677/685/687/689/690
TABLE 17-2:
OSCILLATOR PARAMETERS
Sym.
Characteristic
Freq.
Tolerance
Min.
Typ
Max.
Units
Conditions
OS06
TWARM
TOSC
Slowest clock
OS07
TSC
21
ms
LFINTOSC/64
OS08
HFOSC
Internal Calibrated
HFINTOSC Frequency(2)
1%
7.92
8.0
8.08
MHz
2%
7.84
8.0
8.16
MHz
5%
7.60
8.0
8.40
MHz
15
31
45
kHz
5.5
12
24
3.5
14
11
Internal Uncalibrated
LFINTOSC Frequency
OS09*
LFOSC
OS10*
Note 1:
2:
3:
DS40001262F-page 236
PIC16F631/677/685/687/689/690
FIGURE 17-5:
Cycle
Write
Fetch
Read
Execute
Q4
Q1
Q2
Q3
FOSC
OS12
OS11
OS20
OS21
CLKOUT
OS19
OS18
OS16
OS13
OS17
I/O pin
(Input)
OS14
OS15
I/O pin
(Output)
New Value
Old Value
OS18, OS19
TABLE 17-3:
Sym.
Characteristic
Min.
Conditions
TOSH2CKL
70
ns
VDD = 5.0V
OS12
TOSH2CKH
FOSC to CLKOUT
72
ns
VDD = 5.0V
OS13
TCKL2IOV
20
ns
OS14
TIOV2CKH
TOSC + 200 ns
ns
OS15
TOSH2IOV
50
70*
ns
VDD = 5.0V
OS16
TOSH2IOI
50
ns
VDD = 5.0V
OS17
TIOV2OSH
20
ns
OS18
TIOR
15
40
72
32
ns
VDD = 2.0V
VDD = 5.0V
OS19
TIOF
28
15
55
30
ns
VDD = 2.0V
VDD = 5.0V
OS20*
TINP
25
ns
OS21*
TRAP
TCY
ns
OS11
Note 1:
2:
(1)
DS40001262F-page 237
PIC16F631/677/685/687/689/690
FIGURE 17-6:
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out
32
OSC
Start-up Time
Internal Reset(1)
Watchdog Timer
Reset(1)
31
34
34
I/O pins
Note
1:
Asserted low.
FIGURE 17-7:
VDD
VBOR + VHYST
VBOR
37
Reset
(due to BOR)
*
33*
DS40001262F-page 238
PIC16F631/677/685/687/689/690
TABLE 17-4:
Sym.
Characteristic
Min.
Typ
Max. Units
Conditions
30
TMCL
2
5
s
s
31
TWDT
10
10
17
17
25
30
ms
ms
32
TOST
1024
33*
TPWRT
40
65
140
ms
34*
TIOZ
2.0
35
VBOR
2.0
2.2
36*
VHYST
50
mV
37*
TBOR
100
TOSC (Note 3)
(Note 4)
VDD VBOR
DS40001262F-page 239
PIC16F631/677/685/687/689/690
FIGURE 17-8:
T0CKI
40
41
42
T1CKI
45
46
49
47
TMR0 or
TMR1
TABLE 17-5:
Sym.
TT0H
Characteristic
T0CKI High Pulse Width
No Prescaler
With Prescaler
41*
TT0L
No Prescaler
42*
TT0P
T0CKI Period
45*
TT1H
With Prescaler
Asynchronous
46*
TT1L
T1CKI Low
Time
Synchronous, No Prescaler
Synchronous,
with Prescaler
Asynchronous
47*
TT1P
48
FT1
49*
Asynchronous
Min.
Typ
Max.
Units
0.5 TCY + 20
ns
10
ns
0.5 TCY + 20
ns
10
ns
Greater of:
20 or TCY + 40
N
ns
0.5 TCY + 20
ns
15
ns
30
ns
0.5 TCY + 20
ns
15
ns
30
ns
Greater of:
30 or TCY + 40
N
ns
60
ns
32.768
kHz
2 TOSC
7 TOSC
Conditions
N = prescale value
(2, 4, ..., 256)
N = prescale value
(1, 2, 4, 8)
Timers in Sync
mode
DS40001262F-page 240
PIC16F631/677/685/687/689/690
FIGURE 17-9:
CCP1
(Capture mode)
CC01
CC02
CC03
Note:
TABLE 17-6:
Sym.
TccL
TccH
TccP
Characteristic
CCP1 Input Low Time
CCP1 Input High Time
CCP1 Input Period
Min.
Typ
Max.
Units
No Prescaler
0.5TCY + 20
ns
With Prescaler
20
ns
No Prescaler
0.5TCY + 20
ns
With Prescaler
20
ns
3TCY + 40
N
ns
Conditions
N = prescale
value (1, 4 or
16)
DS40001262F-page 241
PIC16F631/677/685/687/689/690
TABLE 17-7:
COMPARATOR SPECIFICATIONS
Standard Operating Conditions (unless otherwise stated)
Operating temperature
-40C TA +125C
Comparator Specifications
Param.
No.
CM01
Sym.
Characteristics
VOS
CM02
VCM
CM03*
CMRR
CM04*
TRT
Response Time
*
Note 1:
Typ.
Max.
Units
5.0
10
mV
VDD - 1.5
+55
db
Falling
150
600
ns
Rising
200
1000
ns
10
CM05*
Min.
Comments
(Note 1)
TABLE 17-8:
Sym.
Characteristics
Min.
Typ
Max.
Units
Comments
CV01*
CLSB
Step Size(2)
VDD/24
VDD/32
V
V
CV02*
CACC
Absolute Accuracy
1/2
1/2
LSb
LSb
CV03*
CR
2k
CST
Time(1)
10
CV04*
Settling
TABLE 17-9:
Symbol
Characteristics
Typ.
Max.
Units
VR01
VROUT
VR voltage output
0.5
0.6
0.7
VR02*
TSTABLE
Settling Time
10
100*
Comments
DS40001262F-page 242
PIC16F631/677/685/687/689/690
FIGURE 17-10:
RB7/TX/CK
pin
121
121
RB5/AN11/RX/DT
pin
120
Note:
122
Symbol
Characteristic
FIGURE 17-11:
Min.
Max.
Units
40
ns
20
20
ns
ns
Conditions
RB7/TX/CK
pin
RB5/AN11/RX/DT
pin
125
126
Note: Refer to Figure 17-3 for load conditions.
Symbol
Characteristic
Min.
Max.
Units
10
ns
15
ns
Conditions
DS40001262F-page 243
PIC16F631/677/685/687/689/690
FIGURE 17-12:
SS
70
SCK
(CKP = 0)
71
72
78
79
79
78
SCK
(CKP = 1)
80
bit 6 - - - - - -1
MSb
SDO
LSb
75, 76
SDI
MSb In
bit 6 - - - -1
LSb In
74
73
Note: Refer to Figure 17-3 for load conditions.
FIGURE 17-13:
SS
81
SCK
(CKP = 0)
71
72
79
73
SCK
(CKP = 1)
80
78
SDO
MSb
bit 6 - - - - - -1
LSb
bit 6 - - - -1
LSb In
75, 76
SDI
MSb In
74
DS40001262F-page 244
PIC16F631/677/685/687/689/690
FIGURE 17-14:
SS
70
SCK
(CKP = 0)
83
71
72
78
79
79
78
SCK
(CKP = 1)
80
MSb
SDO
LSb
bit 6 - - - - - -1
77
75, 76
SDI
MSb In
bit 6 - - - -1
LSb In
74
73
Note: Refer to Figure 17-3 for load conditions.
FIGURE 17-15:
SS
SCK
(CKP = 0)
70
83
71
72
SCK
(CKP = 1)
80
SDO
MSb
bit 6 - - - - - -1
LSb
75, 76
SDI
MSb In
77
bit 6 - - - -1
LSb In
74
Note: Refer to Figure 17-3 for load conditions.
DS40001262F-page 245
PIC16F631/677/685/687/689/690
TABLE 17-12: SPI MODE REQUIREMENTS
Param
No.
Symbol
70*
Characteristic
Min.
Typ
TCY
ns
71*
TSCH
TCY + 20
ns
72*
TSCL
TCY + 20
ns
73*
100
ns
74*
TSCH2DIL,
TSCL2DIL
100
ns
75*
TDOR
10
25
ns
76*
TDOF
3.0-5.5V
2.0-5.5V
25
50
ns
10
25
ns
77*
TSSH2DOZ
10
50
ns
78*
TSCR
3.0-5.5V
10
25
ns
2.0-5.5V
25
50
ns
79*
TSCF
10
25
ns
80*
3.0-5.5V
50
ns
2.0-5.5V
145
ns
81*
Tcy
ns
82*
TSSL2DOV
50
ns
83*
1.5TCY + 40
ns
FIGURE 17-16:
SCL
91
90
93
92
SDA
Start
Condition
Stop
Condition
DS40001262F-page 246
PIC16F631/677/685/687/689/690
TABLE 17-13: I2C BUS START/STOP BITS REQUIREMENTS
Param
No.
Symbol
Characteristic
90*
TSU:STA
91*
THD:STA
92*
TSU:STO
93
Start condition
4700
Setup time
600
Start condition
4000
Hold time
600
Stop condition
4700
Setup time
Hold time
*
Min.
600
4000
600
Conditions
ns
ns
ns
ns
FIGURE 17-17:
102
100
101
SCL
90
106
107
91
92
SDA
In
110
109
109
SDA
Out
Note: Refer to Figure 17-3 for load conditions.
DS40001262F-page 247
PIC16F631/677/685/687/689/690
TABLE 17-14: I2C BUS DATA REQUIREMENTS
Param.
No.
100*
Symbol
THIGH
Characteristic
Clock high time
Min.
Max.
Units
4.0
0.6
1.5TCY
4.7
1.3
SSP Module
101*
TLOW
SSP Module
102*
103*
90*
91*
106*
107*
92*
109*
110*
TR
TF
TSU:STA
THD:STA
THD:DAT
TSU:DAT
TSU:STO
TAA
TBUF
CB
*
Note 1:
2:
Conditions
1.5TCY
1000
ns
0.1CB
300
ns
300
ns
20 + 0.1CB
300
ns
CB is specified to be from
10-400 pF
Only relevant for
Repeated Start condition
20 +
4.7
0.6
4.0
0.6
ns
0.9
250
ns
100
ns
Start condition
setup time
4.7
0.6
3500
ns
ns
4.7
1.3
400
pF
CB is specified to be from
10-400 pF
(Note 2)
(Note 1)
Time the bus must be free
before a new transmission
can start
DS40001262F-page 248
PIC16F631/677/685/687/689/690
TABLE 17-15: A/D CONVERTER (ADC) CHARACTERISTICS:
Standard Operating Conditions (unless otherwise stated)
Operating temperature
-40C TA +125C
Param
Sym.
No.
Characteristic
Min.
Typ
Max.
Units
Conditions
AD01
NR
Resolution
10 bits
AD02
EIL
Integral Error
AD03
EDL
Differential Error
AD04
EOFF
Offset Error
+1.5
+3.0
AD07
EGN
Gain Error
AD06
AD06A
VREF
Reference Voltage(3)
2.2
2.5
VDD
AD07
VAIN
Full-Scale Range
VSS
VREF
AD08
ZAIN
Recommended
Impedance of Analog
Voltage Source
10
AD09* IREF
10
1000
50
AD04A
bit
DS40001262F-page 249
PIC16F631/677/685/687/689/690
FIGURE 17-18:
BSF ADCON0, GO
134
1 TCY
(TOSC/2)(1)
131
Q4
130
A/D CLK
9
A/D Data
0
NEW_DATA
OLD_DATA
ADRES
1 TCY
ADIF
GO
Sample
Note 1:
DONE
Sampling Stopped
132
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.
Sym.
TAD
Characteristic
A/D Clock Period
A/D Internal RC
Oscillator Period
Min.
Typ
Max.
Units
Conditions
1.5
3.0*
3.0*
6.0
9.0*
2.0*
4.0
6.0*
At VDD = 5.0V
Set GO bit to new data in A/D Result
register
131
TCNV
Conversion Time
(not including
Acquisition Time)(1)
11
TAD
132*
TACQ
Acquisition Time
(2)
11.5
5*
TOSC/2
134
TGO
Q4 to A/D Clock
Start
DS40001262F-page 250
PIC16F631/677/685/687/689/690
FIGURE 17-19:
BSF ADCON0, GO
134
(TOSC/2 + TCY)(1)
1 TCY
131
Q4
130
A/D CLK
9
A/D Data
0
NEW_DATA
OLD_DATA
ADRES
ADIF
1 TCY
GO
DONE
Note 1:
Sampling Stopped
132
Sample
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.
TABLE 1:
Sym.
TAD
Characteristic
A/D Internal RC
Oscillator Period
Min.
Typ
Max.
Units
Conditions
3.0*
6.0
9.0*
2.0*
4.0
6.0*
131
TCNV
Conversion Time
(not including
Acquisition Time)(1)
11
TAD
132*
TACQ
Acquisition Time
(2)
11.5
5*
TOSC/2 + TCY
134
TGO
Q4 to A/D Clock
Start
DS40001262F-page 251
PIC16F631/677/685/687/689/690
17.8
PIC16F685
PIC16F687
PIC16F689
PIC16F690
Value
Units
Parameter
Source
20
mA
Sink
50
mA
Source
mA
Sink
10
mA
Source
mA
Sink
8.5
mA
Source
20
mA
Sink
50
mA
155
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 above
maximum rating conditions for extended periods may affect device reliability.
DS40001262F-page 252
PIC16F631/677/685/687/689/690
VOLTAGE-FREQUENCY GRAPH, -40C TA +150C
FIGURE 17-20:
6.0
5.5
VDD (V)
5.0
4.5
4.0
3.5
3.0
2.5
10
20
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
FIGURE 17-21:
150
7.5%
125
5%
Temperature (C)
85
2%
60
1%
25
-40
2.1
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 253
PIC16F631/677/685/687/689/690
TABLE 17-18: ADC CLOCK PERIOD (TAD) VS. DEVICE OPERATING FREQUENCIES (VDD > 3.0V,
VREF > 2.5V)
ADC Clock Period (TAD)
ADC Clock Source
ADCS<2:0>
20 MHz
8 MHz
4 MHz
1 MHz
Fosc/2
000
100 ns
250 ns
500 ns
2.0 s
Fosc/4
100
200 ns
500 ns
1.0 s
4.0 s
Fosc/8
001
400 ns
1.0 s
2.0 s
8.0 s
Fosc/16
101
800 ns
2.0 s
4.0 s
16.0 s
Fosc/32
010
1.6 s
4.0 s
8.0 s
32.0 s
Fosc/64
110
3.2 s
8.0 s
16.0 s
64.0 s
Frc
x11
2-6 s
2-6 s
2-6 s
2-6 s
Legend: Shaded cells should not be used for conversions at temperatures above +125C.
Note 1: TAD must be between 1.6 s and 4.0 s.
DS40001262F-page 254
PIC16F631/677/685/687/689/690
TABLE 17-19: DC CHARACTERISTICS FOR IDD SPECIFICATIONS FOR PIC16F685/687/689/690-H
(High Temp.)
Param
No.
D001
D010
Device
Characteristics
VDD
Supply Current (IDD)
D011
D012
D013
D014
D015
D016
D017
D018
D019
Condition
Min.
Typ.
Max.
Units
VDD
Note
2.1
5.5
2.1
5.5
FOSC 4 MHz
47
69
3.0
2.1
108
5.0
357
2.1
533
729
535
875
1.32
336
477
777
505
724
3.0
A
mA
2.1
3.0
2.1
3.0
2.1
3.0
1.30
mA
5.0
51
2.1
92
117
mA
665
970
3.0
1.56
mA
5.0
936
2.1
1.34
2.27
605
903
1.43
6.61
7.81
A
mA
mA
Fosc = 31 kHz
LFINTOSC
2.1
3.0
mA
Fosc = 4 MHz
EC Oscillator
5.0
Fosc = 1 MHz
EC Oscillator
5.0
Fosc = 4 MHz
XT Oscillator
5.0
Fosc = 1 MHz
XT Oscillator
5.0
Fosc = 32 kHz
LP Oscillator
3.0
Fosc = 4 MHz
HFINTOSC
Fosc = 8 MHz
HFINTOSC
5.0
2.1
3.0
Fosc = 4 MHz
EXTRC
5.0
4.5
5.0
Fosc = 20 MHz
HS Oscillator
DS40001262F-page 255
PIC16F631/677/685/687/689/690
TABLE 17-20: DC CHARACTERISTICS FOR IPD SPECIFICATIONS FOR PIC16F685/687/689/690-H
(High Temp.)
Param
No.
D020E
Device
Characteristics
Power Down Base
Current (IPD)
D021E
D022E
D023E
D024E
D024AE
D025E
D026E
D027E
Condition
Units
Min.
Typ.
Max.
VDD
27
29
2.1
A
3.0
32
5.0
55
2.1
59
69
75
147
73
117
3.0
Note
IPD Base: WDT, BOR,
Comparators, VREF and
T1OSC disabled
WDT Current
5.0
A
3.0
5.0
BOR Current
2.1
A
3.0
235
5.0
102
2.1
128
170
133
167
3.0
5.0
2.1
A
3.0
222
5.0
36
2.1
41
47
22
24
189
250
3.0
5.0
A
A
3.0
5.0
3.0
5.0
Analog-to-Digital current,
no conversion in progress
VP6 current (Fixed Voltage
Reference)
Sym.
Characteristic
Min.
Typ.
Max.
Units
Conditions
D061
IIL
0.5
5.0
D062
IIL
50
250
400
VDD = 5.0V
Note 1:
2:
This specification applies when RA3/MCLR is configured as an input with the pull-up disabled. The
leakage current for the RA3/MCLR pin is higher than for the standard I/O port pins.
This specification applies when RA3/MCLR is configured as the MCLR reset pin function with the weak
pull-up enabled.
Sym.
D120A ED
Characteristic
Byte Endurance
DS40001262F-page 256
Min.
Typ.
Max.
Units
5K
50K
E/W
Conditions
126C TA 150C
PIC16F631/677/685/687/689/690
TABLE 17-23: OSCILLATOR PARAMETERS FOR PIC16F685/687/689/690-H (High Temp.)
Param
No.
OS08
Note 1:
Sym.
Characteristic
Frequency
Tolerance
Min.
Typ.
Max.
Units
7.5%
7.4
8.0
8.6
MHz
Conditions
2.1V VDD 5.5V
-40C TA 150C
To ensure these oscillator frequency tolerances, VDD and VSS must be capacitively decoupled as close to
the device as possible. 0.1 F and 0.01 F values in parallel are recommended.
Sym.
TWDT
Characteristic
Watchdog Timer Time-out Period
(No Prescaler)
Min.
Typ.
Max.
Units
10
20
70
ms
Conditions
150C Temperature
Sym.
VBOR
Characteristic
Brown-Out Reset Voltage
Min.
Typ.
Max.
Units
2.0
2.3
Conditions
150C Temperature
Sym.
VOS
Characteristic
Input Offset Voltage
Min.
Typ.
Max.
Units
20
mV
Conditions
(VDD - 1.5)/2
DS40001262F-page 257
PIC16F631/677/685/687/689/690
18.0
The graphs and tables provided in this section are for design guidance and are not tested.
In some graphs or tables, the data presented are outside specified operating range (i.e., outside specified VDD
range). This is for information only and devices are ensured to operate properly only within the specified range.
Note:
The graphs and tables provided following this note are a statistical summary based on a limited number of
samples and are provided for informational purposes only. The performance characteristics listed herein
are not tested or guaranteed. In some graphs or tables, the data presented may be outside the specified
operating range (e.g., outside specified power supply range) and therefore, outside the warranted range.
Typical represents the mean of the distribution at 25C. Maximum or minimum represents
(mean + 3) or (mean - 3) respectively, where is a standard deviation, over each temperature range.
FIGURE 18-1:
3.5
3.0
5.5V
5.0V
IDD (mA)
2.5
2.0
4.0V
1.5
3.0V
1.0
2.0V
0.5
0.0
1 MHz
2 MHz
4 MHz
6 MHz
8 MHz
10 MHz
12 MHz
14 MHz
16 MHz
18 MHz
20 MHz
FOSC
DS40001262F-page 258
PIC16F631/677/685/687/689/690
FIGURE 18-2:
4.0
3.5
5.5V
5.0V
3.0
IDD (mA)
2.5
4.0V
2.0
3.0V
1.5
2.0V
1.0
0.5
0.0
1 MHz
2 MHz
4 MHz
6 MHz
8 MHz
10 MHz
12 MHz
14 MHz
16 MHz
18 MHz
20 MHz
FOSC
FIGURE 18-3:
4.0
3.5
5.5V
3.0
5.0V
IDD (mA)
2.5
4.5V
2.0
1.5
4.0V
3.5V
3.0V
1.0
0.5
0.0
4 MHz
10 MHz
16 MHz
20 MHz
FOSC
DS40001262F-page 259
PIC16F631/677/685/687/689/690
FIGURE 18-4:
5.0
4.5
4.0
IDD (mA)
3.5
5.0V
3.0
4.5V
2.5
2.0
1.5
4.0V
3.5V
3.0V
1.0
0.5
0.0
4 MHz
10 MHz
16 MHz
20 MHz
FOSC
FIGURE 18-5:
900
800
700
IDD (A)
600
500
4 MHz
400
300
1 MHz
200
100
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 260
PIC16F631/677/685/687/689/690
FIGURE 18-6:
1,400
Typical: Statistical Mean @25C
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
1,200
1,000
IDD (A)
800
4 MHz
600
400
1 MHz
200
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-7:
80
70
IDD (uA)
60
50
32 kHz Maximum
40
30
32 kHz Typical
20
10
0
2.0
2.5
3.0
4.0
3.5
4.5
5.0
5.5
VDD (V)
DS40001262F-page 261
PIC16F631/677/685/687/689/690
FIGURE 18-8:
800
Typical: Statistical Mean @25C
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
700
600
IDD (A)
500
4 MHz
400
300
1 MHz
200
100
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
5.0
5.5
VDD (V)
FIGURE 18-9:
EXTRC Mode
1,400
1,200
IDD (A)
1,000
4 MHz
800
600
1 MHz
400
200
0
2.0
2.5
3.0
3.5
4.0
4.5
VDD (V)
DS40001262F-page 262
PIC16F631/677/685/687/689/690
FIGURE 18-10:
80
Typical: Statistical Mean @25C
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
70
60
IDD (A)
50
Maximum
40
30
Typical
20
10
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-11:
1,600
1,400
5.5V
5.0V
1,200
IDD (A)
1,000
4.0V
800
3.0V
600
2.0V
400
200
0
125 kHz
250 kHz
500 kHz
1 MHz
2 MHz
4 MHz
8 MHz
FOSC
DS40001262F-page 263
PIC16F631/677/685/687/689/690
FIGURE 18-12:
2,000
1,800
5.5V
5.0V
1,600
1,400
4.0V
IDD (A)
1,200
1,000
3.0V
800
600
2.0V
400
200
0
125 kHz
250 kHz
500 kHz
1 MHz
2 MHz
4 MHz
8 MHz
FOSC
FIGURE 18-13:
0.45
0.40
0.35
IPD (A)
0.30
0.25
0.20
0.15
0.10
0.05
0.0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 264
PIC16F631/677/685/687/689/690
FIGURE 18-14:
18.0
16.0
14.0
Max. 125C
IPD (A)
12.0
10.0
8.0
6.0
4.0
Max. 85C
2.0
0.0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-15:
180
160
140
IPD (A)
120
Maximum
100
Typical
80
60
40
20
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 265
PIC16F631/677/685/687/689/690
FIGURE 18-16:
160
140
120
IPD (A)
100
Maximum
80
Typical
60
40
20
0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-17:
3.0
2.5
Typical: Statistical
StatisticalMean
Mean @25C
@25C
Typical:
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
IPD (A)
2.0
1.5
1.0
0.5
0.0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 266
PIC16F631/677/685/687/689/690
FIGURE 18-18:
25.0
20.0
IPD (A)
Max. 125C
15.0
10.0
Max. 85C
5.0
0.0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-19:
30
28
26
Max. (85C)
24
Time (ms)
22
20
Typical
18
16
14
Minimum
12
10
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 267
PIC16F631/677/685/687/689/690
FIGURE 18-20:
30
28
26
Maximum
24
Time (ms)
22
20
Typical
18
16
Minimum
14
12
10
-40C
25C
85C
125C
Temperature (C)
FIGURE 18-21:
140
120
100
IPD (A)
Max. 125C
80
Max. 85C
60
Typical
40
20
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 268
PIC16F631/677/685/687/689/690
FIGURE 18-22:
180
Typical: Statistical Mean @25C
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
160
140
120
IPD (A)
Max. 125C
100
Max. 85C
80
Typical
60
40
20
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-23:
160
140
IPD (uA)
120
100
Typical
80
60
40
20
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 269
PIC16F631/677/685/687/689/690
FIGURE 18-24:
180
160
140
Max 125C
IPD (uA)
120
Max 85C
100
80
60
40
20
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
5.0
5.5
VDD (V)
FIGURE 18-25:
30
25
IPD (uA)
20
15
10
2
2.5
3
3.5
4
4.5
5
5.5
Typ 25C
2.022
2.247
2.472
2.453
2.433
2.711
2.989
3.112
Max 85C
4.98
5.23
5.49
5.79
6.08
6.54
7.00
7.34
Max 125C
17.54
19.02
20.29
21.50
Max. 85C
22.45
23.30
24.00
Typ. 25C
0
2.0
2.5
3.0
3.5
4.0
4.5
VDD (V)
DS40001262F-page 270
PIC16F631/677/685/687/689/690
FIGURE 18-26:
0.8
0.7
Max. 125C
0.6
VOL (V)
0.5
Max. 85C
0.4
Typical 25C
0.3
0.2
Min. -40C
0.1
0.0
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
IOL (mA)
FIGURE 18-27:
0.45
Typical: Statistical Mean @25C
Typical:
Statistical
Mean Temp)
@25C+ 3
Maximum:
Mean
(Worst-case
Maximum: Meas(-40C
+ 3 to 125C)
(-40C to 125C)
0.40
Max. 125C
0.35
Max. 85C
VOL (V)
0.30
0.25
Typ. 25C
0.20
0.15
Min. -40C
0.10
0.05
0.00
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5
10.0
IOL (mA)
DS40001262F-page 271
PIC16F631/677/685/687/689/690
FIGURE 18-28:
3.5
3.0
Max. -40C
Typ. 25C
2.5
Min. 125C
VOH (V)
2.0
1.5
1.0
0.5
0.0
0.0
-0.5
-1.0
-1.5
-2.0
-2.5
-3.0
-3.5
-4.0
IOH (mA)
FIGURE 18-29:
(VDD = 5.0V)
VOH vs. IOH OVER TEMPERATURE
(
,
)
5.5
5.0
Max. -40C
Typ. 25C
VOH (V)
4.5
Min. 125C
4.0
3.5
3.0
0.0
-0.5
-1.0
-1.5
-2.0
-2.5
-3.0
-3.5
-4.0
-4.5
-5.0
IOH (mA)
DS40001262F-page 272
PIC16F631/677/685/687/689/690
FIGURE 18-30:
1.7
1.5
VIN (V)
1.3
Typ. 25C
1.1
Min. 125C
0.9
0.7
0.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-31:
4.0
VIH Max. 125C
3.5
VIN (V)
3.0
2.5
2.0
VIL Max. -40C
1.5
1.0
0.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 273
PIC16F631/677/685/687/689/690
FIGURE 18-32:
806
1000
900
Max. 125C
800
700
600
Note:
500
Max. 85C
400
300
Typ. 25C
200
Min. -40C
100
0
2.0
2.5
4.0
5.5
VDD (V)
FIGURE 18-33:
1000
900
Max. 125C
800
700
600
500
Note:
Max. 85C
400
300
Typ. 25C
200
Min. -40C
100
0
2.0
2.5
4.0
5.5
VDD (V)
DS40001262F-page 274
PIC16F631/677/685/687/689/690
FIGURE 18-34:
45,000
40,000
Max. -40C
35,000
Typ. 25C
Frequency (Hz)
30,000
25,000
20,000
Min. 85C
Min. 125C
15,000
10,000
5,000
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-35:
8
Typical: Statistical Mean @25C
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
125C
6
Time (s)
85C
25C
-40C
2
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 275
PIC16F631/677/685/687/689/690
FIGURE 18-36:
16
Typical: Statistical Mean @25C
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
14
85C
12
25C
Time (s)
10
-40C
8
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-37:
25
Time (s)
20
15
85C
25C
10
-40C
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 276
PIC16F631/677/685/687/689/690
FIGURE 18-38:
10
9
Typical: Statistical Mean @25C
Maximum: Mean (Worst-case Temp) + 3
(-40C to 125C)
8
7
Time (s)
85C
6
25C
5
-40C
4
3
2
1
0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-39:
5
4
3
2
1
0
-1
-2
-3
-4
-5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 277
PIC16F631/677/685/687/689/690
FIGURE 18-40:
5
4
Change from Calibration (%)
3
2
1
0
-1
-2
-3
-4
-5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-41:
5
4
3
2
1
0
-1
-2
-3
-4
-5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
DS40001262F-page 278
PIC16F631/677/685/687/689/690
FIGURE 18-42:
5
4
3
2
1
0
-1
-2
-3
-4
-5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (V)
FIGURE 18-43:
0.65
0.64
0.63
VP6 (V)
0.62
0.61
0.60
0.59
Typical
0.58
0.57
0.56
0.55
2
5.5
VDD (V)
DS40001262F-page 279
PIC16F631/677/685/687/689/690
FIGURE 18-44:
0.66
0.64
Max.
VP6 (V)
0.62
0.6
Typical
0.58
Min.
0.56
0.54
0.52
-40C
25C
85C
125C
Temperature (C)
FIGURE 18-45:
0.66
0.64
VP6 (V)
0.62
Max.
0.6
Typical
0.58
0.56
Min.
0.54
0.52
-40 C
25 C
85 C
125 C
Temperature (C)
DS40001262F-page 280
PIC16F631/677/685/687/689/690
FIGURE 18-46:
35
Parts=118
Number of Parts
30
25
20
15
10
5
0.690
0.700
0.690
0.700
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
FIGURE 18-47:
40
35
Parts=118
Number of Parts
30
25
20
15
10
5
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
DS40001262F-page 281
PIC16F631/677/685/687/689/690
FIGURE 18-48:
40
35
Parts=118
Number of Parts
30
25
20
15
10
5
0.700
0.690
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
FIGURE 18-49:
30
Parts=118
Number of Parts
25
20
15
10
0.700
0.690
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
DS40001262F-page 282
PIC16F631/677/685/687/689/690
FIGURE 18-50:
30
Number of Parts
25
Parts=118
20
15
10
0.700
0.690
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
FIGURE 18-51:
35
Number of Parts
30
Parts=118
25
20
15
10
5
0.700
0.690
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
DS40001262F-page 283
PIC16F631/677/685/687/689/690
FIGURE 18-52:
30
25
Number of Parts
Parts=118
20
15
10
0.700
0.690
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
FIGURE 18-53:
30
Number of Parts
25
Parts=118
20
15
10
0.700
0.690
0.680
0.670
0.660
0.650
0.640
0.630
0.620
0.610
0.600
0.590
0.580
0.570
0.560
0.550
0.540
0.530
0.520
0.510
0.500
Voltage (V)
DS40001262F-page 284
PIC16F631/677/685/687/689/690
19.0
PACKAGING INFORMATION
19.1
Example
PIC16F685-I/P e3
0710017
XXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXX
YYWWNNN
Example
PIC16F685-I
/SO e3
0710017
YYWWNNN
20-Lead SSOP
Example
XXXXXXXXXXX
XXXXXXXXXXX
YYWWNNN
20-Lead QFN
Example
XXXXXX
XXXXXX
YWWNNN
Legend: XX...X
Y
YY
WW
NNN
e3
Note:
PIC16F687
-I/SS e3
0710017
16F690
-I/ML e3
710017
Customer-specific information
Year code (last digit of calendar year)
Year code (last 2 digits of calendar year)
Week code (week of January 1 is week 01)
Alphanumeric traceability code
Pb-free JEDEC designator for Matte Tin (Sn)
This package is Pb-free. The Pb-free JEDEC designator ( e3 )
can be found on the outer packaging for this package.
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.
DS40001262F-page 285
PIC16F631/677/685/687/689/690
19.2
Package Details
/HDG3ODVWLF'XDO,Q/LQH3PLO%RG\>3',3@
1RWH
)RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
E1
NOTE 1
3
D
E
A2
A1
b1
b
eB
e
8QLWV
'LPHQVLRQ/LPLWV
1XPEHURI3LQV
,1&+(6
0,1
120
0$;
3LWFK
7RSWR6HDWLQJ3ODQH
0ROGHG3DFNDJH7KLFNQHVV
$
%DVHWR6HDWLQJ3ODQH
$
6KRXOGHUWR6KRXOGHU:LGWK
0ROGHG3DFNDJH:LGWK
(
2YHUDOO/HQJWK
'
7LSWR6HDWLQJ3ODQH
/HDG7KLFNQHVV
E
H%
8SSHU/HDG:LGWK
/RZHU/HDG:LGWK
2YHUDOO5RZ6SDFLQJ
%6&
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
6LJQLILFDQW&KDUDFWHULVWLF
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
DS40001262F-page 286
PIC16F631/677/685/687/689/690
Note:
For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
DS40001262F-page 287
PIC16F631/677/685/687/689/690
Note:
For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
DS40001262F-page 288
PIC16F631/677/685/687/689/690
Note:
For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
DS40001262F-page 289
PIC16F631/677/685/687/689/690
/HDG3ODVWLF6KULQN6PDOO2XWOLQH66PP%RG\>6623@
1RWH
)RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D
N
E
E1
NOTE 1
1 2
e
b
c
A2
A1
L1
8QLWV
'LPHQVLRQ/LPLWV
1XPEHURI3LQV
L
0,//,0(7(56
0,1
120
0$;
3LWFK
2YHUDOO+HLJKW
%6&
0ROGHG3DFNDJH7KLFNQHVV
$
6WDQGRII
$
2YHUDOO:LGWK
0ROGHG3DFNDJH:LGWK
(
2YHUDOO/HQJWK
'
)RRW/HQJWK
)RRWSULQW
/
5()
/HDG7KLFNQHVV
)RRW$QJOH
/HDG:LGWK
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
'LPHQVLRQV'DQG(GRQRWLQFOXGHPROGIODVKRUSURWUXVLRQV0ROGIODVKRUSURWUXVLRQVVKDOOQRWH[FHHGPPSHUVLGH
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
0LFURFKLS 7HFKQRORJ\ 'UDZLQJ &%
DS40001262F-page 290
PIC16F631/677/685/687/689/690
Note:
For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
DS40001262F-page 291
PIC16F631/677/685/687/689/690
/HDG3ODVWLF4XDG)ODW1R/HDG3DFNDJH0/[[PP%RG\>4)1@
1RWH
)RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
D2
EXPOSED
PAD
e
E2
2
E
b
1
K
N
N
NOTE 1
TOP VIEW
BOTTOM VIEW
A
A1
A3
8QLWV
'LPHQVLRQ/LPLWV
1XPEHURI3LQV
0,//,0(7(56
0,1
120
0$;
3LWFK
2YHUDOO+HLJKW
6WDQGRII
$
&RQWDFW7KLFNQHVV
$
2YHUDOO:LGWK
([SRVHG3DG:LGWK
(
2YHUDOO/HQJWK
'
([SRVHG3DG/HQJWK
%6&
5()
%6&
%6&
'
&RQWDFW:LGWK
&RQWDFW/HQJWK
&RQWDFWWR([SRVHG3DG
1RWHV
3LQYLVXDOLQGH[IHDWXUHPD\YDU\EXWPXVWEHORFDWHGZLWKLQWKHKDWFKHGDUHD
3DFNDJHLVVDZVLQJXODWHG
'LPHQVLRQLQJDQGWROHUDQFLQJSHU$60(<0
%6& %DVLF'LPHQVLRQ7KHRUHWLFDOO\H[DFWYDOXHVKRZQZLWKRXWWROHUDQFHV
5() 5HIHUHQFH'LPHQVLRQXVXDOO\ZLWKRXWWROHUDQFHIRULQIRUPDWLRQSXUSRVHVRQO\
DS40001262F-page 292
PIC16F631/677/685/687/689/690
1RWH
)RUWKHPRVWFXUUHQWSDFNDJHGUDZLQJVSOHDVHVHHWKH0LFURFKLS3DFNDJLQJ6SHFLILFDWLRQORFDWHGDW
KWWSZZZPLFURFKLSFRPSDFNDJLQJ
DS40001262F-page 293
PIC16F631/677/685/687/689/690
APPENDIX A:
DATA SHEET
REVISION HISTORY
APPENDIX B:
MIGRATING FROM
OTHER PIC
DEVICES
B.1
TABLE B-1:
PIC16F676 to PIC16F685
FEATURE COMPARISON
Feature
Max Operating
Speed
Max Program
Memory (Words)
PIC16F676
PIC16F685
20 MHz
20 MHz
1024
4096
SRAM (bytes)
64
128
A/D Resolution
10-bit
10-bit
Data EEPROM
(Bytes)
128
256
Timers (8/16-bit)
1/1
2/1
Oscillator Modes
Brown-out Reset
Internal Pull-ups
RA0/1/2/4/5
RA0/1/2/4/5,
MCLR
Interrupt-on-change
RA0/1/2/3/4/5 RA0/1/2/3/4/5
Comparator
ECCP+
Ultra Low-Power
Wake-up
Extended WDT
Software Control
Option of WDT/BOR
INTOSC
Frequencies
4 MHz
31 kHz-8 MHz
Clock Switching
Note:
DS40001262F-page 294
PIC16F631/677/685/687/689/690
THE MICROCHIP WEB SITE
CUSTOMER SUPPORT
Distributor or Representative
Local Sales Office
Field Application Engineer (FAE)
Technical Support
Customers
should
contact
their
distributor,
representative or Field Application Engineer (FAE) for
support. Local sales offices are also available to help
customers. A listing of sales offices and locations is
included in the back of this document.
Technical support is available through the web site
at: http://www.microchip.com/support
DS40001262F-page 295
PIC16F631/677/685/687/689/690
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
PART NO.
/XX
XXX
Device
Temperature
Range
Package
Pattern
Examples:
a)
b)
Device:
Temperature Range:
I
E
= -40C to +85C
= -40C to +125C
Package:
ML
P
SO
SS
=
=
=
=
c)
(Industrial)
(Extended)
Pattern:
DS40001262F-page 296
1:
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
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 Microchips 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 Microchips 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.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC,
FlashFlex, flexPWR, JukeBlox, KEELOQ, KEELOQ logo, Kleer,
LANCheck, MediaLB, MOST, MOST logo, MPLAB,
OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC,
SST, SST Logo, SuperFlash and UNI/O are registered
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
The Embedded Control Solutions Company and mTouch are
registered trademarks of Microchip Technology Incorporated
in the U.S.A.
Analog-for-the-Digital Age, BodyCom, chipKIT, chipKIT logo,
CodeGuard, dsPICDEM, dsPICDEM.net, ECAN, In-Circuit
Serial Programming, ICSP, Inter-Chip Connectivity, KleerNet,
KleerNet logo, MiWi, MPASM, MPF, MPLAB Certified logo,
MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code
Generation, PICDEM, PICDEM.net, PICkit, PICtail,
RightTouch logo, REAL ICE, SQI, Serial Quad I/O, Total
Endurance, TSHARC, USBCheck, VariSense, ViewSpan,
WiperLock, Wireless DNA, and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
Silicon Storage Technology is a registered trademark of
Microchip Technology Inc. in other countries.
GestIC is a registered trademarks of Microchip Technology
Germany II GmbH & Co. KG, a subsidiary of Microchip
Technology Inc., in other countries.
All other trademarks mentioned herein are property of their
respective companies.
2005-2015, Microchip Technology Incorporated, Printed in
the U.S.A., All Rights Reserved.
ISBN: 978-1-63277-235-0
== ISO/TS 16949 ==
2005-2015 Microchip Technology Inc.
DS40001262F-page 297
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://www.microchip.com/
support
Web Address:
www.microchip.com
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
Austria - Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829
India - Bangalore
Tel: 91-80-3090-4444
Fax: 91-80-3090-4123
France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Germany - Dusseldorf
Tel: 49-2129-3766400
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Hong Kong
Tel: 852-2943-5100
Fax: 852-2401-3431
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
China - Beijing
Tel: 86-10-8569-7000
Fax: 86-10-8528-2104
Austin, TX
Tel: 512-257-3370
China - Chengdu
Tel: 86-28-8665-5511
Fax: 86-28-8665-7889
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
China - Chongqing
Tel: 86-23-8980-9588
Fax: 86-23-8980-9500
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Cleveland
Independence, OH
Tel: 216-447-0464
Fax: 216-447-0643
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Novi, MI
Tel: 248-848-4000
Houston, TX
Tel: 281-894-5983
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
New York, NY
Tel: 631-435-6000
San Jose, CA
Tel: 408-735-9110
Canada - Toronto
Tel: 905-673-0699
Fax: 905-673-6509
China - Dongguan
Tel: 86-769-8702-9880
China - Hangzhou
Tel: 86-571-8792-8115
Fax: 86-571-8792-8116
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
India - Pune
Tel: 91-20-3019-1500
Japan - Osaka
Tel: 81-6-6152-7160
Fax: 81-6-6152-9310
Germany - Pforzheim
Tel: 49-7231-424750
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Japan - Tokyo
Tel: 81-3-6880- 3770
Fax: 81-3-6880-3771
Italy - Venice
Tel: 39-049-7625286
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
China - Shenzhen
Tel: 86-755-8864-2200
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
Taiwan - Kaohsiung
Tel: 886-7-213-7828
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
Poland - Warsaw
Tel: 48-22-3325737
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
Sweden - Stockholm
Tel: 46-8-5090-4654
UK - Wokingham
Tel: 44-118-921-5800
Fax: 44-118-921-5820
Taiwan - Taipei
Tel: 886-2-2508-8600
Fax: 886-2-2508-0102
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
01/27/15
DS40001262F-page 298