PIC16F872
Data Sheet
28-Pin, 8-Bit CMOS Flash
Microcontroller with 10-Bit A/D
©
2006 Microchip Technology Inc.
DS30221C
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 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.
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 Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. 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
EE
L
OQ
, 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,
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, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, ECAN,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, Linear Active
Thermistor, Mindi, MiWi, MPASM, MPLIB, MPLINK, PICkit,
PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartTel, Total
Endurance, UNI/O, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
© 2006, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
Microchip received ISO/TS-16949:2002 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona, Gresham, Oregon and Mountain View, California. The
Company’s quality system processes and procedures are for its
PICmicro
®
8-bit MCUs, K
EE
L
OQ
®
code hopping 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.
DS30221C-page ii
©
2006 Microchip Technology Inc.
PIC16F872
28-Pin, 8-Bit CMOS FLASH Microcontroller
with 10-bit A/D
High Performance RISC CPU:
• Only 35 single word instructions to learn
• All single cycle instructions except for program
branches, which are two-cycle
• Operating speed: DC - 20 MHz clock input
DC - 200 ns instruction cycle
• 2K x 14 words of FLASH Program Memory
• 128 bytes of Data Memory (RAM)
• 64 bytes of EEPROM Data Memory
• Pinout compatible to the PIC16C72A
• Interrupt capability (up to 10 sources)
• Eight level deep hardware stack
• Direct, Indirect and Relative Addressing modes
Pin Diagram
DIP, SOIC, SSOP
Peripheral Features:
• High Sink/Source Current: 25 mA
• Timer0: 8-bit timer/counter with 8-bit prescaler
• Timer1: 16-bit timer/counter with prescaler,
can be incremented during SLEEP via external
crystal/clock
• Timer2: 8-bit timer/counter with 8-bit period
register, prescaler and postscaler
• One Capture, Compare, PWM 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, 5-channel Analog-to-Digital converter (A/D)
• Synchronous Serial Port (SSP) with SPI™ (Master
mode) and I
2
C™ (Master/Slave)
• Brown-out detection circuitry for
Brown-out Reset (BOR)
MCLR/V
PP
RA0/AN0
RA1/AN1
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RA4/T0CKI
RA5/AN4/SS
V
SS
OSC1/CLKIN
OSC2/CLKOUT
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RC2/CCP1
RC3/SCK/SCL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
28
27
26
25
24
23
22
21
20
19
18
17
16
15
RB7/PGD
RB6/PGC
RB5
RB4
RB3/PGM
RB2
RB1
RB0/INT
V
DD
V
SS
RC7/RX/DT
RC6/TX/CK
RC5/SDO
RC4/SDI/SDA
Special Microcontroller Features:
• Power-on Reset (POR), Power-up Timer (PWRT)
and Oscillator Start-up Timer (OST)
• Watchdog Timer (WDT) with its own on-chip RC
oscillator for reliable operation
• Programmable code protection
• Power saving SLEEP mode
• Selectable oscillator options
• In-Circuit Serial Programming™ (ICSP™) via two
pins
• Single 5V In-Circuit Serial Programming capability
• In-Circuit Debugging via two pins
• Processor read/write access to program memory
CMOS Technology:
• Low power, high speed CMOS FLASH/EEPROM
technology
• Wide operating voltage range: 2.0V to 5.5V
• Fully static design
• Commercial, Industrial and Extended temperature
ranges
• Low power consumption:
- < 2 mA typical @ 5V, 4 MHz
- 20
μA
typical @ 3V, 32 kHz
- < 1
μA
typical standby current
©
2006 Microchip Technology Inc.
PIC16F872
DS30221C-page 1
PIC16F872
Table of Contents
1.0 Device Overview ......................................................................................................................................................................... 3
2.0 Memory Organization.................................................................................................................................................................. 7
3.0 Data EEPROM and FLASH Program Memory ......................................................................................................................... 23
4.0 I/O Ports.................................................................................................................................................................................... 29
5.0 Timer0 Module .......................................................................................................................................................................... 35
6.0 Timer1 Module .......................................................................................................................................................................... 39
7.0 Timer2 Module .......................................................................................................................................................................... 43
8.0 Capture/Compare/PWM Module............................................................................................................................................... 45
9.0 Master Synchronous Serial Port (MSSP) Module..................................................................................................................... 51
10.0 Analog-to-Digital Converter (A/D) Module ................................................................................................................................ 79
11.0 Special Features of the CPU .................................................................................................................................................... 87
12.0 Instruction Set Summary......................................................................................................................................................... 103
13.0 Development Support ............................................................................................................................................................. 111
14.0 Electrical Characteristics......................................................................................................................................................... 117
15.0 DC and AC Characteristics Graphs and Tables ..................................................................................................................... 139
16.0 Packaging Information ............................................................................................................................................................ 151
Appendix A: Revision History ........................................................................................................................................................... 155
Appendix B: Conversion Considerations........................................................................................................................................... 155
Index ................................................................................................................................................................................................. 157
On-Line Support................................................................................................................................................................................ 163
Reader Response ............................................................................................................................................................................. 164
PIC16F872 Product Identification System ........................................................................................................................................ 165
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@mail.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)
• The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include liter-
ature number) you are using.
Customer Notification System
Register on our web site at
www.microchip.com/cn
to receive the most current information on all of our products.
DS30221C-page 2
©
2006 Microchip Technology Inc.
PIC16F872
1.0
DEVICE OVERVIEW
This document contains device specific information
about the PIC16F872 microcontroller. Additional infor-
mation may be found in the PICmicro™ Mid-Range
Reference Manual (DS33023), which may be obtained
from your local Microchip Sales Representative or
downloaded from the Microchip website. The Refer-
ence Manual should be considered a complementary
document to this data sheet, and is highly recom-
mended reading for a better understanding of the
device architecture and operation of the peripheral
modules.
The block diagram of the PIC16F872 architecture is
shown in Figure 1-1. A pinout description is provided in
Table 1-2.
TABLE 1-1:
KEY FEATURES OF THE PIC16F872
DC - 20 MHz
POR, BOR (PWRT, OST)
2K
128
64
10
Ports A, B, C
3
1
MSSP
5 input channels
35 Instructions
28-lead PDIP
28-lead SOIC
28-lead SSOP
Operating Frequency
RESETS (and Delays)
FLASH Program Memory (14-bit words)
Data Memory (bytes)
EEPROM Data Memory (bytes)
Interrupts
I/O Ports
Timers
Capture/Compare/PWM module
Serial Communications
10-bit Analog-to-Digital Module
Instruction Set
Packaging
©
2006 Microchip Technology Inc.
DS30221C-page 3