Professional Documents
Culture Documents
Pic16F685/687/689/690 Data Sheet: 20-Pin Flash-Based, 8-Bit Cmos Microcontrollers With Nanowatt Technology
Pic16F685/687/689/690 Data Sheet: 20-Pin Flash-Based, 8-Bit Cmos Microcontrollers With Nanowatt Technology
Data Sheet
20-Pin Flash-Based, 8-Bit
CMOS Microcontrollers with
nanoWatt Technology
Preliminary
DS41262A
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, Accuron,
dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC, and SmartShunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
PICMASTER, SEEVAL, SmartSensor and The Embedded
Control Solutions Company are registered trademarks of
Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, dsPICDEM,
dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR,
FanSense, FlexROM, fuzzyLAB, In-Circuit Serial
Programming, ICSP, ICEPIC, MPASM, MPLIB, MPLINK,
MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail,
PowerCal, PowerInfo, PowerMate, PowerTool, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartTel, Total
Endurance and WiperLock 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.
All other trademarks mentioned herein are property of their
respective companies.
2005, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
DS41262A-page ii
Preliminary
PIC16F685/687/689/690
20-Pin Flash-Based, 8-Bit CMOS Microcontrollers with
nanoWatt Technology
High-Performance RISC CPU:
Low-Power Features:
Standby Current:
- 1 nA @ 2.0V, typical
Operating Current:
- 20 A @ 32 kHz, 2.0V, typical
- <1 mA @ 4 MHz, 5.5V, 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
Preliminary
DS41262A-page 1
PIC16F685/687/689/690
Program
Memory
Data Memory
Device
I/O
10-bit A/D
Comparators
(ch)
Timers
8/16-bit
SSP
ECCP+ EUSART
Flash
(words)
SRAM
(bytes)
EEPROM
(bytes)
PIC16F685
PIC16F687
PIC16F689
4096
2048
4096
256
128
256
256
256
256
18
18
18
12
12
12
2
2
2
2/1
1/1
1/1
No
Yes
Yes
Yes
No
No
No
Yes
Yes
PIC16F690
4096
256
256
18
12
2/1
Yes
Yes
Yes
Pin Diagrams
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/AN3/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5/CPP1
RC4/C2OUT
RC3/AN7
RC6/AN8/SS
RC7/AN9/SDO
RB7/TX/CK
1
2
3
4
5
6
7
8
9
10
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/AN3/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5/CCP1/P1A
RC4/C2OUT/P1B
RC3/AN7/P1C
RC6/AN8/SS
RC7/AN9/SDO
RB7/TX/CK
1
2
3
4
5
6
7
8
9
10
DS41262A-page 2
20
19
18
17
16
15
14
13
12
11
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RC0/AN4/C2IN+
RC1/AN5/C12INRC2/AN6/P1D
RB4/AN10
RB5/AN11
RB6
20
19
18
17
16
15
14
13
12
11
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RC0/AN4/C2IN+
RC1/AN5/C12INRC2/AN6
RB4/AN10/SDI/SDA
RB5/AN11/RX/DT
RB6/SCK/SCL
20
19
18
17
16
15
14
13
12
11
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RC0/AN4/C2IN+
RC1/AN5/C12INRC2/AN6/P1D
RB4/AN10/SDI/SDA
RB5/AN11/RX/DT
RB6/SCK/SCL
PIC16F685
1
2
3
4
5
6
7
8
9
10
PIC16F687/689
VDD
RA5/T1CKI/OSC1/CLKIN
RA4/AN3/T1G/OSC2/CLKOUT
RA3/MCLR/VPP
RC5/CCP1/P1A
RC4/C2OUT/P1B
RC3/AN7/P1C
RC6/AN8
RC7/AN9
RB7
PIC16F690
Preliminary
PIC16F685/687/689/690
Pin Diagrams (Continued)
RA3/MCLR/VPP
RC5/CCP1/P1A(1)
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
VDD
VSS
RA0/AN0/C1IN+/ICSPDAT/ULPWU
20
19
18
17
16
20-pin QFN
PIC16F685/687/
689/690
14
RA2/AN2/T0CKI/INT/C1OUT
13
RC0/AN4/C2IN+
RC2/AN6/P1D(1)
RB4/AN10/SDI/SDA(2)
RB7/TX/CK
(2)
6
RC7/AN9/SDO(2)
11
10
RB5/AN11/RX/DT(2)
RC1/AN5/C12IN-
12
RC6/AN8/SS(2)
RB6/SCK/SCL(2)
(1)
RC3/AN7/P1C
2:
RA1/AN1/C12IN-/VREF/ICSPCLK
(1)
RC4/C2OUT/P1B
Note 1:
15
Preliminary
DS41262A-page 3
PIC16F685/687/689/690
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 5
2.0 Memory Organization ................................................................................................................................................................. 15
3.0 Clock Sources ............................................................................................................................................................................ 35
4.0 I/O Ports ..................................................................................................................................................................................... 47
5.0 Timer0 Module ........................................................................................................................................................................... 69
6.0 Timer1 Module with Gate Control............................................................................................................................................... 73
7.0 Timer2 Module ........................................................................................................................................................................... 77
8.0 Comparator Module.................................................................................................................................................................... 79
9.0 Analog-to-Digital Converter (A/D) Module .................................................................................................................................. 93
10.0 Data EEPROM and Flash Program Memory Control ............................................................................................................... 105
11.0 Enhanced Capture/Compare/PWM+ (ECCP+) Module ........................................................................................................... 113
12.0 Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART) ............................................................... 131
13.0 SSP Module Overview ............................................................................................................................................................. 155
14.0 Special Features of the CPU .................................................................................................................................................... 173
15.0 Instruction Set Summary .......................................................................................................................................................... 193
16.0 Development Support............................................................................................................................................................... 203
17.0 Electrical Specifications............................................................................................................................................................ 209
18.0 DC and AC Characteristics Graphs and Tables ....................................................................................................................... 237
19.0 Packaging Information.............................................................................................................................................................. 239
Appendix A: Data Sheet Revision History.......................................................................................................................................... 245
Appendix B: Migrating from other PICmicro Devices ...................................................................................................................... 245
The Microchip Web Site ..................................................................................................................................................................... 253
Customer Change Notification Service .............................................................................................................................................. 253
Customer Support .............................................................................................................................................................................. 253
Reader Response .............................................................................................................................................................................. 254
Product Identification System............................................................................................................................................................. 255
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.
DS41262A-page 4
Preliminary
PIC16F685/687/689/690
1.0
DEVICE OVERVIEW
FIGURE 1-1:
Configuration
13
Data Bus
PORTA
Program Counter
Flash
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
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/AN10
RB5/AN11
RB6
RB7
FSR Reg
Status Reg
8
PORTC
3
Power-up
Timer
Instruction
Decode and
Control
Oscillator
Start-up Timer
OSC1/CLKI
OSC2/CLKO
ALU
Power-on
Reset
Timing
Generation
RC0/AN4/C2IN+
RC1/AN5/C12INRC2/AN6/P1D
RC3/AN7/P1C
RC4/C2OUT/P1B
RC5/CCP1/P1A
RC6/AN8
RC7/AN9
MUX
Watchdog
Timer
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
T0CKI
Timer0
VSS
T1G
CCP1/
P1A
T1CKI
Timer1
Timer2
ECCP+
Analog-To-Digital Converter
2
Analog Comparators
and Reference
VREF AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C1IN- C1IN+ C1OUT C2IN- C2IN+ C2OUT
Preliminary
EEDAT
8
256 Bytes
Data
EEPROM
EEADR
DS41262A-page 5
PIC16F685/687/689/690
FIGURE 1-2:
Configuration
13
Data Bus
PORTA
Program Counter
Flash
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
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
7
Direct Addr
Indirect
Addr
RB4/AN10/SDI/SDA
RB5/AN11/RX/DT
RB6/SCK/SCL
RB7/TX/CK
FSR Reg
Status Reg
8
PORTC
3
Power-up
Timer
Instruction
Decode and
Control
Oscillator
Start-up Timer
OSC1/CLKI
OSC2/CLKO
ALU
Power-on
Reset
Timing
Generation
RC0/AN4/C2IN+
RC1/AN5/C12INRC2/AN6
RC3/AN7
RC4/C2OUT
RC5/CCP1
RC6/AN8/SS
RC7/AN9/SDO
MUX
Watchdog
Timer
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
T0CKI
Timer0
VSS
T1G
T1CKI
Timer1
TX/CK RX/DT
SDI/ SCK/
SDO SDA SCL SS
EUSART
Synchronous
Serial Port
Analog-To-Digital Converter
2
Analog Comparators
and Reference
VREF AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C1IN- C1IN+ C1OUT C2IN- C2IN+ C2OUT
EEDAT
8
256 Bytes
Data
EEPROM
EEADR
DS41262A-page 6
Preliminary
PIC16F685/687/689/690
FIGURE 1-3:
Configuration
13
Data Bus
PORTA
Program Counter
Flash
RA0/AN0/C1IN+/ICSPDAT/ULPWU
RA1/AN1/C12IN-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA3/MCLR/VPP
RA4/AN3/T1G/OSC2/CLKOUT
RA5/T1CKI/OSC1/CLKIN
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/AN10/SDI/SDA
RB5/AN11/RX/DT
RB6/SCK/SCL
RB7/TX/CK
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
Watchdog
Timer
RC0/AN4/C2IN+
RC1/AN5/C12INRC2/AN6/P1D
RC3/AN7/P1C
RC4/C2OUT/P1B
RC5/CCP1/P1A
RC6/AN8/SS
RC7/AN9/SDO
MUX
ALU
8
W Reg
Brown-out
Reset
Internal
Oscillator
Block
MCLR VDD
T0CKI
Timer0
T1G
VSS
TX/CK RX/DT
T1CKI
Timer1
Timer2
CCP1/
P1A
ECCP+
EUSART
SDI/ SCK/
SDO SDA SCL SS
Synchronous
Serial Port
Analog-To-Digital Converter
2
Analog Comparators
and Reference
VREF AN0 AN1 AN2 AN3 AN4 AN5 AN6 AN7 C1IN- C1IN+ C1OUT C2IN- C2IN+ C2OUT
Preliminary
EEDAT
8
256 Bytes
Data
EEPROM
EEADR
DS41262A-page 7
PIC16F685/687/689/690
TABLE 1-1:
Name
RA0/AN0/C1IN+/ICSPDAT/
ULPWU
RA1/AN1/C12IN-/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
Output
Type
RA0
TTL
Description
General purpose I/O. Individually controlled interrupt-onchange. Individually enabled pull-up.
AN0
AN
C1IN+
AN
ICSPDAT
TTL
CMOS
ULPWU
AN
RA1
TTL
CMOS
AN1
AN
C12IN-
AN
VREF
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
CMOS
AN2
AN
T0CKI
ST
INT
ST
C1OUT
CMOS
RA3
TTL
MCLR
ST
Comparator 1 output.
VPP
HV
RA4
TTL
CMOS
AN3
AN
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
CMOS
FOSC/4 output.
RA5
TTL
CMOS
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
CLKIN
ST
RB4
TTL
CMOS
AN10
AN
RB5
TTL
CMOS
AN11
AN
RB6
RB6
TTL
CMOS
RB7
RB7
TTL
CMOS
RC0/AN4/C2IN+
RC0
ST
CMOS
AN4
AN
C2IN+
AN
Legend:
DS41262A-page 8
Preliminary
PIC16F685/687/689/690
TABLE 1-1:
Name
RC1/AN5/C12IN-
RC2/AN6/P1D
RC3/AN7/P1C
RC4/C2OUT/P1B
Function
Input
Type
Output
Type
RC1
ST
CMOS
Description
General purpose I/O.
AN5
AN
C12IN-
AN
RC2
ST
CMOS
AN6
AN
P1D
CMOS
PWM output.
RC3
ST
CMOS
AN7
AN
P1C
CMOS
PWM output.
RC4
ST
CMOS
C2OUT
CMOS
Comparator 2 output.
P1B
CMOS
PWM output.
RC5
ST
CMOS
CCP1
ST
CMOS
Capture/Compare input.
P1A
ST
CMOS
PWM output.
RC6
ST
CMOS
AN8
AN
RC7
ST
CMOS
AN9
AN
VSS
VSS
Power
Ground reference.
VDD
VDD
Power
Positive supply.
RC5/CCP1/P1A
RC6/AN8
RC7/AN9
Legend:
Preliminary
DS41262A-page 9
PIC16F685/687/689/690
TABLE 1-2:
Name
RA0/AN0/C1IN+/ICSPDAT/
ULPWU
RA1/AN1/C12IN-/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
Output
Type
RA0
TTL
AN0
AN
AN
ICSPDAT
TTL
CMOS
ULPWU
AN
RA1
TTL
CMOS
AN1
AN
C12IN-
AN
VREF
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
CMOS
AN2
AN
T0CKI
ST
INT
ST
C1OUT
CMOS
RA3
TTL
External Interrupt.
Comparator 1 output.
General purpose input. Individually controlled interrupt-onchange.
MCLR
ST
VPP
HV
Programming voltage.
RA4
TTL
CMOS
AN3
AN
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
CMOS
FOSC/4 output.
RA5
TTL
CMOS
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
External clock input/RC oscillator connection.
CLKIN
ST
RB4
TTL
CMOS
AN10
AN
SDI
ST
SDA
ST
OD
RB5
TTL
CMOS
AN11
AN
RX
ST
ST
CMOS
DS41262A-page 10
C1IN+
DT
Legend:
Description
Preliminary
PIC16F685/687/689/690
TABLE 1-2:
Name
RB6/SCK/SCL
RB7/TX/CK
RC0/AN4/C2IN+
Function
Input
Type
Output
Type
RB6
TTL
CMOS
SCK
ST
CMOS
SPI clock.
SCL
ST
OD
I2C clock.
RB7
TTL
CMOS
TX
CMOS
Description
CK
ST
CMOS
RC0
ST
CMOS
AN4
AN
C2IN+
AN
RC1
ST
CMOS
AN5
AN
C12IN-
AN
RC2/AN6
RC2
ST
CMOS
AN6
AN
RC3/AN7
RC3
ST
CMOS
AN7
AN
RC4/C2OUT
RC4
ST
CMOS
RC1/AN5/C12IN-
RC5/CCP1
RC6/AN8/SS
RC7/AN9/SDO
VSS
Legend:
CMOS
Comparator 2 output.
RC5
ST
CMOS
CCP1
ST
CMOS
Capture/Compare input.
RC6
ST
CMOS
AN8
AN
SS
ST
RC7
ST
CMOS
AN9
AN
SDO
CMOS
VSS
Power
Ground reference.
Power
Positive supply.
C2OUT
VDD
VDD
Preliminary
DS41262A-page 11
PIC16F685/687/689/690
TABLE 1-3:
Name
RA0/AN0/C1IN+/ICSPDAT/
ULPWU
RA1/AN1/C12IN-/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
Output
Type
RA0
TTL
AN0
AN
AN
ICSPDAT
TTL
CMOS
ULPWU
AN
RA1
TTL
CMOS
AN1
AN
C12IN-
AN
VREF
AN
ICSPCLK
ST
ICSP clock.
RA2
ST
CMOS
AN2
AN
T0CKI
ST
INT
ST
C1OUT
CMOS
RA3
TTL
External Interrupt.
Comparator 1 output.
General purpose input. Individually controlled interrupt-onchange.
MCLR
ST
VPP
HV
Programming voltage.
RA4
TTL
CMOS
AN3
AN
T1G
ST
OSC2
XTAL
Crystal/Resonator.
CLKOUT
CMOS
FOSC/4 output.
RA5
TTL
CMOS
T1CKI
ST
OSC1
XTAL
Crystal/Resonator.
External clock input/RC oscillator connection.
CLKIN
ST
RB4
TTL
CMOS
AN10
AN
SDI
ST
SDA
ST
OD
RB5
TTL
CMOS
AN11
AN
RX
ST
ST
CMOS
DS41262A-page 12
C1IN+
DT
Legend:
Description
Preliminary
PIC16F685/687/689/690
TABLE 1-3:
Name
RB6/SCK/SCL
RB7/TX/CK
RC0/AN4/C2IN+
RC1/AN5/C12IN-
RC2/AN6/P1D
RC3/AN7/P1C
RC4/C2OUT/P1B
RC5/CCP1/P1A
RC6/AN8/SS
RC7/AN9/SDO
VSS
Input
Type
Output
Type
RB6
TTL
CMOS
SCK
ST
CMOS
SPI clock.
SCL
ST
OD
I2C clock.
RB7
TTL
CMOS
TX
CMOS
CK
ST
CMOS
ST
CMOS
AN4
AN
C2IN+
AN
RC1
ST
CMOS
AN5
AN
C12IN-
AN
RC2
ST
CMOS
AN6
AN
P1D
CMOS
PWM output.
RC3
ST
CMOS
AN7
AN
P1C
CMOS
PWM output.
RC4
ST
CMOS
C2OUT
CMOS
Comparator 2 output.
P1B
CMOS
PWM output.
RC5
ST
CMOS
CCP1
ST
CMOS
Capture/Compare input.
P1A
ST
CMOS
PWM output.
RC6
ST
CMOS
AN8
AN
SS
ST
RC7
ST
CMOS
AN9
AN
SDO
CMOS
VSS
Power
Ground reference.
Power
Positive supply.
Description
RC0
VDD
VDD
Legend:
Function
Preliminary
DS41262A-page 13
PIC16F685/687/689/690
NOTES:
DS41262A-page 14
Preliminary
PIC16F685/687/689/690
2.0
MEMORY ORGANIZATION
2.1
FIGURE 2-2:
CALL, RETURN
RETFIE, RETLW
13
Stack Level 1
Stack Level 2
Stack Level 8
FIGURE 2-1:
Reset Vector
0000h
Interrupt Vector
0004h
0005h
PC<12:0>
CALL, RETURN
RETFIE, RETLW
On-chip Program
13
Memory
07FFh
Stack Level 1
0800h
Stack Level 2
Access 0-7FFh
1FFFh
Stack Level 8
Reset Vector
0000h
Interrupt Vector
0004h
0005h
On-chip Program
Memory
0FFFh
1000h
Access 0-FFFh
1FFFh
Preliminary
DS41262A-page 15
PIC16F685/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
DS41262A-page 16
Preliminary
PIC16F685/687/689/690
FIGURE 2-3:
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
PCLATH
INTCON
PIE1
PR2
WPUA
IOCA
WDTCON
ADRESL
ADCON1
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
General
Purpose
Register
General
Purpose
Register
7Fh
Bank 0
Note 1:
accesses
70h-7Fh
Bank1
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
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
Bank2
16Fh
170h
17Fh
accesses
70h-7Fh
1F0h
1FFh
Bank3
Preliminary
DS41262A-page 17
PIC16F685/687/689/690
FIGURE 2-4:
File
Address
File
Address
File
Address
00h
01h
02h
03h
80h
81h
82h
83h
100h
101h
102h
103h
180h
181h
182h
183h
FSR
PORTA
PORTB
PORTC
04h
05h
06h
07h
08h
09h
FSR
TRISA
TRISB
TRISC
84h
85h
86h
87h
88h
89h
FSR
PORTA
PORTB
PORTC
104h
105h
106h
107h
108h
109h
FSR
TRISA
TRISB
TRISC
184h
185h
186h
187h
188h
189h
PCLATH
INTCON
PIR1
0Ah
0Bh
0Ch
PCLATH
INTCON
PIE1
8Ah
8Bh
8Ch
PCLATH
INTCON
EEDAT
10Ah
10Bh
10Ch
PCLATH
INTCON
EECON1
18Ah
18Bh
18Ch
PIR2
0Dh
PIE2
8Dh
EEADR
10Dh
EECON2(1)
18Dh
TMR1L
0Eh
PCON
8Eh
EEDATH
(3)
10Eh
18Eh
EEADRH(3)
10Fh
110h
111h
112h
18Fh
190h
191h
192h
113h
114h
115h
116h
117h
118h
119h
193h
194h
195h
196h
197h
198h
199h
19Ah
19Bh
19Ch
19Dh
19Eh
TMR1H
T1CON
0Fh
10h
11h
12h
OSCCON
OSCTUNE
8Fh
90h
91h
92h
SSPBUF
SSPCON
13h
14h
15h
16h
17h
18h
19h
SSPADD(2)
SSPSTAT
WPUA
IOCA
WDTCON
TXSTA
SPBRG
93h
94h
95h
96h
97h
98h
99h
1Ah
1Bh
1Ch
1Dh
1Eh
1Fh
20h
SPBRGH
BAUDCTL
9Ah
9Bh
9Ch
9Dh
9Eh
9Fh
RCSTA
TXREG
RCREG
ADRESH
ADCON0
General
Purpose
Register
General
Purpose
Register
32 Bytes
48 Bytes
(PIC16F689 only)
96 Bytes
7Fh
Bank 0
ADRESL
ADCON1
accesses
70h-7Fh
WPUB
IOCB
VRCON
CM1CON0
CM2CON0
CM2CON1
ANSEL
ANSELH
A0h
BFh
C0h
11Ah
11Bh
11Ch
11Dh
11Eh
11Fh
SRCON
19Fh
1A0h
120h
General
Purpose
Register
80 Bytes
(PIC16F689 only)
EFh
F0h
FFh
Bank1
accesses
70h-7Fh
Bank2
170h
17Fh
accesses
70h-7Fh
1F0h
1FFh
Bank3
DS41262A-page 18
Preliminary
PIC16F685/687/689/690
FIGURE 2-5:
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
Bank1
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
Bank2
16Fh
170h
17Fh
accesses
70h-7Fh
1F0h
1FFh
Bank3
Preliminary
DS41262A-page 19
PIC16F685/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
Reset
Value on
all other
Resets(1)
Bank 0
00h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical register)
01h
TMR0
02h
PCL
03h
STATUS
04h
FSR
05h
PORTA
06h
PORTB
RB7
07h
PORTC
RC7
08h
Unimplemented
09h
Unimplemented
0Ah
PCLATH
0Bh
INTCON
GIE
PEIE
T0IE
INTE
RABIE
0Ch
PIR1
ADIF
RCIF(3)
TXIF(3)
SSPIF(3)
0Dh
PIR2
OSFIF
C2IF
C1IF
EEIF
0Eh
TMR1L
Holding Register for the Least Significant Byte of the 16-bit TMR1
0Fh
TMR1H
Holding Register for the Most Significant Byte of the 16-bit TMR1
IRP
RP1
RP0
TO
PD
DC
RA5
RA4
RA3
RA2
RA1
RA0
RB6
RB5
RB4
RC6
RC5
RC4
RC3
RC2
RC1
RC0
INTF
CCP1IF(4) TMR2IF(4)
TMR1IF
10h
T1CON
TMR2
12h
T2CON
13h
SSPBUF(3)
14h
SSPCON(3, 5)
15h
CCPR1L(4)
16h
CCPR1H
(4)
17h
CCP1CON(4)
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CCP1M2
CCP1M1
CCP1M0
18h
RCSTA(3)
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
19h
TXREG(3)
1Ah
(3)
RCREG
1Bh
1Ch
PWM1CON(4)
1Dh
ECCPAS(4)
ECCPASE ECCPAS2
1Eh
ADRESH
1Fh
ADCON0
3:
4:
5:
TMR1GE
11h
Legend:
Note 1:
2:
T1GINV
T1CKPS1
T1CKPS0
T1OSCEN
T1SYNC
TMR1CS
TOUTPS2
TOUTPS1
TOUTPS0
TMR2ON
T2CKPS1
SSPM2
SSPM1
TOUTPS3
SSPOV
SSPEN
CKP
SSPM3
Unimplemented
PRSEN
ADFM
PDC6
VCFG
PDC5
PDC4
PDC3
PDC2
PDC1
PDC0
ECCPAS1
ECCPAS0
PSSAC1
PSSAC0
PSSBD1
PSSBD0
CHS2
CHS1
CHS0
GO/DONE
ADON
CHS3
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Other (non Power-up) Resets include MCLR Reset and Watchdog Timer Reset during normal operation.
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
mismatched exists.
PIC16F687/PIC16F689/PIC16F690 only.
PIC16F685/PIC16F690 only.
When SSPCON 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.
DS41262A-page 20
Preliminary
PIC16F685/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
Reset
Value on
all other
Resets(1)
xxxx xxxx
xxxx xxxx
1111 1111
1111 1111
Bank 1
80h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical
register)
81h
OPTION_REG
82h
PCL
83h
STATUS
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
RP1
RP0
0000 0000
0000 0000
000q quuu
TO
PD
DC
0001 1xxx
xxxx xxxx
uuuu uuuu
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
--11 1111
--11 1111
84h
FSR
85h
TRISA
86h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
87h
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
TRISA5
88h
Unimplemented
89h
Unimplemented
8Ah
PCLATH
---0 0000
---0 0000
8Bh
INTCON
GIE
PEIE
T0IE
0000 000x
0000 000x
(3)
INTE
RABIE
PIE1
ADIE
PIE2
OSFIE
C2IE
8Eh
PCON
8Fh
OSCCON
IRCF2
IRCF1
IRCF0
90h
OSCTUNE
TUN4
TUN3
EEIE
ULPWUE SBOREN
SSPIE
(3)
8Ch
C1IE
TXIE
(3)
8Dh
91h
RCIE
RABIF(2)
INTF
(4)
TMR1IE
-000 0000
-000 0000
0000 ----
0000 ----
POR
BOR
--01 --qq
--0u --uu
OSTS
HTS
LTS
SCS
-110 q000
-110 x000
TUN2
TUN1
TUN0
---0 0000
---u uuuu
TMR2IE
(4)
Unimplemented
92h
PR2(4)
93h
SSPADD(3, 6)
93h
SSPMSK(3, 6)
(3)
MSK7
MSK6
MSK5
MSK4
MSK3
MSK2
MSK1
1111 1111
1111 1111
0000 0000
0000 0000
MSK0
1111 1111
1111 1111
0000 0000
94h
SSPSTAT
SMP
CKE
D/A
R/W
UA
BF
0000 0000
95h
WPUA(5)
WPUA5
WPUA4
WPUA2
WPUA1
WPUA0
--11 -111
--11 -111
96h
IOCA
IOCA5
IOCA4
IOCA3
IOCA2
IOCA1
IOCA0
--00 0000
--00 0000
97h
WDTCON
WDTPS3
WDTPS2
WDTPS1
WDTPS0
SWDTEN
---0 1000
---0 1000
98h
TXSTA(3)
CSRC
TX9
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
99h
SPBRG(3)
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
(3)
9Ah
SPBRGH
9Bh
BAUDCTL(3)
9Ch
Unimplemented
9Dh
Unimplemented
9Eh
ADRESL
xxxx xxxx
uuuu uuuu
9Fh
ADCON1
-000 ----
-000 ---
Legend:
Note 1:
2:
3:
4:
5:
6:
ADCS2
ADCS1
ADCS0
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Other (non Power-up) Resets include MCLR Reset and Watchdog Timer Reset during normal operation.
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
mismatched exists.
PIC16F687/PIC16F689/PIC16F690 only.
PIC16F685/PIC16F690 only.
RA3 pull-up is enabled when pin is configured as MCLR in Configuration Word.
Accessible only when SSPM<3:0> = 1001.
Preliminary
DS41262A-page 21
PIC16F685/687/689/690
TABLE 2-3:
Addr
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR/BOR
Reset
Value on
all other
Resets(1)
Bank 2
100h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical register)
101h
TMR0
102h
PCL
103h
STATUS
IRP
RP1
RP0
TO
PD
DC
RA4
RA3
RA2
RA1
RA0
104h
FSR
105h
PORTA
106h
PORTB
RB7
RB6
RB5
RB4
107h
PORTC
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
108h
Unimplemented
109h
Unimplemented
RA5
10Ah PCLATH
10Bh INTCON
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF(2)
10Ch EEDAT
EEDAT7
EEDAT6
EEDAT5
EEDAT4
EEDAT3
EEDAT2
EEDAT1
EEDAT0
10Dh EEADR
EEADR7
EEADR6
EEADR5
EEADR4
EEADR3
EEADR2
EEADR1
EEADR0
(3)
EEDATH3
EEDATH2
EEDATH1
10Fh EEADRH(3)
10Eh EEDATH
EEDATH5 EEDATH4
110h
Unimplemented
111h
Unimplemented
112h
Unimplemented
113h
Unimplemented
114h
Unimplemented
115h
WPUB
116h
IOCB
117h
118h
VRCON
WPUB7
WPUB6
WPUB5
WPUB4
IOCB7
IOCB6
IOCB5
IOCB4
C2VREN
VRR
VP6EN
VR3
VR2
VR1
VR0
Unimplemented
C1VREN
119h
CM1CON0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C1CH0
11Ah
CM2CON0
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
C2CH0
11Bh
CM2CON1
MC1OUT
MC2OUT
T1GSS
C2SYNC
11Ch
Unimplemented
11Dh
Unimplemented
11Eh
ANSEL
11Fh
ANSELH
Legend:
Note 1:
2:
3:
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
ANS11
ANS10
ANS9
ANS8
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Other (non Power-up) Resets include MCLR Reset and Watchdog Timer Reset during normal operation.
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
mismatched exists.
PIC16F685/PIC16F689/PIC16F690 only.
DS41262A-page 22
Preliminary
PIC16F685/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
Reset
Value on
all other
Resets(1)
xxxx xxxx
xxxx xxxx
1111 1111
1111 1111
0000 0000
0000 0000
0001 1xxx
000q quuu
Bank 3
180h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical
register)
181h
OPTION_REG
182h
PCL
183h
STATUS
184h
FSR
185h
TRISA
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
RP1
RP0
TO
PD
DC
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
xxxx xxxx
uuuu uuuu
--11 1111
--11 1111
186h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
187h
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
188h
Unimplemented
189h
Unimplemented
18Ah
PCLATH
---0 0000
---0 0000
18Bh
INTCON
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF(2)
0000 000x
0000 000x
18Ch
EECON1
EEPGD
WRERR
WREN
WR
RD
x--- x000
0--- q000
18Dh
EECON2
---- ----
---- ----
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(3)
19Eh
SRCON
19Fh
Legend:
Note 1:
2:
3:
STRSYNC
STRD
STRC
STRB
STRA
---0 0001
---0 0001
SR1
SR0
C1SEN
C2REN
PULSS
PULSR
0000 00--
0000 00--
Unimplemented
= Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Other (non Power-up) Resets include MCLR Reset and Watchdog Timer Reset during normal operation.
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
mismatched exists.
PIC16F685/PIC16F690 only.
Preliminary
DS41262A-page 23
PIC16F685/687/689/690
2.2.2.1
Status Register
REGISTER 2-1:
R/W-0
R/W-0
R-1
R-1
R/W-x
R/W-x
R/W-x
IRP
RP1
RP0
TO
PD
DC(1)
C(1)
bit 7
bit 0
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
DS41262A-page 24
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
2.2.2.2
OPTION Register
Note:
TMR0/WDT prescaler
External RA2/INT interrupt
TMR0
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
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2-0
TMR0 Rate
WDT Rate(1)
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
Note 1: A dedicated 16-bit WDT postscaler is available. See Section 14.5 Watchdog
Timer (WDT) for more information.
Legend:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 25
PIC16F685/687/689/690
2.2.2.3
INTCON Register
Note:
REGISTER 2-3:
R/W-0
PEIE
R/W-0
T0IE
R/W-0
INTE
R/W-0
(1,3)
RABIE
R/W-0
R/W-0
R/W-x
T0IF(2)
INTF
RABIF
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
DS41262A-page 26
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
2.2.2.4
PIE1 Register
REGISTER 2-4:
Note:
R/W-0
R/W-0
R/W-0
R/W-0
ADIE
RCIE(2)
TXIE(2)
SSPIE(2)
R/W-0
R/W-0
CCP1IE(1) TMR2IE(1)
bit 7
R/W-0
TMR1IE
bit 0
bit 7
Unimplemented: Read as 0
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 27
PIC16F685/687/689/690
2.2.2.5
PIE2 Register
REGISTER 2-5:
Note:
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
bit 7
bit 6
bit 5
bit 4
bit 3-0
Unimplemented: Read as 0
Legend:
DS41262A-page 28
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
2.2.2.6
PIR1 Register
REGISTER 2-6:
Note:
R/W-0
R-0
R-0
R/W-0
ADIF
RCIF(1)
TXIF(1)
SSPIF(1)
R/W-0
R/W-0
CCP1IF(2) TMR2IF(2)
R/W-0
TMR1IF
bit 7
bit 0
bit 7
Unimplemented: Read as 0
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 29
PIC16F685/687/689/690
2.2.2.7
PIR2 Register
REGISTER 2-7:
Note:
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
bit 7
bit 6
bit 5
bit 4
bit 3-0
Unimplemented: Read as 0
Legend:
DS41262A-page 30
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
2.2.2.8
PCON Register
REGISTER 2-8:
U-0
R/W-0
R/W-1
ULPWUE SBOREN
(1)
U-0
U-0
R/W-0
R/W-x
POR
BOR
bit 7
bit 0
bit 7-6
Unimplemented: Read as 0
bit 5
bit 4
bit 3-2
Unimplemented: Read as 0
bit 1
bit 0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 31
PIC16F685/687/689/690
2.3
FIGURE 2-6:
12
Instruction with
PCL as
Destination
PCLATH<4:0>
ALU Result
PCLATH
PCH
11 10
PCL
8
PC
GOTO, CALL
2
PCLATH<4:3>
11
OPCODE<10:0>
COMPUTED GOTO
2.3.2
PCLATH
2.3.1
2.4
PCL
PC
12
LOADING OF PC IN
DIFFERENT SITUATIONS
PCH
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
STACK
DS41262A-page 32
Preliminary
PIC16F685/687/689/690
FIGURE 2-7:
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-3, 2-4 and 2-5.
Preliminary
DS41262A-page 33
PIC16F685/687/689/690
NOTES:
DS41262A-page 34
Preliminary
PIC16F685/687/689/690
3.0
CLOCK SOURCES
3.1
Overview
1.
2.
3.
4.
5.
6.
7.
8.
FIGURE 3-1:
External Oscillator
OSC2
Sleep
MUX
OSC1
IRCF<2:0>
(OSCCON<6:4>)
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
Preliminary
DS41262A-page 35
PIC16F685/687/689/690
3.2
3.3.1
TABLE 3-1:
3.3
Switch From
Switch To
Frequency
Sleep/POR
LFINTOSC
HFINTOSC
31 kHz
125 kHz to 8 MHz
Sleep/POR
EC, RC
DC 20 MHz
EC, RC
DC 20 MHz
Oscillator Delay
Sleep/POR
LP, XT, HS
32 kHz to 20 MHz
HFINTOSC
1 s (approx.)
Note 1:
3.3.2
EC MODE
FIGURE 3-2:
Clock from
Ext. System
DS41262A-page 36
Preliminary
RA4/AN3/T1G/
OSC2/CLKOUT
I/O (OSC2)
PIC16F685/687/689/690
3.3.3
FIGURE 3-4:
CERAMIC RESONATOR
OPERATION
(XT OR HS MODE)
PIC16F685/687/689/690
OSC1
C1
To Internal
Logic
RP(3)
RF(2)
Sleep
OSC2
RS(1)
C2 Ceramic
Resonator
FIGURE 3-3:
QUARTZ CRYSTAL
OPERATION (LP, XT OR
HS MODE)
PIC16F685/687/689/690
OSC1
C1
To Internal
Logic
Quartz
Crystal
OSC2
RF(2)
Sleep
RS(1)
C2
Note 1:
2:
Preliminary
DS41262A-page 37
PIC16F685/687/689/690
3.3.4
EXTERNAL RC MODES
3.4
FIGURE 3-5:
2.
RC MODE
VDD
REXT
Internal
Clock
OSC1
CEXT
3.4.1
PIC16F685/687/689/690
VSS
FOSC/4
OSC2/CLKOUT
FIGURE 3-6:
RCIO MODE
VDD
REXT
3.4.2
Internal
Clock
OSC1
CEXT
VSS
PIC16F685/687/689/690
RA4
I/O (OSC2)
HFINTOSC
DS41262A-page 38
Preliminary
PIC16F685/687/689/690
3.4.2.1
OSCTUNE Register
REGISTER 3-1:
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
bit 7-5
Unimplemented: Read as 0
bit 4-0
00001 =
00000 = Oscillator module is running at the calibrated frequency.
11111 =
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 39
PIC16F685/687/689/690
3.4.3
LFINTOSC
3.4.5
3.4.4
1.
2.
3.
5.
4.
6.
8 MHz
4 MHz (Default after Reset)
2 MHz
1 MHz
500 kHz
250 kHz
125 kHz
31 kHz
Note:
DS41262A-page 40
Preliminary
PIC16F685/687/689/690
3.5
Clock Switching
3.5.1
3.5.2
3.6
3.6.1
3.6.2
1.
2.
3.
4.
7.
Note:
5.
6.
TWO-SPEED START-UP
SEQUENCE
Preliminary
DS41262A-page 41
PIC16F685/687/689/690
3.6.3
CHECKING EXTERNAL/INTERNAL
CLOCK STATUS
FIGURE 3-7:
TWO-SPEED START-UP
Q1
Q2
Q3
Q4
Q1
Q2
Q3
Q4
Q1
INTOSC
TOST
OSC1
1022 1023
OSC2
Program Counter
PC
PC + 1
PC + 2
System Clock
DS41262A-page 42
Preliminary
PIC16F685/687/689/690
3.7
3.7.3
FIGURE 3-8:
Primary
Clock
LFINTOSC
Oscillator
64
31 kHz
(~32 s)
488 Hz
(~2 ms)
3.7.4
Note:
FAIL-SAFE DETECTION
3.7.2
Clock
Failure
Detected
3.7.1
FAIL-SAFE OPERATION
Preliminary
DS41262A-page 43
PIC16F685/687/689/690
FIGURE 3-9:
Sample Clock
Oscillator
Failure
System
Clock
Output
CM Output
(Q)
Failure
Detected
OSCFIF
CM Test
Note:
CM Test
CM 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.
DS41262A-page 44
Preliminary
PIC16F685/687/689/690
REGISTER 3-2:
R/W-1
IRCF2
R/W-1
IRCF1
R/W-0
R-1
IRCF0
OSTS
(1)
R-0
R-0
R/W-0
HTS
LTS
SCS
bit 7
bit 0
bit 7
Unimplemented: Read as 0
bit 6-4
bit 3
bit 2
bit 1
bit 0
TABLE 3-2:
Address
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
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(1)
0Ch
PIR1
ADIF
RCIF
TXIF
SSPIF
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
8Fh
OSCCON
IRCF2
IRCF1
IRCF0
OSTS
HTS
LTS
SCS
90h
OSCTUNE
TUN4
TUN3
TUN2
TUN1
TUN0
2007h(2)
CONFIG
CPD
CP
WDTE
FOSC2
FOSC1
FOSC0
Legend:
Note 1:
2:
MCLRE PWRTE
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 Register 14-1 for operation of all Configuration Word register bits.
Preliminary
DS41262A-page 45
PIC16F685/687/689/690
NOTES:
DS41262A-page 46
Preliminary
PIC16F685/687/689/690
4.0
I/O PORTS
EXAMPLE 4-1:
4.1
BCF
BCF
CLRF
BSF
CLRF
BSF
BCF
MOVLW
MOVWF
BCF
4.2
INITIALIZING PORTA
STATUS,RP0
STATUS,RP1
PORTA
STATUS,RP1
ANSEL
STATUS,RP0
STATUS,RP1
0Ch
TRISA
;Bank 0
;
;Init PORTA
;Bank 2
;digital I/O
;Bank 1
;
;Set RA<3:2> as inputs
;and set RA<5:4,1:0>
;as outputs
STATUS,RP0 ;Bank 0
4.2.1
WEAK PULL-UPS
REGISTER 4-1:
U-0
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
RA5
RA4
RA3
RA2
RA1
RA0
bit 7
bit 0
bit 7-6:
Unimplemented: Read as 0
bit 5-0:
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 47
PIC16F685/687/689/690
REGISTER 4-2:
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
bit 7-6
Unimplemented: Read as 0
bit 5-0
Legend:
REGISTER 4-3:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
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
bit 7-6
Unimplemented: Read as 0
bit 5-4
bit 3
Unimplemented: Read as 0
bit 2-0
DS41262A-page 48
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
4.2.2
INTERRUPT-ON-CHANGE
b)
REGISTER 4-4:
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
bit 7-6
Unimplemented: Read as 0
bit 5-0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 49
PIC16F685/687/689/690
4.2.3
DS41262A-page 50
EXAMPLE 4-2:
BCF
BCF
BSF
BSF
BCF
BSF
BCF
BCF
CALL
BSF
BSF
BSF
MOVLW
MOVWF
BCF
SLEEP
Preliminary
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
PIC16F685/687/689/690
4.2.4
4.2.4.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
WPUDA
RABPU
RD
WPUDA
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-onChange
RD PORTA
To Comparator
To A/D Converter
Note
1:
Preliminary
DS41262A-page 51
PIC16F685/687/689/690
4.2.4.2
RA1/AN1/C12IN-/VREF/ICSPCLK
4.2.4.3
RA2/AN2/T0CKI/INT/C1OUT
Figure 4-2 shows the diagram for this pin. The RA1/
AN1/C12IN-/VREF/ICSPCLK pin is configurable to
function as one of the following:
FIGURE 4-2:
Data Bus
WR
WPUA
Analog(1)
Input Mode
Figure 4-3 shows the diagram for this pin. The RA2/
AN2/T0CKI/INT/C1OUT pin is configurable to function
a general purpose I/O
an analog input for the A/D
the clock input for TMR0
an external edge triggered interrupt
a digital output from Comparator 1
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
To TMR0
To INT
Note
1:
To A/D Converter
Note
DS41262A-page 52
Preliminary
1:
PIC16F685/687/689/690
4.2.4.4
4.2.4.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
Q
Q
INTOSC/
RC/EC(2)
CLKOUT
Enable
RD
TRISA
Analog
Input Mode
RD
PORTA
D
WR
IOCA
CK
Q
Q
Q
EN
RD
IOCA
Interrupt-onChange
Q3
D
EN
RD PORTA
To T1G
To A/D Converter
Note 1: CLK modes are XT, HS, LP, LPTMR1 and CLKOUT
Enable.
2: With CLKOUT option.
3: ANSEL determines Analog Input mode.
Preliminary
DS41262A-page 53
PIC16F685/687/689/690
4.2.4.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
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
DS41262A-page 54
Preliminary
PIC16F685/687/689/690
TABLE 4-1:
Address
Name
05h/105h
PORTA
0Bh/8Bh/
INTCON
10Bh/18Bh
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
RA5
RA4
RA3
RA2
RA1
RA0
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
10h
T1CON
14h
SSPCON
WCOL
SSPOV
SSPEN
CKP
SSPM3
SSPM2
SSPM1
SSPM0
1Fh
ADCON0
ADFM
VCFG
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
TMR1CS
81h/181h
OPTION_REG
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
85h/185h
TRISA
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
95h
WPUA
WPUA5
WPUA4
WPUA2
WPUA1
WPUA0
96h
IOCA
IOCA5
IOCA4
IOCA3
IOCA2
IOCA1
IOCA0
119h
CM1CON0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C1CH0
11Eh
ANSEL
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
Legend:
x = unknown, u = unchanged, = unimplemented locations read as 0. Shaded cells are not used by PORTA.
Preliminary
DS41262A-page 55
PIC16F685/687/689/690
4.3
4.4
EXAMPLE 4-3:
BCF
BCF
CLRF
BSF
MOVLW
MOVWF
BCF
STATUS,RP0
STATUS,RP1
PORTB
STATUS,RP0
FFh
TRISB
STATUS,RP0
4.4.1
4.4.2
;Bank 0
;
;Init PORTB
;Bank 1
;Set RB<7:4> as inputs
;
;Bank 0
This interrupt can wake the device from Sleep. The user,
in the Interrupt Service Routine, clears the interrupt by:
a)
DS41262A-page 56
INTERRUPT-ON-CHANGE
INITIALIZING PORTB
b)
Note:
WEAK PULL-UPS
Preliminary
PIC16F685/687/689/690
REGISTER 4-5:
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
bit 7-4
bit 3-0
Unimplemented: Read as 0
Legend:
REGISTER 4-6:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
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
bit 7-4
bit 3-0
Unimplemented: Read as 0
Legend:
REGISTER 4-7:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
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
bit 7-4
bit 3-0
Unimplemented: Read as 0
Note 1: Global RABPU 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).
Legend:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 57
PIC16F685/687/689/690
REGISTER 4-8:
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
bit 7-4
bit 3-0
Unimplemented: Read as 0
Legend:
DS41262A-page 58
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/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
SSPEN
VDD
0
1
CK Q
1
0
D
WR
TRISB
I/O Pin
CK Q
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 SSPSR
To A/D Converter
Preliminary
1:
DS41262A-page 59
PIC16F685/687/689/690
4.4.3.2
RB5/AN11/RX/DT
FIGURE 4-8:
Figure 4-8 shows the diagram for this pin. The RB5/
AN11/RX/DT(1) pin is configurable to function as one
of the following:
WR
WPUB
Data Bus
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
I/O Pin
D
WR
TRISB
CK Q
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
DS41262A-page 60
Preliminary
1:
PIC16F685/687/689/690
4.4.3.3
RB6/SCK/SCL
FIGURE 4-9:
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
Data Bus
WR
WPUB
CK Q
D
WR
PORTB
Weak
RABPU
RD
WPUB
VDD
CK Q
SSPEN
VDD
0
1
0
1
D
WR
TRISB
I/O Pin
CK Q
VSS
RD
TRISB
RD
PORTB
D
WR
IOCB
Q
Q
CK Q
D
EN
RD
IOCB
Q3
D
ST
EN
Interrupt-onChange
RD PORTB
To SSPSR
Available on PIC16F687/PIC16F689/PIC16F690 only.
Preliminary
DS41262A-page 61
PIC16F685/687/689/690
4.4.3.4
RB7/TX/CK
FIGURE 4-10:
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
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
VSS
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.
DS41262A-page 62
Preliminary
PIC16F685/687/689/690
TABLE 4-2:
Address
Name
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on:
POR, BOR
Value on all
other
Resets
uuuu ----
06h/106h
PORTB
RB7
RB6
RB5
RB4
xxxx ----
86h/186h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
0Bh/8Bh/
10Bh/18Bh
INTCON
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
115h
WPUB
WPUB7
WPUB6
WPUB5
WPUB4
1111 ----
1111 ----
116h
IOCB
IOCB7
IOCB6
IOCB5
IOCB4
0000 ----
0000 ----
Legend:
x = unknown, u = unchanged, = unimplemented locations read as 0. Shaded cells are not used by PORTB.
Preliminary
DS41262A-page 63
PIC16F685/687/689/690
4.5
REGISTER 4-9:
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-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 7-0
bit 0
REGISTER 4-10:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
bit 7
bit 7-0
bit 0
DS41262A-page 64
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
4.5.1
RC0/AN4/C2IN+
4.5.3
RC2/AN6/P1D
4.5.2
RC1/AN5/C12IN-
FIGURE 4-11:
4.5.4
RC3/AN7/P1C
WR
PORTC
CK
WR
TRISC
CK
FIGURE 4-12:
D
Q
VSS
Analog Input
Mode(1)
WR
PORTC
CK
CCPOUT
0
1
1
0
D
RD
PORTC
To Comparators
To A/D Converter
Note
PIC16F685/
Data Bus
RD
TRISC
on
VDD
I/O Pin
D
PIC16F685/
Data Bus
on
1:
WR
TRISC
CK
I/O Pin
Q
Q
VSS
Analog Input
Mode(1)
RD
TRISC
RD
PORTC
To A/D Converter
Preliminary
1:
DS41262A-page 65
PIC16F685/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
on
RC5/CCP1/P1A
PIC16F685/
FIGURE 4-14:
CCP1OUT
Enable
WR
PORTC
C2OUT EN
CCPOUT EN
WR
TRISC
WR
TRISC
VDD
0
1
CCP1OUT
0
1
I/O Pin
CK Q
CK
I/O Pin
Q
Q
VSS
RD
TRISC
1
0
Data Bus
VDD
0
1
CCPOUT EN
CCPOUT
WR
PORTC
CK
C2OUT EN
C2OUT
Data bus
FIGURE 4-13:
on
RD
PORTC
To Enhanced CCP
VSS
CK Q
RD
TRISC
RD
PORTC
DS41262A-page 66
Preliminary
PIC16F685/687/689/690
4.5.7
RC6/AN8/SS
The RC6/AN8/SS
of the following:
(1)
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
VSS
Analog Input
Mode(1)
RD
TRISC
RD
PORTC
VDD
1
0
I/O Pin
VSS
Analog Input
Mode(1)
RD
TRISC
WR
PORTC
0
1
RD
PORTC
To A/D Converter
1:
Preliminary
1:
DS41262A-page 67
PIC16F685/687/689/690
TABLE 4-3:
Address
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
07h/107h
PORTC
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
xxxx xxxx
uuuu uuuu
14h
SSPCON(1)
WCOL
SSPOV
SSPEN
CKP
SSPM3
SSPM2
SSPM1
SSPM0
0000 0000
0000 0000
17h
CCP1CON(2)
P1M1
P1M0
DC1B1
DC1B0
0000 0000
0000 0000
1Dh
ECCPAS(2)
0000 0000
87h/187h
TRISC
11Ah
PSSAC1
PSSAC0
PSSBD1
PSSBD0
0000 0000
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
CM2CON0
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
C2CH0
0000 -000
0000 -000
11Bh
CM2CON1
MC1OUT
MC2OUT
T1GSS
C2SYNC
00-- --10
00-- --10
11Eh
ANSEL
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
1111 1111
1111 1111
ANS11
ANS10
ANS9
ANS8
---- 1111
---- 1111
STRSYNC
STRD
STRC
STRB
STRA
---0 0001
---0 0001
11Fh
ANSELH
19Dh
PSTRCON
19Eh
SRCON
SR1
SR0
C1SEN
C2REN
PULSS
PULSR
0000 00--
0000 00--
118h
VRCON
C1VREN
C2VREN
VRR
VP6EN
VR3
VR2
VR1
VR0
0000 0000
0000 0000
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.
DS41262A-page 68
Preliminary
PIC16F685/687/689/690
5.0
TIMER0 MODULE
5.2
Timer0 Interrupt
8-bit timer/counter
Readable and writable
8-bit software programmable prescaler
Internal or external clock select
Interrupt on overflow from FFh to 00h
Edge select for external clock
5.1
Timer0 Operation
FIGURE 5-1:
CLKOUT
(= FOSC/4)
Data Bus
0
8
1
Sync 2
cycles
1
T0CKI
pin
TMR0
0
0
T0CS
T0SE
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:
T0SE, T0CS, PSA, PS<2:0> are bits in the OPTION register, WDTPS<3:0> are bits in the WDTCON register.
Preliminary
DS41262A-page 69
PIC16F685/687/689/690
5.3
REGISTER 5-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
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2-0
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
Note 1: A dedicated 16-bit WDT postscaler is available. See Section 14.5 Watchdog
Timer (WDT) for more information.
Legend:
DS41262A-page 70
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
5.4
EXAMPLE 5-1:
Prescaler
5.4.1
SWITCHING PRESCALER
ASSIGNMENT
TABLE 5-1:
Address
CHANGING PRESCALER
(TIMER0 WDT)
BCF
STATUS,RP0
BCF
STATUS,RP1
CLRWDT
CLRF
TMR0
;Bank 0
;
;Clear WDT
;Clear TMR0 and
;prescaler
;Bank 1
;Required if desired
;PS<2:0> is
;000 or 001
;
;Set postscaler to
;desired WDT rate
;Bank 0
BSF
STATUS,RP0
MOVLW
b00101111
MOVWF
OPTION_REG
CLRWDT
MOVLW
MOVWF
BCF
b00101xxx
OPTION_REG
STATUS,RP0
EXAMPLE 5-2:
CHANGING PRESCALER
(WDT TIMER0)
CLRWDT
BSF
BCF
MOVLW
STATUS,RP0
STATUS,RP1
bxxxx0xxx
MOVWF
BCF
OPTION_REG
STATUS,RP0
01h/101h
TMR0
0Bh/8Bh/
10Bh/18Bh
INTCON
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
T0IE
INTE
RABIE
T0IF
INTF
RABIF
Value on
POR, BOR
Value on
all other
Resets
xxxx xxxx
uuuu uuuu
0000 000x
0000 000x
GIE
PEIE
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
1111 1111
1111 1111
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
--11 1111
--11 1111
81h/181h
OPTION_REG
85h/185h
TRISA
Legend:
= Unimplemented locations, read as 0, u = unchanged, x = unknown. Shaded cells are not used by the Timer0 module.
Preliminary
DS41262A-page 71
PIC16F685/687/689/690
NOTES:
DS41262A-page 72
Preliminary
PIC16F685/687/689/690
6.0
FIGURE 6-1:
T1GINV
TMR1ON
TMR1GE
TMR1
TMR1H
To C2 Comparator Module
TMR1 Clock
(1)
Synchronized
clock input
TMR1L
1
Oscillator
OSC1/T1CKI
T1SYNC
1
0
OSC2/T1G
1
FOSC/4
Internal
Clock
Synchronize
Prescaler
1, 2, 4, 8
det
0
2
T1CKPS<1:0>
Sleep input
FOSC = 000
FOSC = X00
T1OSCEN
T1CKI
0
C2OUT
T1CS
T1OSCEN
*
Note 1:
T1GSS
ST Buffer is low power type when using LP osc, or high speed type when using T1CKI.
Timer1 register increments on rising edge
Preliminary
DS41262A-page 73
PIC16F685/687/689/690
6.1
6.3
6.2
6.4
Timer1 Gate
Timer1 Interrupt
Timer1 Prescaler
FIGURE 6-2:
T1CKI = 1
when TMR1
Enabled
T1CKI = 0
when TMR1
Enabled
Note 1:
2:
DS41262A-page 74
Preliminary
PIC16F685/687/689/690
REGISTER 6-1:
(1)
R/W-0
R/W-0
(2)
TMR1GE
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
TMR1CS TMR1ON
bit 7
bit 0
bit 7
bit 6
bit 5-4
bit 3
bit 2
bit 1
bit 0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 75
PIC16F685/687/689/690
6.5
Timer1 Operation in
Asynchronous Counter Mode
6.6
6.5.1
Timer1 Oscillator
Note:
6.7
TABLE 6-1:
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
0Bh/8Bh/
INTCON
10Bh/18Bh
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
Addr
0Ch
PIR1
-000 0000
-000 0000
0Eh
TMR1L
Holding register for the Least Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
uuuu uuuu
0Fh
TMR1H
Holding register for the Most Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
uuuu uuuu
10h
T1CON
uuuu uuuu
11Bh
8Ch
PIE1
Legend:
T1GINV
ADIE
T1SYNC
TMR1CS
T1GSS
C2SYNC
00-- --10
00-- --10
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
x = unknown, u = unchanged, = unimplemented, read as 0. Shaded cells are not used by the Timer1 module.
DS41262A-page 76
Preliminary
PIC16F685/687/689/690
7.0
TIMER2 MODULE
7.1
Timer2 Operation
REGISTER 7-1:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
bit 7
bit 0
bit 7
Unimplemented: Read as 0
bit 6-3
bit 2
bit 1-0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 77
PIC16F685/687/689/690
7.2
Timer2 Interrupt
FIGURE 7-1:
TMR2
Output
Prescaler
1:1, 1:4, 1:16
FOSC/4
TMR2
Reset
Comparator
EQ
Postscaler
1:1 to 1:16
T2CKPS<1:0>
4
PR2
TOUTPS<3:0>
TABLE 7-1:
Addr
0Bh/8Bh/
10Bh/18Bh
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
INTCON
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
0Ch
PIR1
11h
TMR2
Value on
POR, BOR
12h
T2CON
8Ch
PIE1
92h
PR2
Legend:
x = unknown, u = unchanged, = unimplemented, read as 0. Shaded cells are not used by the Timer2 module.
DS41262A-page 78
RCIE
TXIE
Value on
all other
Resets
SSPIE
CCP1IE
TMR2IE
Preliminary
PIC16F685/687/689/690
8.0
COMPARATOR MODULE
8.1
TABLE 8-1:
Input Condition
C1POL
C1OUT
Control Registers
8.1.1
COMPARATOR C1 CONTROL
REGISTER
Comparator enable
Comparator input selection
Comparator reference selection
Output mode
Preliminary
DS41262A-page 79
PIC16F685/687/689/690
FIGURE 8-1:
C1POL
2
D
RA1/AN1/C12IN-/VREF/ICSPCLK
RC1/AN5/C12IN1-
Q1
RC2/AN6/P1D
1
MUX
2
RC3/AN7/P1C
EN
To
Data Bus
RD_CM1CON0
Set C1IF
Q3*RD_CM1CON0
C1ON(1)
EN
CL
NRESET
C1R
To PWM Logic
C1OE
C1VN
RA0/AN0/C1IN+/ICSPDAT/ULPWU
C1VREF
0
MUX
1
C1OUT
C1VP C1
RA2/AN2/T0CKI/INT/C1OUT(2)
C1POL
Note 1:
2:
DS41262A-page 80
When C1ON = 0, the C1 comparator will produce a 0 output to the XOR Gate.
Output shown for reference only. For more detail see Figure 4-3.
Preliminary
PIC16F685/687/689/690
REGISTER 8-1:
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
bit 7
bit 6
bit 5
bit 4
bit 3
Unimplemented: Read as 0
bit 2
bit 1-0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 81
PIC16F685/687/689/690
8.1.2
COMPARATOR 2 CONTROL
REGISTERS
8.1.2.1
TABLE 8-2:
Input Condition
C2POL
C2OUT
Bits C2CH<1:0> (CM2CON0<1:0>) select the comparator input from the four analog pins, AN<7:5,1>.
FIGURE 8-2:
EN
To
Data Bus
RD_CM2CON0
C2CH<1:0>
Set C2IF
2
RA1/AN1/C12IN-/VREF/ICSPCLK
RC1/AN5/C12IN-
RC2/AN6/P1D
RC3/AN7/P1C
C2R
Q3*RD_CM2CON0
EN
CL
NRESET
C2ON(1)
1
MUX C2VN
C2
2
C2VP
C2SYNC
C2POL
C2VREF
Note 1:
2:
DS41262A-page 82
0
MUX
1
Timer1
To PWM Logic
C2OUT
D
RC0/AN4/C2IN+
0
MUX
1
C2OE
RC4/C2OUT/P1B(2)
From TMR1
Clock
When C2ON = 0, the C2 comparator will produce a 0 output to the XOR Gate.
Output shown for reference only. See Figure 4-14 for more detail.
Preliminary
PIC16F685/687/689/690
REGISTER 8-2:
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
bit 7
bit 6
bit 5
bit 4
bit 3
Unimplemented: Read as 0
bit 2
bit 1-0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 83
PIC16F685/687/689/690
8.1.2.2
REGISTER 8-3:
R-0
U-0
U-0
U-0
U-0
R/W-1
R/W-0
MC1OUT
MC2OUT
T1GSS
C2SYNC
bit 7
bit 0
bit 7
bit 6
bit 5-2
Unimplemented: Read as 0
bit 1
bit 0
DS41262A-page 84
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
8.2
8.2.1
Comparator Outputs
COMPARATOR INTERRUPT
OPERATION
Preliminary
DS41262A-page 85
PIC16F685/687/689/690
8.3
SR Latch Output
REGISTER 8-4:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
U-0
U-0
(2)
SR0(2)
C1SEN
C2REN
PULSS
PULSR
SR1
bit 7
bit 0
bit 7-6
bit 5
bit 4
bit 3
bit 2
bit 1-0
Unimplemented: Read as 0.
Note 1: The C1OUT or C2OUT bits in the CM1CON0 and CM2CON0 registers, respectively,
will always reflect the actual comparator outputs (not the pins), regardless the SR
latch operation.
2: To enable the SR Latch output to the pins, the appropriate C1OE, C2OE, TRISA2
and TRISC4 bits (CM1CON0, CM2CON0, TRISA and TRISC registers, respectively) must be properly configured.
Legend:
DS41262A-page 86
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
FIGURE 8-3:
SR LATCH CONFIGURATIONS
SR<1:0> = 00
SR<1:0> = 11
Pulse
Gen
PULSS
C1OUT
S
C1OUT
C1
RC1/AN5/C12IN-
RC0/AN4/C2IN+
C2OUT
C2
C1
C2
VIN-
C2OUT
VIN+
Pulse
Gen
PULSR
SR<1:0> = 10
SR<1:0> = 01
PULSS
Pulse
Gen
C1OUT
Q
C1
C2
R
PULSR
Pulse
Gen
PULSS
S
Note:
RA1/AN1/C12IN-/
VREF/ICSPCLK
RA0/AN0/C1IN+/
ICSPDAT/ULPWU
VIN-
VIN+
RC1/AN5/C12IN-
VIN-
RC0/AN4/C2IN+
VIN+
Pulse
Gen
S
C1
C2OUT
C2
Pulse
Gen
PULSR
FIGURE 8-4:
PULSS
C1
2
MUX
1
C1SEN
C2
Reset
Dominant(1)
C2REN
2
MUX
1
PULSR
0
SR<1:0>
2
Note 1:
If R = 1 and S = 1 simultaneously, Q = 0, Q = 1
Preliminary
DS41262A-page 87
PIC16F685/687/689/690
8.4
8.4.3
Comparator Reference
8.4.1
VP6 REFERENCE
8.4.4
EQUATION 8-1:
VOLTAGE REFERENCE
OUTPUT VOLTAGE
8.4.2
VOLTAGE REFERENCE
ACCURACY/ERROR
DS41262A-page 88
Preliminary
PIC16F685/687/689/690
REGISTER 8-5:
C2VREN
VRR
VP6EN
VR3
VR2
VR1
bit 7
R/W-0
VR0
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3-0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 89
PIC16F685/687/689/690
FIGURE 8-5:
VDD
8R
VRR
16-1 Analog
MUX
CVREF
VR<3:0>
C1VREN
C1VREF to
Comparator 1
Input
1
0
VP6EN
C2VREN
C2VREF to
Comparator 2
Input
Sleep
HFINTOSC enable
1
0
0.6V
EN
VP6
Reference
A/D Converter
Module
DS41262A-page 90
Preliminary
PIC16F685/687/689/690
8.5
8.6
8.7
TABLE 8-3:
Address
Effects of a Reset
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
05h, 105h
PORTA
RA5
RA4
RA3
RA2
RA1
RA0
--xx xxxx
--uu uuuu
07h, 107h
PORTC
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
xxxx xxxx
uuuu uuuu
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
0Bh/8Bh/
INTCON
10Bh/18Bh
0Ch
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
85h/185h
TRISA
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
--11 1111
--11 1111
87h/187h
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
118h
VRCON
C1VREN
C2VREN
VRR
VP6EN
VR3
VR2
VR1
VR0
0000 0000
0000 0000
119h
CM1CON0
C1ON
C1OUT
C1OE
C1POL
C1R
C1CH1
C1CH0
0000 0000
0000 -000
11Ah
CM2CON0
C2ON
C2OUT
C2OE
C2POL
C2R
C2CH1
C2CH0
0000 0000
0000 -000
11Bh
CM2CON1
T1GSS
C2SYNC
00-- --10
00-- --10
11Eh
ANSEL
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
1111 1111
1111 1111
19Eh
SRCON
SR1
SR0
C1SEN
C2SEN
PULSS
PULSR
0000 00--
0000 00--
MC1OUT MC2OUT
Legend: x = unknown, u = unchanged, = unimplemented, read as 0. Shaded cells are not used by the Capture, Compare or Timer1 module.
Preliminary
DS41262A-page 91
PIC16F685/687/689/690
NOTES:
DS41262A-page 92
Preliminary
PIC16F685/687/689/690
9.0
ANALOG-TO-DIGITAL
CONVERTER (A/D) MODULE
FIGURE 9-1:
RA0/AN0/C1IN+/ICSPDAT/ULPWU
VCFG = 1
RA1/AN1/C12IN-/VREF/ICSPCLK
RA2/AN2/T0CKI/INT/C1OUT
RA4/AN3/T1G/OSC2/CLKOUT
RC0/AN4/C2IN+
RC1/AN5/C12IN1RC2/AN6/P1D(2)
A/D
RC3/AN7/P1C(2)
RC6/AN8/SS(3)
10
GO/DONE
RC7/AN9/SDO(3)
ADFM
RB4/AN10/SDI/SDA(3)
10
ADON(1)
RB5/AN11/RX/DT(3)
ADRESH
CVREF
13
VP6 Reference
ADRESL
VSS
CHS<3:0>
Note 1:
When ADON = 0 all input channels are disconnected from ADC (no loading).
2:
3:
Preliminary
DS41262A-page 93
PIC16F685/687/689/690
9.1
9.1.1
9.1.2
CHANNEL SELECTION
There
are
fourteen
analog
channels
on
PIC16F685/687/689/690.
The
CHS<3:0>
bits
(ADCON0<5:2>) control which channel is connected to
the sample and hold circuit.
TABLE 9-1:
VOLTAGE REFERENCE
9.1.4
The
ANS<11:0>
bits
(ANSEL<7:0>
and
ANSELH<3:0>) and the TRISA<4,2:0>, TRISB<5:4>
and TRISC<7:6,3:0>> bits control the operation of the
A/D port pins. Set the corresponding TRISx bits to 1 to
set the pin output driver to its high-impedance state.
Likewise, set the corresponding ANSx bit to disable the
digital input buffer.
Note:
9.1.3
CONVERSION CLOCK
FOSC/2
FOSC/4
FOSC/8
FOSC/16
FOSC/32
FOSC/64
FRC (dedicated internal oscillator)
Device Frequency
Operation
ADCS<2:0>
20 MHz
5 MHz
4 MHz
1.25 MHz
2 TOSC
000
100 ns(2)
400 ns(2)
500 ns(2)
1.6 s
4 TOSC
100
200
ns(2)
ns(2)
s(2)
3.2 s
8 TOSC
001
400 ns(2)
1.6 s
2.0 s
6.4 s
101
ns(2)
3.2 s
4.0 s
12.8 s(3)
16 TOSC
800
800
1.0
s(3)
25.6 s(3)
32 TOSC
010
1.6 s
6.4 s
64 TOSC
110
3.2 s
12.8 s(3)
16.0 s(3)
51.2 s(3)
s(1,4)
s(1,4)
2-6 s(1,4)
A/D RC
Legend:
Note 1:
2:
3:
4:
x11
2-6
s(1,4)
2-6
8.0
2-6
DS41262A-page 94
Preliminary
PIC16F685/687/689/690
9.1.5
STARTING A CONVERSION
A/D
conversion
sample.
Instead,
the
ADRESH:ADRESL registers will retain the value of the
previous conversion. After an aborted conversion, a
2 TAD delay is required before another acquisition can
be initiated. Following the delay, an input acquisition is
automatically started on the selected channel.
Note:
FIGURE 9-2:
TAD2
TAD3
TAD4
TAD5
TAD6
TAD7
TAD8
b9
b8
b7
b6
b5
b4
b3
b1
b0
Conversion Starts
Holding Capacitor is Disconnected from Analog Input (typically 100 ns)
Set GO/DONE bit
9.1.6
CONVERSION OUTPUT
FIGURE 9-3:
(ADFM = 0)
ADRESL
MSB
LSB
bit 7
bit 0
bit 7
bit 0
Unimplemented: Read as 0
MSB
bit 7
LSB
bit 0
Unimplemented: Read as 0
bit 7
bit 0
10-bit A/D Result
Preliminary
DS41262A-page 95
PIC16F685/687/689/690
REGISTER 9-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 7-0
bit 0
REGISTER 9-2:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
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
bit 7-4
Unimplemented: Read as 0.
bit 3-0
TABLE 9-2:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
Analog
RB5
Select
Channel
RC7
RC6
RC3
RC2
RC1
RC0
RA4
RA2
RA1
RA0
ANS8
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
AN8
AN7
AN6
AN5
AN4
AN3
AN2
AN1
AN0
AN11
DS41262A-page 96
RB4
AN10
AN9
Preliminary
PIC16F685/687/689/690
REGISTER 9-3:
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
bit 7
bit 6
bit 5-2
bit 1
bit 0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 97
PIC16F685/687/689/690
REGISTER 9-4:
R/W-0
R/W-0
R/W-0
U-0
U-0
U-0
U-0
ADCS2
ADCS1
ADCS0
bit 7
bit 0
bit 7
Unimplemented: Read as 0
bit 6-4
bit 3-0
Unimplemented: Read as 0
Legend:
DS41262A-page 98
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
9.1.7
EXAMPLE 9-1:
2.
3.
4.
5.
6.
7.
A/D CONVERSION
Preliminary
DS41262A-page 99
PIC16F685/687/689/690
9.2
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 AP PLIE D 1 ------------ = V CHOLD
2047
TC
----------
RC
V AP P LI ED 1 e = V CHOLD
Tc
---------
1
RC
V AP P LIED 1 e = V A P PLIE D 1 ------------
2047
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 = 2 S + 1.37 S + [ ( 50C- 25C ) ( 0.05 S /C ) ]
= 4.67 S
DS41262A-page 100
Preliminary
PIC16F685/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:
ANx
VA
CPIN
5 pF
VT = 0.6V
VT = 0.6V
RIC 1k
Sampling
Switch
SS Rss
CHOLD
= DAC capacitance
= 10 pF
I LEAKAGE
500 nA
VSS
Legend: CPIN
= Input Capacitance
= Threshold Voltage
VT
I LEAKAGE = Leakage current at the pin due to
various junctions
RIC
= Interconnect Resistance
SS
= Sampling Switch
CHOLD
= Sample/Hold Capacitance (from DAC)
Preliminary
6V
5V
VDD 4V
3V
2V
RSS
5 6 7 8 9 10 11
Sampling Switch
(k)
DS41262A-page 101
PIC16F685/687/689/690
9.3
FIGURE 9-5:
Full-Scale Range
3FFh
3FEh
3FDh
3FCh
1 LSB ideal
3FBh
Full-Scale
Transition
004h
003h
002h
001h
000h
0V
DS41262A-page 102
Zero-Scale
Transition
Preliminary
VREF
PIC16F685/687/689/690
9.4
Effects of Reset
9.5
TABLE 9-3:
Addr
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
05h/105h
PORTA
RA5
RA4
RA3
RA2
RA1
RA0
06h/106h
PORTB
RB7
RB6
RB5
RB4
07h/107h
PORTC
RC7
RC6
RC5
RC4
RC3
RC2
RC1
RC0
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0Bh/8Bh/
INTCON
10Bh/18Bh
0Ch
PIR1
11Eh
ANSEL
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
ANS7
ANS6
ANS5
ANS4
ANS3
ANS2
ANS1
ANS0
ANS11
ANS10
ANS9
ANS8
11Fh
ANSELH
1Eh
1Fh
ADCON0
ADFM
VCFG
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
85h/185h
TRISA
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
86h/186h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
87h/187h
TRISC
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
9Eh
ADRESL
9Fh
ADCON1
Legend:
ADCS2
ADCS1
ADCS0
x = unknown, u = unchanged, = unimplemented read as 0. Shaded cells are not used for A/D module.
Preliminary
DS41262A-page 103
PIC16F685/687/689/690
NOTES:
DS41262A-page 104
Preliminary
PIC16F685/687/689/690
10.0
10.1
EECON1
EECON2
EEDAT
EEDATH
EEADR
EEADRH
10.1.1
Preliminary
DS41262A-page 105
PIC16F685/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
EEDAT7
EEDAT6
EEDAT5
EEDAT4
EEDAT3
EEDAT2
EEDAT1
EEDAT0
bit 7
bit 7-0
bit 0
REGISTER 10-2:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
EEDAR7
EEDAR6
EEDAR5
EEDAR4
EEDAR3
EEDAR2
EEDAR1
EEDAR0
bit 7
bit 7-0
bit 0
REGISTER 10-3:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
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 5-0
bit 0
EEDATH<5:0>: Byte value to Write to or Read from data EEPROM bits or to Read from program memory
Note 1:
PIC16F685/PIC16F689/PIC16F690 only.
Legend:
REGISTER 10-4:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
U-0
U-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
EEADRH3
EEADRH2
EEADRH1
EEADRH0
bit 7
bit 3-0
bit 0
EEADRH<3:0>: Specifies one of 256 locations for EEPROM Read/Write Operation bits or high bits for
program memory reads
Note 1:
PIC16F685/PIC16F689/PIC16F690 only.
Legend:
DS41262A-page 106
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
REGISTER 10-5:
U-0
U-0
U-0
R/W-x
R/W-0
R/S-0
R/S-0
EEPGD
WRERR
WREN
WR
RD
bit 7
bit 0
bit 7
bit 6-4
Unimplemented: Read as 0
bit 3
bit 2
bit 1
bit 0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 107
PIC16F685/687/689/690
10.1.2
10.1.3
EXAMPLE 10-1:
BSF
BCF
MOVLW
MOVWF
STATUS, RP1
STATUS, RP0
DATA_EE_ADDR
EEADR
BSF
BCF
STATUS, RP0
EECON1, EEPGD
BCF
BCF
MOVF
BCF
EECON1, RD
STATUS, RP1
EEDAT, W
STATUS, RP0
Required
Sequence
EXAMPLE 10-2:
;Bank 2
;
;
;Data Memory
;Address to read
;Bank 3
;Point to DATA
;memory
;EE Read
;Bank 2
;W = EEDAT
;Bank 0
BCF
BSF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BCF
BSF
STATUS, RP0
STATUS, RP1
DATA_EE_ADDR
EEADR
DATA_EE_DATA
EEDAT
STATUS, RP0
EECON1, EEPGD
EECON1, WREN
;Bank 2
;
;
;Data Memory Address to write
;
;Data Memory Value to write
;Bank 3
;Point to DATA memory
;Enable writes
BCF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BSF
INTCON, GIE
55h
EECON2
AAh
EECON2
EECON1, WR
INTCON, GIE
;Disable INTs.
;
;Write 55h
;
;Write AAh
;Set WR bit to begin write
;Enable INTs.
SLEEP
BCF
BCF
EECON1, WREN
STATUS, RP0
DS41262A-page 108
Preliminary
PIC16F685/687/689/690
10.1.4
Required
Sequence
EXAMPLE 10-3:
BCF
BSF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BSF
BSF
STATUS, RP0
STATUS, RP1
MS_PROG_EE_ADDR
EEADRH
LS_PROG_EE_ADDR
EEADR
STATUS, RP0
EECON1, EEPGD
EECON1, RD
;Bank 2
;
;
;MS Byte of Program Address to read
;
;LS Byte of Program Address to read
;Bank 3
;Point to PROGRAM memory
;EE Read
;
BCF
MOVF
MOVF
BCF
STATUS, RP0
EEDAT, W
EEDATH, W
STATUS, RP1
;Bank 2
;W = LS Byte of Program EEDAT
;W = MS Byte of Program EEDAT
;Bank 0
Preliminary
DS41262A-page 109
PIC16F685/687/689/690
FIGURE 10-1:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
PC
Flash ADDR
Flash Data
PC + 1
INSTR (PC)
INSTR(PC - 1)
executed here
EEADRH,EEADR
INSTR (PC + 1)
BSF EECON1,RD
executed here
PC
+3
PC+3
EEDATH,EEDAT
INSTR(PC + 1)
executed here
PC + 5
PC + 4
INSTR (PC + 3)
Forced NOP
executed here
INSTR (PC + 4)
INSTR(PC + 3)
executed here
INSTR(PC + 4)
executed here
RD bit
EEDATH
EEDAT
Register
EERHLT
DS41262A-page 110
Preliminary
PIC16F685/687/689/690
10.2
Write Verify
10.4
EXAMPLE 10-4:
WRITE VERIFY
BCF
BSF
MOVF
STATUS, RP0
STATUS, RP1
EEDAT, W
BSF
BSF
STATUS, RP0
EECON1, RD
BCF
XORWF
BTFSS
GOTO
:
BCF
STATUS, RP0
EEDAT, W
STATUS, Z
WRITE_ERR
10.2.1
STATUS, RP1
;Bank 2
;
;EEDAT not changed
;from previous write
;Bank 3
;YES, Read the
;value written
;Bank 2
;
;Is data the same
;No, handle error
;Yes, continue
;Bank 0
10.2.2
EEPROM ENDURANCE
10.3
Preliminary
DS41262A-page 111
PIC16F685/687/689/690
TABLE 10-1:
Addr
Name
0Bh/8Bh/
INTCON
10Bh/18Bh
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
0Dh
PIR2
OSFIF
C2IF
C1IF
EEIF
0000 ----
0000 ----
8Dh
PIE2
OSFIE
C2IE
C1IE
EEIE
0000 ----
0000 ----
10Eh
EEDATH
(1)
10Fh
EEADRH(1)
--00 0000
--00 0000
---- 0000
---- 0000
10Ch
EEDAT
EEDAT7
EEDAT6
EEDAT5
EEDAT4
EEDAT3
EEDAT2
EEDAT1
EEDAT0
0000 0000
0000 0000
10Dh
EEADR
EEADR7 EEADR6
EEADR5
EEADR4
EEADR3
EEADR2
EEADR1
EEADR0
0000 0000
0000 0000
18Ch
EECON1
EEPGD
WRERR
WREN
WR
RD
x--- x000
0--- q000
18Dh
EECON2
---- ----
---- ----
Legend:
Note
1:
DS41262A-page 112
Preliminary
PIC16F685/687/689/690
11.0
ENHANCED
CAPTURE/COMPARE/PWM+
(ECCP+) MODULE
TABLE 11-1:
REGISTER 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
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CCP1M2
CCP1M1
CCP1M0
bit 7
bit 0
bit 7-6
bit 5-4
bit 3-0
PIC16F685/PIC16F690 only.
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 113
PIC16F685/687/689/690
11.1
Capture Mode
EXAMPLE 11-1:
BCF
BCF
CLRF
MOVLW
CHANGING BETWEEN
CAPTURE PRESCALERS
STATUS, RP0
STATUS, RP1
CCP1CON
NEW_CAPT_PS
;Bank 0
;
;Turn ECCP module off
;Load the W reg with
;the new prescaler
;move value and ECCP ON
;Load CCP1CON with this
;value
MOVWF CCP1CON
11.1.1
FIGURE 11-1:
Prescaler
1, 4, 16
CAPTURE MODE
OPERATION BLOCK
DIAGRAM
CCPR1H
and
Edge Detect
CCPR1L
FIGURE 11-2:
Capture
Enable
TMR1H
Compare Mode
Driven high
Driven low
Remains unchanged
RC5/CCP1/P1A
pin
11.2
COMPARE MODE
OPERATION BLOCK
DIAGRAM
TMR1L
CCP1CON<3:0>
CCP1CON<3:0>
Mode Select
Qs
11.1.2
11.1.3
RC5/CCP1/P1A
pin
CCPR1H CCPR1L
Q
S
R
Output
Logic
Match
Comparator
TMR1H
TRISC<5>
Output Enable
SOFTWARE INTERRUPT
11.1.4
TMR1L
ECCP PRESCALER
DS41262A-page 114
Preliminary
PIC16F685/687/689/690
11.2.1
11.2.4
11.2.2
11.2.3
TABLE 11-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
0Bh/8Bh/
INTCON
10Bh/18Bh
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
Addr
0Ch
PIR1
-000 0000
-000 0000
0Eh
TMR1L
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
uuuu uuuu
0Fh
TMR1H
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
xxxx xxxx
uuuu uuuu
10h
T1CON
0000 0000
uuuu uuuu
11Bh
CM2CON1
MC1OUT MC2OUT
00-- --10
00-- --10
15h
CCPR1L
xxxx xxxx
uuuu uuuu
16h
CCPR1H
xxxx xxxx
uuuu uuuu
17h
CCP1CON
87h/187h
TRISC
8Ch
PIE1
Legend:
Note
T1GINV
T1SYNC
TMR1CS TMR1ON
T1GSS
C2SYNC
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CCP1M2
CCP1M1
CCP1M0
0000 0000
0000 0000
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
1111 1111
1111 1111
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
= Unimplemented locations, read as 0, u = unchanged, x = unknown. Shaded cells are not used by the Capture, Compare or Timer1
module.
1:
PIC16F685/PIC16F690 only.
Preliminary
DS41262A-page 115
PIC16F685/687/689/690
11.3
FIGURE 11-3:
CCP1M<3:0>
4
P1M<1:0>
2
CCPR1L
CCP1/P1A
RC5/CCP1/P1A
TRISC<5>
CCPR1H (Slave)
P1B
R
Comparator
TRISC<4>
Output
Controller
RC4/C2OUT/P1B
RC3/AN7/P1C
P1C
(1)
TMR2
TRISC<3>
S
P1D
Comparator
Clear Timer2,
toggle PWM pin and
latch duty cycle
PR2
Note
11.3.1
1:
TRISC<2>
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.
Single Output
Half-bridge Output
Full-bridge Output, Forward mode
Full-bridge Output, Reverse mode
TABLE 11-3:
RC2/AN6/P1D
ECCP Mode
CCP1CON
Configuration
RC5
RC4
RC3
RC2
Compatible CCP
00xx11xx
CCP1
RC4/C2OUT
RC3/AN7
RC2/AN6
Dual PWM
10xx11xx
P1A
P1B
RC3/AN7
RC2/AN6
Quad PWM
x1xx11xx
P1A
P1B
P1C
P1D
Legend: x = Dont care. Shaded cells indicate pin assignments not used by ECCP in a given mode.
Note 1: TRIS register values must be configured appropriately.
2: With ECCP in Dual or Quad PWM mode, the C2OUT output control of PORTC must be disabled.
DS41262A-page 116
Preliminary
PIC16F685/687/689/690
11.3.2
PWM PERIOD
EQUATION 11-2:
EQUATION 11-1:
11.3.3
EQUATION 11-3:
TABLE 11-4:
F OSC
log -------------------------------------------------------------
F PWM TMR2 Prescaler
Resolution = --------------------------------------------------------------------------- bits
log ( 2 )
All control registers are double buffered and are loaded
at the beginning of a new PWM cycle (the period
boundary when Timer2 resets) in order to prevent
glitches on any of the outputs. The exception is the PWM
delay register, which is loaded at either the duty cycle
boundary or the period boundary (whichever comes
first). Because of the buffering, the module waits until the
timer resets, instead of starting immediately. This means
that enhanced PWM waveforms do not exactly match
the standard PWM waveforms, but are instead offset by
one full instruction cycle (4 TOSC).
Note:
PWM Frequency
1.22 kHz(1)
4.88 kHz(1)
19.53 kHz
78.12 kHz
156.3 kHz
208.3 kHz
16
PR2 Value
0xFF
0xFF
0xFF
0x3F
0x1F
0x17
10
10
10
6.6
Note 1:
Preliminary
DS41262A-page 117
PIC16F685/687/689/690
FIGURE 11-4:
00
PR2+1
Duty
Cycle
Signal
CCP1CON
Period
(Single Output)
P1A Modulated
Delay(1)
Delay(1)
P1A Modulated
(Half-bridge)
10
P1B Modulated
P1A Active
(Full-bridge,
Forward)
01
P1B Inactive
P1C Inactive
P1D Modulated
P1A Inactive
(Full-bridge,
Reverse)
11
P1B Modulated
P1C Active
P1D Inactive
Relationships:
Period = 4 * TOSC * (PR2 + 1) * (TMR2 prescale value)
Duty Cycle = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 prescale value)
Delay = 4 * TOSC * (PWM1CON<6:0>)
Note 1: Dead band delay is programmed using the PWM1CON register (Section 11.3.7 Programmable Dead Band Delay).
FIGURE 11-5:
CCP1CON
<7:6>
00
(Single Output)
Period
P1A Modulated
P1A Modulated
10
(Half-bridge)
PR2+1
Duty
Cycle
Signal
Delay(1)
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)
Duty Cycle = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMR2 prescale value)
Delay = 4 * TOSC * (PWM1CON<6:0>)
Note
1:
DS41262A-page 118
Dead band delay is programmed using the PWM1CON register (Section 11.3.7 Programmable Dead Band Delay).
Preliminary
PIC16F685/687/689/690
11.3.4
HALF-BRIDGE MODE
FIGURE 11-6:
Period
Period
Duty Cycle
P1A(2)
td
td
P1B(2)
(1)
(1)
(1)
FIGURE 11-7:
HALF-BRIDGE PWM
OUTPUT
+
V
-
P1A
PIC16F685/690
Load
FET
Driver
+
V
-
P1B
V-
FET
Driver
FET
Driver
P1A
PIC16F685/690
FET
Driver
Load
FET
Driver
P1B
V-
Preliminary
DS41262A-page 119
PIC16F685/687/689/690
11.3.5
FULL-BRIDGE MODE
FIGURE 11-8:
Forward Mode
Period
P1A
(2)
Duty Cycle
P1B(2)
P1C(2)
P1D(2)
(1)
(1)
Reverse Mode
Period
Duty Cycle
P1A(2)
P1B(2)
P1C(2)
P1D(2)
(1)
Note 1:
2:
(1)
DS41262A-page 120
Preliminary
PIC16F685/687/689/690
FIGURE 11-9:
FET
Driver
QC
QA
FET
Driver
P1A
Load
P1B
PIC16F685/690
FET
Driver
P1C
FET
Driver
QD
QB
VP1D
11.3.5.1
Preliminary
DS41262A-page 121
PIC16F685/687/689/690
FIGURE 11-10:
Signal
Period
P1A (Active-High)
P1B (Active-High)
DC
P1C (Active-High)
(2)
P1D (Active-High)
DC
Note 1:
2:
The direction bit in the ECCP Control register (CCP1CON<7>) 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 at intervals
of 4 TOSC, 16 TOSC or 64 TOSC, depending on the Timer2 prescaler value. The modulated P1B and P1D signals
are inactive at this time.
FIGURE 11-11:
t1
Reverse Period
P1A
P1B
DC
P1C
P1D
DC
TON
External Switch C
TOFF
External Switch D
Potential
Shoot-Through
Current
Note 1:
T = TOFF - TON
2:
3:
TOFF is the turn off delay of power switch QD and its driver.
DS41262A-page 122
Preliminary
PIC16F685/687/689/690
11.3.6
REGISTER 11-2:
Note:
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 7-5
bit 4
bit 3
bit 2
bit 1
bit 0
bit 0
Unimplemented: Read as 0
STRSYNC: Steering Sync bit
1 = Output steering update occurs on next PWM period
0 = Output steering update occurs at the beginning of the instruction cycle boundary
STRD: Steering Enable bit D
1 = P1D pin has the PWM waveform with polarity control from CCPM<1:0>
0 = P1D pin is assigned to port pin
STRC: Steering Enable bit C
1 = P1C pin has the PWM waveform with polarity control from CCPM<1:0>
0 = P1C pin is assigned to port pin
STRB: Steering Enable bit B
1 = P1B pin has the PWM waveform with polarity control from CCPM<1:0>
0 = P1B pin is assigned to port pin
STRA: Steering Enable bit A
1 = P1A pin has the PWM waveform with polarity control from CCPM<1:0>
0 = P1A pin is assigned to port pin
Note 1: PIC16F685/PIC16F690 only.
2: The PWM Steering is available only when the CCP1M<3:2> = 11 and
P1M<1:0> = 00 (CCP1CON register).
Legend:
R = Readable bit
-n = Value at POR
W = Writable bit
1 = Bit is set
Preliminary
DS41262A-page 123
PIC16F685/687/689/690
TABLE 11-5:
STRD
STRC
STRB
STRA
P1D
P1C
P1B
P1A
Port
Port
Port
Port
Port
Port
Port
P1A
Port
Port
P1B
Port
Port
Port
P1B
P1A
Port
P1C
Port
Port
Port
P1C
Port
P1A
Port
P1C
P1B
Port
Port
P1C
P1B
P1A
P1D
Port
Port
Port
P1D
Port
Port
P1A
P1D
Port
P1B
Port
P1D
Port
P1B
P1A
P1D
P1C
Port
Port
P1D
P1C
Port
P1A
P1D
P1C
P1B
Port
P1D
P1C
P1B
P1A
1
Note:
DS41262A-page 124
Preliminary
PIC16F685/687/689/690
11.3.6.1
Steering Synchronization
FIGURE 11-12:
PWM
STRn
P1<D:A>
q4
q4
Port Data
Port Data
P1n = PWM
FIGURE 11-13:
PWM
STRn
P1<D:A>
Port Data
Port Data
P1n PWM
Preliminary
DS41262A-page 125
PIC16F685/687/689/690
11.3.7
REGISTER 11-3:
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 7
bit 6-0
bit 0
DS41262A-page 126
W = Writable bit
1 = Bit is set
Preliminary
PIC16F685/687/689/690
11.3.8
ENHANCED PWM
AUTO-SHUTDOWN
REGISTER 11-4:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
PSSAC1
PSSAC0
PSSBD1
PSSBD0
bit 7
bit 7
bit 6-4
bit 3-2
bit 1-0
bit 0
Legend:
R = Readable bit
- n = Value at POR
W = Writable bit
1 = Bit is set
Preliminary
DS41262A-page 127
PIC16F685/687/689/690
11.3.8.1
11.3.9
FIGURE 11-14:
START-UP CONSIDERATIONS
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
Start of
PWM Period
FIGURE 11-15:
Shutdown
Shutdown
Event Occurs Event Clears
PWM
Resumes
Shutdown Event
ECCPASE bit
PWM Activity
Normal PWM
Start of
PWM Period
DS41262A-page 128
ECCPASE
Cleared by
Shutdown
Shutdown Firmware PWM
Event Occurs Event Clears
Resumes
Preliminary
PIC16F685/687/689/690
11.3.10
11.3.12
11.3.10.1
2.
3.
1.
11.3.11
4.
EFFECTS OF A RESET
5.
6.
7.
8.
9.
Preliminary
DS41262A-page 129
PIC16F685/687/689/690
TABLE 11-6:
Addr
Value on
all other
Resets
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
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
0Ch
PIR1
11h
TMR2
12h
T2CON
15h
CCPR1L
16h
CCPR1H
17h
CCP1CON
P1M1
P1M0
DC1B1
DC1B0
CCP1M3
CCP1M2
CCP1M1
CCP1M0
1Ch
PWM1CON
PRSEN
PDC6
PDC5
PDC4
PDC3
PDC2
PDC1
PDC0
1Dh
ECCPAS
PSSAC1
PSSAC0
PSSBD1
PSSBD0
87h/187h
TRISC
8Ch
PIE1
92h
PR2
19Dh
PSTRCON
Legend:
Note
TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
TRISC7
TRISC6
TRISC5
TRISC4
TRISC3
TRISC2
TRISC1
TRISC0
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IF
TMR1IF
STRSYNC
STRD
STRC
STRB
STRA
= Unimplemented locations, read as 0, u = unchanged, x = unknown. Shaded cells are not used by the Capture, Compare or Timer1
module.
1:
PIC16F685/PIC16F690 only.
DS41262A-page 130
Preliminary
PIC16F685/687/689/690
12.0
ENHANCED UNIVERSAL
SYNCHRONOUS
ASYNCHRONOUS RECEIVER
TRANSMITTER (EUSART)
12.1
Preliminary
DS41262A-page 131
PIC16F685/687/689/690
REGISTER 12-1:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R-1
R/W-0
CSRC
TX9
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
Legend:
DS41262A-page 132
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
REGISTER 12-2:
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
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 133
PIC16F685/687/689/690
REGISTER 12-3:
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
bit 7
bit 6
bit 5
Unimplemented: Read as 0
bit 4
bit 3
bit 2
Unimplemented: Read as 0
bit 1
bit 0
DS41262A-page 134
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/687/689/690
12.2
12.2.1
SAMPLING
EXAMPLE 12-1:
TABLE 12-1:
CALCULATING BAUD
RATE ERROR
( 9615 9600 )
= ---------------------------------- = 0.16%
9600
Note:
Configuration Bits
BRG/EUSART Mode
SYNC
BRG16
BRGH
8-bit/Asynchronous
FOSC/[64 (n+1)]
8-bit/Asynchronous
FOSC/[16 (n+1)]
16-bit/Asynchronous
16-bit/Asynchronous
8-bit/Synchronous Master
16-bit/Synchronous Master
FOSC/[4 (n+1)]
Preliminary
DS41262A-page 135
PIC16F685/687/689/690
TABLE 12-2:
Addr
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
18h
RCSTA
SPEN
RX9
SREN
CREN
ADDEN
FERR
OERR
RX9D
0000 000x
0000 000x
98h
TXSTA
CSRC
TX9
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
99h
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
9Ah
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
9Bh
BAUDCTL
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
Legend:
Note
x = unknown, u = unchanged, - = unimplemented locations read as 0. Shaded cells are not used by oscillators.
1:
PIC16F687/PIC16F689/PIC16F690 only.
DS41262A-page 136
Preliminary
PIC16F685/687/689/690
TABLE 12-3:
BAUD
RATE
(K)
%
Error
SPBRG
value
(decimal)
Actual
Rate
(K)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
0.3
1.2
1.221
1.73
255
1.202
0.16
129
1201
-0.16
103
2.4
2.404
0.16
129
2.404
0.16
64
2403
-0.16
51
9.6
9.766
1.73
31
9.766
1.73
15
9615
-0.16
12
19.2
19.531
1.73
15
19.531
1.73
57.6
62.500
8.51
52.083
-9.58
115.2
104.167
-9.58
78.125
-32.18
%
Error
0.3
0.300
0.16
1.2
1.202
0.16
%
Error
207
300
-0.16
51
1201
-0.16
SPBRG
value
(decimal)
%
Error
103
300
-0.16
51
25
1201
-0.16
12
SPBRG
value
(decimal)
SPBRG
value
(decimal)
2.4
2.404
0.16
25
2403
-0.16
12
9.6
8.929
-6.99
19.2
20.833
8.51
57.6
62.500
8.51
115.2
62.500
-45.75
%
Error
SPBRG
value
(decimal)
Actual
Rate
(K)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
2.4
2.441
1.73
255
2403
-0.16
9.6
9.615
0.16
129
9.615
0.16
64
9615
-0.16
207
51
19.2
19.231
0.16
64
19.531
1.73
31
19230
-0.16
25
57.6
56.818
-1.36
21
56.818
-1.36
10
55555
3.55
115.2
113.636
-1.36
10
125.000
8.51
%
Error
SPBRG
value
(decimal)
Actual
Rate
(K)
%
Error
SPBRG
value
(decimal)
%
Error
SPBRG
value
(decimal)
0.3
300
-0.16
207
1.2
1.202
0.16
207
1201
-0.16
103
1201
-0.16
51
2.4
2.404
0.16
103
2403
-0.16
51
2403
-0.16
25
9.6
9.615
0.16
25
9615
-0.16
12
19.2
19.231
0.16
12
57.6
62.500
8.51
115.2
125.000
8.51
Preliminary
DS41262A-page 137
PIC16F685/687/689/690
TABLE 12-3:
BAUD
RATE
(K)
(decimal)
Actual
Rate
(K)
%
Error
0.02
-0.03
4165
1041
0.300
1.200
2.399
-0.03
520
Actual
Rate
(K)
%
Error
0.3
1.2
0.300
1.200
2.4
SPBRG
value
(decimal)
Actual
Rate
(K)
%
Error
0.02
-0.03
2082
520
300
1201
-0.04
-0.16
1665
415
2.404
0.16
259
2403
-0.16
207
SPBRG
value
SPBRG
value
(decimal)
9.6
9.615
0.16
129
9.615
0.16
64
9615
-0.16
51
19.2
19.231
0.16
64
19.531
1.73
31
19230
-0.16
25
57.6
56.818
-1.36
21
56.818
-1.36
10
55555
3.55
115.2
113.636
-1.36
10
125.000
8.51
%
Error
0.3
1.2
0.300
1.202
0.04
0.16
2.4
2.404
0.16
(decimal)
Actual
Rate
(K)
%
Error
832
207
300
1201
-0.16
-0.16
103
2403
SPBRG
value
(decimal)
Actual
Rate
(K)
%
Error
415
103
300
1201
-0.16
-0.16
207
51
-0.16
51
2403
-0.16
25
SPBRG
value
SPBRG
value
(decimal)
9.6
9.615
0.16
25
9615
-0.16
12
19.2
19.231
0.16
12
57.6
62.500
8.51
115.2
125.000
8.51
(decimal)
Actual
Rate
(K)
%
Error
0.00
16665
0.300
0.00
0.02
4165
1.200
0.02
2.400
0.02
2082
2.402
9.6
9.596
-0.03
520
19.2
19.231
0.16
259
57.6
57.471
-0.22
86
115.2
116.279
0.94
42
Actual
Rate
(K)
%
Error
0.3
0.300
1.2
1.200
2.4
SPBRG
value
%
Error
8332
300
-0.01
6665
2082
1200
-0.04
1665
0.06
1040
2400
-0.04
832
9.615
0.16
259
9615
-0.16
207
19.231
0.16
129
19230
-0.16
103
58.140
0.94
42
57142
0.79
34
113.636
-1.36
21
117647
-2.12
16
SPBRG
value
(decimal)
SPBRG
value
(decimal)
%
Error
3332
300
-0.04
832
1201
-0.16
0.16
415
2403
9.615
0.16
103
19.231
0.16
Actual
Rate
(K)
%
Error
0.3
0.300
0.01
1.2
1.200
0.04
2.4
2.404
9.6
19.2
%
Error
1665
300
-0.04
832
415
1201
-0.16
207
-0.16
207
2403
-0.16
103
9615
-0.16
51
9615
-0.16
25
51
19230
-0.16
25
19230
-0.16
12
SPBRG
value
(decimal)
SPBRG
value
(decimal)
SPBRG
value
(decimal)
57.6
58.824
2.12
16
55555
3.55
115.2
111.111
-3.55
DS41262A-page 138
Preliminary
PIC16F685/687/689/690
12.2.2
AUTO-BAUD DETECT
TABLE 12-4:
BRG16
BRGH
FOSC/512
FOSC/128
FOSC/128
FOSC/32
1
Note:
Preliminary
DS41262A-page 139
PIC16F685/687/689/690
FIGURE 12-1:
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
XXXXh
1Ch
SPBRGH
XXXXh
00h
Note
1:
DS41262A-page 140
The ABD sequence requires the EUSART module to be configured in Asynchronous mode and WUE = 0.
Preliminary
PIC16F685/687/689/690
12.3
12.3.1
EUSART ASYNCHRONOUS
TRANSMITTER
2.
3.
4.
5.
6.
7.
Preliminary
DS41262A-page 141
PIC16F685/687/689/690
FIGURE 12-2:
TXREG Register
TXIE
8
MSb
RB7/TX/CK Pin
LSb
(8)
Pin Buffer
and Control
TSR Register
Interrupt
Baud Rate CLK
TXEN
TRMT
BRG16
SPBRGH
SPEN
SPBRG
TX9
TX9D
FIGURE 12-3:
ASYNCHRONOUS TRANSMISSION
Write to TXREG
BRG Output
(Shift Clock)
Word 1
RB7/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
RB7/TX/CK
pin
TXIF bit
(Interrupt Reg. Flag)
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
TRMT bit
(Transmit Shift
Reg. Empty Flag)
Note:
Word 1
Transmit Shift Reg.
Word 2
Transmit Shift Reg.
DS41262A-page 142
Preliminary
PIC16F685/687/689/690
TABLE 12-5:
Addr
Name
0Ch
PIR1
18h
RCSTA
Bit 6
Bit 5
ADIF
RCIF
SPEN
RX9
SREN
Bit 4
Value on
POR, BOR
Value on
all other
Resets
Bit 3
Bit 2
Bit 1
Bit 0
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
CREN
ADDEN
FERR
OERR
RX9D
0000 000X
0000 000X
0000 0000
19h
TXREG
0000 0000
1Ah
RCREG
0000 0000
0000 0000
86h
TRISB
8Ch
PIE1
98h
TXSTA
99h
SPBRG
9Ah
9Bh
TRISB7
TRISB6
ADIE
CSRC
TX9
BRG7
BRG6
SPBRGH
BRG15
BAUDCTL
ABDOVF
Legend:
Note
TRISB5
TRISB4
1111 ----
1111 ----
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
x = unknown, - = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Transmission.
1:
PIC16F687/PIC16F689/PIC16F690 only.
Preliminary
DS41262A-page 143
PIC16F685/687/689/690
12.3.2
EUSART ASYNCHRONOUS
RECEIVER
12.3.3
FIGURE 12-5:
OERR
FERR
RCIDL
SPBRGH
SPBRG
64
or
16
or
4
RSR Register
MSb
(8)
Stop
LSb
0
Start
RX9
RB5/AN11/
RX/DT Pin
Pin Buffer
and Control
Data
Recovery
RX9D
RCREG Register
FIFO
SPEN
8
Interrupt
RCIF
Data Bus
RCIE
DS41262A-page 144
Preliminary
PIC16F685/687/689/690
FIGURE 12-6:
ASYNCHRONOUS RECEPTION
Start
bit
bit 0
RB5/AN11/
RX/DT Pin
bit 1
Rcv Shift
Reg.
Rcv. Buffer Reg.
Start
bit
bit 0
bit 7/8
Stop
bit
Word 2
RCREG
Word 1
RCREG
RCIDL
Start
bit
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.
TABLE 12-6:
Addr
Name
Bit 6
Bit 5
ADIF
RCIF
SPEN
RX9
SREN
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
CREN
ADDEN
FERR
OERR
RX9D
0000 000X
0000 000X
Bit 4
0Ch
PIR1
18h
RCSTA
19h
TXREG
0000 0000
0000 0000
1Ah
RCREG
0000 0000
0000 0000
86h
TRISB
8Ch
PIE1
98h
TXSTA
CSRC
99h
SPBRG
BRG7
9Ah
SPBRGH
BRG15
9Bh
BAUDCTL
ABDOVF
Legend:
Note
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
ADIE
RCIE
TXIE
SSPIE
CCPIE
TMR2IE
TMR1IE
-000 0000
-000 0000
TX9
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
x = unknown, = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Reception.
1:
PIC16F687/PIC16F689/PIC16F690 only.
Preliminary
DS41262A-page 145
PIC16F685/687/689/690
12.3.4
AUTO-WAKE-UP ON RX PIN
FALLING EDGE
12.3.4.1
3.
4.
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:
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
DS41262A-page 146
Sleep Ends
Preliminary
PIC16F685/687/689/690
12.3.5
12.3.5.1
12.3.6
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 Buffer
Reg. Empty Flag)
TRMT bit
(Transmit Shift
Reg. Empty Flag)
SENB Sampled Here
Auto Cleared
SENB
(Transmit Shift
Reg. Empty Flag)
Preliminary
DS41262A-page 147
PIC16F685/687/689/690
12.4
12.4.1
3.
4.
5.
6.
7.
8.
FIGURE 12-10:
SYNCHRONOUS TRANSMISSION
Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4
RB5/AN11/
RX/DT pin
bit 0
RB7/
TX/CK pin
(SCKP = 0)
bit 1
Word 1
bit 2
Q3Q4 Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4
bit 7
bit 0
bit 1
Word 2
bit 7
RB7/
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.
DS41262A-page 148
Preliminary
PIC16F685/687/689/690
FIGURE 12-11:
RB5/AN11/RX/DT pin
bit 0
bit 2
bit 1
bit 6
bit 7
RB7/TX/CK pin
Write to
TXREG Reg
TXIF bit
TRMT bit
TXEN bit
TABLE 12-7:
Addr
Name
0Ch
PIR1
18h
RCSTA
Bit 6
Bit 5
ADIF
RCIF
SPEN
RX9
SREN
Bit 4
Value on
POR, BOR
Value on
all other
Resets
Bit 3
Bit 2
Bit 1
Bit 0
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
CREN
ADDEN
FERR
OERR
RX9D
0000 000X
0000 000X
19h
TXREG
0000 0000
0000 0000
1Ah
RCREG
0000 0000
0000 0000
86h
TRISB
8Ch
PIE1
TRISB7
TRISB6
TRISB5
TRISB4
1111 ----
1111 ----
ADIE
RCIE
TXIE
SSPIE
CCPIE
TMR2IE
TMR1IE
-000 0000
98h
-000 0000
TXSTA
CSRC
TX9
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
99h
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
9Ah
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
9Bh
BAUDCTL
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
Legend:
Note
x = unknown, = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Reception.
1:
PIC16F687/PIC16F689/PIC16F690 only.
Preliminary
DS41262A-page 149
PIC16F685/687/689/690
12.4.2
3.
4.
5.
6.
2.
FIGURE 12-12:
Q2 Q3Q4Q1Q2Q3Q4Q1Q2 Q3Q4 Q1Q2Q3Q4Q1Q2 Q3Q4 Q1Q2Q3Q4Q1Q2Q3 Q4 Q1Q2 Q3Q4 Q1Q2Q3 Q4 Q1Q2 Q3Q4 Q1Q2Q3Q4
RB5/AN11/
RX/DT pin
bit 0
bit 1
bit 2
bit 3
bit 4
bit 5
bit 6
bit 7
RB7/
TX/CK pin
(SCKP = 0)
RB7/
TX/CK pin
(SCKP = 1)
Write to
bit SREN
SREN bit
CREN bit
RCIF bit
(Interrupt)
Read
RXREG
Note:
Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
DS41262A-page 150
Preliminary
PIC16F685/687/689/690
TABLE 12-8:
Addr
Name
Bit 6
Bit 5
ADIF
RCIF
SPEN
RX9
SREN
0Ch
PIR1
18h
RCSTA
19h
TXREG
1Ah
RCREG
86h
TRISB
TRISB7
TRISB6
TRISB5
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
CREN
ADDEN
FERR
OERR
RX9D
0000 000X
0000 000X
0000 0000
0000 0000
Bit 4
0000 0000
0000 0000
TRISB4
1111 ----
1111 ----
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
CCPIE
TMR2IE
TMR1IE
-000 0000
-000 0000
98h
TXSTA
CSRC
TX9
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
99h
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
9Ah
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
9Bh
BAUDCTL
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
Legend:
Note
x = unknown, = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Reception.
1:
PIC16F687/PIC16F689/PIC16F690 only.
Preliminary
DS41262A-page 151
PIC16F685/687/689/690
12.5
12.5.1
2.
3.
4.
5.
6.
7.
8.
9.
b)
c)
d)
e)
TABLE 12-9:
Addr
Name
0Ch
PIR1
18h
RCSTA
Bit 7
Bit 6
Bit 5
ADIF
RCIF
SPEN
RX9
SREN
Bit 4
Value on
POR, BOR
Value on
all other
Resets
Bit 3
Bit 2
Bit 1
Bit 0
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
CREN
ADDEN
FERR
OERR
RX9D
0000 000X
0000 000X
0000 0000
19h
TXREG
0000 0000
1Ah
RCREG
0000 0000
0000 0000
86h
TRISB
1111 ----
1111 ----
8Ch
PIE1
98h
TXSTA
TRISB7
TRISB6
ADIE
CSRC
TX9
TRISB5
TRISB4
RCIE
TXIE
SSPIE
CCPIE
TMR2IE
TMR1IE
-000 0000
-000 0000
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
99h
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
9Ah
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
9Bh
BAUDCTL
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
Legend:
Note
x = unknown, = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Reception.
1:
PIC16F687/PIC16F689/PIC16F690 only.
DS41262A-page 152
Preliminary
PIC16F685/687/689/690
12.5.2
2.
3.
4.
5.
6.
7.
8.
9.
Name
Bit 7
Bit 6
Bit 5
ADIF
RCIF
SPEN
RX9
SREN
0Ch
PIR1
18h
RCSTA
19h
TXREG
1Ah
RCREG
86h
TRISB
TRISB7
TRISB6
TRISB5
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR, BOR
Value on
all other
Resets
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
-000 0000
CREN
ADDEN
FERR
OERR
RX9D
0000 000X
0000 000X
0000 0000
0000 0000
Bit 4
0000 0000
0000 0000
TRISB4
1111 ----
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
CCPIE
TMR2IE
TMR1IE
-000 0000
98h
TXSTA
CSRC
TX9
TXEN
SYNC
SENB
BRGH
TRMT
TX9D
0000 0010
0000 0010
99h
SPBRG
BRG7
BRG6
BRG5
BRG4
BRG3
BRG2
BRG1
BRG0
0000 0000
0000 0000
9Ah
SPBRGH
BRG15
BRG14
BRG13
BRG12
BRG11
BRG10
BRG9
BRG8
0000 0000
0000 0000
9Bh
BAUDCTL
ABDOVF
RCIDL
SCKP
BRG16
WUE
ABDEN
01-0 0-00
01-0 0-00
Legend:
Note
x = unknown, = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Reception.
1:
PIC16F687/PIC16F689/PIC16F690 only.
Preliminary
DS41262A-page 153
PIC16F685/687/689/690
NOTES:
DS41262A-page 154
Preliminary
PIC16F685/687/689/690
13.0
FIGURE 13-1:
Internal
Data Bus
Read
Write
SSPBUF reg
RB4/AN10/
SDI/SDA
13.1
SSPSR reg
Shift
Clock
bit 0
SPI Mode
RC7/AN9/
SDO
Peripheral OE
SS Control
Enable
RC6/AN8/
SS
Edge
Select
2
Clock Select
SSPM<3:0>
4
Edge
Select
RB6/SCK/
SCL
TMR2 Output
2
Prescaler TCY
4, 16, 64
TRISB<6>
Preliminary
DS41262A-page 155
PIC16F685/687/689/690
REGISTER 13-1:
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
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
DS41262A-page 156
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F685/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
WCOL
SSPOV
SSPEN
CKP
SSPM3(2)
SSPM2(2)
SSPM1(2)
SSPM0(2)
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3-0
PIC16F687/PIC16F689/PIC16F690 only.
When this mode is selected, any reads or writes to the SSPADD SFR address actually
accesses the SSPMSK register.
Legend:
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS41262A-page 157
PIC16F685/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
DS41262A-page 158
;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
Preliminary
PIC16F685/687/689/690
13.3
13.4
Typical Connection
FIGURE 13-2:
SDO
SDI
SDI
Shift Register
(SSPSR)
MSb
SDO
LSb
MSb
SCK
Serial Clock
Processor 1
Shift Register
(SSPSR)
LSb
SCK
Processor 2
Preliminary
DS41262A-page 159
PIC16F685/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 0
bit 7
Input
Sample
(SMP = 1)
SSPIF
Next Q4 Cycle
after Q2
SSPSR to
SSPBUF
DS41262A-page 160
Preliminary
PIC16F685/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
Next Q4 Cycle
after Q2
Preliminary
DS41262A-page 161
PIC16F685/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
Next Q4 Cycle
after Q2
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 5
bit 4
bit 3
bit 2
bit 1
bit 0
bit 0
bit 7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 Cycle
after Q2
SSPSR to
SSPBUF
DS41262A-page 162
Preliminary
PIC16F685/687/689/690
13.8
Sleep Operation
TABLE 13-1:
13.9
Effects of a Reset
Standard SPI
Mode Terminology
CKP
CKE
0, 0
0, 1
1, 0
1, 1
TABLE 13-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
0Bh/8Bh/
INTCON
10Bh/18Bh
GIE
PEIE
T0IE
INTE
RABIE
T0IF
INTF
RABIF
0000 000x
0000 000x
ADIF
RCIF
TXIF
SSPIF
Address
-000 0000
-000 0000
xxxx xxxx
uuuu uuuu
SSPM0
0000 0000
0000 0000
1111 ----
1111 ----
0Ch
PIR1
13h
SSPBUF
14h
SSPCON
WCOL
SSPOV
SSPEN
CKP
SSPM3
SSPM2
SSPM1
86h/186h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
87h/187h
TRISC
8Ch
PIE1
94h
SSPSTAT
Legend:
Note
ADIE
RCIE
TXIE
SSPIE
SMP
CKE
D/A
UA
BF
1111 1111
1111 1111
-000 0000
-000 0000
0000 0000
0000 0000
x = unknown, u = unchanged, - = unimplemented, read as 0. Shaded cells are not used by the SSP in SPI mode.
1:
PIC16F687/PIC16F689/PIC16F690 only.
Preliminary
DS41262A-page 163
PIC16F685/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:
Internal
Data Bus
Read
Write
SSPBUF reg
SSPSR reg
Shift
Clock
RB4/
AN10/
SDI/SDA
RB6/
SCK/
SCL
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.
DS41262A-page 164
b)
Preliminary
PIC16F685/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.
Preliminary
DS41262A-page 165
PIC16F685/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.
DS41262A-page 166
Preliminary
PIC16F685/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
MSK7
MSK6
MSK5
MSK4
MSK3
MSK2
MSK1
MSK0(2)
bit 7
bit 0
bit 7-1
bit 0
13.12.4
R = Readable bit
W = Writable bit
- n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
Preliminary
DS41262A-page 167
DS41262A-page 168
Preliminary
5
6
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
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
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:
PIC16F685/687/689/690
I2C SLAVE MODE TIMING (RECEPTION, 10-BIT ADDRESS)
PIC16F685/687/689/690
13.12.5
TRANSMISSION
FIGURE 13-10:
SDA
SCL
A7
A6
1
2
Data in
sampled
R/W = 1
A5
A4
A3
A2
A1
ACK
Transmitting Data
ACK
D7
1
SCL held low
while CPU
responds to SSPIF
D6
D5
D4
D3
D2
D1
D0
Cleared in software
SSPIF (PIR1<3>)
BF (SSPSTAT<0>)
CKP (SSPCON<4>)
Set bit after writing to SSPBUF
(the SSPBUF must be written to
before the CKP bit can be set)
Preliminary
DS41262A-page 169
DS41262A-page 170
Preliminary
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
PIC16F685/687/689/690
I2C SLAVE MODE TIMING (TRANSMISSION, 10-BIT ADDRESS)
PIC16F685/687/689/690
13.13 Master Mode
13.14.1
Preliminary
DS41262A-page 171
PIC16F685/687/689/690
FIGURE 13-12:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
SDA
DX
DX-1
SCL
Master device
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.
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.
DS41262A-page 172
Preliminary
PIC16F685/687/689/690
14.0
Preliminary
DS41262A-page 173
PIC16F685/687/689/690
14.1
Configuration Bits
Note:
REGISTER 14-1:
bit 13
bit 0
bit 13-12
bit 11
bit 10
bit 9-8
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2-0
1:
2:
3:
4:
Legend:
R = Readable
-n = Value at POR
DS41262A-page 174
W = Writable bit
1 = Bit is set
Preliminary
x = Bit is unknown
PIC16F685/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:
Preliminary
DS41262A-page 175
PIC16F685/687/689/690
14.2.1
14.2.3
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:
14.2.2
MCLR
DS41262A-page 176
Preliminary
PIC16F685/687/689/690
14.2.4
Note:
FIGURE 14-2:
BROWN-OUT SITUATIONS
VDD
Internal
Reset
VBOR
64 ms(1)
VDD
Internal
Reset
VBOR
< 64 ms
64 ms(1)
VDD
VBOR
Internal
Reset
Note 1:
64 ms(1)
Preliminary
DS41262A-page 177
PIC16F685/687/689/690
14.2.5
TIME-OUT SEQUENCE
14.2.6
TABLE 14-1:
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
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(1)
03h/83h/
103h/183h
STATUS
IRP
RP1
RPO
TO
PD
DC
0001 1xxx
000q quuu
8Eh
PCON
ULPWUE
SBOREN
POR
BOR
--01 --qq
--0u --uu
Addr
Legend:
Note 1:
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.
DS41262A-page 178
Preliminary
PIC16F685/687/689/690
FIGURE 14-3:
VDD
MCLR
Internal POR
TPWRT
PWRT Time-out
TOST
OST Time-out
Internal Reset
FIGURE 14-4:
VDD
MCLR
Internal POR
TPWRT
PWRT Time-out
TOST
OST Time-out
Internal Reset
FIGURE 14-5:
MCLR
Internal POR
TPWRT
PWRT Time-out
TOST
OST Time-out
Internal Reset
Preliminary
DS41262A-page 179
PIC16F685/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
--00 0000
--uu uuuu
PORTB
06h/106h
xxxx ----
0000 ----
uuuu ----
PORTC
07h/107h
xxxx xxxx
0000 0000
uuuu uuuu
PCLATH
0Ah/8Ah/
10Ah/18Ah
---0 0000
---0 0000
---u uuuu
INTCON
0Bh/8Bh/
10Bh/18Bh
0000 000x
0000 000x
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
xxxx xxxx
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:
DS41262A-page 180
Preliminary
PIC16F685/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 --qq
OSCCON
8Fh
-110 q000
-110 x000
-uuu uuuu
OSCTUNE
90h
---0 0000
---u uuuu
---u uuuu
PR2
92h
1111 1111
1111 1111
1111 1111
SSPADD
93h
0000 0000
1111 1111
uuuu uuuu
(6)
--0u --uu
--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:
Preliminary
DS41262A-page 181
PIC16F685/687/689/690
TABLE 14-5:
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 --10
PC + 1(1)
uuu1 0uuu
--uu --uu
DS41262A-page 182
Preliminary
PIC16F685/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
14.3.2
Preliminary
TMR0 INTERRUPT
DS41262A-page 183
PIC16F685/687/689/690
14.3.3
PORTA/PORTB INTERRUPT
FIGURE 14-6:
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
Interrupt to CPU
INTF
INTE
RABIF
RABIE
TMR1IF
TMR1IE
C1IF
C1IE
PEIE
C2IF
C2IE
GIE
ADIF
ADIE
EEIF
EEIE
Note 1:
OSFIF
OSFIE
CCP1IF
CCP1IE
DS41262A-page 184
Preliminary
PIC16F685/687/689/690
FIGURE 14-7:
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
Instruction
Executed
Note 1:
Inst (PC + 1)
Inst (PC)
0005h
Inst (0004h)
Inst (0005h)
Dummy Cycle
Inst (0004h)
Dummy Cycle
Inst (PC)
0004h
PC + 1
PC + 1
Inst (PC 1)
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:
Address
PC
Name
0Bh/8Bh/
INTCON
10Bh/18Bh
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
-000 0000
0Ch
PIR1
ADIF
RCIF
TXIF
SSPIF
CCP1IF
TMR2IF
TMR1IF
-000 0000
0Dh
PIR2
OSFIF
C2IF
C1IF
EEIF
0000 ----
0000 ----
8Ch
PIE1
ADIE
RCIE
TXIE
SSPIE
CCP1IE
TMR2IE
TMR1IE
-000 0000
-000 0000
8Dh
PIE2
OSFIE
C2IE
C1IE
EEIE
0000 ----
0000 ----
Legend:
Preliminary
DS41262A-page 185
PIC16F685/687/689/690
14.4
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
DS41262A-page 186
Preliminary
PIC16F685/687/689/690
14.5
14.5.2
14.5.1
WDT OSCILLATOR
FIGURE 14-8:
WDT CONTROL
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
WDT
WDTE = 0
Cleared
CLRWDT Command
Oscillator Fail Detected
Exit Sleep + System Clock = T1OSC, EXTRC, INTOSC, EXTCLK
Exit Sleep + System Clock = XT, HS, LP
Preliminary
DS41262A-page 187
PIC16F685/687/689/690
REGISTER 14-2:
U-0
U-0
R/W-0
R/W-1
R/W-0
WDTPS3
WDTPS2
WDTPS1
R/W-0
R/W-0
WDTPS0 SWDTEN(1)
bit 7
bit 0
bit 7-5
Unimplemented: Read as 0
bit 4-1
bit 0
TABLE 14-8:
Address
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
97h
WDTCON
81h/181h
OPTION_REG
2007h
(1)
Legend:
Note 1:
x = Bit is unknown
CONFIG
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
WDTPS3
WDTPS2
WSTPS1
WDTPS0
SWDTEN
RABPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
CPD
CP
MCLRE
PWRTE
WDTE
FOSC2
FOSC1
FOSC0
DS41262A-page 188
Preliminary
PIC16F685/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.
9.
14.6.2
Preliminary
DS41262A-page 189
PIC16F685/687/689/690
FIGURE 14-9:
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>)
Processor in
Sleep
Instruction Flow
PC
Instruction
Fetched
Instruction
Executed
Note
14.7
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
DS41262A-page 190
Preliminary
PIC16F685/687/689/690
FIGURE 14-10:
TYPICAL IN-CIRCUIT
SERIAL PROGRAMMING
CONNECTION
To Normal
Connections
External
Connector
Signals
PIC16F685/
687/689/690
+5V
VDD
0V
VSS
VPP
RA3/MCLR/VPP
CLK
RA1
Data I/O
RA0
To Normal
Connections
*
Preliminary
DS41262A-page 191
PIC16F685/687/689/690
NOTES:
DS41262A-page 192
Preliminary
PIC16F685/687/689/690
15.0
TABLE 15-1:
Field
Description
PC
Program Counter
TO
Time-out bit
PD
Power-down bit
FIGURE 15-1:
OPCODE FIELD
DESCRIPTIONS
Read-Modify-Write Operations
0
k (literal)
0
f (FILE #)
OPCODE
15.1
Preliminary
11
OPCODE
10
0
k (literal)
DS41262A-page 193
PIC16F685/687/689/690
TABLE 15-2:
Mnemonic,
Operands
14-Bit Opcode
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 PORTA, 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.
DS41262A-page 194
Preliminary
PIC16F685/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:
f,b
Preliminary
DS41262A-page 195
PIC16F685/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]
Operation:
(f) (destination)
Status Affected:
Description:
DECF
Decrement f
Syntax:
f,d
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:
DS41262A-page 196
Preliminary
PIC16F685/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:
GOTO k
INCF f,d
Preliminary
INCFSZ f,d
IORWF
f,d
DS41262A-page 197
PIC16F685/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
0x5A
After Instruction
W =
DS41262A-page 198
NOP
0x5A
Preliminary
PIC16F685/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
ADDWF PC ;W = offset
RETLW k1 ;Begin table
RETLW k2 ;
RETFIE
After Interrupt
PC =
GIE =
RETLW k
TABLE
TOS
1
Before Instruction
W = 0x07
After Instruction
W = value of k8
RETURN
Syntax:
[ label ]
Operands:
None
Operation:
TOS PC
RETURN
Status Affected:
None
Description:
Preliminary
DS41262A-page 199
PIC16F685/687/689/690
RLF
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operation:
Status Affected:
Description:
RLF
Words:
Cycles:
Example
f,d
RLF
REG1,0
REG1
C
=
=
1110 0110
0
=
=
=
1110 0110
1100 1100
1
After Instruction
REG1
W
C
Syntax:
[ label ] SLEEP
Operands:
None
Operation:
00h WDT,
0 WDT prescaler,
1 TO,
0 PD
Status Affected:
TO, PD
Description:
SUBLW
Syntax:
[ label ] SUBLW k
Operands:
0 k 255
Operation:
k - (W) (W)
SUBWF
Subtract W from f
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operation:
Register f
Before Instruction
RRF
SLEEP
RRF f,d
Status Affected:
Description:
DS41262A-page 200
Syntax:
Operands:
0 f 127
d [0,1]
Operation:
Register f
Preliminary
PIC16F685/687/689/690
SWAPF
Swap Nibbles in f
Syntax:
Operands:
0 f 127
d [0,1]
Operation:
(f<3:0>) (destination<7:4>),
(f<7:4>) (destination<3:0>)
Status Affected:
None
Description:
XORLW
Syntax:
[ label ] XORLW k
Operands:
0 k 255
Operation:
Status Affected:
Description:
XORWF
Exclusive OR W with f
Syntax:
[ label ] XORWF
Operands:
0 f 127
d [0,1]
Operation:
Status Affected:
Description:
f,d
Preliminary
DS41262A-page 201
PIC16F685/687/689/690
NOTES:
DS41262A-page 202
Preliminary
PIC16F685/687/689/690
16.0
DEVELOPMENT SUPPORT
16.1
16.2
MPASM Assembler
Preliminary
DS41262A-page 203
PIC16F685/687/689/690
16.3
16.6
16.4
16.5
DS41262A-page 204
16.7
The MPLAB SIM software simulator allows code development in a PC hosted environment by simulating the
PICmicro series microcontrollers on an instruction
level. On any given instruction, the data areas can be
examined or modified and stimuli can be applied from
a file, or user defined key press, to any pin. The execution can be performed in Single-Step, Execute Until
Break or Trace mode.
The MPLAB SIM simulator fully supports symbolic
debugging using the MPLAB C17 and MPLAB C18
C Compilers, as well as the MPASM assembler. The
software simulator offers the flexibility to develop and
debug code outside of the laboratory environment,
making it an excellent, economical software
development tool.
16.8
Preliminary
PIC16F685/687/689/690
16.9
Preliminary
DS41262A-page 205
PIC16F685/687/689/690
16.14 PICSTART Plus Development
Programmer
DS41262A-page 206
Preliminary
PIC16F685/687/689/690
16.20 PICDEM 17 Demonstration Board
The PICDEM 17 demonstration board is an evaluation
board that demonstrates the capabilities of several
Microchip microcontrollers, including PIC17C752,
PIC17C756A, PIC17C762 and PIC17C766. A programmed sample is included. The PRO MATE II device
programmer, or the PICSTART Plus development programmer, can be used to reprogram the device for user
tailored application development. The PICDEM 17
demonstration board supports program download and
execution from external on-board Flash memory. A
generous prototype area is available for user hardware
expansion.
Preliminary
DS41262A-page 207
PIC16F685/687/689/690
NOTES:
DS41262A-page 208
Preliminary
PIC16F685/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.
Preliminary
DS41262A-page 209
PIC16F685/687/689/690
FIGURE 17-1:
5.5
5.0
4.5
VDD
(Volts)
4.0
3.5
3.0
2.5
2.0
0
10
12
16
20
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
DS41262A-page 210
Preliminary
PIC16F685/687/689/690
17.1
DC CHARACTERISTICS
Param
No.
Sym
VDD
Characteristic
Typ
Max Units
Conditions
2.0
3.0
4.5
5.5
5.5
5.5
V
V
V
1.5*
Supply Voltage
D001
D001C
D001D
D002
VDR
D003
VPOR
VSS
D004
SVDD
0.05*
D005
VBOR
2.175
Preliminary
DS41262A-page 211
PIC16F685/687/689/690
17.2
DC CHARACTERISTICS
Param
No.
D010
Conditions
Device Characteristics
Min
Typ
Max
Units
VDD
D011
D012
D013
D014
D015
D016
D017
D018
(1, 2)
TBD
2.0
18
TBD
3.0
35
TBD
5.0
110
TBD
2.0
190
TBD
3.0
330
TBD
5.0
220
TBD
2.0
370
TBD
3.0
0.6
TBD
mA
5.0
70
TBD
2.0
140
TBD
3.0
260
TBD
5.0
180
TBD
2.0
320
TBD
3.0
580
TBD
5.0
TBD
TBD
2.0
TBD
TBD
3.0
TBD
TBD
mA
5.0
340
TBD
2.0
500
TBD
3.0
0.8
TBD
mA
5.0
180
TBD
2.0
320
TBD
3.0
580
TBD
5.0
2.1
TBD
mA
4.5
2.4
TBD
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
INTOSC mode
FOSC = 8 MHz
INTOSC mode
FOSC = 4 MHz
EXTRC mode
FOSC = 20 MHz
HS Oscillator mode
DS41262A-page 212
Preliminary
PIC16F685/687/689/690
17.2
DC CHARACTERISTICS
Param
No.
D020
Device Characteristics
Power-down Base
Current (IPD)(4)
D021
D022
D023
D024
D025
D026
D027
Min
Typ
Max
Units
VDD
Note
WDT, BOR, Comparators, VREF and
T1OSC disabled
0.1
TBD
2.0
0.4
TBD
3.0
0.8
TBD
5.0
0.3
TBD
2.0
1.8
TBD
3.0
8.4
TBD
5.0
58
TBD
3.0
109
TBD
5.0
3.3
TBD
2.0
6.1
TBD
3.0
11.5
TBD
5.0
58
TBD
2.0
85
TBD
3.0
138
TBD
5.0
4.0
TBD
2.0
4.6
TBD
3.0
6.0
TBD
5.0
1.2
TBD
nA
3.0
2.2
TBD
nA
5.0
TBD
TBD
3.0
TBD
TBD
5.0
WDT Current
BOR Current
Comparator Current(3)
CVREF Current
T1OSC Current
A/D Current
VP6 Current
Preliminary
DS41262A-page 213
PIC16F685/687/689/690
17.3
DC CHARACTERISTICS
Param
No.
Device Characteristics
D011E
D012E
D013E
D014E
D015E
D016E
D017E
D018E
Min
Typ
Max
Units
VDD
TBD
2.0
18
TBD
3.0
35
TBD
5.0
110
TBD
2.0
190
TBD
3.0
330
TBD
5.0
220
TBD
2.0
370
TBD
3.0
0.6
TBD
mA
5.0
70
TBD
2.0
140
TBD
3.0
260
TBD
5.0
180
TBD
2.0
320
TBD
3.0
580
TBD
5.0
TBD
TBD
2.0
TBD
TBD
3.0
TBD
TBD
mA
5.0
340
TBD
2.0
500
TBD
3.0
0.8
TBD
mA
5.0
180
TBD
2.0
320
TBD
3.0
580
TBD
5.0
2.1
TBD
mA
4.5
2.4
TBD
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
INTOSC mode
FOSC = 8 MHz
INTOSC mode
FOSC = 4 MHz
EXTRC mode
FOSC = 20 MHz
HS Oscillator mode
DS41262A-page 214
Preliminary
PIC16F685/687/689/690
17.3
DC CHARACTERISTICS
Param
No.
Device Characteristics
D021E
Min
Typ
Max
Units
VDD
Note
WDT, BOR, Comparators, VREF and
T1OSC disabled
0.1
TBD
2.0
0.4
TBD
3.0
0.8
TBD
5.0
0.3
TBD
2.0
1.8
TBD
3.0
8.4
TBD
5.0
D022E
58
TBD
3.0
109
TBD
5.0
D023E
3.3
TBD
2.0
D024E
D025E
D026E
D027E
6.1
TBD
3.0
11.5
TBD
5.0
58
TBD
2.0
85
TBD
3.0
138
TBD
5.0
4.0
TBD
2.0
4.6
TBD
3.0
6.0
TBD
5.0
1.2
TBD
nA
3.0
2.2
TBD
nA
5.0
TBD
TBD
3.0
TBD
TBD
5.0
WDT Current
BOR Current
Comparator Current(3)
CVREF Current
T1OSC Current
A/D Current(3)
VP6 Current
Preliminary
DS41262A-page 215
PIC16F685/687/689/690
17.4
DC CHARACTERISTICS
Param
No.
Sym
VIL
Characteristic
Typ
Max
Units
Vss
Vss
Conditions
0.8
0.15 VDD
Otherwise
Vss
0.2 VDD
Entire range
D030
D030A
D031
D032
VSS
0.2 VDD
D033
VSS
0.3 VDD
D033A
VSS
0.6 VDD
1.0
D0033B
VSS
0.1 VDD
VIH
D040
D040A
D041
2.0
(0.25 VDD + 0.8)
VDD
VDD
V
V
0.8 VDD
VDD
Entire range
D042
MCLR, PORTA
0.8 VDD
VDD
D043
0.7 VDD
VDD
D043A
0.9 VDD
VDD
50*
50*
250
250
400*
400*
A
A
D070
IPUR
IIL
(Note 1)
(Note 1)
D060
I/O port
D061
MCLR(3)
D063
OSC1
I/O port
0.6
OSC2/CLKOUT
0.6
VOL
D080
D083
*
Note 1:
2:
3:
4:
DS41262A-page 216
Preliminary
PIC16F685/687/689/690
17.4
DC CHARACTERISTICS
Param
No.
Sym
VOH
Characteristic
Typ
Max
Units
Conditions
D090
I/O port
VDD 0.7
D092
OSC2/CLKOUT
VDD 0.7
200
nA
15*
pF
50*
pF
100K
1M
E/W
D100
IULP
D100
D101
CIO
ED
Byte Endurance
D120A
ED
Byte Endurance
10K
100K
E/W
D121
VDRW
VMIN
5.5
-40C TA +85C
+85C TA +125C
Using EECON1 to read/write
VMIN = Minimum operating
voltage
D122
TDEW
ms
D123
TRETD
Characteristic Retention
40
Year
Provided no other
specifications are violated
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
+85C TA +125C
D131
VPR
VMIN
5.5
D132
VPEW
4.5
5.5
D133
TPEW
2.5
ms
D134
TRETD
Characteristic Retention
40
Year
Note 1:
2:
3:
4:
Provided no other
specifications are violated
Preliminary
DS41262A-page 217
PIC16F685/687/689/690
17.5
Frequency
Time
osc
OSC1
RC
ck
CLKOUT
rd
RD
cs
CS
rw
RD or WR
di
SDI
sc
SCK
do
SDO
ss
SS
dt
Data in
t0
T0CKI
io
I/O port
t1
T1CKI
mc
MCLR
wr
WR
Fall
Period
High
Rise
Invalid (High-impedance)
Valid
Low
High-impedance
FIGURE 17-2:
LOAD CONDITIONS
Load Condition 1
Load Condition 2
VDD/2
RL
CL
Pin
CL
Pin
VSS
VSS
RL = 464
CL = 50 pF
15 pF
DS41262A-page 218
Preliminary
PIC16F685/687/689/690
17.6
FIGURE 17-3:
Q1
Q2
Q3
Q4
Q1
OSC1
1
2
CLKOUT
TABLE 17-1:
Sym
FOSC
2
3
TOSC
TCY
TosL,
TosH
TosR,
TosF
Characteristic
Min
Typ
Max
Units
DC
DC
DC
DC
37
4
20
20
kHz
MHz
MHz
MHz
LP Oscillator mode
XT Oscillator mode
HS Oscillator mode
EC Oscillator mode
Oscillator Frequency(1)
TBD
0.1
1
32
4
20
MHz
MHz
kHz
MHz
MHz
27
50
50
250
s
ns
ns
ns
LP Oscillator mode
HS Oscillator mode
EC Oscillator mode
XT Oscillator mode
Oscillator Period(1)
250
250
50
31
125
TBD
10,000
1,000
s
ns
ns
ns
ns
LP Oscillator mode
INTOSC Oscillator mode
RC Oscillator mode
XT Oscillator mode
HS Oscillator mode
200
2*
20*
TCY
ns
s
ns
100 *
50*
25*
15*
ns
ns
ns
ns
TCY = 4/FOSC
LP oscillator, TOSC L/H duty cycle
HS oscillator, TOSC L/H duty cycle
XT oscillator, TOSC L/H duty cycle
LP oscillator
XT oscillator
HS oscillator
Conditions
Preliminary
DS41262A-page 219
PIC16F685/687/689/690
TABLE 17-2:
F14
Sym
FOSC
Characteristic
Internal Calibrated
INTOSC Frequency(1)
Freq
Min
Tolerance
Typ
Max
Units
1%
2%
8.00
8.00
TBD
TBD
5%
8.00
TBD
TBD
TBD
TBD
TBD
TBD
TBD
Conditions
DS41262A-page 220
Preliminary
PIC16F685/687/689/690
FIGURE 17-4:
Q4
Q2
Q3
OSC1
11
10
22
23
CLKOUT
13
12
19
14
18
16
I/O pin
(Input)
15
17
I/O pin
(Output)
New Value
Old Value
20, 21
TABLE 17-3:
Sym
Characteristic
Min
Typ
Max
Units
Conditions
10
75
200
ns
(Note 1)
11
75
200
ns
(Note 1)
12
TCKR
35
100
ns
(Note 1)
13
TCKF
35
100
ns
(Note 1)
14
TCKL2IOV
20
ns
(Note 1)
TOSC + 200 ns
ns
(Note 1)
ns
(Note 1)
15
16
TCKH2IOI
17
50
150*
ns
300
ns
100
ns
18
TOSH2IOI
19
ns
20
TIOR
10
40
ns
21
TIOF
10
40
ns
22
TINP
25
ns
23
TRBP
TCY
ns
Preliminary
DS41262A-page 221
PIC16F685/687/689/690
FIGURE 17-5:
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out
32
OSC
Time-out
Internal
Reset
Watchdog
Timer
Reset
34
31
34
I/O pins
FIGURE 17-6:
VDD
BVDD
35
Note 1:
64 ms Time-out(1)
DS41262A-page 222
Preliminary
PIC16F685/687/689/690
TABLE 17-4:
Sym
Characteristic
Min
Typ
Max
Units
Conditions
30
TMCL
2
11
18
24
s
ms
31
TWDT
7
10
18
17
33
30
ms
ms
32
TOST
1024TOSC
33*
TPWRT
28*
TBD
64
TBD
132*
TBD
ms
ms
34
TIOZ
2.0
BVHY
25
mV
BVDD
2.025
2.175
TBOR
100*
35
Preliminary
DS41262A-page 223
PIC16F685/687/689/690
FIGURE 17-7:
T0CKI
40
41
42
T1CKI
45
46
48
47
TMR0 or
TMR1
TABLE 17-5:
Param
No.
40*
Sym
TT0H
Characteristic
T0CKI High Pulse Width
No Prescaler
With Prescaler
41*
TT0L
No Prescaler
With Prescaler
42*
TT0P
T0CKI Period
45*
TT1H
T1CKI High
Time
Synchronous, No Prescaler
Synchronous,
with Prescaler
Asynchronous
46*
TT1L
47*
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
Asynchronous
30
ns
Greater of:
30 or TCY + 40
N
ns
T1CKI Input
Period
FT1
Typ
Synchronous
TT1P
Asynchronous
48
Min
60
ns
DC
200*
kHz
2 TOSC*
7 TOSC*
Conditions
N = prescale
value (2, 4, ...,
256)
N = prescale
value (1, 2, 4,
8)
DS41262A-page 224
Preliminary
PIC16F685/687/689/690
FIGURE 17-8:
CCP1
(Capture mode)
50
51
52
CCP1
(Compare or PWM mode)
53
Note:
TABLE 17-6:
54
TccL
TccH
TccP
Characteristic
CCP1 Input Low Time
CCP1 Input High Time
Min
No Prescaler
0.5TCY + 20
ns
With Prescaler
20
ns
No Prescaler
0.5TCY + 20
ns
With Prescaler
20
ns
3TCY + 40
N
ns
53*
TccR
10
25
ns
54*
TccF
10
25
ns
Conditions
N = prescale
value (1, 4 or
16)
Preliminary
DS41262A-page 225
PIC16F685/687/689/690
TABLE 17-7:
COMPARATOR SPECIFICATIONS
Standard Operating Conditions (unless otherwise stated)
Operating temperature
-40C TA +125C
Comparator Specifications
Param.
No.
C01
Sym
Characteristics
VOS
C02
VCM
C03
CMRR
C04
TRT
C05
*
Note 1:
Max
Units
5.0
10
mV
VDD - 1.5
db
Response Time(1)
150
400*
ns
10*
Comments
CV01
Typ
+55*
TABLE 17-8:
Param
No.
Min
Symbol
Characteristics
Resolution
CVRES
CV02
Absolute Accuracy
CV03
CV04
CV05
Typ
Max
Units
VDD/24*
VDD/32*
LSb
1/4*
1/2*
LSb
LSb
2K*
10*
TBD
TBD
TBD
Comments
TABLE 17-9:
Symbol
Characteristics
Typ
Max
Units
TBD
0.6
TBD
VR01
VROUT
VR voltage output
VR02
TCVOUT
150
TBD
ppm/C
VR03
VROUT/
VDD
200
V/V
VR04
TSTABLE
Settling Time
10
100*
Comments
DS41262A-page 226
Preliminary
PIC16F685/687/689/690
FIGURE 17-9:
RB7/TX/CK
pin
121
121
RB5/AN11/RX/DT
pin
120
Note:
122
Symbol
Characteristic
FIGURE 17-10:
Min
Max
Units
40
ns
20
20
ns
ns
Conditions
RC4/C2OUT/TX/CK
pin
RC5/RX/DT
pin
125
126
Note: Refer to Figure 17-2 for load conditions.
Symbol
Characteristic
Preliminary
Min
Max
Units
10
ns
15
ns
Conditions
DS41262A-page 227
PIC16F685/687/689/690
FIGURE 17-11:
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-2 for load conditions.
FIGURE 17-12:
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
DS41262A-page 228
Preliminary
PIC16F685/687/689/690
FIGURE 17-13:
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-2 for load conditions.
FIGURE 17-14:
SS
SCK
(CKP = 0)
70
83
71
72
SCK
(CKP = 1)
80
MSb
SDO
bit 6 - - - - - -1
LSb
75, 76
SDI
MSb In
77
bit 6 - - - -1
LSb In
74
Note: Refer to Figure 17-2 for load conditions.
Preliminary
DS41262A-page 229
PIC16F685/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-15:
SCL
91
93
90
92
SDA
Stop
Condition
Start
Condition
Note: Refer to Figure 17-2 for load conditions.
DS41262A-page 230
Preliminary
PIC16F685/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
Typ
4700
Max Units
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-16:
102
100
101
SCL
90
106
107
91
92
SDA
In
110
109
109
SDA
Out
Note: Refer to Figure 17-2 for load conditions.
Preliminary
DS41262A-page 231
PIC16F685/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
DS41262A-page 232
Preliminary
PIC16F685/687/689/690
TABLE 17-15: PIC16F685/687/689/690 A/D CONVERTER CHARACTERISTICS:
Standard Operating Conditions (unless otherwise stated)
Operating Temperature -40C TA +125C
Param
No.
Sym
Characteristic
Min
Typ
Max
Units
10 bits
bit
Conditions
A01
NR
Resolution
A03
EIL
Integral Error
A04
EDL
Differential Error
A05
EFS
Full-scale Range
2.2*
5.5*
A06
EOFF
Offset Error
A07
EGN
Gain Error
(1)
VDD + 0.3
VSS
VREF
Recommended
Impedance of
Analog Voltage
Source
10
VREF Input
Current*(2)
150
A10
Monotonicity
A20
VREF
Reference Voltage
2.0
A25
VAIN
Analog Input
Voltage
A30
ZAIN
A50
IREF
guaranteed
Preliminary
DS41262A-page 233
PIC16F685/687/689/690
FIGURE 17-17:
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
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.
Sym
Characteristic
130
TAD
130
TAD
A/D Internal RC
Oscillator Period
131
TCNV
Conversion Time
(not including
Acquisition Time)(1)
132
TACQ
Acquisition Time
134
TGO
Q4 to A/D Clock
Start
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
11
TAD
11.5
5*
TOSC/2
DS41262A-page 234
Preliminary
PIC16F685/687/689/690
FIGURE 17-18:
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.
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
Preliminary
DS41262A-page 235
PIC16F685/687/689/690
NOTES:
DS41262A-page 236
Preliminary
PIC16F685/687/689/690
18.0
DC AND AC
CHARACTERISTICS GRAPHS
AND TABLES
Preliminary
DS41262A-page 237
PIC16F685/687/689/690
NOTES:
DS41262A-page 238
Preliminary
PIC16F685/687/689/690
19.0
PACKAGING INFORMATION
19.1
Example
PIC16F685-I/P e3
0510017
XXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXX
YYWWNNN
Example
XXXXXXXXXXXXXX
XXXXXXXXXXXXXX
XXXXXXXXXXXXXX
PIC16F685-I
/SO e3
0510017
YYWWNNN
20-Lead SSOP
Example
XXXXXXXXXXX
XXXXXXXXXXX
YYWWNNN
PIC16F687
-I/SS e3
0510017
20-Lead QFN
Example
XXXXXXX
XXXXXXX
16F690
-I/ML e3
YYWWNNN
0510017
Legend: XX...X
Y
YY
WW
NNN
e3
Note:
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.
Preliminary
DS41262A-page 239
PIC16F685/687/689/690
19.2
Package Details
E1
2
n
1
E
A2
c
A1
B1
eB
B
Units
Dimension Limits
n
p
MIN
INCHES*
NOM
20
.100
.155
.130
MAX
MILLIMETERS
NOM
20
2.54
3.56
3.94
2.92
3.30
0.38
7.49
7.87
6.10
6.35
26.04
26.24
3.05
3.30
0.20
0.29
1.40
1.52
0.36
0.46
7.87
9.40
5
10
5
10
MIN
Number of Pins
Pitch
Top to Seating Plane
A
.140
.170
Molded Package Thickness
A2
.115
.145
Base to Seating Plane
A1
.015
Shoulder to Shoulder Width
E
.295
.310
.325
Molded Package Width
E1
.240
.250
.260
Overall Length
D
1.025
1.033
1.040
Tip to Seating Plane
L
.120
.130
.140
c
Lead Thickness
.008
.012
.015
Upper Lead Width
B1
.055
.060
.065
Lower Lead Width
B
.014
.018
.022
eB
Overall Row Spacing
.310
.370
.430
DS41262A-page 240
Preliminary
MAX
4.32
3.68
8.26
6.60
26.42
3.56
0.38
1.65
0.56
10.92
15
15
PIC16F685/687/689/690
20-Lead Plastic Small Outline (SO) Wide, 300 mil Body (SOIC)
E
E1
p
2
B
45
c
A2
A1
Units
Dimension Limits
n
p
Number of Pins
Pitch
Overall Height
Molded Package Thickness
Standoff
Overall Width
Molded Package Width
Overall Length
Chamfer Distance
Foot Length
Foot Angle
Lead Thickness
Lead Width
Mold Draft Angle Top
Mold Draft Angle Bottom
* Controlling Parameter
Significant Characteristic
A
A2
A1
E
E1
D
h
L
c
B
MIN
.093
.088
.004
.394
.291
.496
.010
.016
0
.009
.014
0
0
INCHES*
NOM
20
.050
.099
.091
.008
.407
.295
.504
.020
.033
4
.011
.017
12
12
MAX
.104
.094
.012
.420
.299
.512
.029
.050
8
.013
.020
15
15
MILLIMETERS
NOM
20
1.27
2.36
2.50
2.24
2.31
0.10
0.20
10.01
10.34
7.39
7.49
12.60
12.80
0.25
0.50
0.41
0.84
0
4
0.23
0.28
0.36
0.42
0
12
0
12
MIN
MAX
2.64
2.39
0.30
10.67
7.59
13.00
0.74
1.27
8
0.33
0.51
15
15
Notes:
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010 (0.254mm) per side.
JEDEC Equivalent: MS-013
Drawing No. C04-094
Preliminary
DS41262A-page 241
PIC16F685/687/689/690
20-Lead Plastic Shrink Small Outline (SS) 209 mil Body, 5.30 mm (SSOP)
E
E1
p
2
1
A2
f
L
Units
Dimension Limits
n
p
MIN
A1
INCHES
NOM
20
.026
.069
.307
.209
.283
.030
4
-
MAX
MILLIMETERS*
NOM
20
0.65
1.65
1.75
0.05
7.40
7.80
5.00
5.30
.295
7.20
0.55
0.75
0.09
0
4
0.22
-
MIN
Number of Pins
Pitch
Overall Height
A
.079
Molded Package Thickness
A2
.065
.073
Standoff
A1
.002
Overall Width
E
.291
.323
Molded Package Width
E1
.197
.220
Overall Length
D
.272
.289
Foot Length
L
.022
.037
c
Lead Thickness
.004
.010
f
Foot Angle
0
8
Lead Width
B
.009
.015
*Controlling Parameter
Notes:
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions
shall not exceed .010" (0.254mm) per side.
MAX
2.00
1.85
8.20
5.60
7.50
0.95
0.25
8
0.38
DS41262A-page 242
Revised 11/03/03
Preliminary
PIC16F685/687/689/690
20-Lead Plastic Quad Flat No Lead Package (ML) 4x4x0.9 mm Body (QFN) Saw Singulated
D1
EXPOSED
METAL
PAD
E1
b
1
OPTIONAL
INDEX
AREA
TOP VIEW
BOTTOM VIEW
A3
A1
Number of Pins
Pitch
Overall Height
Standoff
Contact Thickness
Overall Width
Exposed Pad Width
Overall Length
Exposed Pad Length
Contact Width
Contact Length
Units
Dimension Limits
n
e
A
A1
A3
E
E2
D
D2
b
L
MIN
.031
.000
.152
.100
.152
.100
.007
.012
INCHES
NOM
20
.020 BSC
.035
.001
.008 REF
.157
.106
.157
.106
.010
.016
MAX
.039
.002
.163
.110
.163
.110
.012
.020
MILLIMETERS*
NOM
20
0.50 BSC
0.80
0.90
0.00
0.02
0.20 REF
4.00
3.85
2.55
2.70
3.85
4.00
2.55
2.70
0.18
0.25
0.30
0.40
MIN
MAX
1.00
0.05
4.15
2.80
4.15
2.80
0.30
0.50
*Controlling Parameter
Notes:
JEDEC equivalent: Not Registered
Drawing No. C04-126
Revised 04-24-05
Preliminary
DS41262A-page 243
PIC16F685/687/689/690
NOTES:
DS41262A-page 244
Preliminary
PIC16F685/687/689/690
APPENDIX A:
DATA SHEET
REVISION HISTORY
APPENDIX B:
Revision A
This is a new data sheet.
B.1
PIC16F676 to PIC16F685
TABLE B-1:
FEATURE COMPARISON
Feature
PIC16F676
PIC16F685
20 MHz
20 MHz
1024
4096
Max Program
Memory (Words)
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:
MIGRATING FROM
OTHER PICmicro
DEVICES
Preliminary
DS41262A-page 245
PIC16F685/687/689/690
NOTES:
DS41262A-page 246
Preliminary
PIC16F685/687/689/690
A
A/D ...................................................................................... 93
Acquisition Requirements ......................................... 100
Analog Port Pins ......................................................... 94
Associated registers.................................................. 103
Block Diagram............................................................. 93
Calculating Acquisition Time..................................... 100
Channel Selection....................................................... 94
Configuration and Operation....................................... 94
Configuring.................................................................. 99
Configuring Interrupt ................................................... 99
Conversion Clock........................................................ 94
Effects of a Reset...................................................... 103
Internal Sampling Switch (RSS) Impedance.............. 100
Operation During Sleep ............................................ 102
Output Format............................................................. 95
Reference Voltage (VREF)........................................... 94
Source Impedance.................................................... 100
Special Event Trigger................................................ 103
Specifications............................................ 233, 234, 235
Starting a Conversion ................................................. 95
Using the CCP Trigger.............................................. 103
Absolute Maximum Ratings .............................................. 209
AC Characteristics
Industrial and Extended ............................................ 219
Load Conditions ........................................................ 218
ACK pulse ......................................................................... 164
ADCON0 Register............................................................... 97
ADCON1 Register............................................................... 98
Analog-to-Digital Converter. See A/D
ANSEL Register .................................................................. 96
ANSELH Register ............................................................... 96
Assembler
MPASM Assembler................................................... 203
Auto-Wake-Up on RX Pin Falling Edge ............................ 146
B
BAUDCTL Register ........................................................... 134
BF bit................................................................................. 156
Block Diagrams
A/D .............................................................................. 93
Analog Input Model ................................................... 101
Capture Mode Operation .......................................... 114
Comparator 1 .............................................................. 80
Comparator 2 .............................................................. 82
Compare ................................................................... 114
EUSART Receive ..................................................... 144
EUSART Transmit .................................................... 142
Fail-Safe Clock Monitor (FSCM) ................................. 43
In-Circuit Serial Programming Connections.............. 191
Interrupt Logic ........................................................... 184
On-Chip Reset Circuit ............................................... 175
PIC16F685.................................................................... 5
PIC16F687/689............................................................. 6
PIC16F690.................................................................... 7
PWM (Enhanced)...................................................... 116
RA0 Pins ..................................................................... 51
RA1 Pins ..................................................................... 52
RA2 Pin....................................................................... 52
RA3 Pin....................................................................... 53
RA4 Pin....................................................................... 53
RA5 Pin....................................................................... 54
RB4 Pin....................................................................... 59
RB5 Pin....................................................................... 60
RB6 Pin....................................................................... 61
RB7 Pin....................................................................... 62
C
C Compilers
MPLAB C17.............................................................. 204
MPLAB C18.............................................................. 204
MPLAB C30.............................................................. 204
Capture Module. See Enhanced Capture/Compare/PWM+
(ECCP+)
CCP1CON Register.......................................................... 113
CCPR1H Register............................................................. 113
CCPR1L Register ............................................................. 113
CKE bit ............................................................................. 156
CKP bit ............................................................................. 157
Clock Accuracy with Asynchronous Operation ................. 131
CM1CON0 .......................................................................... 81
CM2CON0 Register............................................................ 83
CM2CON1 Register............................................................ 84
Code Examples
Assigning Prescaler to Timer0.................................... 71
Assigning Prescaler to WDT....................................... 71
Changing Between Capture Prescalers ................... 114
Indirect Addressing..................................................... 32
Initializing A/D............................................................. 99
Initializing PORTA ...................................................... 47
Initializing PORTB ...................................................... 56
Initializing PORTC ...................................................... 64
Loading the SSPBUF (SSPSR) Register ................. 158
Saving Status and W Registers in RAM ................... 186
Ultra Low-Power Wake-up Initialization...................... 50
Write Verify ............................................................... 111
Code Protection ................................................................ 190
Comparator Module ............................................................ 79
C1 Output State Versus Input Conditions................... 79
C2 Output State Versus Input Conditions................... 82
Comparator Voltage Reference (CVREF)............................ 89
Accuracy/Error............................................................ 89
Associated registers ................................................... 92
Configuring ................................................................. 89
Effects of a Reset ....................................................... 92
Response Time .......................................................... 92
Specifications ........................................................... 226
Comparators
Associated Registers.................................................. 92
C2OUT as T1 Gate..................................................... 74
Effects of a Reset ....................................................... 92
Operation During Sleep .............................................. 92
Response Time .......................................................... 92
Specifications ........................................................... 226
Preliminary
DS41262A-page 247
PIC16F685/687/689/690
Compare Module. See Enhanced Capture/Compare/PWM+
(ECCP+)
CONFIG Register.............................................................. 174
Configuration Bits.............................................................. 174
CPU Features ................................................................... 173
Customer Change Notification Service ............................. 253
Customer Notification Service........................................... 253
Customer Support ............................................................. 253
D
D/A bit ............................................................................... 156
Data EEPROM Memory .................................................... 105
Associated Registers ................................................ 112
Code Protection ........................................................ 111
Reading..................................................................... 108
Writing ....................................................................... 108
Data Memory....................................................................... 16
Data/Address bit (D/A) ...................................................... 156
DC Characteristics
Extended ................................................................... 214
Industrial ................................................................... 212
Industrial and Extended .................................... 211, 216
Demonstration Boards
PICDEM 1 ................................................................. 206
PICDEM 17 ............................................................... 207
PICDEM 18R ............................................................ 207
PICDEM 2 Plus ......................................................... 206
PICDEM 3 ................................................................. 206
PICDEM 4 ................................................................. 206
PICDEM LIN ............................................................. 207
PICDEM USB............................................................ 207
PICDEM.net Internet/Ethernet .................................. 206
Development Support ....................................................... 203
Device Overview ................................................................... 5
E
ECCP+. See Enhanced Capture/Compare/PWM+ (ECCP+)
ECCPAS Register ............................................................. 127
EEADR Register ............................................................... 106
EEADR Registers.............................................................. 105
EEADRH Registers ................................................... 105, 106
EECON1 Register ..................................................... 105, 107
EECON2 Register ............................................................. 105
EEDAT Register................................................................ 106
EEDATH Register ............................................................. 106
EEPROM Data Memory
Avoiding Spurious Write............................................ 111
Write Verify ............................................................... 111
Electrical Specifications .................................................... 209
Enhanced Capture/Compare/PWM+ (ECCP+) ................. 113
Associated registers.................................................. 130
Associated registers w/ Capture/Compare/Timer1 ... 115
Capture Mode ........................................................... 114
Prescaler........................................................... 114
CCP1 Pin Configuration ............................................ 114
Compare Mode ......................................................... 114
CCP1 Pin Configuration.................................... 115
Software Interrupt Mode ................................... 115
Special Event Trigger and A/D Conversions..... 115
Timer1 Mode Selection ..................................... 115
Enhanced PWM Mode .............................................. 116
Auto-restart ....................................................... 128
Auto-shutdown .......................................... 127, 128
Direction Change in Full-Bridge Output Mode .. 121
Duty Cycle......................................................... 117
Effects of Reset................................................. 129
DS41262A-page 248
F
Fail-Safe Clock Monitor ...................................................... 43
Fail-Safe Condition Clearing....................................... 43
Fail-Safe Detection ..................................................... 43
Fail-Safe Operation..................................................... 43
Reset or Wake-up from Sleep .................................... 43
Firmware Instructions ....................................................... 193
Flash Program Memory .................................................... 105
Fuses. See Configuration Bits
G
General Purpose Register File ........................................... 16
Preliminary
PIC16F685/687/689/690
I
I2C Mode
Addressing ................................................................ 165
Associated Registers ................................................ 172
Master Mode ............................................................. 171
Mode Selection ......................................................... 164
Multi-Master Mode .................................................... 171
Operation .................................................................. 164
Reception.................................................................. 166
Slave Mode
SCL and SDA pins ............................................ 164
Transmission............................................................. 169
ID Locations ...................................................................... 190
In-Circuit Serial Programming (ICSP) ............................... 190
Indirect Addressing, INDF and FSR registers ..................... 32
Instruction Format ............................................................. 193
Instruction Set ................................................................... 193
ADDLW ..................................................................... 195
ADDWF..................................................................... 195
ANDLW ..................................................................... 195
ANDWF..................................................................... 195
BCF........................................................................... 195
BSF ........................................................................... 195
BTFSC ...................................................................... 195
BTFSS ...................................................................... 196
CALL ......................................................................... 196
CLRF......................................................................... 196
CLRW ....................................................................... 196
CLRWDT................................................................... 196
COMF ....................................................................... 196
DECF ........................................................................ 196
DECFSZ.................................................................... 197
GOTO ....................................................................... 197
INCF.......................................................................... 197
INCFSZ ..................................................................... 197
IORLW ...................................................................... 197
IORWF ...................................................................... 197
MOVF........................................................................ 198
MOVLW .................................................................... 198
MOVWF .................................................................... 198
NOP .......................................................................... 198
RETFIE ..................................................................... 199
RETLW ..................................................................... 199
RETURN ................................................................... 199
RLF ........................................................................... 200
RRF........................................................................... 200
SLEEP ...................................................................... 200
SUBLW ..................................................................... 200
SUBWF ..................................................................... 200
SWAPF ..................................................................... 201
XORLW..................................................................... 201
XORWF..................................................................... 201
INTCON Register ................................................................ 26
Inter-Integrated Circuit (I2C). See I2C Mode
Internal Oscillator Block
INTOSC
Specifications.................................................... 220
Internal Sampling Switch (RSS) Impedance ...................... 100
Internet Address................................................................ 253
Interrupts ........................................................................... 183
A/D .............................................................................. 99
Associated Registers ................................................ 185
Capture ..................................................................... 114
Compare ................................................................... 114
Context Saving.......................................................... 186
Interrupt-on-Change.................................................... 49
2005 Microchip Technology Inc.
Interrupt-on-change .................................................... 56
PORTA/PORTB Interrupt-on-Change ...................... 184
RA2/INT.................................................................... 183
TMR0........................................................................ 183
TMR1.......................................................................... 74
TMR2 to PR2 Match ................................................... 78
TMR2 to PR2 Match (PWM)....................................... 77
INTOSC Specifications ..................................................... 220
IOCA Register..................................................................... 49
IOCB Register..................................................................... 58
L
Load Conditions................................................................ 218
M
MCLR ............................................................................... 176
Internal...................................................................... 176
Memory Organization ......................................................... 15
Data ............................................................................ 16
Program...................................................................... 15
Microchip Internet Web Site.............................................. 253
Migrating from other PICmicro Devices ............................ 245
MPLAB ASM30 Assembler, Linker, Librarian ................... 204
MPLAB ICD 2 In-Circuit Debugger ................................... 205
MPLAB ICE 2000 High-Performance Universal
In-Circuit Emulator.................................................... 205
MPLAB ICE 4000 High-Performance Universal
In-Circuit Emulator.................................................... 205
MPLAB Integrated Development Environment Software.. 203
MPLAB PM3 Device Programmer .................................... 205
MPLINK Object Linker/MPLIB Object Librarian ................ 204
O
OPCODE Field Descriptions............................................. 193
OPTION Register.......................................................... 25, 70
OSCCON Register.............................................................. 45
Oscillator
Associated registers ................................................... 45
Oscillator Configurations..................................................... 35
Oscillator Specifications.................................................... 219
Oscillator Start-up Timer (OST)
Specifications ........................................................... 223
Oscillator Switching
Fail-Safe Clock Monitor .............................................. 43
Two-Speed Clock Start-up ......................................... 41
P
P (Stop) bit........................................................................ 156
P1A/P1B/P1C/P1D.See Enhanced Capture/Compare/PWM
(ECCP) ..................................................................... 116
Packaging ......................................................................... 239
Marking..................................................................... 239
PDIP Details ............................................................. 240
PCL and PCLATH............................................................... 32
Computed GOTO ....................................................... 32
Stack........................................................................... 32
PCON Register ................................................................. 178
PICkit 1 Flash Starter Kit .................................................. 207
PICSTART Plus Development Programmer..................... 206
PIE1 Register ..................................................................... 27
PIE2 Register ..................................................................... 28
Pin Diagram ...................................................................... 2, 3
PIR1 Register ..................................................................... 29
PIR2 Register ..................................................................... 30
PORTA
Additional Pin Functions ............................................. 47
Preliminary
DS41262A-page 249
PIC16F685/687/689/690
Interrupt-on-Change............................................ 49
Ultra Low-Power Wake-up ............................ 47, 50
Weak Pull-up....................................................... 47
Associated Registers .................................................. 55
Pin Descriptions and Diagrams................................... 51
RA0 ............................................................................. 51
RA1 ............................................................................. 52
RA2 ............................................................................. 52
RA3 ............................................................................. 53
RA4 ............................................................................. 53
RA5 ............................................................................. 54
Registers ..................................................................... 47
Specifications ............................................................ 221
PORTA Register ................................................................. 47
PORTB
Additional Pin Functions ............................................. 56
Weak Pull-up....................................................... 56
Associated Registers .................................................. 63
Interrupt-on-change .................................................... 56
Pin Descriptions and Diagrams................................... 59
RB4 ............................................................................. 59
RB5 ............................................................................. 60
RB6 ............................................................................. 61
RB7 ............................................................................. 62
Registers ..................................................................... 56
PORTB Register ................................................................. 57
PORTC................................................................................ 64
Associated Registers .................................................. 45
Associated registers.................................................... 68
P1A/P1B/P1C/P1D.See Enhanced Capture/Compare/
PWM+ (ECCP+).................................................. 64
RC0 ............................................................................. 65
RC1 ............................................................................. 65
RC2 ............................................................................. 65
RC3 ............................................................................. 65
RC4 ............................................................................. 66
RC5 ............................................................................. 66
RC6 ............................................................................. 67
RC7 ............................................................................. 67
Registers ..................................................................... 64
Specifications ............................................................ 221
PORTC Register ................................................................. 64
Power-Down Mode (Sleep) ............................................... 189
Power-on Reset (POR) ..................................................... 176
Power-up Timer (PWRT)................................................... 176
Specifications ............................................................ 223
Precision Internal Oscillator Parameters........................... 220
Prescaler
Shared WDT/Timer0 ................................................... 71
Switching Prescaler Assignment................................. 71
PRO MATE II Universal Device Programmer ................... 205
Program Memory ................................................................ 15
Map and Stack ............................................................ 15
Programming, Device Instructions .................................... 193
PSTRCON Register .......................................................... 123
Pulse Steering................................................................... 123
PWM (ECCP+ Module)
Pulse Steering........................................................... 123
PWM Steering Operation Table ................................ 124
Steering Synchronization .......................................... 125
PWM Mode. See Enhanced Capture/Compare/PWM ...... 116
PWM Steering ................................................................... 124
PWM1CON Register ......................................................... 126
RCREG............................................................................. 144
RCSTA Register ............................................................... 133
SPEN Bit................................................................... 131
Reader Response............................................................. 254
Read-Write-Modify Operations ......................................... 193
Receive Overflow Indicator bit (SSPOV) .......................... 157
Register
RCREG Register ...................................................... 139
Registers
ADCON0 (A/D Control 0)............................................ 97
ADCON1 (A/D Control 1)............................................ 98
ANSEL (Analog Select) .............................................. 96
ANSELH (Analog Select High) ................................... 96
BAUDCTL (Baud Rate Control) ................................ 134
CCP1CON (Enhanced CCP Operation) ................... 113
CCPR1H ................................................................... 113
CCPR1L ................................................................... 113
CM1CON0 (C1 Control).............................................. 81
CM2CON0 (C2 Control).............................................. 83
CM2CON1 (C2 Control).............................................. 84
CONFIG (Configuration Word) ................................. 174
ECCPAS (Enhanced CCP Auto-shutdown Control) . 127
EEADR (EEPROM Address) .................................... 106
EEADRH (EEPROM Address).................................. 106
EECON1 (EEPROM Control 1) ................................ 107
EEDAT (EEPROM Data) .......................................... 106
EEDATH (EEPROM Data)........................................ 106
INTCON (Interrupt Control)......................................... 26
IOCA (Interrupt-on-change PORTA)........................... 49
IOCB (Interrupt-on-change PORTB)........................... 58
OPTION_REG ...................................................... 25, 70
OSCCON (Oscillator Control) ..................................... 45
PCON (Power Control) ....................................... 31, 178
PIE1 (Peripheral Interrupt Enable 1)........................... 27
PIE2 (Peripheral Interrupt Enable Register 2) ............ 28
PIR1 (Peripheral Interrupt Request Register 1).......... 29
PIR2 (Peripheral Interrupt Request Register 2).......... 30
PORTA ....................................................................... 47
PORTB ....................................................................... 57
PORTC ....................................................................... 64
PSTRCON (Pulse Steering Control)......................... 123
PWM1CON (Enhanced PWM Configuration) ........... 126
RCSTA (Receive Status and Control) ...................... 133
Reset Values ............................................................ 180
Reset Values (special registers) ............................... 182
Special Function Register Map
PIC16F685 ......................................................... 17
PIC16F687/689 .................................................. 18
PIC16F690 ......................................................... 19
Special Function Registers ......................................... 16
Special Register Summary
Bank 0 ................................................................ 20
Bank 1 ................................................................ 21
Bank 2 ................................................................ 22
Bank 3 ................................................................ 23
SRCON (SR Latch Control) ........................................ 87
SSPCON (Sync Serial Port Control) Register .......... 157
SSPMSK (SSP Mask)............................................... 167
SSPSTAT (Sync Serial Port Status) Register........... 156
Status ......................................................................... 24
T1CON (Timer1 Control) ............................................ 75
T2CON (Timer2 Control) ............................................ 77
TRISA (Tri-state PORTA) ........................................... 48
TRISB (Tri-state PORTB) ........................................... 57
TRISC (Tri-state PORTC)........................................... 64
DS41262A-page 250
Preliminary
PIC16F685/687/689/690
TXSTA (Transmit Status and Control) ...................... 132
VRCON (Voltage Reference Control) ......................... 90
WDTCON (Watchdog Timer Control) ....................... 188
WPUA (Weak Pull-up PORTA) ................................... 48
WPUB (Weak Pull-up PORTB) ................................... 57
Reset................................................................................. 175
Revision History ................................................................ 245
S
S (Start) bit ........................................................................ 156
Shoot-through Current ...................................................... 126
Slave Select Synchronization ........................................... 161
SMP bit ............................................................................. 156
Software Simulator (MPLAB SIM)..................................... 204
Software Simulator (MPLAB SIM30)................................. 204
SPBRG ............................................................................. 135
SPBRGH ........................................................................... 135
Special Event Trigger........................................................ 103
Special Function Registers ................................................. 16
SPI Mode .................................................................. 155, 161
Associated Registers ................................................ 163
Bus Mode Compatibility ............................................ 163
Effects of a Reset...................................................... 163
Enabling SPI I/O ....................................................... 159
Master Mode ............................................................. 160
Master/Slave Connection.......................................... 159
Serial Clock (SCK pin) .............................................. 155
Serial Data In (SDI pin) ............................................. 155
Serial Data Out (SDO pin) ........................................ 155
Slave Select .............................................................. 155
Slave Select Synchronization ................................... 161
Sleep Operation ........................................................ 163
SPI Clock .................................................................. 160
Typical Connection ................................................... 159
SRCON Register................................................................. 87
SSP
Overview
SPI Master/Slave Connection ................................... 159
SSP I2C Operation ............................................................ 164
Slave Mode ............................................................... 164
SSP Module
Clock Synchronization and the CKP Bit.................... 171
SPI Master Mode ...................................................... 160
SPI Slave Mode ........................................................ 161
SSPBUF.................................................................... 160
SSPSR...................................................................... 160
SSPCON Register ............................................................ 157
SSPEN bit ......................................................................... 157
SSPM bits ......................................................................... 157
SSPMSK Register............................................................. 167
SSPOV bit ......................................................................... 157
SSPSTAT Register ........................................................... 156
Status Register ................................................................... 24
Synchronous Serial Port Enable bit (SSPEN)................... 157
Synchronous Serial Port Mode Select bits (SSPM) .......... 157
Synchronous Serial Port. See SSP
T
T1CON Register ................................................................. 75
Time-out Sequence........................................................... 178
Timer0 ................................................................................. 69
Associated Registers .................................................. 71
External Clock............................................................. 70
External Clock Requirements ................................... 224
Interrupt....................................................................... 69
Operation .................................................................... 69
T0CKI ......................................................................... 70
Timer1 ................................................................................ 73
Associated registers ................................................... 76
Asynchronous Counter Mode ..................................... 76
Reading and Writing ........................................... 76
External Clock Requirements ................................... 224
Interrupt ...................................................................... 74
Modes of Operations .................................................. 74
Operation During Sleep .............................................. 76
Oscillator..................................................................... 76
Prescaler .................................................................... 74
Timer1 Gate
Inverting Gate ..................................................... 74
Selecting Source ................................................ 74
TMR1H Register......................................................... 73
TMR1L Register ......................................................... 73
Timer2 ................................................................................ 77
Associated Registers.................................................. 78
Operation.................................................................... 77
Postscaler................................................................... 77
PR2 Register .............................................................. 77
Prescaler .................................................................... 77
TMR2 Register ........................................................... 77
TMR2 to PR2 Match Interrupt............................... 77, 78
Timing Diagrams
A/D Conversion ........................................................ 234
A/D Conversion (Sleep Mode).................................. 235
Asynchronous Reception.......................................... 145
Asynchronous Transmission .................................... 142
Asynchronous Transmission (Back to Back) ............ 142
Automatic Baud Rate Calculator .............................. 140
Auto-Wake-up Bit (WUE) During Normal Operation. 146
Auto-Wake-Up Bit (WUE) During Sleep ................... 146
Brown-out Reset (BOR)............................................ 222
Brown-out Reset Situations ...................................... 177
CLKOUT and I/O ...................................................... 221
Clock Synchronization .............................................. 172
Enhanced Capture/Compare/PWM (ECCP)............. 225
EUSART Synchronous Receive (Master/Slave)....... 227
EUSART Synchronous Transmission (Master/Slave) ....
227
External Clock .......................................................... 219
Fail-Safe Clock Monitor (FSCM)................................. 44
Full-Bridge PWM Output........................................... 120
Half-Bridge PWM Output .......................................... 119
I2C Bus Data............................................................. 231
I2C Bus Start/Stop Bits ............................................. 230
I2C Reception (7-bit Address)................................... 166
I2C Slave Mode (Transmission, 10-bit Address) ...... 170
I2C Slave Mode with SEN = 0 (Reception,
10-bit Address) ................................................. 168
I2C Transmission (7-bit Address) ............................. 169
INT Pin Interrupt ....................................................... 185
PWM Auto-shutdown
Auto-restart Disabled........................................ 128
Auto-restart Enabled......................................... 128
PWM Direction Change ............................................ 122
PWM Direction Change at Near 100% Duty Cycle... 122
PWM Output (Active-High) ....................................... 118
PWM Output (Active-Low) ........................................ 118
Reset, WDT, OST and Power-up Timer ................... 222
Send Break Character Sequence............................. 147
Slave Synchronization .............................................. 161
SPI Master Mode (CKE = 1, SMP = 1) ..................... 228
SPI Mode (Master Mode) ......................................... 160
SPI Mode (Slave Mode with CKE = 0)...................... 162
Preliminary
DS41262A-page 251
PIC16F685/687/689/690
SPI Mode (Slave Mode with CKE = 1) ...................... 162
SPI Slave Mode (CKE = 0) ....................................... 229
SPI Slave Mode (CKE = 1) ....................................... 229
Synchronous Reception (Master Mode, SREN) ....... 150
Synchronous Transmission....................................... 148
Synchronous Transmission (Through TXEN) ........... 149
Time-out Sequence
Case 1............................................................... 179
Case 2............................................................... 179
Case 3............................................................... 179
Timer0 and Timer1 External Clock ........................... 224
Timer1 Incrementing Edge.......................................... 74
Two Speed Start-up .................................................... 42
Wake-up from Interrupt ............................................. 190
Timing Parameter Symbology........................................... 218
Timing Requirements
I2C Bus Data ............................................................. 232
I2C Bus Start/Stop Bits ............................................. 231
SPI Mode .................................................................. 230
TRISA
Registers ..................................................................... 47
TRISA Register ................................................................... 48
TRISB
Registers ..................................................................... 56
TRISB Register ................................................................... 57
TRISC
Registers ..................................................................... 64
TRISC Register ................................................................... 64
Two-Speed Clock Start-up Mode ........................................ 41
TXREG.............................................................................. 141
TXSTA Register ................................................................ 132
BRGH Bit .................................................................. 135
W
Wake-up Using Interrupts ................................................. 189
Watchdog Timer (WDT).................................................... 187
Associated registers ................................................. 188
Specifications ........................................................... 223
WCOL bit .......................................................................... 157
WDTCON Register ........................................................... 188
WPUA Register................................................................... 48
WPUB Register................................................................... 57
Write Collision Detect bit (WCOL) .................................... 157
WWW Address ................................................................. 253
WWW, On-Line Support ....................................................... 4
U
UA ..................................................................................... 156
Ultra Low-Power Wake-up ...................................... 12, 47, 50
Ultra Low-power Wake-up............................................... 8, 10
Update Address bit, UA..................................................... 156
V
Voltage Reference (VR)
Specifications ............................................................ 226
Voltage Reference. See Comparator Voltage Reference
(CVREF)
Voltage References
VP6 Stabilization ......................................................... 89
VRCON Register................................................................. 90
VREF. SEE A/D Reference Voltage
DS41262A-page 252
Preliminary
PIC16F685/687/689/690
THE MICROCHIP WEB SITE
CUSTOMER SUPPORT
Distributor or Representative
Local Sales Office
Field Application Engineer (FAE)
Technical Support
Development Systems Information Line
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://support.microchip.com
In addition, there is a Development Systems
Information Line which lists the latest versions of
Microchips development systems software products.
This line also provides information on how customers
can receive currently available upgrade kits.
The Development
numbers are:
Systems
Information
Line
Preliminary
DS41262A-page 253
PIC16F685/687/689/690
READER RESPONSE
It is our intention to provide you with the best documentation possible to ensure successful use of your Microchip product. If you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation
can better serve you, please FAX your comments to the Technical Publications Manager at (480) 792-4150.
Please list the following information, and use this outline to provide us with your comments about this document.
To:
RE:
Reader Response
From: Name
Company
Address
City / State / ZIP / Country
Telephone: (_______) _________ - _________
Application (optional):
Would you like a reply?
Device: PIC16F685/687/689/690
N
Literature Number: DS41262A
Questions:
1. What are the best features of this document?
2. How does this document meet your hardware and software development needs?
3. Do you find the organization of this document easy to follow? If not, why?
4. What additions to the document do you think would enhance the structure and subject?
5. What deletions from the document could be made without affecting the overall usefulness?
DS41262A-page 254
Preliminary
PIC16F685/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:
Preliminary
1:
DS41262A-page 255
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://support.microchip.com
Web Address:
www.microchip.com
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
India - Bangalore
Tel: 91-80-2229-0061
Fax: 91-80-2229-0062
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
Austria - Weis
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark - Ballerup
Tel: 45-4450-2828
Fax: 45-4485-2829
China - Chengdu
Tel: 86-28-8676-6200
Fax: 86-28-8676-6599
Japan - Kanagawa
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
France - Massy
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
China - Fuzhou
Tel: 86-591-8750-3506
Fax: 86-591-8750-3521
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Germany - Ismaning
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Atlanta
Alpharetta, GA
Tel: 770-640-0034
Fax: 770-640-0307
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
Kokomo, IN
Tel: 765-864-8360
Fax: 765-864-8387
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
China - Shunde
Tel: 86-757-2839-5507
Fax: 86-757-2839-5571
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
England - Berkshire
Tel: 44-118-921-5869
Fax: 44-118-921-5820
Taiwan - Hsinchu
Tel: 886-3-572-9526
Fax: 886-3-572-6459
China - Qingdao
Tel: 86-532-502-7355
Fax: 86-532-502-7205
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
San Jose
Mountain View, CA
Tel: 650-215-1444
Fax: 650-961-0286
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
03/01/05
DS41262A-page 256
Preliminary