PIC18F1220/1320
Data Sheet
18/20/28-Pin High-Performance,
Enhanced Flash Microcontrollers
with 10-Bit A/D and nanoWatt Technology
©
2007 Microchip Technology Inc.
DS39605F
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.
© 2007, 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 PIC
®
MCUs and dsPIC DSCs, 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.
DS39605F-page ii
©
2007 Microchip Technology Inc.
PIC18F1220/1320
18/20/28-Pin High-Performance, Enhanced Flash MCUs
with 10-bit A/D and nanoWatt Technology
Low-Power Features:
• Power Managed modes:
- Run: CPU on, peripherals on
- Idle: CPU off, peripherals on
- Sleep: CPU off, peripherals off
• Power Consumption modes:
- PRI_RUN: 150
μA,
1 MHz, 2V
- PRI_IDLE: 37
μA,
1 MHz, 2V
- SEC_RUN: 14
μA,
32 kHz, 2V
- SEC_IDLE: 5.8
μA,
32 kHz, 2V
- RC_RUN: 110
μA,
1 MHz, 2V
- RC_IDLE: 52
μA,
1 MHz, 2V
- Sleep: 0.1
μA,
1 MHz, 2V
• Timer1 Oscillator: 1.1
μA,
32 kHz, 2V
• Watchdog Timer: 2.1
μA
• Two-Speed Oscillator Start-up
Peripheral Highlights:
• High current sink/source 25 mA/25 mA
• Three external interrupts
• Enhanced Capture/Compare/PWM (ECCP) module:
- One, two or four PWM outputs
- Selectable polarity
- Programmable dead time
- Auto-Shutdown and Auto-Restart
- Capture is 16-bit, max resolution 6.25 ns (T
CY
/16)
- Compare is 16-bit, max resolution 100 ns (T
CY
)
• Compatible 10-bit, up to 13-channel Analog-to-
Digital Converter module (A/D) with programmable
acquisition time
• Enhanced USART module:
- Supports RS-485, RS-232 and LIN 1.2
- Auto-Wake-up on Start bit
- Auto-Baud Detect
Oscillators:
• Four Crystal modes:
- LP, XT, HS: up to 25 MHz
- HSPLL: 4-10 MHz (16-40 MHz internal)
• Two External RC modes, up to 4 MHz
• Two External Clock modes, up to 40 MHz
• Internal oscillator block:
- 8 user-selectable frequencies: 31 kHz, 125 kHz,
250 kHz, 500 kHz, 1 MHz, 2 MHz, 4 MHz, 8 MHz
- 125 kHz to 8 MHz calibrated to 1%
- Two modes select one or two I/O pins
- OSCTUNE
–
Allows user to shift frequency
• Secondary oscillator using Timer1 @ 32 kHz
• Fail-Safe Clock Monitor
- Allows for safe shutdown if peripheral clock stops
Special Microcontroller Features:
• 100,000 erase/write cycle Enhanced Flash
program memory typical
• 1,000,000 erase/write cycle Data EEPROM
memory typical
• Flash/Data EEPROM Retention: > 40 years
• Self-programmable under software control
• Priority levels for interrupts
• 8 x 8 Single-Cycle Hardware Multiplier
• Extended Watchdog Timer (WDT):
- Programmable period from 41 ms to 131s
- 2% stability over V
DD
and Temperature
• Single-supply 5V In-Circuit Serial Programming™
(ICSP™) via two pins
• In-Circuit Debug (ICD) via two pins
• Wide operating voltage range: 2.0V to 5.5V
Program Memory
Device
Flash
(bytes)
4K
8K
# Single-Word
Instructions
2048
4096
Data Memory
SRAM
(bytes)
256
256
EEPROM
(bytes)
256
256
I/O
10-bit
A/D (ch)
7
7
ECCP
(PWM)
1
1
EUSART
Timers
8/16-bit
1/3
1/3
PIC18F1220
PIC18F1320
16
16
Y
Y
©
2007 Microchip Technology Inc.
DS39605F-page 1
PIC18F1220/1320
Pin Diagrams
18-Pin PDIP, SOIC
RA0/AN0
RA1/AN1/LVDIN
RA4/T0CKI
MCLR/V
PP
/RA5
V
SS
/AV
SS
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RB0/AN4/INT0
RB1/AN5/TX/
CK/INT1
1
2
18
17
RB3/CCP1/P1A
RB2/P1B/INT2
OSC1/CLKI/RA7
OSC2/CLKO/RA6
V
DD
/AV
DD
RB7/PGD/T1OSI/
P1D/KBI3
RB6/PGC/T1OSO/
T13CKI/P1C/KBI2
RB5/PGM/KBI1
RB4/AN6/RX/
DT/KBI0
20-Pin SSOP
RA0/AN0
RA1/AN1/LVDIN
RA4/T0CKI
MCLR/V
PP
/RA5
V
SS
AV
SS
RA2/AN2/V
REF
-
RA3/AN3/V
REF
+
RB0/AN4/INT0
RB1/AN5/TX/
CK/INT1
1
2
3
20
19
18
RB3/CCP1/P1A
RB2/P1B/INT2
OSC1/CLKI/RA7
OSC2/CLKO/RA6
V
DD
AV
DD
RB7/PGD/T1OSI/
P1D/KBI3
RB6/PGC/T1OSO/
T13CKI/P1C/KBI2
RB5/PGM/KBI1
RB4/AN6/RX/
DT/KBI0
PIC18F1X20
3
4
5
6
7
8
9
16
15
14
13
12
11
10
5
6
7
8
9
10
PIC18F1X20
4
17
16
15
14
13
12
11
RB3/CCP1/P1A
24
RB2/P1B/INT2
23
28-Pin QFN
RA4/T0CKI
RA1/AN1/LVDIN
RA0/AN0
28
27
26
25
NC
MCLR/V
PP
/RA5
NC
V
SS
NC
AV
SS
NC
RA2/AN2/V
REF
-
22
21
20
19
1
2
3
4
5
6
7
10
11
12
13
14
8
9
NC
OSC1/CLKI/RA7
OSC2/CLKO/RA6
V
DD
NC
AV
DD
RB7/PGD/T1OSI/P1D/KBI3
RB6/PGC/T1OSO/T13CKI/P1C/KBI2
PIC18F1X20
18
17
16
15
RA3/AN3/V
REF
+
RB1/AN5/TX/CK/INT1
RB4/AN6/RX/DT/KBI0
RB5/PGM/KBI1
RB0/AN4/INT0
NC
NC
DS39605F-page 2
©
2007 Microchip Technology Inc.
PIC18F1220/1320
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 5
2.0 Oscillator Configurations ............................................................................................................................................................ 11
3.0 Power Managed Modes ............................................................................................................................................................. 19
4.0 Reset .......................................................................................................................................................................................... 33
5.0 Memory Organization ................................................................................................................................................................. 41
6.0 Flash Program Memory.............................................................................................................................................................. 57
7.0 Data EEPROM Memory ............................................................................................................................................................. 67
8.0 8 x 8 Hardware Multiplier............................................................................................................................................................ 71
9.0 Interrupts .................................................................................................................................................................................... 73
10.0 I/O Ports ..................................................................................................................................................................................... 87
11.0 Timer0 Module ........................................................................................................................................................................... 99
12.0 Timer1 Module ......................................................................................................................................................................... 103
13.0 Timer2 Module ......................................................................................................................................................................... 109
14.0 Timer3 Module ......................................................................................................................................................................... 111
15.0 Enhanced Capture/Compare/PWM (ECCP) Module................................................................................................................ 115
16.0 Enhanced Addressable Universal Synchronous Asynchronous Receiver Transmitter (EUSART) .......................................... 131
17.0 10-Bit Analog-to-Digital Converter (A/D) Module ..................................................................................................................... 155
18.0 Low-Voltage Detect .................................................................................................................................................................. 165
19.0 Special Features of the CPU.................................................................................................................................................... 171
20.0 Instruction Set Summary .......................................................................................................................................................... 191
21.0 Development Support............................................................................................................................................................... 233
22.0 Electrical Characteristics .......................................................................................................................................................... 237
23.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 267
24.0 Packaging Information.............................................................................................................................................................. 285
Appendix A: Revision History............................................................................................................................................................. 291
Appendix B: Device Differences ........................................................................................................................................................ 291
Appendix C: Conversion Considerations ........................................................................................................................................... 292
Appendix D: Migration from Baseline to Enhanced Devices.............................................................................................................. 292
Appendix E: Migration from Mid-Range to Enhanced Devices .......................................................................................................... 293
Appendix F: Migration from High-End to Enhanced Devices ............................................................................................................. 293
Index .................................................................................................................................................................................................. 295
The Microchip Web Site ..................................................................................................................................................................... 303
Customer Change Notification Service .............................................................................................................................................. 303
Customer Support .............................................................................................................................................................................. 303
Reader Response .............................................................................................................................................................................. 304
PIC18F1220/1320 Product Identification System .............................................................................................................................. 305
©
2007 Microchip Technology Inc.
DS39605F-page 3