PIC16F818/819
Data Sheet
18/20-Pin
Enhanced Flash Microcontrollers
with nanoWatt Technology
2004 Microchip Technology Inc.
DS39598E
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 WAR-
RANTIES 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’s products 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
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, 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, Migratable Memory, MPASM,
MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net,
PICLAB, PICtail, PowerCal, PowerInfo, PowerMate,
PowerTool, rfLAB, rfPICDEM, Select Mode, Smart Serial,
SmartTel and Total Endurance 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.
© 2004, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
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
®
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.
DS39598E-page ii
2004 Microchip Technology Inc.
PIC16F818/819
18/20-Pin Enhanced Flash Microcontrollers
with nanoWatt Technology
Low-Power Features:
• Power-Managed modes:
- Primary Run: XT, RC oscillator,
87
µA,
1 MHz, 2V
- INTRC: 7
µA,
31.25 kHz, 2V
- Sleep: 0.2
µA,
2V
• Timer1 oscillator: 1.8
µA,
32 kHz, 2V
• Watchdog Timer: 0.7
µA,
2V
• Wide operating voltage range:
- Industrial: 2.0V to 5.5V
Pin Diagram
18-Pin PDIP, SOIC
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RA4/AN4/T0CKI
RA5/MCLR/V
PP
V
SS
RB0/INT
RB1/SDI/SDA
RB2/SDO/CCP1
RB3/CCP1/PGM
•1
2
3
4
5
6
7
8
9
18
17
16
15
14
13
12
11
10
RA1/AN1
RA0/AN0
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
RB7/T1OSI/PGD
RB6/T1OSO/T1CKI/PGC
RB5/SS
RB4/SCK/SCL
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
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
TM
(ICSP
TM
) via two pins
• Processor read/write access to program memory
• Low-Voltage Programming
• In-Circuit Debugging via two pins
Peripheral Features:
•
•
•
•
•
•
16 I/O pins with individual direction control
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
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, 5-channel Analog-to-Digital converter
Synchronous Serial Port (SSP) with
SPI™ (Master/Slave) and I
2
C™ (Slave)
•
•
Program Memory
Device
Flash
(Bytes)
1792
3584
# Single-Word
Instructions
1024
2048
Data Memory
SRAM
(Bytes)
128
256
EEPROM I/O Pins
(Bytes)
128
256
16
16
10-bit
A/D (ch)
5
5
CCP
(PWM)
1
1
PIC16F818/819
SSP
Slave
SPI™
2
I C™
Y
Y
Y
Y
Timers
8/16-bit
2/1
2/1
PIC16F818
PIC16F819
2004 Microchip Technology Inc.
DS39598E-page 1
PIC16F818/819
Pin Diagrams
18-Pin PDIP, SOIC
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RA4/AN4/T0CKI
RA5/MCLR/V
PP
V
SS
RB0/INT
RB1/SDI/SDA
RB2/SDO/CCP1
RB3/CCP1/PGM
•1
2
3
4
5
6
7
8
9
18
17
16
15
14
13
12
11
10
RA1/AN1
RA0/AN0
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
RB7/T1OSI/PGD
RB6/T1OSO/T1CKI/PGC
RB5/SS
RB4/SCK/SCL
20-Pin SSOP
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RA4/AN4/T0CKI
RA5/MCLR/V
PP
V
SS
V
SS
RB0/INT
RB1/SDI/SDA
RB2/SDO/CCP1
RB3/CCP1/PGM
•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/T1OSI/PGD
RB6/T1OSO/T1CKI/PGC
RB5/SS
RB4/SCK/SCL
PIC16F818/819
RA4/AN4/T0CKI
RA3/AN3/V
REF
+
RA2/AN2/V
REF
-
28-Pin QFN
RA1/AN1
RA0/AN0
NC
28
27
26
25
24
23
22
NC
RA5/MCLR/V
PP
NC
V
SS
NC
V
SS
NC
RB0/INT
1
2
3
4
5
6
7
10
11
12
13
14
8
9
21
20
19
RA7/OSC1/CLKI
RA6/OSC2/CLKO
V
DD
NC
V
DD
RB7/T1OSI/PGD
RB6/T1OSO/T1CKI/PGC
PIC16F818/819
18
17
16
15
RB3/CCP1/PGM
RB2/SDO/CCP1
RB4/SCK/SCL
NC
RB1/SDI/SDA
RB5/SS
NC
DS39598E-page 2
PIC16F818/819
2004 Microchip Technology Inc.
PIC16F818/819
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 5
2.0 Memory Organization ................................................................................................................................................................... 9
3.0 Data EEPROM and Flash Program Memory.............................................................................................................................. 25
4.0 Oscillator Configurations ............................................................................................................................................................ 33
5.0 I/O Ports ..................................................................................................................................................................................... 39
6.0 Timer0 Module ........................................................................................................................................................................... 53
7.0 Timer1 Module ........................................................................................................................................................................... 57
8.0 Timer2 Module ........................................................................................................................................................................... 63
9.0 Capture/Compare/PWM (CCP) Module ..................................................................................................................................... 65
10.0 Synchronous Serial Port (SSP) Module ..................................................................................................................................... 71
11.0 Analog-to-Digital Converter (A/D) Module.................................................................................................................................. 81
12.0 Special Features of the CPU...................................................................................................................................................... 89
13.0 Instruction Set Summary .......................................................................................................................................................... 103
14.0 Development Support............................................................................................................................................................... 111
15.0 Electrical Characteristics .......................................................................................................................................................... 117
16.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 143
17.0 Packaging Information.............................................................................................................................................................. 157
Appendix A: Revision History............................................................................................................................................................. 163
Appendix B: Device Differences ........................................................................................................................................................ 163
Index .................................................................................................................................................................................................. 165
On-Line Support................................................................................................................................................................................. 171
Systems Information and Upgrade Hot Line ...................................................................................................................................... 171
Reader Response .............................................................................................................................................................................. 172
PIC16F818/819 Product Identification System .................................................................................................................................. 173
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.
2004 Microchip Technology Inc.
DS39598E-page 3