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 Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•Microchip is willing to work with the customer who is concerned about the integrity of their code.
•Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digit al Millennium Copyright Act. If suc h a c t s
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED,
WRITTEN OR ORAL, STATUTORY OR OTHERWISE,
RELATED TO THE INFORMATION, INCLUDING BUT NOT
LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE,
MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and
its use. Use of M icrochip’s prod ucts as critical components in
life support systems is not authorized except with express
written approval by Microchip. No licenses are conveyed,
implicitly or otherwise, under any Microchip intellectual property
rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, 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
Programmin g, IC SP, ICEPI C, M PASM, 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.
Microchip received ISO/TS-16949:2002 quality system certification for
its worldwide headquarters, design and wafer fabrication facilities in
Chandler and Tempe, Arizona and Mountain View, California in
October 2003. The Company’s quality system processes and
procedures are for its PICmicro
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
6.0Timer1 Module with Gate Control...............................................................................................................................................73
10.0 Data EEPROM and Flash Program Memory Control ............................................................................................................... 105
14.0 Special Features of the CPU........................................................ ..................... ....................................................................... 173
15.0 Instruction Set Summary.......................................................................................................................................................... 193
16.0 Development Support. .............................................................................................................................................................. 203
18.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 237
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
It is our intention to provide our valued customers with the best docum entation possible to ensure s uccessful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via Email at docerrors@microchip.com or fax the Reader Response Form in the back of this data sheet to (480) 792-4150. We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000A is version A of document DS30000).
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision of
silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
The PIC16F685/687/689/690 has a 13-bit program
counter capable of addressing an 8k x 14 program
memory space. Onl y the first 2k x 14 (0000h-07 FFh) for
the PIC16F687 is physic ally impleme nted and first 4k x
14 (0000h-0FFFh) for the PIC16F685/PIC16F689/
PIC16F690. Accessing a location above these
boundaries will caus e a wrap around. The Reset vector
is at 0000h and the interrupt vector is at 0004h (see
Figures 2-1 and 2-2).
The data memory (see Figures 2-3, 2-4 and 2-5) is
partitioned into four banks which contain the General
Purpose Registers (GPR) and the Special Function
Registers (SFR). The Special Function Registers are
located in the fir st 32 l oca tio ns o f eac h ba nk. Regi ste r
locations 20h-7Fh in Bank 0 and A0h-EFh (A0-BF,
PIC16F687 only) in Bank 1 are General Purpose
Registers, implemented as static RAM. Register
locations F0h-FFh i n Bank 1, 170 h-17Fh in Ban k 2 an d
1F0h-1FFh in Bank 3 point to addresses 70h-7Fh in
Bank 0. Other General Purpose Resisters (GPR) are
also available in Bank 1 an d Ban k 2 , depending on the
device. Details are shown in Figures 2-3, 2-4 and 2-5.
All other RAM is unimplemented and returns ‘0’ when
read. RP<1:0> (STATUS<6:5>) are the bank select
bits:
RP1
RP0
00→Bank 0 is selected
01→Bank 1 is selected
10→Bank 2 is selected
11→Bank 3 is selected
2.2.1GENERAL PURPOSE REGISTER
FILE
The register file is organized as 128 x 8 in the
PIC16F687 and 256 x 8 in the PIC16F685/PIC16F689/
PIC16F690. Each register is accessed, either directly or
indirectly, through the File Select Register (FSR) (see
Section 2.4 “Indirect Addressing, INDF and FSR
Registers”).
2.2.2SPECIAL FUNCTION REGISTERS
The Special Function Registe rs are registers used by
the CPU and peripheral functions for controlling the
desired operation of the device (see Tables 2-1, 2-2, 2-3
and 2-4). These registers are static RAM.
The special re gisters can be classifi ed into two sets:
core and peripheral. The Special Function Registers
associated with the “c ore” are des cribed in this sect ion.
Registers related to the operati on of peripheral features
are described in the section of that peri phe ral feature .
———Write Buffer for upper 5 bits of Program Counter---0 0000 ---0 0000
(2)
0000 000x 0000 000x
—ADIFRCIF
(3)
TXIF
(3)
SSPIF
(3)
CCP1IF
(4)
TMR2IF
(4)
TMR1IF -000 0000 -000 0000
OSFIFC2IFC1IFEEIF————0000 ---- 0000 ----
0EhTMR1LHolding Register for the Least Significant Byte of the 16-bit TMR1xxxx xxxx uuuu uuuu
0FhTMR1HHolding Register for the Most Significant Byte of the 16-bit TMR1xxxx xxxx uuuu uuuu
10hT1CONT1GINVTMR1GE T1CKPS1 T1CKPS0 T1OSCEN T1SYNC
Synchronous Serial Port Receive Buffer/Transmit Registerxxxx xxxx uuuu uuuu
WCOLSSPOVSSPENCKPSSPM3SSPM2SSPM1SSPM0 0000 0000 0000 0000
Capture/Compare/PW M Regi st er 1 (LSB )xxxx xxxx uuuu uuuu
Capture/Compare/PW M Regi st er 1 (MSB )xxxx xxxx uuuu uuuu
1EhADRESHA/D Result Register High Bytexxxx xxxx uuuu uuuu
1FhADCON0ADFMVCFGCHS3CHS2CHS1CHS0GO/DONE
ADON0000 0000 0000 0000
Legend:– = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:Other (non Power-up) Resets include MCLR
2: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
Reset and Watchdog Timer Reset dur ing nor mal operation.
mismatched exists.
3:PIC16F687/PIC16F689/PIC16F690 only.
4:PIC16F685/PIC16F690 only.
5:When SSPCON bits SSPM<3:0> = 1001, any reads or writes to the SSPADD SFR address are accessed through the SSPMSK register.
Legend:– = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:Other (non Power-up) Resets include MCLR
2: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
Reset and Watchdog Timer Reset during normal operation.
mismatched exists.
3:PIC16F687/PIC16F689/PIC16F690 only.
4:PIC16F685/PIC16F690 only.
5:RA3 pull-up is enabled when pin is configured as MCLR
Legend:– = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:Other (non Power-up) Resets include MCLR
(3)
(3)
2:MCLR
mismatched exists.
3:PIC16F685/PIC16F689/PIC16F690 only.
——RA5RA4RA3RA2RA1RA0--xx xxxx --uu uuuu
———Write Buffer for the upper 5 bits of the Program Counter---0 0000 ---0 0000
——
————
————ANS11ANS10ANS9A NS8---- 1111 ---- 1111
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
Legend:– = Unimplemented locations read as ‘0’, u = unchange d, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:Other (non Power-up) Resets include MCLR
The Status register, shown in Register 2-1, contains:
• the arithmetic status of the ALU
• the Reset status
• the bank select bits for data memory (GPR and
SFR)
The Status register can be the destination for any
instruction, like any other register. If the Status register
is the destination for an instruction that affects the Z,
DC or C bits, then the write to these three bits is
writable. Therefore, the result of an instruction with the
Status register as destination may be different than
intended.
For example, CLRF STATUS, will clear the upper three
bits and set the Z bit. Thi s leaves the Status register as
‘000u u1uu’ (where u = unchanged).
It is recommended, therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
Stat us register , beca use these instru ctions do not af fect
any Status bits. For other instructions not affecting any
Status bits, see the “Instruction Set Summary.”
disabled. These bit s are set or cleared ac cording to the
device logic. Furthermore, the TO
and PD bits are not
Note 1: The C and DC bits operate as a Borrow
and Digit Borrow out bit, respectively, in
subtraction. See the SUBLW and SUBWF
instructions for examples.
REGISTER 2-1:STATUS – STATUS REGISTER (ADDRESS: 03h, 83h, 103h OR 183h)
R/W-0R/W-0R/W-0R-1R-1R/W-xR/W-xR/W-x
(1)
(1)
bit 7
bit 6-5
bit 4
bit 3
bit 2
bit 1
bit 0
IRPRP1RP0TOPDZDC
bit 7bit 0
IRP: Register Bank Select bit (used for indirect addressing)
1 = Bank 2, 3 (100h-1FFh)
0 = Bank 0, 1 (00h-FFh)
RP<1:0>: Register Bank Select bits (used for direct addressing)
00 = Bank 0 (00h-7Fh)
01 = Bank 1 (80h-FFh)
10 = Bank 2 (100h-17Fh)
11 = Bank 3 (180h-1FFh)
TO: Time-out bit
1 = After power-up, CLRWDT instruction or SLEEP instruction
0 = A WDT time-out occurred
PD: Power-down bit
1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
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
DC: Digit Carry/Borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions)
1 = A carry-out from the 4th low-order bit of the result occurred
0 = No carry-out from the 4th low-order bit of the result
C: Carry/Borrow bit (ADDWF, ADDLW, SUBLW, SUBWF instructions)
(1)
1 = A carry-out from the Most Significant bit of the result occurred
0 = No carry-out from the Most Significant bit of the result occurred
Note 1: For Bo
rrow, the polarity is reversed. A subtraction is executed by adding the two’s
complement of the second operand. For rotate (RRF, RLF) instructions, this bit is
loaded with either the high or low-order bit of the source register.
(1)
C
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
The INTCON register is a readable and writable
register , which c ontains the various en able and fl ag bit s
for TMR0 register overflow, PORTA change and
external RA2/AN2/T0CKI/INT/C1OUT pin interrupts.
Note:Interrupt flag bits are set when an interru pt
condition occurs, regar dless of the st ate of
its corresponding enable bit or the global
enable bit, GIE (INTCON<7>). User
software should ensure the appropriate
interrupt flag bits are clear prior to
enabling an interrupt.
REGISTER 2-3:INTCON – INTERRUPT CONTROL REGISTER (ADDRESS: 0Bh, 8Bh, 10Bh OR
18Bh)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-x
GIEPEIET0IEINTERABIE
bit 7bit 0
bit 7GIE: Global Interrupt Enable bit
1 = Enables all unmasked interrupts
0 = Disables all interrupts
bit 6PEIE: Peripheral Interrupt Enable bit
1 = Enables all unmasked peripheral interrupts
0 = Disables all peripheral interrupts
bit 5T0IE: TMR0 Overflow Interrupt Enable bit
1 = Enables the TMR0 interrupt
0 = Disables the TMR0 in terrupt
bit 4INTE: RA2/INT External Interrupt Enable bit
1 = Enables the RA2/INT external interrupt
0 = Disables the RA2/INT external interrupt
bit 3RABIE: PORTA/PORTB Change Interrupt Enable bit
1 = Enables the PORTA/PORTB change interrupt
0 = Disables the PORTA/PORTB change interrupt
bit 2T0IF: TMR0 Overflow Interrupt Flag bit
1 = TMR0 regis ter has overflowed (must be cleared in software)
0 = TMR0 register did not overflow
bit 1INTF: RA2/INT External Interrupt Flag bit
1 = The RA2/INT external interrupt occurred (must be cleared in software)
0 = The RA2/INT external interrupt did not occur
bit 0RABIF: PORTA/PORTB Change Interrupt Flag bit
1 = When at least o ne of the PORTA or PORTB general purpose I/O p ins cha nge d s tate (must
be cleared in software)
0 = None of the PORTA or PORTB general purpose I/O pins have changed state
(2)
(1,3)
(1, 3)
T0IF
(2)
INTFRABIF
Note 1: IOCA or IOCB register must also be enabled.
2: T0IF bit is set when Timer0 rolls over. Timer0 is unchanged on Reset and should
be initialized before clearing T0IF bit.
3: Includes ULPWU interrupt.
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
- n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown