PIC16F87/88
18/20/28-Pin Enhanced Flash MCUs with nanoWatt Technology
Low-Power Features:
• Power-Managed modes:
- Primary Run: RC oscillator, 76
A,
1 MHz, 2V
- RC_RUN: 7
A,
31.25 kHz, 2V
- SEC_RUN: 9
A,
32 kHz, 2V
- Sleep: 0.1
A,
2V
• Timer1 Oscillator: 1.8
A,
32 kHz, 2V
• Watchdog Timer: 2.2
A,
2V
• Two-Speed Oscillator Start-up
Pin Diagram
18-Pin PDIP, SOIC
RA2/AN2/CV
REF
/
V
REF
-
RA3/AN3/V
REF
+/
C1OUT
RA4/AN4/T0CKI/
C2OUT
RA5/MCLR/V
PP
V
SS
RB0/INT/CCP1
(1)
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/PGM/CCP1
(1)
Note 1:
1
2
3
4
5
6
7
8
9
18
17
16
RA1/AN1
RA0/AN0
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
RB7/AN6/PGD/
T1OSI
RB6/AN5/PGC/
T1OSO/T1CKI
RB5/SS/TX/CK
RB4/SCK/SCL
PIC16F88
15
14
13
12
11
10
Oscillators:
• Three Crystal modes:
- LP, XT, HS: up to 20 MHz
• Two External RC modes
• One External Clock mode:
- ECIO: up to 20 MHz
• Internal oscillator block:
- 8 user selectable frequencies: 31 kHz,
125 kHz, 250 kHz, 500 kHz, 1 MHz, 2 MHz,
4 MHz, 8 MHz
The CCP1 pin is determined by the CCPMX bit in
Configuration Word 1 register.
Special Microcontroller Features:
• 100,000 erase/write cycles Enhanced Flash
program memory typical
• 1,000,000 typical erase/write cycles EEPROM
data memory typical
• EEPROM Data Retention: > 40 years
• In-Circuit Serial Programming™ (ICSP™)
via two pins
• Processor read/write access to program memory
• Low-Voltage Programming
• In-Circuit Debugging via two pins
• Extended Watchdog Timer (WDT):
- Programmable period from 1 ms to 268s
• Wide operating voltage range: 2.0V to 5.5V
Peripheral Features:
• Capture, Compare, PWM (CCP) module:
- Capture is 16-bit, max. resolution is 12.5 ns
- Compare is 16-bit, max. resolution is 200 ns
- PWM max. resolution is 10-bit
• 10-bit, 7-channel Analog-to-Digital Converter
• Synchronous Serial Port (SSP) with SPI
(Master/Slave) and I
2
C™ (Slave)
• Addressable Universal Synchronous
Asynchronous Receiver Transmitter
(AUSART/SCI) with 9-bit address detection:
- RS-232 operation using internal oscillator
(no external crystal required)
• Dual Analog Comparator module:
- Programmable on-chip voltage reference
- Programmable input multiplexing from device
inputs and internal voltage reference
- Comparator outputs are externally accessible
Program Memory
Device
Flash # Single-Word
(bytes) Instructions
7168
7168
4096
4096
Data Memory
SRAM
(bytes)
368
368
EEPROM
(bytes)
256
256
I/O
Pins
16
16
10-bit
CCP
AUSART Comparators
A/D (ch) (PWM)
N/A
1
1
1
Y
Y
2
2
SSP
Timers
8/16-bit
2/1
2/1
PIC16F87
PIC16F88
Y
Y
2002-2013 Microchip Technology Inc.
DS30487D-page 1
PIC16F87/88
Pin Diagrams
18-Pin PDIP, SOIC
RA2/AN2/CV
REF
RA3/AN3/C1OUT
RA4/T0CKI/C2OUT
RA5/MCLR/V
PP
V
SS
RB0/INT/CCP1
(1)
1
2
4
5
6
7
8
9
3
18
17
16
15
14
13
12
11
10
RA1/AN1
RA0/AN0
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
RB7/PGD/T1OSI
RB6/PGC/T1OSO/T1CKI
RB5/SS/TX/CK
RB4/SCK/SCL
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/PGM/CCP1
(1)
20-Pin SSOP
RA2/AN2/CV
REF
RA3/AN3/C1OUT
RA4/T0CKI/C2OUT
RA5/MCLR/V
PP
V
SS
V
SS
RB0/INT/CCP1
(1)
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/PGM/CCP1
(1)
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
RA1/AN1
RA0/AN0
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
V
DD
RB7/PGD/T1OSI
RB6/PGC/T1OSO/T1CKI
RB5/SS/TX/CK
RB4/SCK/SCL
18-Pin PDIP, SOIC
RA2/AN2/CV
REF
/V
REF
-
RA3/AN3/V
REF
+/C1OUT
RA4/AN4/T0CKI/C2OUT
RA5/MCLR/V
PP
V
SS
RB0/INT/CCP1
(1)
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/PGM/CCP1
(1)
1
2
4
5
6
7
8
9
3
PIC16F87
PIC16F87
18
17
16
15
14
13
12
11
10
RA1/AN1
RA0/AN0
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
RB7/AN6/PGD/T1OSI
RB6/AN5/PGC/T1OSO/T1CKI
RB5/SS/TX/CK
RB4/SCK/SCL
20-Pin SSOP
RA2/AN2/CV
REF
/V
REF
-
RA3/AN3/V
REF
+/C1OUT
RA4/AN4/T0CKI/C2OUT
RA5/MCLR1/V
PP
V
SS
V
SS
RB0/INT/CCP1
(1)
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/PGM/CCP1
(1)
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
RA1/AN1
RA0/AN0
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
V
DD
RB7/AN6/PGD/T1OSI
RB6/AN5/PGC/T1OSO/T1CKI
RB5/SS/TX/CK
RB4/SCK/SCL
Note 1:
The CCP1 pin is determined by the CCPMX bit in Configuration Word 1 register.
PIC16F88
PIC16F88
DS30487D-page 2
2002-2013 Microchip Technology Inc.
PIC16F87/88
Pin Diagrams (Cont’d)
RA4/T0CKI/C2OUT
RA3/AN3/C1OUT
28-Pin QFN
(1)
RA2/AN2/CV
REF
RA1/AN1
24
RA0/AN0
23
NC
28
27
26
25
22
21
20
19
RA5/MCLR/V
PP
NC
V
SS
NC
V
SS
NC
RB0/INT/CCP1
(2)
1
2
3
4
5
6
7
10
11
12
13
14
8
9
NC
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
NC
V
DD
RB7/PGD/T1OSI
RB6/PGC/T1OSO/T1CKI
PIC16F87
18
17
16
15
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/PGM/CCP1
(2)
NC
RA4/AN4/T0CKI/C2OUT
RA2/AN2/CV
REF
/V
REF
-
28-Pin QFN
(1)
RA3/AN3/V
REF
+/C1OUT
RA1/AN1
RA0/AN0
23
NC
28
27
26
25
24
22
21
20
19
RA5/MCLR/V
PP
NC
V
SS
NC
V
SS
NC
RB0/INT/CCP1
(2)
1
2
3
4
5
6
7
10
11
12
13
14
8
9
NC
RB5/SS/TX/CK
RB4/SCK/SCL
NC
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
NC
V
DD
RB7/AN6/PGD/T1OSI
RB6/AN5/PGC/T1OSO/T1CKI
PIC16F88
18
17
16
15
RB1/SDI/SDA
RB2/SDO/RX/DT
RB3/PGM/CCP1
(2)
NC
Note 1:
2:
For the QFN package, it is recommended that the bottom pad be connected to V
SS
.
The CCP1 pin is determined by the CCPMX bit in Configuration Word 1 register.
2002-2013 Microchip Technology Inc.
RB5/SS/TX/CK
RB4/SCK/SCL
NC
DS30487D-page 3
PIC16F87/88
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 5
2.0 Memory Organization ................................................................................................................................................................. 11
3.0 Data EEPROM and Flash Program Memory.............................................................................................................................. 27
4.0 Oscillator Configurations ............................................................................................................................................................ 35
5.0 I/O Ports ..................................................................................................................................................................................... 51
6.0 Timer0 Module ........................................................................................................................................................................... 67
7.0 Timer1 Module ........................................................................................................................................................................... 71
8.0 Timer2 Module ........................................................................................................................................................................... 79
9.0 Capture/Compare/PWM (CCP) Module ..................................................................................................................................... 81
10.0 Synchronous Serial Port (SSP) Module ..................................................................................................................................... 87
11.0 Addressable Universal Synchronous Asynchronous Receiver Transmitter (AUSART) ............................................................. 97
12.0 Analog-to-Digital Converter (A/D) Module ................................................................................................................................ 113
13.0 Comparator Module.................................................................................................................................................................. 121
14.0 Comparator Voltage Reference Module ................................................................................................................................... 127
15.0 Special Features of the CPU .................................................................................................................................................... 129
16.0 Instruction Set Summary .......................................................................................................................................................... 149
17.0 Development Support............................................................................................................................................................... 157
18.0 Electrical Characteristics .......................................................................................................................................................... 161
19.0 DC and AC Characteristics Graphs and Tables ....................................................................................................................... 191
20.0 Packaging Information.............................................................................................................................................................. 205
Appendix A: Revision History............................................................................................................................................................. 215
Appendix B: Device Differences......................................................................................................................................................... 215
INDEX ................................................................................................................................................................................................ 217
The Microchip Web Site ..................................................................................................................................................................... 225
Customer Change Notification Service .............................................................................................................................................. 225
Customer Support .............................................................................................................................................................................. 225
Reader Response .............................................................................................................................................................................. 226
PIC16F87/88 Product Identification System ...................................................................................................................................... 227
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful 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
E-mail 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.
DS30487D-page 4
2002-2013 Microchip Technology Inc.
PIC16F87/88
1.0
DEVICE OVERVIEW
TABLE 1-1:
This document contains device specific information for
the operation of the PIC16F87/88 devices. Additional
information may be found in the “PIC
®
Mid-Range MCU
Family Reference Manual”
(DS33023) which may be
downloaded from the Microchip web site. This
Reference Manual should be considered a comple-
mentary document to this data sheet and is highly
recommended reading for a better understanding of the
device architecture and operation of the peripheral
modules.
The PIC16F87/88 belongs to the Mid-Range family of
the PIC
®
devices. Block diagrams of the devices are
shown in Figure 1-1 and Figure 1-2. These devices
contain features that are new to the PIC16 product line:
• Low-power modes: RC_RUN allows the core and
peripherals to be clocked from the INTRC, while
SEC_RUN allows the core and peripherals to be
clocked from the low-power Timer1. Refer to
Section 4.7 “Power-Managed Modes”
for
further details.
• Internal RC oscillator with eight selectable
frequencies, including 31.25 kHz, 125 kHz,
250 kHz, 500 kHz, 1 MHz, 2 MHz, 4 MHz and
8 MHz. The INTRC can be configured as a
primary or secondary clock source. Refer to
Section 4.5 “Internal Oscillator Block”
for
further details.
• The Timer1 module current consumption has
been greatly reduced from 20
A
(previous PIC16
devices) to 1.8
A
typical (32 kHz at 2V), which is
ideal for real-time clock applications. Refer to
Section 7.0 “Timer1 Module”
for further details.
• Extended Watchdog Timer (WDT) that can have a
programmable period from 1 ms to 268s. The
WDT has its own 16-bit prescaler. Refer to
Section 15.12 “Watchdog Timer (WDT)”
for
further details.
• Two-Speed Start-up: When the oscillator is
configured for LP, XT or HS Oscillator mode, this
feature will clock the device from the INTRC while
the oscillator is warming up. This, in turn, will
enable almost immediate code execution. Refer
to
Section 15.12.3 “Two-Speed Clock Start-up
Mode”
for further details.
• Fail-Safe Clock Monitor: This feature will allow the
device to continue operation if the primary or
secondary clock source fails by switching over to
the INTRC.
• The A/D module has a new register for PIC16
devices named ANSEL. This register allows
easier configuration of analog or digital I/O pins.
AVAILABLE MEMORY IN
PIC16F87/88 DEVICES
Program
Flash
4K x 14
Data
Memory
368 x 8
Data
EEPROM
256 x 8
Device
PIC16F87/88
There are 16 I/O pins that are user configurable on a
pin-to-pin basis. Some pins are multiplexed with other
device functions. These functions include:
•
•
•
•
•
•
•
•
•
•
External Interrupt
Change on PORTB Interrupt
Timer0 Clock Input
Low-Power Timer1 Clock/Oscillator
Capture/Compare/PWM
10-bit, 7-channel A/D Converter (PIC16F88 only)
SPI/I
2
C™
Two Analog Comparators
AUSART
MCLR (RA5) can be configured as an input
Table 1-2 details the pinout of the devices with
descriptions and details for each pin.
2002-2013 Microchip Technology Inc.
DS30487D-page 5