PIC12(L)F1840
8-Pin Flash Microcontrollers with XLP Technology
High-Performance RISC CPU
• Only 49 Instructions to Learn:
- All single-cycle instructions except branches
• Operating Speed:
- DC – 32 MHz oscillator/clock input
- DC – 125 ns instruction cycle
• Interrupt Capability with Automatic Context
Saving
• 16-Level Deep Hardware Stack with Optional
Overflow/Underflow Reset
• Direct, Indirect and Relative Addressing modes:
- Two full 16-bit File Select Registers (FSRs)
- FSRs can read program and data memory
Extreme Low-Power Management with
PIC12LF1840 XLP
•
•
•
•
Sleep mode: 20 nA @ 1.8V, typical
Watchdog Timer: 500 nA @ 1.8V, typical
Timer1 Oscillator: 300 nA @ 32 kHz, 1.8V, typical
Operating Current: 30
A/MHz
@ 1.8V, typical
Analog Features
• Analog-to-Digital Converter (ADC) module:
- 10-bit resolution, 4 channels
- Conversion available during Sleep
• Analog Comparator module:
- One rail-to-rail analog comparator
- Power mode control
- Software controllable hysteresis
• Voltage Reference module:
- Fixed Voltage Reference (FVR) with 1.024V,
2.048V and 4.096V output levels
- 5-bit rail-to-rail resistive DAC with positive
and negative reference selection
Flexible Oscillator Structure
• Precision 32 MHz Internal Oscillator Block:
- Factory calibrated to ± 1%, typical
- Software selectable frequencies range of
31 kHz to 32 MHz
• 31 kHz Low-Power Internal Oscillator
• Four Crystal modes up to 32 MHz
• Three External Clock modes up to 32 MHz
• 4X Phase Lock Loop (PLL)
• Fail-Safe Clock Monitor:
- Allows for safe shutdown if peripheral clock
stops
• Two-Speed Oscillator Start-up
• Reference Clock module:
- Programmable clock output frequency and
duty-cycle
Peripheral Highlights
• 5 I/O Pins and 1 Input-Only Pin:
- High current sink/source 25 mA/25 mA
- Programmable weak pull-ups
- Programmable interrupt-on-change pins
• Timer0: 8-Bit Timer/Counter with 8-Bit Prescaler
• Enhanced Timer1:
- 16-bit timer/counter with prescaler
- External Gate Input mode
- Dedicated, low-power 32 kHz oscillator driver
• Timer2: 8-Bit Timer/Counter with 8-Bit Period
Register, Prescaler and Postscaler
• Enhanced CCP (ECCP) module:
- Software selectable time bases
- Auto-shutdown and auto-restart
- PWM steering
• Master Synchronous Serial Port (MSSP) with SPI
and I
2
C
TM
with:
- 7-bit address masking
- SMBus/PMBus
TM
compatibility
• Enhanced Universal Synchronous Asynchronous
Receiver Transmitter (EUSART) module:
- RS-232, RS-485 and LIN compatible
- Auto-Baud Detect
• Capacitive Sensing (CPS) module (mTouch
TM
):
- 4 input channels
Special Microcontroller Features
• Operating Voltage Range:
- 2.3V-5.5V (PIC12F1840)
- 1.8V-3.6V (PIC12LF1840)
• Self-Reprogrammable under Software Control
• Power-on Reset (POR), Power-up Timer (PWRT)
and Oscillator Start-up Timer (OST)
• Programmable Brown-out Reset (BOR)
• Extended Watchdog Timer (WDT)
• In-Circuit Serial Programming™ (ICSP™) via
Two Pins
• In-Circuit Debug (ICD) via Two Pins
• Enhanced Low-Voltage Programming (LVP)
• Programmable Code Protection
• Power-Saving Sleep mode
2011-2015 Microchip Technology Inc.
DS40001441F-page 1
PIC12(L)F1840
Peripheral Features (Continued)
• Data Signal Modulator module:
- Selectable modulator and carrier sources
• SR Latch:
- Multiple Set/Reset input options
- Emulates 555 Timer applications
PIC12(L)F1822/1840/PIC16(L)F182X/1847 Family Types
ECCP (Full-Bridge)
ECCP (Half-Bridge)
CCP
Program Memory
Flash (words)
MSSP (I
2
C™/SPI)
Data Sheet Index
10-bit ADC (ch)
CapSense (ch)
Data EEPROM
(bytes)
Comparators
Data SRAM
(bytes)
SR Latch
Timers
(8/16-bit)
EUSART
Debug
(1)
I/H
I/H
I/H
I/H
I/H
I/H
I/H
I/H
I/H
I/H
I/O’s
(2)
Device
PIC12(L)F1822
(1)
2K
256
128
6
4
4
1
2/1
1
1
0/1/0
Y
PIC12(L)F1840
(2)
4K
256
256
6
4
4
1
2/1
1
1
0/1/0
Y
PIC16(L)F1823
(1)
2K
256
128 12
8
8
2
2/1
1
1
1/0/0
Y
PIC16(L)F1824
(3)
4K
256
256 12
8
8
2
4/1
1
1
1/1/2
Y
PIC16(L)F1825
(4)
8K
256 1024 12
8
8
2
4/1
1
1
1/1/2
Y
PIC16(L)F1826
(5)
2K
256
256 16 12 12
2
2/1
1
1
1/0/0
Y
PIC16(L)F1827
(5)
4K
256
384 16 12 12
2
4/1
1
2
1/1/2
Y
PIC16(L)F1828
(3)
4K
256
256 18 12 12
2
4/1
1
1
1/1/2
Y
PIC16(L)F1829
(4)
8K
256 1024 18 12 12
2
4/1
1
2
1/1/2
Y
PIC16(L)F1847
(6)
8K
256 1024 16 12 12
2
4/1
1
2
1/1/2
Y
Note 1:
I - Debugging, Integrated on Chip; H - Debugging, available using Debug Header.
2:
One pin is input-only.
Data Sheet Index:
(Unshaded devices are described in this document.)
1:
DS41413
PIC12(L)F1822/PIC16(L)F1823 Data Sheet, 8/14-Pin Flash Microcontrollers.
2:
DS41441
PIC12(L)F1840 Data Sheet, 8-Pin Flash Microcontrollers.
3:
DS41419
PIC16(L)F1824/1828 Data Sheet, 28/40/44-Pin Flash Microcontrollers.
4:
DS41440
PIC16(L)F1825/1829 Data Sheet, 14/20-Pin Flash Microcontrollers.
5:
DS41391
PIC16(L)F1826/1827 Data Sheet, 18/20/28-Pin Flash Microcontrollers.
6:
DS41453
PIC16(L)F1847 Data Sheet, 18/20/28-Pin Flash Microcontrollers.
Note:
For other small form-factor package availability and marking information, please visit
http://www.microchip.com/packaging
or contact your local sales office.
DS40001441F-page 2
2011-2015 Microchip Technology Inc.
XLP
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
PIC12(L)F1840
FIGURE 1:
8-PIN DIAGRAM FOR PIC12(L)F1840
PDIP, SOIC, DFN, UDFN
V
DD
RA5
RA4
MCLR/V
PP
/RA3
1
2
3
4
8
7
6
5
V
SS
RA0/ICSPDAT
RA1/ICSPCLK
RA2
PIC12(L)F1840
Note
1:
See
Table 1
for the location of all peripheral functions.
TABLE 1:
8-Pin PDIP/SOIC/DFN/UDFN
8-PIN ALLOCATION TABLE (PIC12(L)F1840)
Comparator
Cap Sense
Reference
Modulator
SR Latch
EUSART
Interrupt
Pull-up
Timers
RA0
RA1
RA2
7
6
5
AN0
AN1
AN2
DACOUT
V
REF
—
CPS0
CPS1
CPS2
C1IN+
C1IN0-
C1OUT
—
SRI
SRQ
—
—
T0CKI
P1B
—
CCP1
P1A
FLT0
—
P1B
(1)
TX
CK
RX
DT
—
SDO
SS
(1)
SCL
SCK
SDA
SDI
SS
SDO
(1)
IOC
IOC
INT/
IOC
IOC
IOC
MDOUT
MDMIN
MDCIN1
Y
Y
Y
Y
Y
ICSPDAT
ICDDAT
ICSPCLK
ICPCLK
—
RA3
RA4
4
3
—
AN3
—
—
—
CPS3
—
C1IN1-
—
—
T1G
(1)
T1G
T1OSO
T1CKI
T1OSI
—
—
—
TX
(1)
CK
(1)
RX
(1)
DT
(1)
—
—
—
MDCIN2
MCLR
V
PP
OSC2
CLKOUT
CLKR
OSC1
CLKIN
V
DD
V
SS
RA5
V
DD
V
SS
Note 1:
2
1
8
—
—
—
—
—
—
—
—
—
—
—
—
SRNQ
—
—
CCP1
(1)
P1A
(1)
—
—
—
—
—
IOC
—
—
—
—
—
Y
—
—
Alternate pin function selected with the APFCON (Register
12-1)
register.
2011-2015 Microchip Technology Inc.
DS40001441F-page 3
Basic
MSSP
ECCP
ADC
I/O
PIC12(L)F1840
Table of Contents
1.0 Device Overview .......................................................................................................................................................................... 6
2.0 Enhanced Mid-range CPU ......................................................................................................................................................... 10
3.0 Memory Organization ................................................................................................................................................................. 12
4.0 Device Configuration .................................................................................................................................................................. 32
5.0 Oscillator Module (with Fail-Safe Clock Monitor) ....................................................................................................................... 38
6.0 Reference Clock Module ............................................................................................................................................................ 56
7.0 Resets ........................................................................................................................................................................................ 59
8.0 Interrupts .................................................................................................................................................................................... 67
9.0 Power-Down Mode (Sleep) ........................................................................................................................................................ 77
10.0 Watchdog Timer (WDT) ............................................................................................................................................................. 81
11.0 Data EEPROM and Flash Program Memory Control ................................................................................................................. 85
12.0 I/O Ports ..................................................................................................................................................................................... 98
13.0 Interrupt-on-Change ................................................................................................................................................................. 105
14.0 Fixed Voltage Reference (FVR) ............................................................................................................................................... 109
15.0 Temperature Indicator Module ................................................................................................................................................. 112
16.0 Analog-to-Digital Converter (ADC) Module .............................................................................................................................. 114
17.0 Digital-to-Analog Converter (DAC) Module .............................................................................................................................. 127
18.0 SR Latch................................................................................................................................................................................... 131
19.0 Comparator Module.................................................................................................................................................................. 135
20.0 Timer0 Module ......................................................................................................................................................................... 143
21.0 Timer1 Module with Gate Control............................................................................................................................................. 146
22.0 Timer2 Module ......................................................................................................................................................................... 157
23.0 Data Signal Modulator .............................................................................................................................................................. 161
24.0 Capture/Compare/PWM Modules ............................................................................................................................................ 171
25.0 Master Synchronous Serial Port Module .................................................................................................................................. 192
26.0 Enhanced Universal Synchronous Asynchronous Receiver Transmitter (EUSART) ............................................................... 247
27.0 Capacitive Sensing (CPS) Module ........................................................................................................................................... 276
28.0 In-Circuit Serial Programming™ (ICSP™) ............................................................................................................................... 284
29.0 Instruction Set Summary .......................................................................................................................................................... 288
30.0 Electrical Specifications............................................................................................................................................................ 302
31.0 DC and AC Characteristics Graphs and Charts ....................................................................................................................... 339
32.0 Development Support............................................................................................................................................................... 376
33.0 Packaging Information.............................................................................................................................................................. 380
Appendix A: Data Sheet Revision History.......................................................................................................................................... 393
Appendix B: Migrating From Other PIC® Devices ............................................................................................................................. 393
The Microchip Web Site ..................................................................................................................................................................... 394
Customer Change Notification Service .............................................................................................................................................. 394
Customer Support .............................................................................................................................................................................. 394
Product Identification System............................................................................................................................................................. 395
DS40001441F-page 4
2011-2015 Microchip Technology Inc.
PIC12(L)F1840
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.
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., DS30000000A is version A of document DS30000000).
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.
2011-2015 Microchip Technology Inc.
DS40001441F-page 5