Note the following details of the code protection feature on Microchip devices:
YSTEM
CERTIFIED BY DNV
== ISO/TS 16949==
•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, dsPIC,
K
logo, rfPIC and UNI/O are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor,
MXDEV, MXLAB, SEEVAL 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, chipKIT,
chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net,
dsPICworks, dsSPEAK, ECAN, ECONOMONITOR,
FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP,
Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB,
MPLINK, mTouch, Omniscient Code Generation, PICC,
PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE,
rfLAB, Select Mode, Total Endurance, TSHARC,
UniWinDriver, 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.
DS41639A-page 2Preliminary 2012 Microchip Technology Inc.
ISBN: 9781620763476
Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
are for its PIC
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.
®
MCUs and dsPIC® DSCs, KEELOQ
®
code hopping
PIC16(L)F1454/5/9
14/20-Pin, 8-Bit Flash USB Microcontroller with
XLP Technology
High-Performance RISC CPU:
• C Compiler Optimized Architecture
• Only 49 Instructions
• 14 Kbytes Linear Program Memory Addressing
• 1024 Bytes Linear Data Memory Addressing
• Operating Speed:
- DC – 48 MHz clock input
- DC – 83 ns instruction cycle
- Selectable 3x or 4x PLL for specific frequencies
• 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)
capable of accessing both data or program
memory
- FSRs can read program and data memory
Special Microcontroller Features:
• Operating Voltage Range:
- 1.8V to 3.6V (PIC16LF145X)
- 2.3V to 5.5V (PIC16F145X)
• Self-Programmable under Software Control
• Power-on Reset (POR)
• Power-up Timer (PWRT)
• Programmable Brown-Out Reset (BOR)
• Low-Power BOR (LPBOR)
• Extended Watchdog Timer (WDT):
- Programmable period from 1 ms to 256s
• Programmable Code Protection
• In-Circuit Serial Programming™ (ICSP™) via Two
Pins
• Enhanced Low-Voltage Programming (LVP)
• Power-Saving Sleep mode:
Universal Serial Bus (USB) Features:
• Self-Tuning from USB Host
(eliminates need for external crystal)
• USB V2.0 Compliant SIE
• Low Speed (1.5 Mb/s) and Full Speed (12 Mb/s)
• Supports Control, Interrupt, Isochronous and Bulk
Transfers
• Supports up to Eight Bidirectional Endpoints
• 512-Byte Dual Access RAM for USB
• Interrupt-on-Change (IOC) on D+/D- for USB Host
Detection
• Configurable Internal Pull-up Resistors for use
with USB
Extreme Low-Power Management
PIC16LF145X with XLP:
• Sleep mode: 25 nA @ 1.8V, typical
• Watchdog Timer Current: 290 nA @ 1.8V, typical
• Timer1 Oscillator: 600 nA @ 32 kHz, typical
• Operating Current: 25 A/MHz @ 1.8V, typical
Flexible Oscillator Structure:
• 16 MHz Internal Oscillator Block:
- Factory calibrated to ±0.25%, typical
- Software selectable frequency range from
16 MHz to 31 kHz
- Tunable to 0.25% across temperature range
- 48 MHz with 3x PLL
• 31 kHz Low-Power Internal Oscillator
• Clock Switching with run from:
- Primary Oscillator
- Secondary Oscillator (SOSC)
- Internal Oscillator
• Clock Reference Output:
- Clock Prescaler
-CLKOUT
Analog Features
• Analog-to-Digital Converter (ADC):
- 10-bit resolution
- Up to nine external channels
- Two internal channels:
- Fixed Voltage Reference channel
- DAC output channel
- Auto acquisition capability
- Conversion available during Sleep
• Two Comparators:
- Rail-to-rail inputs
- Power mode control
- Software controllable hysteresis
• Voltage Reference module:
- Fixed Voltage Reference (FVR) with 1.024V,
2.048V and 4.096V output levels
• Up to One Rail-to-Rail Resistive 5-Bit DAC with
Positive Reference Selection
2.0Enhanced Mid-Range CPU ........................................................................................................................................................ 21
11.0 Flash Program Memory Control ............................................................................................................................................... 112
22.0 Master Synchronous Serial Port (MSSP) Module .................................................................................................................... 203
26.0 Universal Serial Bus (USB) ...................................................................................................................................................... 309
27.0 In-Circuit Serial Programming™ (ICSP™) ............................................................................................................................... 337
28.0 Instruction Set Summary .......................................................................................................................................................... 339
30.0 DC and AC Characteristics Graphs and Charts ....................................................................................................................... 383
31.0 Development Support............................................................................................................................................................... 385
Appendix A: Data Sheet Revision History .......................................................................................................................................... 407
Index .................................................................................................................................................................................................. 409
The Microchip Web Site..................................................................................................................................................................... 415
Customer Change Notification Service .............................................................................................................................................. 415
Customer Support .............................................................................................................................................................................. 415
DS41639A-page 10Preliminary 2012 Microchip Technology Inc.
PIC16(L)F145X
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.
RC5/T0CKI/CWG1A/PWM1RC5TTLCMOS General purpose I/O.
RC6/AN8/SS
RC7/AN9/SDORC7TTLCMOS General purpose I/O.
DDVDDPower—Positive supply.
V
SSVSSPower—Ground reference.
V
USB3V3VUSB3V3Power—Positive supply for USB transceiver.
V
Legend: AN = Analog input or output CMOS= CMOS compatible input or outputOD= Open Drain
Note 1:Default location for peripheral pin function. Alternate location can be selected using the APFCON register.
REF+/C1IN+/C2IN+/
/INT/ICSPCLK
(2)
(1)
/PWM2RC6TTLCMOS General purpose I/O.
TTL = TTL compatible inputST= Schmitt Trigger input with CMOS levels I
HV = High VoltageXTAL = Crystallevels
2:Alternate location for peripheral pin function selected by the APFCON register.
3:LVP support for PIC18(L)F1XK50 legacy designs.
RC0TTLCMOS General purpose I/O.
AN4AN—A/D Channel input.
REF+AN—Positive Voltage Reference input.
V
C1IN+AN—Comparator positive input.
C2IN+AN—Comparator positive input.
ICSPDATSTCMOS ICSP™ Data I/O.
RC1TTLCMOS General purpose I/O.
AN5AN—A/D Channel input.
C1IN1-AN—Comparator negative input.
C2IN1-AN—Comparator negative input.
CWGFLT
INTST—External input.
ICSPCLKST—ICSP Programming Clock.
RC2TTLCMOS General purpose I/O.
AN6AN—A/D Channel input.
DACOUT1—ANDigital-to-Analog Converter output.
C1IN2-AN—Comparator negative input.
C2IN2-AN—Comparator negative input.
RC3TTLCMOS General purpose I/O.
AN7AN—A/D Channel input.
DACOUT2—ANDigital-to-Analog Converter output.
C1IN3-AN—Comparator negative input.
C2IN3-AN—Comparator negative input.
CLKR—CMOS Clock reference output.
RC4TTLCMOS General purpose I/O.
C1OUT—CMOS Comparator output.
C2OUT—CMOS Comparator output.
CWG1B—CMOS CWG complementary output.
T0CKIST—Timer0 clock input.
CWG1A—CMOS CWG complementary output.
PWM1—CMOS PWM output.
AN8AN—A/D Channel input.
SS
PWM2—CMOS PWM output.
AN9AN—A/D Channel input.
SDO—CMOS SPI data output.
Output
Typ e
Typ e
ST—Complementary Waveform Generator Fault input.
ST—Slave Select input.
Description
2
C™ = Schmitt Trigger input with I2C
DS41639A-page 20Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
Data Bus
8
14
Program
Bus
Instruction reg
Program Counter
8 LevelStack
(13-bit)
Direct Addr
7
12
Addr MUX
FSR reg
STATUS reg
MUX
ALU
InstructionDecode &
Control
Timing
Generation
OSC1/CLKIN
OSC2/CLKOUT
8
8
12
3
Internal
Oscillator
Block
Configuration
Data Bus
8
14
Program
Bus
Instruction reg
Program Counter
8 LevelStack
(13-bit)
Direct Addr
7
Addr MUX
FSR reg
STATUS reg
MUX
ALU
W Reg
InstructionDecode &
Control
Timing
Generation
8
8
3
Internal
Oscillator
Block
Configuration
15
Data Bus
8
14
Program
Bus
Instruction Reg
Program Counter
16-Level Stack
(15-bit)
Direct Addr
7
RAM Addr
Addr MUX
Indirect
Addr
FSR0 Reg
STATUS Reg
MUX
ALU
Instruction
Decode and
Control
Timing
Generation
8
8
3
Internal
Oscillator
Block
Configuration
Flash
Program
Memory
RAM
FSR regFSR reg
FSR1 Reg
15
15
MUX
15
Program Memory
Read (PMR)
12
FSR regFSR reg
BSR Reg
5
Power-up
Timer
Power-on
Reset
Watchdog
Timer
V
DD
Brown-out
Reset
VSSVDDVSSVDDVSS
2.0ENHANCED MID-RANGE CPU
This family of devices contain an enhanced mid-range
8-bit CPU core. The CPU has 49 instructions. Interrupt
capability includes automatic context saving. The
hardware stack is 16 levels deep and has Overflow and
Underflow Reset capability. Direct, Indirect, and
FIGURE 2-1:CORE BLOCK DIAGRAM
Relative Addressing modes are available. Two File
Select Registers (FSRs) provide the ability to read
program and data memory.
During interrupts, certain registers are automatically
saved in shadow registers and restored when returning
from the interrupt. This saves stack space and user
code. See Section 8.5 “Automatic Context Saving”,
for more information.
2.216-Level Stack with Overflow and
Underflow
These devices have an external stack memory 15 bits
wide and 16 words deep. A Stack Overflow or Underflow will set the appropriate bit (STKOVF or STKUNF)
in the PCON register, and if enabled will cause a software Reset. See section Section 3.5 “Stack” for more
details.
2.3File Select Registers
There are two 16-bit File Select Registers (FSR). FSRs
can access all file registers and program memory,
which allows one Data Pointer for all memory. When an
FSR points to program memory, there is one additional
instruction cycle in instructions using INDF to allow the
data to be fetched. General purpose memory can now
also be addressed linearly, providing the ability to
access contiguous data larger than 80 bytes. There are
also new instructions to support the FSRs. See
Section 3.6 “Indirect Addressing” for more details.
2.4Instruction Set
There are 49 instructions for the enhanced mid-range
CPU to support the features of the CPU. See
Section 28.0 “Instruction Set Summary” for more
details.
DS41639A-page 22Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
3.0MEMORY ORGANIZATION
These devices contain the following types of memory:
• Program Memory
- Configuration Words
- Device ID
-User ID
- Flash Program Memory
• Data Memory
- Core Registers
- Special Function Registers
- Dual-Port General Purpose RAM
- General Purpose RAM
- Common RAM
The following features are associated with access and
control of program memory and data memory:
• PCL and PCLATH
•Stack
• Indirect Addressing
3.1Program Memory Organization
The enhanced mid-range core has a 15-bit program
counter capable of addressing a 32K x 14 program
memory space. Table 3-1 shows the memory sizes
implemented. Accessing a location above these
boundaries will cause a wrap-around within the
implemented memory space. The Reset vector is at
0000h and the interrupt vector is at 0004h (See
Figure 3-1).
TABLE 3-1:DEVICE SIZES AND ADDRESSES
Device
PIC16F1454
PIC16LF1454
PIC16F1455
PIC16LF1455
PIC16F1459
PIC16LF1459
Note 1: High-endurance Flash applies to low byte of each address in the range.
;select data
RETLW DATA0;Index0 data
RETLW DATA1;Index1 data
RETLW DATA2
RETLW DATA3
my_function
;… LOTS OF CODE…
MOVLWDATA_INDEX
call constants
;… THE CONSTANT IS IN W
FIGURE 3-1:PROGRAM MEMORY MAP
AND STACK FOR
PIC16(L)F1454/5/9
3.1.1READING PROGRAM MEMORY AS
DATA
There are two methods of accessing constants in program memory. The first method is to use tables of
RETLW instructions. The second method is to set an
FSR to point to the program memory.
3.1.1.1RETLW Instruction
The RETLW instruction can be used to provide access
to tables of constants. The recommended way to create
such a table is shown in Example 3-1.
EXAMPLE 3-1:RETLW INSTRUCTION
The BRW instruction makes this type of table very simple to implement. If your code must remain portable
with previous generations of microcontrollers, then the
BRW instruction is not available so the older table read
method must be used.
DS41639A-page 24Preliminary 2012 Microchip Technology Inc.
3.1.1.2Indirect Read with FSR
constants
RETLW DATA0;Index0 data
RETLW DATA1;Index1 data
RETLW DATA2
RETLW DATA3
The program memory can be accessed as data by setting bit 7 of the FSRxH register and reading the matching INDFx register. The MOVIW instruction will place the
lower eight bits of the addressed word in the W register.
Writes to the program memory cannot be performed via
the INDF registers. Instructions that access the program memory via the FSR require one extra instruction
cycle to complete. Example 3-2 demonstrates accessing the program memory via an FSR.
The High directive will set bit<7> if a label points to a
location in program memory.
x00h or x80hINDF0
x01h or x81hINDF1
x02h or x82hPCL
x03h or x83hSTATUS
x04h or x84hFSR0L
x05h or x85hFSR0H
x06h or x86hFSR1L
x07h or x87hFSR1H
x08h or x88hBSR
x09h or x89hWREG
x0Ah or x8AhPCLATH
x0Bh or x8BhINTCON
3.2Data Memory Organization
The data memory is partitioned in 32 memory banks
with 128 bytes in a bank. Each bank consists of
(Figure 3-2):
• 12 core registers
• 20 Special Function Registers (SFR)
• Up to 80 bytes of General Purpose RAM (GPR)
• Up to 80 bytes of Dual-Port General Purpose
RAM (DPR)
• 16 bytes of common RAM
The active bank is selected by writing the bank number
into the Bank Select Register (BSR). Unimplemented
memory will read as ‘0’. All data memory can be
accessed either directly (via instructions that use the
file registers) or indirectly via the two File Select
Registers (FSR). See Section 3.6 “Indirect
Addressing” for more information.
Data memory uses a 12-bit address. The upper 7-bits
of the address define the Bank address and the lower
5-bits select the registers/RAM in that bank.
3.2.1CORE REGISTERS
The core registers contain the registers that directly
affect the basic operation. The core registers occupy
the first 12 addresses of every data memory bank
(addresses x00h/x08h through x0Bh/x8Bh). These
registers are listed below in Ta b l e 3 -2 . For detailed
information, see Tab le 3 -11 .
TABLE 3-2:CORE REGISTERS
DS41639A-page 26Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
3.2.1.1STATUS Register
The STATUS register, shown in Register 3-1, contains:
• the arithmetic status of the ALU
• the Reset status
The STATUS register can be the destination for any
instruction, like any other register. If the STATUS
register is the destination for an instruction that affects
the Z, DC or C bits, then the write to these three bits is
disabled. These bits are set or cleared according to the
device logic. Furthermore, the TO
writable. Therefore, the result of an instruction with the
STATUS register as destination may be different than
intended.
and PD bits are not
For example, CLRF STATUS will clear the upper three
bits and set the Z bit. This leaves the STATUS register
as ‘000u u1uu’ (where u = unchanged).
It is recommended, therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
STATUS register, because these instructions do not
affect any Status bits. For other instructions not
affecting any Status bits (Refer to Section 28.0
“Instruction Set Summary”).
Note 1: The C and DC bits operate as Borrow
and Digit Borrow out bits, respectively, in
subtraction.
3.3Register Definitions: Status
REGISTER 3-1:STATUS: STATUS REGISTER
U-0U-0U-0R-1/qR-1/qR/W-0/uR/W-0/uR/W-0/u
———
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = Value depends on condition
TO
PDZDC
(1)
(1)
C
bit 7-5Unimplemented: Read as ‘0’
bit 4TO
bit 3PD
bit 2Z: Zero bit
bit 1DC: Digit Carry/Digit Borrow
bit 0C: Carry/Borrow
Note 1:For Borrow
second operand. For rotate (RRF, RLF) instructions, this bit is loaded with either the high-order or low-order
bit of the source register.
: Time-Out bit
1 = After power-up, CLRWDT instruction or SLEEP instruction
0 = A WDT time-out occurred
: Power-Down bit
1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero
1 = A carry-out from the 4th low-order bit of the result occurred
0 = No carry-out from the 4th low-order bit of the result
(1)
bit
(ADDWF, ADDLW, SUBLW, SUBWF instructions)
1 = A carry-out from the Most Significant bit of the result occurred
0 = No carry-out from the Most Significant bit of the result occurred
, the polarity is reversed. A subtraction is executed by adding the two’s complement of the
The Special Function Registers are registers used by
the application to control the desired operation of
peripheral functions in the device. The Special Function
Registers occupy the 20 bytes after the core registers of
every data memory bank (addresses x0Ch/x8Ch
through x1Fh/x9Fh). The registers associated with the
operation of the peripherals are described in the appropriate peripheral chapter of this data sheet.
3.3.2GENERAL PURPOSE RAM
There are up to 80 bytes of GPR in each data memory
bank. The Special Function Registers occupy the 20
bytes after the core registers of every data memory
bank (addresses x0Ch/x8Ch through x1Fh/x9Fh).
3.3.2.1Linear Access to GPR
The general purpose RAM can be accessed in a
non-banked method via the FSRs. This can simplify
access to large memory structures. See Section 3.6.2
“Linear Data Memory” for more information.
Refer to Table 3-3 for Dual Port and USB addressing
information.
TABLE 3-3:DUAL PORT RAM ADDRESSING
Port 0Port 1
3.3.3DUAL-PORT RAM
Part of the data memory is mapped to a special dual
access RAM. When the USB module is disabled, the
GPRs in these banks are used like any other GPR in
the data memory space.
When the USB module is enabled, the memory in these
banks is allocated as buffer RAM for USB operation.
This area is shared between the microcontroller core
and the USB Serial Interface Engine (SIE) and is used
to transfer data directly between the two.
It is theoretically possible to use the areas of USB RAM
that are not allocated as USB buffers for normal
scratchpad memory or other variable storage. In practice,
the dynamic nature of buffer allocation makes this risky at
best. Additional information on USB RAM and buffer
operation is provided in Section 26.0 “Universal Serial
Bus (USB)”.
3.3.4COMMON RAM
There are 16 bytes of common RAM accessible from all
banks.
CPU Banked AddressCPU Linear AddressUSB Banked AddressUSB Linear Address
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved. Shaded locations are unimplemented, read as ‘0’.
Note 1:PIC16(L)F1459 only.
(2)
A/D Result Register Lowxxxx xxxx uuuu uuuu
(2)
A/D Result Register Highxxxx xxxx uuuu uuuu
(2)
(2)
(2)
—CHS<4:0>
ADFMADCS<2:0>——
—TRIGSEL<2:0>————-000 ---- -000 ----
——LFIOFRHFIOFS00q0 --00 qqqq --qq
GO/DONE
ADPREF<1:0>
ADON-000 0000 -000 0000
0000 --00 0000 --00
2:PIC16(L)F1455/9 only.
3:Unimplemented, read as ‘1’.
Value on all
other
Resets
DS41639A-page 38Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
TABLE 3-12:SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved. Shaded locations are unimplemented, read as ‘0’.
Note 1:PIC16(L)F1459 only.
—SCKPBRG16—WUEABDEN01-0 0-00 01-0 0-00
2:PIC16(L)F1455/9 only.
3:Unimplemented, read as ‘1’.
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved. Shaded locations are unimplemented, read as ‘0’.
Note 1:PIC16(L)F1459 only.
2:PIC16(L)F1455/9 only.
3:Unimplemented, read as ‘1’.
Value on all
other
Resets
DS41639A-page 40Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
TABLE 3-12:SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved. Shaded locations are unimplemented, read as ‘0’.
Note 1:PIC16(L)F1459 only.
—Unimplemented——
2:PIC16(L)F1455/9 only.
3:Unimplemented, read as ‘1’.
TABLE 3-12:SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
Addres
s
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Value on
POR, BOR
Bank 29
E8Ch—Unimplemented——
E8Dh
E8Eh
E8Fh
E90h
E91h
E92h
E93h
E94h
E95h
E96h
E97h
E98h
E99h
E9Ah
E9Bh
E9Ch
E9Dh
E9Eh
E9Fh
—Unimplemented——
UCON
USTAT
UIR
UCFGUTEYE
UIE
UEIRBTSEF
UFRMH
UFRMLFRM7FRM6FRM5FRM4FRM3FRM2FRM1FRM0
UADDR
UEIEBTSEE
UEP7
UEP6
UEP5
UEP4
UEP3
UEP2
UEP1
UEP0
—
PPBRSTSE0PKTDISUSBENRESUMESUSPND
—
—
—
—————
—
–––
–––
–––
–––
–––
–––
–––
–––
SOFIFSTALLIFIDLEIFTRNIFACTVIFUERRIFURSTIF
Reserved
SOFIESTALLIEIDLEIETRNIEACTVIEUERRIEURSTIE
——
ADDR6ADDR5ADDR4ADDR3ADDR2ADDR1ADDR0
——
ENDP<3:0>DIRPPBI
—
UPUEN
BTOEFDFN8EFCRC16EFCRC5EFPIDEF
BTOEEDFN8EECRC16EECRC5EEPIDEE
EPHSHK
EPHSHK
EPHSHK
EPHSHK
EPHSHK
EPHSHK
EPHSHK
EPHSHK
ReservedFSENPPB<1:0>
FRM10FRM9FRM8
EPCONDIS
EPCONDIS
EPCONDIS
EPCONDIS
EPCONDIS
EPCONDIS
EPCONDIS
EPCONDIS
EPOUTENEPINENEPSTALL
EPOUTENEPINENEPSTALL
EPOUTENEPINENEPSTALL
EPOUTENEPINENEPSTALL
EPOUTENEPINENEPSTALL
EPOUTENEPINENEPSTALL
EPOUTENEPINENEPSTALL
EPOUTENEPINENEPSTALL
—-0x0 000- -0u0 000-
—-xxx xxx- -uuu uuu-
-000 0000 -000 0000
00-0 -000 00-0 -000
-000 0000 -000 0000
0--0 -000 0--0 -000
---- -xxx ---- -uuu
xxxx xxxx uuuu uuuu
-000 0000 -000 0000
0--0 0000 0--0 0000
---0 0000 ---0 0000
---0 0000 ---0 0000
---0 0000 ---0 0000
---0 0000 ---0 0000
---0 0000 ---0 0000
---0 0000 ---0 0000
---0 0000 ---0 0000
---0 0000 ---0 0000
Bank 30
F0Ch
—
F1Fh
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved. Shaded locations are unimplemented, read as ‘0’.
Note 1:PIC16(L)F1459 only.
—Unimplemented——
2:PIC16(L)F1455/9 only.
3:Unimplemented, read as ‘1’.
Value on all
other
Resets
DS41639A-page 42Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
TABLE 3-12:SPECIAL FUNCTION REGISTER SUMMARY (CONTINUED)
Addres
s
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Value on
POR, BOR
Bank 31
F8Ch
—
FE3h
FE4hSTATUS_
FE5hWREG_
FE6hBSR_
FE7hPCLATH_
FE8hFSR0L_
FE9hFSR0H_
FEAhFSR1L_
FEBhFSR1H_
FECh
FEDh
FEEh
FEFh
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved. Shaded locations are unimplemented, read as ‘0’.
Note 1:PIC16(L)F1459 only.
—Unimplemented——
—————Z_SHADDC_SHADC_SHAD---- -xxx ---- -uuu
SHAD
Working Register Shadowxxxx xxxx uuuu uuuu
SHAD
———Bank Select Register Shadow---x xxxx ---u uuuu
SHAD
—Program Counter Latch High Register Shadow-xxx xxxx uuuu uuuu
The Program Counter (PC) is 15 bits wide. The low byte
comes from the PCL register, which is a readable and
writable register. The high byte (PC<14:8>) is not directly
readable or writable and comes from PCLATH. On any
Reset, the PC is cleared. Figure 3-3 shows the five
situations for the loading of the PC.
FIGURE 3-3:LOADING OF PC IN
DIFFERENT SITUATIONS
3.4.1MODIFYING PCL
Executing any instruction with the PCL register as the
destination simultaneously causes the Program Counter PC<14:8> bits (PCH) to be replaced by the contents
of the PCLATH register. This allows the entire contents
of the program counter to be changed by writing the
desired upper seven bits to the PCLATH register. When
the lower eight bits are written to the PCL register, all
15 bits of the program counter will change to the values
contained in the PCLATH register and those being written to the PCL register.
3.4.2COMPUTED GOTO
A computed GOTO is accomplished by adding an offset to
the program counter (ADDWF PCL). When performing a
table read using a computed GOTO method, care should
be exercised if the table location crosses a PCL memory
boundary (each 256-byte block). Refer to Application
Note AN556, “Implementing a Table Read” (DS00556).
3.4.3COMPUTED FUNCTION CALLS
A computed function CALL allows programs to maintain
tables of functions and provide another way to execute
state machines or look-up tables. When performing a
table read using a computed function CALL, care
should be exercised if the table location crosses a PCL
memory boundary (each 256-byte block).
If using the CALL instruction, the PCH<2:0> and PCL
registers are loaded with the operand of the CALL
instruction. PCH<6:3> is loaded with PCLATH<6:3>.
The CALLW instruction enables computed calls by combining PCLATH and W to form the destination address.
A computed CALLW is accomplished by loading the W
register with the desired address and executing CALLW.
The PCL register is loaded with the value of W and
PCH is loaded with PCLATH.
3.4.4BRANCHING
The branching instructions add an offset to the PC.
This allows relocatable code and code that crosses
page boundaries. There are two forms of branching,
BRW and BRA. The PC will have incremented to fetch
the next instruction in both cases. When using either
branching instruction, a PCL memory boundary may be
crossed.
If using BRW, load the W register with the desired
unsigned address and execute BRW. The entire PC will
be loaded with the address PC + 1 + W.
If using BRA, the entire PC will be loaded with PC + 1 +,
the signed value of the operand of the BRA instruction.
DS41639A-page 44Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
0x0F
0x0E
0x0D
0x0C
0x0B
0x0A
0x09
0x08
0x07
0x06
0x05
0x04
0x03
0x02
0x01
0x00
0x0000
STKPTR = 0x1F
Initial Stack Configuration:
After Reset, the stack is empty. The
empty stack is initialized so the Stack
Pointer is pointing at 0x1F. If the Stack
Overflow/Underflow Reset is enabled, the
TOSH/TOSL registers will return ‘0’. If
the Stack Overflow/Underflow Reset is
disabled, the TOSH/TOSL registers will
return the contents of stack address 0x0F.
0x1FSTKPTR = 0x1F
Stack Reset Disabled
(STVREN = 0)
Stack Reset Enabled
(STVREN = 1)
TOSH:TOSL
TOSH:TOSL
3.5Stack
All devices have a 16-level x 15-bit wide hardware
stack (refer to Figures 3-4 through 3-7). The stack
space is not part of either program or data space. The
PC is PUSHed onto the stack when CALL or CALLW
instructions are executed or an interrupt causes a
branch. The stack is POPed in the event of a RETURN,RETLW or a RETFIE instruction execution. PCLATH is
not affected by a PUSH or POP operation.
The stack operates as a circular buffer if the STVREN
bit is programmed to ‘0‘(Configuration Words). This
means that after the stack has been PUSHed sixteen
times, the seventeenth PUSH overwrites the value that
was stored from the first PUSH. The eighteenth PUSH
overwrites the second PUSH (and so on). The
STKOVF and STKUNF flag bits will be set on an Overflow/Underflow, regardless of whether the Reset is
enabled.
Note 1: There are no instructions/mnemonics
called PUSH or POP. These are actions
that occur from the execution of the
CALL, CALLW, RETURN, RETLW and
RETFIE instructions or the vectoring to
an interrupt address.
3.5.1ACCESSING THE STACK
The stack is available through the TOSH, TOSL and
STKPTR registers. STKPTR is the current value of the
Stack Pointer. TOSH:TOSL register pair points to the
TOP of the stack. Both registers are read/writable. TOS
is split into TOSH and TOSL due to the 15-bit size of the
PC. To access the stack, adjust the value of STKPTR,
which will position TOSH:TOSL, then read/write to
TOSH:TOSL. STKPTR is five bits to allow detection of
overflow and underflow.
Note:Care should be taken when modifying the
STKPTR while interrupts are enabled.
During normal program operation, CALL, CALLW and
Interrupts will increment STKPTR while RETLW,RETURN, and RETFIE will decrement STKPTR. At any
time STKPTR can be inspected to see how much stack
is left. The STKPTR always points at the currently used
place on the stack. Therefore, a CALL or CALLW will
increment the STKPTR and then write the PC, and a
return will unload the PC and then decrement the
STKPTR.
Reference Figure 3-4 through Figure 3-7 for examples
of accessing the stack.
This figure shows the stack configuration
after the first CALL or a single interrupt.
If a RETURN instruction is executed, the
return address will be placed in the
Program Counter and the Stack Pointer
decremented to the empty state (0x1F).
TOSH:TOSL
0x0F
0x0E
0x0D
0x0C
0x0B
0x0A
0x09
0x08
0x07
Return Address0x06
Return Address0x05
Return Address0x04
Return Address0x03
Return Address0x02
Return Address0x01
Return Address0x00
STKPTR = 0x06
After seven CALLs or six CALLs and an
interrupt, the stack looks like the figure
on the left. A series of RETURN instructions
will repeatedly place the return addresses
into the Program Counter and pop the stack.
TOSH:TOSL
FIGURE 3-5:ACCESSING THE STACK EXAMPLE 2
FIGURE 3-6:ACCESSING THE STACK EXAMPLE 3
DS41639A-page 46Preliminary 2012 Microchip Technology Inc.
FIGURE 3-7:ACCESSING THE STACK EXAMPLE 4
0x0F
0x0E
0x0D
0x0C
0x0B
0x0A
0x09
0x08
0x07
0x06
0x05
0x04
0x03
0x02
0x01
Return Address0x00STKPTR = 0x10
When the stack is full, the next CALL or
an interrupt will set the Stack Pointer to
0x10. This is identical to address 0x00
so the stack will wrap and overwrite the
return address at 0x00. If the Stack
Overflow/Underflow Reset is enabled, a
Reset will occur and location 0x00 will
not be overwritten.
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
Return Address
TOSH:TOSL
PIC16(L)F1454/5/9
3.5.2OVERFLOW/UNDERFLOW RESET
If the STVREN bit in Configuration Words is
programmed to ‘1’, the device will be reset if the stack
is PUSHed beyond the sixteenth level or POPed
beyond the first level, setting the appropriate bits
(STKOVF or STKUNF, respectively) in the PCON
register.
3.6Indirect Addressing
The INDFn registers are not physical registers. Any
instruction that accesses an INDFn register actually
accesses the register at the address specified by the
File Select Registers (FSR). If the FSRn address
specifies one of the two INDFn registers, the read will
return ‘0’ and the write will not occur (though Status bits
may be affected). The FSRn register value is created
by the pair FSRnH and FSRnL.
The FSR registers form a 16-bit address that allows an
addressing space with 65536 locations. These locations
are divided into three memory regions:
Note:Not all memory regions are completely implemented. Consult device memory tables for memory limits.
0x1FFF
FIGURE 3-8:INDIRECT ADDRESSING
DS41639A-page 48Preliminary 2012 Microchip Technology Inc.
3.6.1TRADITIONAL DATA MEMORY
Indirect AddressingDirect Addressing
Bank Select
Location Select
4BSR6
0
From Opcode
FSRxL70
Bank Select
Location Select
00000 00001 0001011111
0x00
0x7F
Bank 0 Bank 1 Bank 2Bank 31
0
FSRxH70
0000
The traditional data memory is a region from FSR
address 0x000 to FSR address 0xFFF. The addresses
correspond to the absolute addresses of all SFR, GPR,
DPR and common registers.
The linear data memory is the region from FSR
address 0x2000 to FSR address 0x29AF. This region is
a virtual region that points back to the 80-byte blocks of
DPR or GPR memory in all the banks.
Unimplemented memory reads as 0x00. Use of the
linear data memory region allows buffers to be larger
than 80 bytes because incrementing the FSR beyond
one bank will go directly to the DPR or GPR memory of
the next bank.
The 16 bytes of common memory are not included in
the linear data memory region.
FIGURE 3-10:LINEAR DATA MEMORY
MAP
3.6.3PROGRAM FLASH MEMORY
To make constant data access easier, the entire
program Flash memory is mapped to the upper half of
the FSR address space. When the MSB of FSRnH is
set, the lower 15 bits are the address in program
memory which will be accessed through INDF. Only the
lower eight bits of each memory location is accessible
via INDF. Writing to the program Flash memory cannot
be accomplished via the FSR/INDF interface. All
instructions that access program Flash memory via the
FSR/INDF interface will require one additional
instruction cycle to complete.
FIGURE 3-11:PROGRAM FLASH
MEMORY MAP
DS41639A-page 50Preliminary 2012 Microchip Technology Inc.
4.0DEVICE CONFIGURATION
Device configuration consists of Configuration Words,
Code Protection and Device ID.
4.1Configuration Words
There are several Configuration Word bits that allow
different oscillator and memory protection options.
These are implemented as Configuration Word 1 at
8007h and Configuration Word 2 at 8008h.
Note:The DEBUG bit in Configuration Words is
managed automatically by device
development tools including debuggers
and programmers. For normal device
operation, this bit should be maintained as
a '1'.
R = Readable bitP = Programmable bitU = Unimplemented bit, read as ‘1’
‘0’ = Bit is cleared‘1’ = Bit is set-n = Value when blank or after Bulk Erase
DEBUG
LPBORBORVSTVRENPLLEN
——WRT<1:0>
bit 13LVP: Low-Voltage Programming Enable bit
1 = Low-voltage programming enabled
0 = High-voltage on MCLR
bit 12DEBUG: In-Circuit Debugger Mode bit
1 = In-Circuit Debugger disabled, ICSPCLK and ICSPDAT are general purpose I/O pins
0 = In-Circuit Debugger enabled, ICSPCLK and ICSPDAT are dedicated to the debugger
bit 11
bit 10BORV: Brown-out Reset Voltage Selection bit
bit 9STVREN: Stack Overflow/Underflow Reset Enable bit
bit 8PLLEN: PLL Enable bit
bit 7PLLMULT: PLL Multiplier Selection bit
bit 6USBLSCLK: USB Low-Speed Clock Selection bit
bit 5-4CPUDIV<1:0>: CPU System Clock Selection bits
bit 3-2Unimplemented: Read as ‘1’
bit 1-0WRT<1:0>: Flash Memory Self-Write Protection bits
: Low-Power BOR Enable bit
LPBOR
1 = Low-Power Brown-out Reset is disabled
0 = Low-Power Brown-out Reset is enabled
1 = Brown-out Reset voltage (Vbor), low trip point selected
0 = Brown-out Reset voltage (
1 = Stack Overflow or Underflow will cause a Reset
0 = Stack Overflow or Underflow will not cause a Reset
1 = PLL is enabled
0 = PLL is disabled
1 = 3x PLL Output Frequency is selected
0 = 4x PLL Output Frequency is selected
1 = USB Clock divide-by 8 (48 MHz system input clock expected)
0 = USB Clock divide-by 4 (24 MHz system input clock expected)
11 = CPU system clock divided by 6
10 = CPU system clock divided by 3
01 = CPU system clock divided by 2
00 = No CPU system clock divide
8 kW Flash memory
11 = Write protection off
10 = 000h to 01FFh write-protected, 0200h to 1FFFh may be modified
01 = 000h to 0FFFh write-protected, 1000h to 1FFFh may be modified
00 = 000h to 1FFFh write-protected, no addresses may be modified
must be used for programming
Vbor, high trip point selected
:
(1)
(3)
(2)
Note 1:The LVP bit cannot be programmed to ‘0’ when Programming mode is entered via LVP.
2:See Vborparameter for specific trip point voltages.
3:The DEBUG
debuggers and programmers. For normal device operation, this bit should be maintained as a '1'.
DS41639A-page 54Preliminary 2012 Microchip Technology Inc.
bit in Configuration Words is managed automatically by device development tools including
4.3Code Protection
Code protection allows the device to be protected from
unauthorized access. Internal access to the program
memory is unaffected by any code protection setting.
4.3.1PROGRAM MEMORY PROTECTION
The entire program memory space is protected from
external reads and writes by the CP
Words. When CP
program memory are inhibited and a read will return all
‘0’s. The CPU can continue to read program memory,
regardless of the protection bit settings. Writing the
program memory is dependent upon the write
protection setting. See Section 4.4 “Write
Protection” for more information.
= 0, external reads and writes of
bit in Configuration
4.4Write Protection
Write protection allows the device to be protected from
unintended self-writes. Applications, such as
bootloader software, can be protected while allowing
other regions of the program memory to be modified.
The WRT<1:0> bits in Configuration Words define the
size of the program memory block that is protected.
PIC16(L)F1454/5/9
4.5User ID
Four memory locations (8000h-8003h) are designated as
ID locations where the user can store checksum or other
code identification numbers. These locations are
readable and writable during normal execution. See
Section 11.4 “User ID, Device ID and Configuration
Word Access” for more information on accessing these
memory locations.
calculation, see the “PIC16(L)F1454/5/9Memory
The memory location 8005h and 8006h are where the
Device ID and Revision ID are stored. See
Section 11.4 “User ID, Device ID and Configuration
Word Access” for more information on accessing
these memory locations.
Development tools, such as device programmers and
debuggers, may be used to read the Device ID and
Revision ID.
4.7Register Definitions: Revision and Device
REGISTER 4-3:DEVID: DEVICE ID REGISTER
RRRRRR
DEV<13:8>
bit 13bit 8
RRRRRRRR
DEV<7:0>
bit 7bit 0
Legend:
R = Readable bit
‘1’ = Bit is set‘0’ = Bit is cleared
bit 13-0DEV<13:0>: Device ID bits
REGISTER 4-4:REVID: REVISION ID REGISTER
RRRRRR
REV<13:8>
bit 13bit 8
RRRRRRRR
REV<7:0>
bit 7bit 0
Legend:
R = Readable bit
‘1’ = Bit is set‘0’ = Bit is cleared
bit 13-0REV<13:0>: Revision ID bits
DS41639A-page 56Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
5.0OSCILLATOR MODULE (WITH
FAIL-SAFE CLOCK MONITOR)
5.1Overview
The oscillator module has a wide variety of clock
sources and selection features that allow it to be used
in a wide range of applications while maximizing performance and minimizing power consumption. Figure 5-1
illustrates a block diagram of the oscillator module.
Clock sources can be supplied from external oscillators,
quartz crystal resonators, ceramic resonators and
Resistor-Capacitor (RC) circuits. In addition, the system
clock source can be supplied from one of two internal
oscillators, with a choice of speeds selectable via
software. Additional clock features include:
• Selectable system clock source between external
or internal sources via software.
• Two-Speed Start-up mode, which minimizes
latency between external oscillator start-up and
code execution.
• Fail-Safe Clock Monitor (FSCM) designed to
detect a failure of the external clock source (LP,
XT, HS, EC or RC modes) and switch
automatically to the internal oscillator.
5.XT – Medium Gain Crystal or Ceramic Resonator
Oscillator mode (up to 4 MHz)
6.HS – High Gain Crystal or Ceramic Resonator
mode (4 MHz to 20 MHz)
7.RC – External Resistor-Capacitor (RC).
8.INTOSC – Internal oscillator (31 kHz to 16 MHz).
Clock Source modes are selected by the FOSC<2:0>
bits in the Configuration Words. The FOSC bits
determine the type of oscillator that will be used when
the device is first powered.
The EC clock mode relies on an external logic level
signal as the device clock source. The LP, XT, and HS
clock modes require an external crystal or resonator to
be connected to the device. Each mode is optimized for
a different frequency range. The RC clock mode
requires an external resistor and capacitor to set the
oscillator frequency.
The INTOSC internal oscillator block produces a low
and high-frequency clock source, designated
LFINTOSC and HFINTOSC. (see Internal Oscillator
Block, Figure 5-1). A wide selection of device clock
frequencies may be derived from these two clock
sources.
DS41639A-page 58Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
OSC1/CLKIN
OSC2/CLKOUT
Clock from
Ext. System
PIC
®
MCU
FOSC/4 or
I/O
(1)
Note 1:Output depends upon CLKOUTEN bit of the
Configuration Words.
5.2Clock Source Types
Clock sources can be classified as external or internal.
External clock sources rely on external circuitry for the
clock source to function. Examples are: oscillator modules (EC mode), quartz crystal resonators or ceramic
resonators (LP, XT and HS modes) and Resistor-Capacitor (RC) mode circuits.
Internal clock sources are contained within the oscillator
module. The internal oscillator block has two internal
oscillators that are used to generate the internal system
clock sources: the 16 MHz High-Frequency Internal
Oscillator and the 31 kHz Low-Frequency Internal
Oscillator (LFINTOSC).
The system clock can be selected between external or
internal clock sources via the System Clock Select
(SCS) bits in the OSCCON register. See Section 5.3
“CPU Clock Divider” for additional information.
5.2.1EXTERNAL CLOCK SOURCES
An external clock source can be used as the device
system clock by performing one of the following
actions:
• Program the FOSC<2:0> bits in the Configuration
Words to select an external clock source that will
be used as the default system clock upon a
device Reset.
• Write the SCS<1:0> bits in the OSCCON register
to switch the system clock source to:
- Secondary oscillator during run-time, or
- An external clock source determined by the
value of the FOSC bits.
See Section 5.3 “CPU Clock Divider”for more infor-
mation.
5.2.1.1EC Mode
The External Clock (EC) mode allows an externally
generated logic level signal to be the system clock
source. When operating in this mode, an external clock
source is connected to the OSC1 input.
OSC2/CLKOUT is available for general purpose I/O or
CLKOUT. Figure 5-2 shows the pin connections for EC
mode.
EC mode has three power modes to select from through
Configuration Words:
• High power, 4-20 MHz (FOSC = 111)
• Medium power, 0.5-4 MHz (FOSC = 110)
• Low power, 0-0.5 MHz (FOSC = 101)
The Oscillator Start-up Timer (OST) is disabled when
EC mode is selected. Therefore, there is no delay in
operation after a Power-on Reset (POR) or wake-up
from Sleep. Because the PIC
®
MCU design is fully
static, stopping the external clock input will have the
effect of halting the device while leaving all data intact.
Upon restarting the external clock, the device will
resume operation as if no time had elapsed.
FIGURE 5-2:EXTERNAL CLOCK (EC)
MODE OPERATION
5.2.1.2LP, XT, HS Modes
The LP, XT and HS modes support the use of quartz
crystal resonators or ceramic resonators connected to
OSC1 and OSC2 (Figure 5-3). The three modes select
a low, medium or high gain setting of the internal
inverter-amplifier to support various resonator types
and speed.
LP Oscillator mode selects the lowest gain setting of the
internal inverter-amplifier. LP mode current consumption
is the least of the three modes. This mode is designed to
drive only 32.768 kHz tuning-fork type crystals (watch
crystals).
XT Oscillator mode selects the intermediate gain
setting of the internal inverter-amplifier. XT mode
current consumption is the medium of the three modes.
This mode is best suited to drive resonators with a
medium drive level specification.
HS Oscillator mode selects the highest gain setting of the
internal inverter-amplifier. HS mode current consumption
is the highest of the three modes. This mode is best
suited for resonators that require a high drive setting.
Figure 5-3 and Figure 5-4 show typical circuits for
quartz crystal and ceramic resonators, respectively.
Note 1: A series resistor (RS) may be required for
quartz crystals with low drive level.
2: The value of R
F varies with the Oscillator mode
selected (typically between 2 M
to 10 M.
C1
C2
Quartz
R
S
(1)
OSC1/CLKIN
RF
(2)
Sleep
To Internal
Logic
PIC® MCU
Crystal
OSC2/CLKOUT
Note 1: A series resistor (RS) may be required for
ceramic resonators with low drive level.
2: The value of R
F varies with the Oscillator mode
selected (typically between 2 M
to 10 M.
3: An additional parallel feedback resistor (R
P)
may be required for proper ceramic resonator
operation.
C1
C2
Ceramic
R
S
(1)
OSC1/CLKIN
RF
(2)
Sleep
To Internal
Logic
PIC® MCU
RP
(3)
Resonator
OSC2/CLKOUT
FIGURE 5-3:QUARTZ CRYSTAL
OPERATION (LP, XT OR
HS MODE)
Note 1: Quartz crystal characteristics vary
according to type, package and
manufacturer. The user should consult the
manufacturer data sheets for specifications
and recommended application.
2: Always verify oscillator performance over
DD and temperature range that is
the V
expected for the application.
3: For oscillator design assistance, reference
the following Microchip Applications Notes:
• AN826, “Crystal Oscillator Basics and
Crystal Selection for rfPIC
Devices” (DS00826)
• AN849, “Basic PIC
(DS00849)
• AN943, “Practical PICAnalysis and Design” (DS00943)
• AN949, “Making Your Oscillator Work”
(DS00949)
®
and PIC®
®
Oscillator Design”
®
Oscillator
FIGURE 5-4:CERAMIC RESONATOR
OPERATION
(XT OR HS MODE)
5.2.1.3Oscillator Start-up Timer (OST)
If the oscillator module is configured for LP, XT or HS
modes, the Oscillator Start-up Timer (OST) counts 1024
oscillations from OSC1. This occurs following a
Power-on Reset (POR) and when the Power-up Timer
(PWRT) has expired (if configured), or a wake-up from
Sleep. During this time, the program counter does not
increment and program execution is suspended unless
either FSCM or Two-Speed Start-Up are enabled. In this
case, code will continue to execute at the selected
INTOSC frequency while the OST is counting . The OST
ensures that the oscillator circuit, using a quartz crystal
resonator or ceramic resonator, has started and is
providing a stable system clock to the oscillator module.
In order to minimize latency between external oscillator
start-up and code execution, the Two-Speed Clock
Start-up mode can be selected (see Section 5.6
“Two-Speed Clock Start-up Mode”).
DS41639A-page 60Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
C1
C2
32.768 kHz
SOSCI
To Internal
Logic
PIC® MCU
Crystal
SOSCO
Quartz
5.2.1.43x PLL or 4x PLL
The oscillator module contains a PLL that can be used
with both external and internal clock sources to provide a
system clock source. By setting the SPLLMULT bit of the
OSCCON register, 3x PLL is selected. By clearing the
SPLLMULT bit of the OSCCON register, 4x PLL is
selected. The input frequency for the PLL must fall within
specifications. See the PLL Clock Timing Specifications in
Section 29.0 “Electrical Specifications”.
The PLL may be enabled for use by one of two methods:
1.Program the PLLEN bit in Configuration Words
to a ‘1’.
2.Write the SPLLEN bit in the OSCCON register to
a ‘1’. If the PLLEN bit in Configuration Words is
programmed to a ‘1’, then the value of SPLLEN
is ignored.
PLL
HFINTOSC
(MHz)
ECH/HS
(MHz)
System
Clock (MHz)
4x88 - 1232 - 48
3x16, 88 - 1624 - 48
5.2.1.5Secondary Oscillator
The secondary oscillator is a separate crystal oscillator
that is associated with the Timer1 peripheral. It is optimized for timekeeping operations with a 32.768 kHz
crystal connected between the SOSCO and SOSCI
device pins.
The secondary oscillator can be used as an alternate
system clock source and can be selected during
run-time using clock switching. Refer to Section 5.3
“CPU Clock Divider” for more information.
Note 1: Quartz crystal characteristics vary
according to type, package and
manufacturer. The user should consult the
manufacturer data sheets for specifications
and recommended application.
2: Always verify oscillator performance over
DD and temperature range that is
the V
expected for the application.
3: For oscillator design assistance, reference
the following Microchip Applications Notes:
• AN826, “Crystal Oscillator Basics and
Crystal Selection for rfPIC
®
and PIC®
Devices” (DS00826)
®
• AN849, “Basic PIC
Oscillator Design”
(DS00849)
®
• AN943, “Practical PIC
Oscillator
Analysis and Design” (DS00943)
• AN949, “Making Your Oscillator Work”
(DS00949)
• TB097, “Interfacing a Micro Crystal
MS1V-T1K 32.768 kHz Tuning Fork
Crystal to a PIC16F690/SS” (DS91097)
• AN1288, “Design Practices for
Low-Power External Oscillators”
The external Resistor-Capacitor (RC) modes support
the use of an external RC circuit. This allows the
designer maximum flexibility in frequency choice while
keeping costs to a minimum when clock accuracy is not
required.
The RC circuit connects to OSC1. OSC2/CLKOUT is
available for general purpose I/O or CLKOUT. The
function of the OSC2/CLKOUT pin is determined by the
CLKOUTEN
bit in Configuration Words.
Figure 5-6 shows the external RC mode connections.
FIGURE 5-6:EXTERNAL RC MODES
5.2.2INTERNAL CLOCK SOURCES
The device may be configured to use the internal oscillator block as the system clock by performing one of the
following actions:
• Program the FOSC<2:0> bits in Configuration
Words to select the INTOSC clock source, which
will be used as the default system clock upon a
device Reset.
• Write the SCS<1:0> bits in the OSCCON register
to switch the system clock source to the internal
oscillator during run-time. See Section 5.3 “CPU
Clock Divider”for more information.
In INTOSC mode, OSC1/CLKIN is available for general
purpose I/O. OSC2/CLKOUT is available for general
purpose I/O or CLKOUT.
The function of the OSC2/CLKOUT pin is determined
by the CLKOUTEN
The internal oscillator block has two independent
oscillators that provides the internal system clock
source.
1.The HFINTOSC (High-Frequency Internal
Oscillator) is factory calibrated and operates at
16 MHz. The frequency of the HFINTOSC can be
user-adjusted via software using the OSCTUNE
register (Register 5-3).
2.The LFINTOSC (Low-Frequency Internal
Oscillator) is uncalibrated and operates at
31 kHz.
bit in Configuration Words.
The RC oscillator frequency is a function of the supply
voltage, the resistor (R
EXT) and capacitor (CEXT) values
and the operating temperature. Other factors affecting
the oscillator frequency are:
• threshold voltage variation
• component tolerances
• packaging variations in capacitance
The user also needs to take into account variation due
to tolerance of the external RC components used.
DS41639A-page 62Preliminary 2012 Microchip Technology Inc.
5.2.2.1HFINTOSC
The High-Frequency Internal Oscillator (HFINTOSC) is
a factory calibrated 16 MHz internal clock source. The
frequency of the HFINTOSC can be altered via
software using the OSCTUNE register (Register 5-3).
The output of the HFINTOSC connects to a postscaler
and multiplexer (see Figure 5-1). The frequency derived
from the HFINTOSC can be selected via software using
the IRCF<3:0> bits of the OSCCON register. See
Section 5.2.2.4 “Internal Oscillator Frequency
Selection” for more information.
The HFINTOSC is enabled by:
• Configure the IRCF<3:0> bits of the OSCCON
register for the desired HF frequency, and
•FOSC<2:0> = 100, or
• Set the System Clock Source (SCS) bits of the
OSCCON register to ‘1x’.
A fast start-up oscillator allows internal circuits to
power-up and stabilize before switching to HFINTOSC.
The High-Frequency Internal Oscillator Ready bit
(HFIOFR) of the OSCSTAT register indicates when the
HFINTOSC is running.
The High-Frequency Internal Oscillator Stable bit
(HFIOFS) of the OSCSTAT register indicates when the
HFINTOSC is running within 0.5% of its final value.
PIC16(L)F1454/5/9
5.2.2.2Internal Oscillator Frequency
Adjustment
The 16 MHz internal oscillator is factory calibrated.
This internal oscillator can be adjusted in software by
writing to the OSCTUNE register (Register 5-3). Since
all HFINTOSC clock sources are derived from the
16 MHz internal oscillator a change in the OSCTUNE
register value will apply to all HFINTOSC frequencies.
The default value of the OSCTUNE register is ‘0’. The
value is a 7-bit two’s complement number. A value of
3Fh will provide an adjustment to the maximum
frequency. A value of 40h will provide an adjustment to
the minimum frequency.
When the OSCTUNE register is modified, the oscillator
frequency will begin shifting to the new frequency. Code
execution continues during this shift. There is no
indication that the shift has occurred.
OSCTUNE does not affect the LFINTOSC frequency.
Operation of features that depend on the LFINTOSC
clock source frequency, such as the Power-up Timer
(PWRT), Watchdog Timer (WDT), Fail-Safe Clock
Monitor (FSCM) and peripherals, are not affected by the
change in frequency.
5.2.2.3LFINTOSC
The Low-Frequency Internal Oscillator (LFINTOSC) is
an uncalibrated 31 kHz internal clock source.
The output of the LFINTOSC connects to a postscaler
and multiplexer (see Figure 5-1). Select 31 kHz, via
software, using the IRCF<3:0> bits of the OSCCON
register. See Section 5.2.2.4 “Internal Oscillator
Frequency Selection” for more information. The
LFINTOSC is also the frequency for the Power-up Timer
(PWRT), Watchdog Timer (WDT) and Fail-Safe Clock
Monitor (FSCM).
The LFINTOSC is enabled by selecting 31 kHz
(IRCF<3:0> bits of the OSCCON register = 000) as the
system clock source (SCS bits of the OSCCON
register = 1x), or when any of the following are
enabled:
• Configure the IRCF<3:0> bits of the OSCCON
register for the desired LF frequency, and
•FOSC<2:0> = 100, or
• Set the System Clock Source (SCS) bits of the
OSCCON register to ‘1x’
Peripherals that use the LFINTOSC are:
• Power-up Timer (PWRT)
• Watchdog Timer (WDT)
• Fail-Safe Clock Monitor (FSCM)
The Low-Frequency Internal Oscillator Ready bit
(LFIOFR) of the OSCSTAT register indicates when the
LFINTOSC is running.
5.2.2.4Internal Oscillator Frequency
Selection
The system clock speed can be selected via software
using the Internal Oscillator Frequency Select bits
IRCF<3:0> of the OSCCON register.
The output of the 16 MHz HFINTOSC and 31 kHz
LFINTOSC connects to a postscaler and multiplexer
(see Figure 5-1). The Internal Oscillator Frequency
Select bits IRCF<3:0> of the OSCCON register select
the frequency output of the internal oscillators. One of
the following frequencies can be selected via software:
•HFINTOSC
- 48 MHz (requires 3x PLL)
- 32 MHz (requires 4x PLL)
- 24 MHz (requires 3x PLL)
-16 MHz
-8 MHz
-4 MHz
-2 MHz
-1 MHz
- 500 kHz (Default after Reset)
-250 kHz
-125 kHz
-62.5 kHz
-31.25 kHz
•LFINTOSC
-31 kHz
Note:Following any Reset, the IRCF<3:0> bits
of the OSCCON register are set to ‘0111’
and the frequency selection is set to
500 kHz. The user can modify the IRCF
bits to select a different frequency.
The IRCF<3:0> bits of the OSCCON register allow
duplicate selections for some frequencies. These duplicate choices can offer system design trade-offs. Lower
power consumption can be obtained when changing
oscillator sources for a given frequency. Faster transition times can be obtained between frequency changes
that use the same oscillator source.
5.2.2.5Internal Oscillator Frequency
Selection Using the PLL
The Internal Oscillator Block can be used with the PLL
associated with the External Oscillator Block to
produce a 24 MHz, 32 MHz or 48 MHz internal system
clock source. The following settings are required to use
the PLL internal clock sources:
• The FOSC bits of the Configuration Words must
be set to use the INTOSC source as the device
system clock (FOSC<2:0> = 100).
• The SCS bits of the OSCCON register must be
cleared to use the clock determined by
FOSC<2:0> in Configuration Words
(SCS<1:0> = 00).
• For 24 MHz or 32 MHz, the IRCF bits of the
OSCCON register must be set to the 8 MHz
HFINTOSC set to use (IRCF<3:0> = 1110).
• For 48 MHz, the IRCF bits of the OSCCON regis-
ter must be set to the 16 MHz HFINTOSC set to
use (IRCF<3:0> = 1111).
• For 24 MHz or 48 MHz, the 3x PLL is required.
The SPLLMULT of the OSCCON register must be
set to use (SPLLMULT = 1).
• For 32 MHz, the 4x PLL is required. The
SPLLMULT of the OSCCON register must be
clear to use (SPLLMULT = 0).
• The SPLLEN bit of the OSCCON register must be
set to enable the PLL, or the PLLEN bit of the
Configuration Words must be programmed to a
'1'.
Note:When using the PLLEN bit of the
Configuration Words, the PLL cannot be
disabled by software. The 8 MHz and 16
MHz HFINTOSC options will no longer be
available.
5.2.2.6Internal Oscillator Clock Switch
Timing
When switching between the HFINTOSC and the
LFINTOSC, the new oscillator may already be shut
down to save power (see Figure 5-7). If this is the case,
there is a delay after the IRCF<3:0> bits of the
OSCCON register are modified before the frequency
selection takes place. The OSCSTAT register will
reflect the current active status of the HFINTOSC and
LFINTOSC oscillators. The sequence of a frequency
selection is as follows:
1.IRCF<3:0> bits of the OSCCON register are
modified.
2.If the new clock is shut down, a clock start-up
delay is started.
3.Clock switch circuitry waits for a falling edge of
the current clock.
4.The current clock is held low and the clock
switch circuitry waits for a rising edge in the new
clock.
5.The new clock is now active.
6.The OSCSTAT register is updated as required.
7.Clock switch is complete.
See Figure 5-7 for more details.
If the internal oscillator speed is switched between two
clocks of the same source, there is no start-up delay
before the new frequency is selected. Clock switching
time delays are shown in Table 5-3.
Start-up delay specifications are located in the
oscillator tables of Section 29.0 “Electrical
Specifications”.
The PLL is not available for use with the internal oscillator when the SCS bits of the OSCCON register are
set to '1x'. The SCS bits must be set to '00' to use the
PLL with the internal oscillator.
DS41639A-page 64Preliminary 2012 Microchip Technology Inc.
The CPU Clock divider allows the system clock to run
at a slower speed than the Low/Full-Speed USB
module clock, while sharing the same clock source.
Only the oscillator defined by the settings of the FOSC
bits of the Configuration Words may be used with the
CPU clock divider. the CPU clock divider is controlled
by the CPUDIV<1:0> bits of the Configuration Words.
Setting the CPUDIV bits will set the system clock to:
• Equal the clock speed of the USB module
• Half the clock speed of the USB module
• One third the clock speed of the USB Module
• One sixth clock speed of the USB module
For more information on the CPU Clock Divider, see
Figure 5-1 and Configuration Words.
5.4USB Operation
The USB module is designed to operate in two different
modes:
• Low Speed
• Full Speed
To achieve the timing requirements imposed by the
USB specifications, the internal oscillator or the primary
external oscillator are required for the USB module.
The FOSC bits of the Configuration Words must be set
to INTOSC, ECH or HS mode with a clock frequency of
6, 12, or 16 MHz.
5.4.1LOW-SPEED OPERATION
For low-speed USB Operation, a 24 MHz clock is
required for the USB module. To generate the 24 MHz
clock, the following Oscillator modes are allowed:
• HFINTOSC with PLL
• ECH mode
•HS mode
Table 5-1 shows the recommended Clock mode for
low-speed operation.
5.4.2HIGH-SPEED OPERATION
For full-speed USB operation, a 48 MHz clock is
required for the USB module. To generate the 48 MHz
clock, the following oscillator modes are allowed:
• HFINTOSC with PLL
• ECH mode
•HS mode
Table 5-1 shows the recommended Clock mode for
full-speed operation.
TABLE 5-1:LOW-SPEED USB CLOCK SETTINGS
Clock Mode
HFINTOSC
ECH or HS mode
Clock
Frequency
16 MHz3x1
8 MHz3x0
16 MHz3x1
12 MHz4x1
8 MHz3x0
PLL ValueUSBLSCLKCPUDIV<1:0>
11
10
01
00
11
10
01
00
11
10
01
00
11
10
01
00
11
10
01
00
System Clock
Frequency
(MHz)
8
16
24
48
4
8
12
24
8
16
24
48
8
16
24
48
4
8
12
24
DS41639A-page 66Preliminary 2012 Microchip Technology Inc.
The system clock source can be switched between
external and internal clock sources via software using
the System Clock Select (SCS) bits of the OSCCON
register. The following clock sources can be selected
using the SCS bits:
• Default system oscillator determined by FOSC
bits in Configuration Words
• Secondary oscillator 32 kHz crystal
• Internal Oscillator Block (INTOSC)
5.5.1SYSTEM CLOCK SELECT (SCS)
BITS
The System Clock Select (SCS) bits of the OSCCON
register selects the system clock source that is used for
the CPU and peripherals.
• When the SCS bits of the OSCCON register = 00,
the system clock source is determined by value of
the FOSC<2:0> bits in the Configuration Words.
• When the SCS bits of the OSCCON register = 01,
the system clock source is the secondary
oscillator.
• When the SCS bits of the OSCCON register = 1x,
the system clock source is chosen by the internal
oscillator frequency selected by the IRCF<3:0>
bits of the OSCCON register. After a Reset, the
SCS bits of the OSCCON register are always
cleared.
Note:Any automatic clock switch, which may
occur from Two-Speed Start-up or
Fail-Safe Clock Monitor, does not update
the SCS bits of the OSCCON register. The
user can monitor the OSTS bit of the
OSCSTAT register to determine the current
system clock source.
5.5.3SECONDARY OSCILLATOR
The secondary oscillator is a separate crystal oscillator
associated with the Timer1 peripheral. It is optimized
for timekeeping operations with a 32.768 kHz crystal
connected between the SOSCO and SOSCI device
pins.
The secondary oscillator is enabled using the
T1OSCEN control bit in the T1CON register. See
Section 20.0 “Timer1 Module with Gate Control” for
more information about the Timer1 peripheral.
5.5.4SECONDARY OSCILLATOR READY
(SOSCR) BIT
The user must ensure that the secondary oscillator is
ready to be used before it is selected as a system clock
source. The Secondary Oscillator Ready (SOSCR) bit
of the OSCSTAT register indicates whether the
secondary oscillator is ready to be used. After the
SOSCR bit is set, the SCS bits can be configured to
select the secondary oscillator.
When switching between clock sources, a delay is
required to allow the new clock to stabilize. These oscillator delays are shown in Table 5-3.
5.5.2OSCILLATOR START-UP TIMER
STATUS (OSTS) BIT
The Oscillator Start-up Timer Status (OSTS) bit of the
OSCSTAT register indicates whether the system clock
is running from the external clock source, as defined by
the FOSC<2:0> bits in the Configuration Words, or
from the internal clock source. In particular, OSTS
indicates that the Oscillator Start-up Timer (OST) has
timed out for LP, XT or HS modes. The OST does not
reflect the status of the secondary oscillator.
DS41639A-page 68Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
5.6Two-Speed Clock Start-up Mode
Two-Speed Start-up mode provides additional power
savings by minimizing the latency between external
oscillator start-up and code execution. In applications
that make heavy use of the Sleep mode, Two-Speed
Start-up will remove the external oscillator start-up
time from the time spent awake and can reduce the
overall power consumption of the device. This mode
allows the application to wake-up from Sleep, perform
a few instructions using the INTOSC internal oscillator
block as the clock source and go back to Sleep without
waiting for the external oscillator to become stable.
Two-Speed Start-up provides benefits when the oscillator module is configured for LP, XT, or HS modes.
The Oscillator Start-up Timer (OST) is enabled for
these modes and must count 1024 oscillations before
the oscillator can be used as the system clock source.
If the oscillator module is configured for any mode
other than LP, XT or HS mode, then Two-Speed
Start-up is disabled. This is because the external clock
oscillator does not require any stabilization time after
POR or an exit from Sleep.
If the OST count reaches 1024 before the device
enters Sleep mode, the OSTS bit of the OSCSTAT register is set and program execution switches to the
external oscillator. However, the system may never
operate from the external oscillator if the time spent
awake is very short.
Note:Executing a SLEEP instruction will abort
the oscillator start-up time and will cause
the OSTS bit of the OSCSTAT register to
remain clear.
5.6.1TWO-SPEED START-UP MODE
CONFIGURATION
Two-Speed Start-up mode is configured by the
following settings:
• IESO (of the Configuration Words) = 1; Inter-
nal/External Switchover bit (Two-Speed Start-up
mode enabled).
• SCS (of the OSCCON register) = 00.
• FOSC<2:0> bits in the Configuration Words
configured for LP, XT or HS mode.
Two-Speed Start-up mode is entered after:
• Power-on Reset (POR) and, if enabled, after
Power-up Timer (PWRT) has expired, or
• Wake-up from Sleep.
Note:When FSCM is enabled, Two-Speed
Start-Up will automatically be enabled.
TABLE 5-3:OSCILLATOR SWITCHING DELAYS
Switch FromSwitch ToFrequencyOscillator Delay
Sleep/POR
Sleep/POREC, RCDC – 20 MHz2 cycles
LFINTOSCEC, RCDC – 20 MHz1 cycle of each
Sleep/POR
Any clock sourceHFINTOSC
Any clock sourceLFINTOSC
Any clock sourceSecondary Oscillator 32 kHz1024 Clock Cycles (OST)
oscillator at the frequency set in the IRCF<3:0>
bits of the OSCCON register.
3.OST enabled to count 1024 clock cycles.
4.OST timed out, wait for falling edge of the
internal oscillator.
5.OSTS is set.
6.System clock held low until the next falling edge
of new clock (LP, XT or HS mode).
7.System clock is switched to external clock
source.
FIGURE 5-8:TWO-SPEED START-UP
5.6.3CHECKING TWO-SPEED CLOCK
STATUS
Checking the state of the OSTS bit of the OSCSTAT
register will confirm if the microcontroller is running
from the external clock source, as defined by the
FOSC<2:0> bits in the Configuration Words, or the
internal oscillator.
DS41639A-page 70Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
External
LFINTOSC
÷ 64
S
R
Q
31 kHz
(~32
s)
488 Hz
(~2 ms)
Clock Monitor
Latch
Clock
Failure
Detected
Oscillator
Clock
Q
Sample Clock
5.7Fail-Safe Clock Monitor
The Fail-Safe Clock Monitor (FSCM) allows the device
to continue operating should the external oscillator fail.
The FSCM can detect oscillator failure any time after
the Oscillator Start-up Timer (OST) has expired. The
FSCM is enabled by setting the FCMEN bit in the
Configuration Words. The FSCM is applicable to all
external Oscillator modes (LP, XT, HS, EC, RC and
secondary oscillator).
FIGURE 5-9:FSCM BLOCK DIAGRAM
5.7.1FAIL-SAFE DETECTION
The FSCM module detects a failed oscillator by
comparing the external oscillator to the FSCM sample
clock. The sample clock is generated by dividing the
LFINTOSC by 64. See Figure 5-9. Inside the fail
detector block is a latch. The external clock sets the
latch on each falling edge of the external clock. The
sample clock clears the latch on each rising edge of the
sample clock. A failure is detected when an entire
half-cycle of the sample clock elapses before the
external clock goes low.
5.7.3FAIL-SAFE CONDITION CLEARING
The Fail-Safe condition is cleared after a Reset,
executing a SLEEP instruction or changing the SCS bits
of the OSCCON register. When the SCS bits are
changed, the OST is restarted. While the OST is
running, the device continues to operate from the
INTOSC selected in OSCCON. When the OST times
out, the Fail-Safe condition is cleared after successfully
switching to the external clock source. The OSFIF bit
should be cleared prior to switching to the external
clock source. If the Fail-Safe condition still exists, the
OSFIF flag will again become set by hardware.
5.7.4RESET OR WAKE-UP FROM SLEEP
The FSCM is designed to detect an oscillator failure
after the Oscillator Start-up Timer (OST) has expired.
The OST is used after waking up from Sleep and after
any type of Reset. The OST is not used with the EC or
RC Clock modes so that the FSCM will be active as
soon as the Reset or wake-up has completed. When
the FSCM is enabled, the Two-Speed Start-up is also
enabled. Therefore, the device will always be executing
code while the OST is operating.
Note:Due to the wide range of oscillator start-up
times, the Fail-Safe circuit is not active
during oscillator start-up (i.e., after exiting
Reset or Sleep). After an appropriate
amount of time, the user should check the
Status bits in the OSCSTAT register to
verify the oscillator start-up and that the
system clock switchover has successfully
completed.
5.7.2FAIL-SAFE OPERATION
When the external clock fails, the FSCM switches the
device clock to an internal clock source and sets the bit
flag OSFIF of the PIR2 register. Setting this flag will
generate an interrupt if the OSFIE bit of the PIE2
register is also set. The device firmware can then take
steps to mitigate the problems that may arise from a
failed clock. The system clock will continue to be
sourced from the internal clock source until the device
firmware successfully restarts the external oscillator
and switches back to external operation.
The internal clock source chosen by the FSCM is
determined by the IRCF<3:0> bits of the OSCCON
register. This allows the internal oscillator to be
configured before a failure occurs.
Note:The system clock is normally at a much higher frequency than the sample clock. The relative frequencies in
this example have been chosen for clarity.
(Q)
Te st
TestTest
Clock Monitor Output
FIGURE 5-10:FSCM TIMING DIAGRAM
DS41639A-page 72Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
ACTSRC
FSUSB_clk
SOSC_clk
ACTEN
Active
Clock
Tuning
ACT_clk
Enable
ACTEN
Write
OSCTUNE
ACTEN
ACTUD
16 MHz
Internal OSC
1
0
OSCTUNE<6:0>
7
7
ACT data
sfr data
5.8Active Clock Tuning (ACT)
The Active Clock Tuning (ACT) continuously adjusts
the 16 MHz Internal Oscillator, using an available
external reference, to achieve ± 0.20% accuracy. This
eliminates the need for a high-speed, high-accuracy
external crystal when the system has an available
lower speed, lower power, high-accuracy clock source
available.
Systems implementing a Real-Time Clock Calendar
(RTCC) or a full-speed USB application can take full
advantage of the ACT.
5.8.1ACTIVE CLOCK TUNING
OPERATION
The ACT defaults to the disabled state after any Reset.
When the ACT is disabled, the user can write to the
TUN<6:0> bits in the OSCTUNE register to manually
adjust the 16 MHz Internal Oscillator.
The ACT is enabled by setting the ACTEN bit of the
ACTCON register. When enabled, the ACT takes
control of the OSCTUNE register. The ACT uses the
selected ACT reference clock to tune the 16 MHz
Internal Oscillator to an accuracy of 16MHz ± 0.2%.
The tuning automatically adjusts the OSCTUNE
register every reference clock cycle.
Note 1: When the ACT is enabled, the
OSCTUNE register is only updated by
the ACT. Writes to the OSCTUNE register by the user are inhibited, but reading
the register is permitted.
2: After disabling the ACT, the user should
wait three instructions before writing to
the OSCTUNE register.
5.8.2ACTIVE CLOCK TUNING SOURCE
SELECTION
The ACT reference clock is selected with the ACTSRC
bit of the ACTCON register. The reference clock
sources are provided by the:
• USB module in full-speed operation (ACT_clk)
• Secondary clock at 32.768 kHz (SOSC_clk)
5.8.3ACT LOCK STATUS
The ACTLOCK bit will be set to '1', when the 16 MHz
Internal Oscillator is successfully tuned.
The bit will be cleared by the following conditions:
• Out of Lock condition
• Device Reset
• ACT is disabled
5.8.4ACT OUT-OF-RANGE STATUS
If the ACT requires an OSCTUNE value outside the
range to achieve ± 0.20% accuracy, then
the ACT Out-of-Range (ACTOR) Status bit will be set
to '1'.
An out-of-range status can occur:
• When the 16 MHz internal oscillator is tuned to its
lowest frequency and the next ACT_clk event
requests a lower frequency.
• When the 16 MHz internal oscillator is tuned to its
highest frequency and the next ACT_clk event
requests a higher frequency.
When the ACT out-of-range event occurs, the 16 MHz
internal oscillator will continue to use the last written
OSCTUNE value. When the OSCTUNE value moves
back within the tunable range and ACTLOCK is
established, the ACTOR bit is cleared to '0'.
When the ACT is enabled, the OSCTUNE register is
continuously updated every ACT_clk period. Setting
the ACT Update Disable bit can be used to suspend
updates to the OSCTUNE register, without disabling
the ACT. If the 16 MHz internal oscillator drifts out of the
accuracy range, the ACT Status bits will change and an
interrupt can be generated to notify the application.
Clearing the ACTUD bit will engage the ACT updates
to OSCTUNE and an interrupt can be generated to
notify the application.
5.8.6INTERRUPTS
The ACT will set the ACT Interrupt Flag, (ACTIF) when
either of the ACT Status bits (ACTLOCK or ACTORS)
change state, regardless if the interrupt is enabled,
(ACTIE = 1). The ACTIF and ACTIE bits are in the PIRx
and PIEx registers, respectively. When ACTIE = 1, an
interrupt will be generated whenever the ACT Status
bits change.
The ACTIF bit must be cleared in software, regardless
of the interrupt enable setting.
5.8.7OPERATION DURING SLEEP
This ACT does not run during Sleep and will not generate interrupts during Sleep.
DS41639A-page 74Preliminary 2012 Microchip Technology Inc.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7SPLLEN: Software PLL Enable bit
If PLLEN in Configuration Words = 1:
SPLLEN bit is ignored. PLL is always enabled (subject to oscillator requirements)
If PLLEN in Configuration Words =
1 = PLL is enabled
0 = PLL is disabled
bit 6SPLLMULT: Software PLL Multiplier Select bit
1 = 3x PLL is enabled
0 = 4x PLL is enabled
bit 5-2IRCF<3:0>: Internal Oscillator Frequency Select bits
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = Conditional
bit 7SOSCR: Secondary Oscillator Ready bit
If T1OSCEN =
1 = Secondary oscillator is ready
0 = Secondary oscillator is not ready
If T1OSCEN = 0:
1 = Timer1 clock source is always ready
bit 6PLLRDY: PLL Ready bit
1 = PLL is ready
0 = PLL is not ready
bit 5OSTS: Oscillator Start-up Timer Status bit
1 = Running from the clock defined by the FOSC<2:0> bits of the Configuration Words
0 = Running from an internal oscillator (FOSC<2:0> = 100)
bit 4HFIOFR: High-Frequency Internal Oscillator Ready bit
1 = HFINTOSC is ready
0 = HFINTOSC is not ready
bit 3-2Unimplemented: Read as ‘0’
bit 1LFIOFR: Low-Frequency Internal Oscillator Ready bit
1 = LFINTOSC is ready
0 = LFINTOSC is not ready
bit 0HFIOFS: High-Frequency Internal Oscillator Stable bit
1 = HFINTOSC 16 MHz Oscillator is stable and is driving the INTOSC
0 = HFINTOSC 16 MHz is not stable, the Start-up Oscillator is driving INTOSC
1:
——
LFIOFRHFIOFS
DS41639A-page 76Preliminary 2012 Microchip Technology Inc.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7Unimplemented: Read as ‘0’
bit 6-0TUN<6:0>: Frequency Tuning bits
1000000 = Minimum frequency
•
•
•
1111111 =
0000000 = Oscillator module is running at the factory-calibrated frequency.
0000001 =
•
•
•
0111110 =
0111111 = Maximum frequency
(1,2)
Note 1:When active clock tuning is enabled (ACTSEL = 1) the oscillator is tuned automatically, the user cannot
REGISTER 5-4:ACTCON: ACTIVE CLOCK TUNING (ACT) CONTROL REGISTER
R/W-0/0R/W-0/0U-0R/W-0/0R-0/0U-0R-0/0U-0
ACTENACTUD
—ACTSRC
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7ACTEN: Active Clock Tuning Selection bit
1 = ACT is enabled, updates to OSCTUNE are exclusive to the ACT
0 = ACT is disabled
bit 6ACTUD: Active Clock Tuning Update Disable bit
1 = Updates to the OSCTUNE register from ACT are disabled
0 = Updates to the OSCTUNE register from ACT are enabled
bit 5Unimplemented: Read as ‘0’
bit 4ACTSRC: Active Clock Tuning Source Selection bit
1 = The HFINTOSC oscillator is tuned using Fll-speed USB events
0 = The HFINTOSC oscillator is tuned using the 32.768 kHz oscillator (SOSC) clock source
bit 3ACTLOCK: Active Clock Tuning Lock Status bit
1 = Locked; 16 MHz internal oscillator is within ± 0.20%.Locked
0 = Not locked; 16 MHz internal oscillator tuning has not stabilized within ± 0.20%
bit 2Unimplemented: Read as ‘0’
bit 1ACTORS: Active Clock Tuning Out-of-Range Status bit
1 = Out-of-range; oscillator frequency is outside of the OSCTUNE range
0 = In-range; oscillator frequency is within the OSCTUNE range
bit 0Unimplemented: Read as ‘0’
(1)
ACTLOCK—ACTORS—
Note 1:The ACTSRC bit should only be changed when ACTEN = 0.
TABLE 5-4:SUMMARY OF REGISTERS ASSOCIATED WITH CLOCK SOURCES
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
ACTCON
OSCCONSPLLENSPLLMULTIRCF<3:0>SCS<1:0>75
OSCSTATSOSCRPLLRDYOSTSHFIOFR
OSCTUNE
PIR2
PIE2
T1CON
Legend:— = unimplemented location, read as ‘
ACTENACTUD
—TUNE<6:0>77
OSFIF
OSFIE
TMR1CS<1:0>T1CKPS<1:0>T1OSCENT1SYNC—TMR1ON
C2IFC1IF—BCL1IFUSBIFACTIF—
C2IEC1IE—BCL1IEUSBIEACTIE—
—ACTSRCACTLOCK—ACTORS—
——LFIOFRHFIOFS76
0’. Shaded cells are not used by clock sources.
Register
on Page
75
98
100
195
TABLE 5-5:SUMMARY OF CONFIGURATION WORD WITH CLOCK SOURCES
The POR circuit holds the device in Reset until VDD has
reached an acceptable level for minimum operation.
Slow rising V
performance may require greater than minimum V
The PWRT, BOR or MCLR
extend the start-up period until all device operation
conditions have been met.
6.1.1POWER-UP TIMER (PWRT)
The Power-up Timer provides a nominal 64 ms timeout on POR or Brown-out Reset.
The device is held in Reset as long as PWRT is active.
The PWRT delay allows additional time for the V
rise to an acceptable level. The Power-up Timer is
enabled by clearing the PWRTE bit in Configuration
Words.
The Power-up Timer starts after the release of the POR
and BOR.
For additional information, refer to Application Note
AN607, “Power-up Trouble Shooting” (DS00607).
DD, fast operating speeds or analog
DD.
features can be used to
DD to
6.2Brown-Out Reset (BOR)
The BOR circuit holds the device in Reset when VDD
reaches a selectable minimum level. Between the
POR and BOR, complete voltage range coverage for
execution protection can be implemented.
The Brown-out Reset module has four operating
modes controlled by the BOREN<1:0> bits in Configuration Words. The four operating modes are:
• BOR is always on
• BOR is off when in Sleep
• BOR is controlled by software
• BOR is always off
Refer to Tab le 6 -1 for more information.
The Brown-out Reset voltage level is selectable by
configuring the BORV bit in Configuration Words.
DD noise rejection filter prevents the BOR from trig-
A V
gering on small events. If V
duration greater than parameter T
will reset. See Figure 6-2 for more information.
DD falls below VBOR for a
BORDC, the device
TABLE 6-1:BOR OPERATING MODES
BOREN<1:0>SBORENDevice ModeBOR Mode
11XXActiveWaits for BOR ready
10X
1
01
0XDisabledBegins immediately
00XXDisabled
Note 1: In these specific cases, “release of POR” and “wake-up from Sleep,” there is no delay in start-up. The BOR
ready flag, (BORRDY = 1), will be set before the CPU is ready to execute instructions because the BOR
circuit is forced on by the BOREN<1:0> bits.
AwakeActiveWaits for BOR ready
SleepDisabled
X
ActiveWaits for BOR ready
Instruction Execution upon:
Release of POR or Wake-up from Sleep
(1)
(BORRDY = 1)
(BORRDY = 1)
(1)
(BORRDY = 1)
(BORRDY = x)
6.2.1BOR IS ALWAYS ON
When the BOREN bits of Configuration Words are programmed to ‘11’, the BOR is always on. The device
start-up will be delayed until the BOR is ready and VDD
is higher than the BOR threshold.
BOR protection is active during Sleep. The BOR does
not delay wake-up from Sleep.
6.2.2BOR IS OFF IN SLEEP
When the BOREN bits of Configuration Words are programmed to ‘10’, the BOR is on, except in Sleep. The
device start-up will be delayed until the BOR is ready
DD is higher than the BOR threshold.
and V
DS41639A-page 80Preliminary 2012 Microchip Technology Inc.
BOR protection is not active during Sleep. The device
wake-up will be delayed until the BOR is ready.
6.2.3BOR CONTROLLED BY SOFTWARE
When the BOREN bits of Configuration Words are
programmed to ‘01’, the BOR is controlled by the
SBOREN bit of the BORCON register. The device
start-up is not delayed by the BOR ready condition or
DD level.
the V
BOR protection begins as soon as the BOR circuit is
ready. The status of the BOR circuit is reflected in the
BORRDY bit of the BORCON register.
BOR protection is unchanged by Sleep.
FIGURE 6-2: BROWN-OUT SITUATIONS
TPWRT
(1)
VBOR
V
DD
Internal
Reset
VBOR
V
DD
Internal
Reset
TPWRT
(1)
< TPWRT
TPWRT
(1)
VBOR
V
DD
Internal
Reset
Note 1: TPWRT delay only if PWRTE bit is programmed to ‘0’.
PIC16(L)F1454/5/9
6.3Register Definitions: BOR Control
REGISTER 6-1:BORCON: BROWN-OUT RESET CONTROL REGISTER
R/W-1/uR/W-0/uU-0U-0U-0U-0U-0R-q/u
SBORENBORFS
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = Value depends on condition
bit 7SBOREN: Software Brown-out Reset Enable bit
If BOREN <1:0> in Configuration Word
1 = BOR Enabled
0 = BOR Disabled
If BOREN <1:0> in Configuration Words
SBOREN is read/write, but has no effect on the BOR.
bit 6BORFS: Brown-out Reset Fast Start bit
If BOREN <1:0> = 10 (Disabled in Sleep) or BOREN<1:0> = 01 (Under software control):
1 = Band gap is forced on always (covers sleep/wake-up/operating cases)
0 = Band gap operates normally, and may turn off
If BOREN<1:0> = 11 (Always on) or BOREN<1:0> = 00 (Always off)
BORFS is Read/Write, but has no effect.
bit 5-1Unimplemented: Read as ‘0’
bit 0BORRDY: Brown-out Reset Circuit Ready Status bit
1 = The Brown-out Reset circuit is active
0 = The Brown-out Reset circuit is inactive
—————BORRDY
s = 01:
00:
(1)
Note 1:BOREN<1:0> bits are located in Configuration Words.
The Low-Power Brown-Out Reset (LPBOR) is an
essential part of the Reset subsystem. Refer to
Figure 6-1 to see how the BOR interacts with other
modules.
The LPBOR is used to monitor the external V
When too low of a voltage is detected, the device is
held in Reset. When this occurs, a register bit (BOR) is
changed to indicate that a BOR Reset has occurred.
The same bit is set for both the BOR and the LPBOR.
Refer to Register 6-2.
DD pin.
6.4.1ENABLING LPBOR
The LPBOR is controlled by the LPBOR bit of
Configuration Words. When the device is erased, the
LPBOR module defaults to disabled.
6.4.1.1LPBOR Module Output
The output of the LPBOR module is a signal indicating
whether or not a Reset is to be asserted. This signal is
OR’d together with the Reset signal of the BOR module to provide the generic BOR
the PCON register and to the power control block.
signal which goes to
6.5MCLR
The MCLR is an optional external input that can reset
the device. The MCLR
MCLRE bit of Configuration Words and the LVP bit of
Configuration Words (Table 6-2).
TABLE 6-2:MCLR CONFIGURATION
MCLRELVPMCLR
00Disabled
10Enabled
x1Enabled
6.5.1MCLR ENABLED
When MCLR is enabled and the pin is held low, the
device is held in Reset. The MCLR
V
DD through an internal weak pull-up.
The device has a noise filter in the MCLR
The filter will detect and ignore small pulses.
Note:A Reset does not drive the MCLR
6.5.2MCLR DISABLED
When MCLR is disabled, the pin functions as a general
purpose input and the internal weak pull-up is under
software control. See Section 12.3 “PORTA Regis-
ters” for more information.
function is controlled by the
pin is connected to
Reset path.
pin low.
6.6Watchdog Timer (WDT) Reset
The Watchdog Timer generates a Reset if the firmware
does not issue a CLRWDT instruction within the time-out
period. The TO
changed to indicate the WDT Reset. See Section 10.0
“Watchdog Timer (WDT)” for more information.
and PD bits in the STATUS register are
6.7RESET Instruction
A RESET instruction will cause a device Reset. The RI
bit in the PCON register will be set to ‘0’. See Ta b le 6 - 4
for default conditions after a RESET instruction has
occurred.
6.8Stack Overflow/Underflow Reset
The device can reset when the Stack Overflows or
Underflows. The STKOVF or STKUNF bits of the PCON
register indicate the Reset condition. These Resets are
enabled by setting the STVREN bit in Configuration
Words. See Section 3.5.2 “Overflow/Underflow
Reset” for more information.
6.9Programming Mode Exit
Upon exit of Programming mode, the device will
behave as if a POR had just occurred.
6.10Power-Up Timer
The Power-up Timer optionally delays device execution
after a BOR or POR event. This timer is typically used to
allow VDD to stabilize before allowing the device to start
running.
The Power-up Timer is controlled by the PWRTE
Configuration Words.
bit of
6.11Start-up Sequence
Upon the release of a POR or BOR, the following must
occur before the device will begin executing:
1.Power-up Timer runs to completion (if enabled).
2.M
CLR must be released (if enabled).
The total time-out will vary based on oscillator configuration and Power-up Timer configuration. See
Section 6.0 “Active Clock Tuning (ACT) Module” for
more information.
The Power-up Timer runs independently of MCLR
Reset. If MCLR is kept low long enough, the Power-up
Timer will expire. Upon bringing MCLR
will begin execution immediately (see Figure 6-3). This
is useful for testing purposes or to synchronize more
than one device operating in parallel.
high, the device
DS41639A-page 82Preliminary 2012 Microchip Technology Inc.
Upon any Reset, multiple bits in the STATUS and
PCON registers are updated to indicate the cause of
the Reset. Tab le 6 - 3 and Ta bl e 6 -4 show the Reset
conditions of these registers.
TABLE 6-3:RESET STATUS BITS AND THEIR SIGNIFICANCE
STKOVF STKUNF RWDT RMCLRRIPORBORTOPDCondition
00 1 1 10 x11Power-on Reset
00 1 1 10 x0xIllegal, TO
00 1 1 10 xx0Illegal, PD is set on POR
00 u 1 1u 011Brown-out Reset
uu 0 u uu u0uWDT Reset
uu u u uu u00WDT Wake-up from Sleep
uu u u uu u10Interrupt Wake-up from Sleep
uu u 0 uu uuuMCLR
uu u 0 uu u10MCLR
uuuu0uuuuRESET Instruction Executed
1u u u uu uuuStack Overflow Reset (STVREN = 1)
u1 u u uu uuuStack Underflow Reset (STVREN = 1)
is set on POR
Reset during normal operation
Reset during Sleep
(1)
(2)
STATUS
Register
---1 0uuuuu-- uuuu
PCON
Register
TABLE 6-4:RESET CONDITION FOR SPECIAL REGISTERS
Condition
Power-on Reset0000h---1 100000-- 110x
MCLR
Reset during normal operation0000h---u uuuuuu-- 0uuu
Legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ‘0’.
Note 1: When the wake-up is due to an interrupt and Global Interrupt Enable bit (GIE) is set, the return address is
pushed on the stack and PC is loaded with the interrupt vector (0004h) after execution of PC + 1.
2: If a Status bit is not implemented, that bit will be read as ‘0’.
Program
Counter
DS41639A-page 84Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
6.13Power Control (PCON) Register
The Power Control (PCON) register contains flag bits
to differentiate between a:
HC = Bit is cleared by hardwareHS = Bit is set by hardware
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = Value depends on condition
bit 7STKOVF: Stack Overflow Flag bit
1 = A Stack Overflow occurred
0 = A Stack Overflow has not occurred or cleared by firmware
bit 6STKUNF: Stack Underflow Flag bit
1 = A Stack Underflow occurred
0 = A Stack Underflow has not occurred or cleared by firmware
bit 5Unimplemented: Read as ‘0’
bit 4RWDT
bit 3RMCLR
bit 2RI: RESET Instruction Flag bit
bit 1POR
bit 0BOR
: Watchdog Timer Reset Flag bit
1 = A Watchdog Timer Reset has not occurred or set by firmware
0 = A Watchdog Timer Reset has occurred (cleared by hardware)
: MCLR Reset Flag bit
1 = A MCLR Reset has not occurred or set by firmware
0 = A MCLR
1 = A RESET instruction has not been executed or set by firmware
0 = A RESET instruction has been executed (cleared by hardware)
: Power-on Reset Status bit
1 = No Power-on Reset occurred
0 = A Power-on Reset occurred (must be set in software after a Power-on Reset occurs)
1 = No Brown-out Reset occurred
0 = A Brown-out Reset occurred (must be set in software after a Power-on Reset or Brown-out Reset
Legend:— = unimplemented location, read as ‘0’. Shaded cells are not used by Resets.
13:8
7:0
13:8
7:0
——
CPMCLREPWRTEWDTE<1:0>
——LVPDEBUGLPBORBORVSTVREN
PLLMULT USBLSCLKCPUDIV<1:0>
FCMENIESO
CLKOUTENBOREN<1:0>—
FOSC<2:0>
——WRT<1:0>
PLLEN
Register
on Page
52
54
DS41639A-page 86Preliminary 2012 Microchip Technology Inc.
PIC16(L)F1454/5/9
7.0REFERENCE CLOCK MODULE
The reference clock module provides the ability to send
a divided clock to the clock output pin of the device
(CLKR). This module is available in all oscillator configurations and allows the user to select a greater range
of clock submultiples to drive external devices in the
application. The reference clock module includes the
following features:
• System clock is the source
• Available in all oscillator configurations
• Programmable clock divider
• Output enable to a port pin
• Selectable duty cycle
• Slew rate control
The reference clock module is controlled by the
CLKRCON register (Register 7-1) and is enabled when
setting the CLKREN bit. To output the divided clock signal to the CLKR port pin, the CLKROE bit must be set.
The CLKRDIV<2:0> bits enable the selection of eight
different clock divider options. The CLKRDC<1:0> bits
can be used to modify the duty cycle of the output
(1)
. The CLKRSLR bit controls slew rate limiting.
clock
Note 1: If the base clock rate is selected without
a divider, the output clock will always
have a duty cycle equal to that of the
source clock, unless a 0% duty cycle is
selected. If the clock divider is set to base
clock/2, then 25% and 75% duty cycle
accuracy will be dependent upon the
source clock.
7.3Conflicts with the CLKR Pin
There are two cases when the reference clock output
signal cannot be output to the CLKR pin, if:
• LP, XT or HS Oscillator mode is selected.
• CLKOUT function is enabled.
7.3.1OSCILLATOR MODES
If LP, XT or HS Oscillator modes are selected, the
OSC2/CLKR pin must be used as an oscillator input pin
and the CLKR output cannot be enabled. See
Section 5.2 “Clock Source Types” for more informa-
tion on different oscillator modes.
7.3.2CLKOUT FUNCTION
The CLKOUT function has a higher priority than the reference clock module. Therefore, if the CLKOUT function is enabled by the CLKOUTEN bit in Configuration
Words, F
Reference Section 4.0 “Device Configuration” for
more information.
OSC/4 will always be output on the port pin.
7.4Operation During Sleep
As the reference clock module relies on the system
clock as its source, and the system clock is disabled in
Sleep, the module does not function in Sleep, even if
an external clock source or the Timer1 clock source is
configured as the system clock. The module outputs
will remain in their current state until the device exits
Sleep.
7.1Slew Rate
The slew rate limitation on the output port pin can be
disabled. The slew rate limitation can be removed by
clearing the CLKRSLR bit in the CLKRCON register.
7.2Effects of a Reset
Upon any device Reset, the reference clock module is
disabled. The user's firmware is responsible for
initializing the module before enabling the output. The
registers are reset to their default values.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7CLKREN: Reference Clock Module Enable bit
1 = Reference clock module is enabled
0 = Reference clock module is disabled
bit 6CLKROE: Reference Clock Output Enable bit
1 = Reference clock output is enabled on CLKR pin
0 = Reference clock output disabled on CLKR pin
bit 5CLKRSLR: Reference Clock Slew Rate Control limiting enable bit
1 = Slew rate limiting is enabled
0 = Slew rate limiting is disabled
bit 4-3CLKRDC<1:0>: Reference Clock Duty Cycle bits
11 = Clock outputs duty cycle of 75%
10 = Clock outputs duty cycle of 50%
01 = Clock outputs duty cycle of 25%
00 = Clock outputs duty cycle of 0%
bit 2-0CLKRDIV<2:0> Reference Clock Divider bits
111 = Base clock value divided by 128
110 = Base clock value divided by 64
101 = Base clock value divided by 32
100 = Base clock value divided by 16
011 = Base clock value divided by 8
010 = Base clock value divided by 4
001 = Base clock value divided by 2
000 = Base clock value
(2)
(1)
(3)
Note 1: In this mode, the 25% and 75% duty cycle accuracy will be dependent on the source clock duty cycle.
2: In this mode, the duty cycle will always be equal to the source clock duty cycle, unless a duty cycle of 0%
is selected.
3: To route CLKR to pin, CLKOUTEN
Words = 0 will result in F
DS41639A-page 88Preliminary 2012 Microchip Technology Inc.
OSC/4. See Section 7.3 “Conflicts with the CLKR Pin” for details.
of Configuration Words = 1 is required. CLKOUTEN of Configuration
PIC16(L)F1454/5/9
TABLE 7-1:SUMMARY OF REGISTERS ASSOCIATED WITH REFERENCE CLOCK SOURCES
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
CLKRCONCLKRENCLKROECLKRSLRCLKRDC<1:0>
Legend:— = unimplemented locations read as ‘0’. Shaded cells are not used by reference clock sources.
CLKRDIV<2:0>
TABLE 7-2:SUMMARY OF CONFIGURATION WORD WITH REFERENCE CLOCK SOURCES
DS41639A-page 90Preliminary 2012 Microchip Technology Inc.
8.0INTERRUPTS
TMR0IF
TMR0IE
INTF
INTE
IOCIF
IOCIE
Interrupt
to CPU
Wake-up
(If in Sleep mode)
GIE
(TMR1IF) PIR1<0>
PIRn<7>
PIEn<7>
PEIE
Peripheral Interrupts
(TMR1IF) PIR1<0>
The interrupt feature allows certain events to preempt
normal program flow. Firmware is used to determine
the source of the interrupt and act accordingly. Some
interrupts can be configured to wake the MCU from
Sleep mode.
This chapter contains the following information for
Interrupts:
• Operation
• Interrupt Latency
• Interrupts During Sleep
•INT Pin
• Automatic Context Saving
Many peripherals produce interrupts. Refer to the
corresponding chapters for details.
A block diagram of the interrupt logic is shown in
Interrupts are disabled upon any device Reset. They
are enabled by setting the following bits:
• GIE bit of the INTCON register
• Interrupt Enable bit(s) for the specific interrupt
event(s)
• PEIE bit of the INTCON register (if the Interrupt
Enable bit of the interrupt event is contained in the
PIE1 and PIE2 registers)
The INTCON, PIR1 and PIR2 registers record individual interrupts via interrupt flag bits. Interrupt flag bits will
be set, regardless of the status of the GIE, PEIE and
individual interrupt enable bits.
The following events happen when an interrupt event
occurs while the GIE bit is set:
• Current prefetched instruction is flushed
• GIE bit is cleared
• Current Program Counter (PC) is pushed onto the
stack
• Critical registers are automatically saved to the
shadow registers (See “Section 8.5 “Automatic
Context Saving”.”)
• PC is loaded with the interrupt vector 0004h
The firmware within the Interrupt Service Routine (ISR)
should determine the source of the interrupt by polling
the interrupt flag bits. The interrupt flag bits must be
cleared before exiting the ISR to avoid repeated
interrupts. Because the GIE bit is cleared, any interrupt
that occurs while executing the ISR will be recorded
through its interrupt flag, but will not cause the
processor to redirect to the interrupt vector.
The RETFIE instruction exits the ISR by popping the
previous address from the stack, restoring the saved
context from the shadow registers and setting the GIE
bit.
For additional information on a specific interrupt’s
operation, refer to its peripheral chapter.
8.2Interrupt Latency
Interrupt latency is defined as the time from when the
interrupt event occurs to the time code execution at the
interrupt vector begins. The latency for synchronous
interrupts is three or four instruction cycles. For asynchronous interrupts, the latency is three to five instruction cycles, depending on when the interrupt occurs.
See Figure 8-2 and Figure 8.3 for more details.
Note 1: Individual interrupt flag bits are set,
regardless of the state of any other
enable bits.
2: All interrupts will be ignored while the GIE
bit is cleared. Any interrupt occurring
while the GIE bit is clear will be serviced
when the GIE bit is set again.
DS41639A-page 92Preliminary 2012 Microchip Technology Inc.
Latency is the same whether Inst (PC) is a single cycle or a 2-cycle instruction.
3: CLKOUT not available in all oscillator modes.
4: For minimum width of INT pulse, refer to AC specifications in Section 29.0 “Electrical Specifications”
5:
INTF is enabled to be set any time during the Q4-Q1 cycles.
(1)
(2)
(3)
(4)
(5)
(1)
FIGURE 8-3:INT PIN INTERRUPT TIMING
DS41639A-page 94Preliminary 2012 Microchip Technology Inc.
8.3Interrupts During Sleep
Some interrupts can be used to wake from Sleep. To
wake from Sleep, the peripheral must be able to
operate without the system clock. The interrupt source
must have the appropriate Interrupt Enable bit(s) set
prior to entering Sleep.
On waking from Sleep, if the GIE bit is also set, the
processor will branch to the interrupt vector. Otherwise,
the processor will continue executing instructions after
the SLEEP instruction. The instruction directly after the
SLEEP instruction will always be executed before
branching to the ISR. Refer to Section 9.0 “Power-
Down Mode (Sleep)” for more details.
8.4INT Pin
The INT pin can be used to generate an asynchronous
edge-triggered interrupt. This interrupt is enabled by
setting the INTE bit of the INTCON register. The
INTEDG bit of the OPTION_REG register determines on
which edge the interrupt will occur. When the INTEDG
bit is set, the rising edge will cause the interrupt. When
the INTEDG bit is clear, the falling edge will cause the
interrupt. The INTF bit of the INTCON register will be set
when a valid edge appears on the INT pin. If the GIE and
INTE bits are also set, the processor will redirect
program execution to the interrupt vector.
PIC16(L)F1454/5/9
8.5Automatic Context Saving
Upon entering an interrupt, the return PC address is
saved on the stack. Additionally, the following registers
are automatically saved in the shadow registers:
• W register
• STATUS register (except for TO
• BSR register
• FSR registers
• PCLATH register
Upon exiting the Interrupt Service Routine, these registers are automatically restored. Any modifications to
these registers during the ISR will be lost. If modifications to any of these registers are desired, the corresponding shadow register should be modified and the
value will be restored when exiting the ISR. The
shadow registers are available in Bank 31 and are
readable and writable. Depending on the user’s application, other registers may also need to be saved.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7GIE: Global Interrupt Enable bit
1 = Enables all active interrupts
0 = Disables all interrupts
bit 6PEIE: Peripheral Interrupt Enable bit
1 = Enables all active peripheral interrupts
0 = Disables all peripheral interrupts
bit 5TMR0IE: Timer0 Overflow Interrupt Enable bit
1 = Enables the Timer0 interrupt
0 = Disables the Timer0 interrupt
bit 4INTE: INT External Interrupt Enable bit
1 = Enables the INT external interrupt
0 = Disables the INT external interrupt
bit 3IOCIE: Interrupt-on-Change Enable bit
1 = Enables the interrupt-on-change
0 = Disables the interrupt-on-change
bit 2TMR0IF: Timer0 Overflow Interrupt Flag bit
1 = TMR0 register has overflowed
0 = TMR0 register did not overflow
bit 1INTF: INT External Interrupt Flag bit
1 = The INT external interrupt occurred
0 = The INT external interrupt did not occur
bit 0IOCIF: Interrupt-on-Change Interrupt Flag bit
1 = When at least one of the interrupt-on-change pins changed state
0 = None of the interrupt-on-change pins have changed state
(1)
(1)
Note 1:The IOCIF Flag bit is read-only and cleared when all the interrupt-on-change flags in the IOCBF register
Note:Interrupt flag bits are set when an interrupt
DS41639A-page 96Preliminary 2012 Microchip Technology Inc.
have been cleared by software.
condition occurs, regardless of the state of
its corresponding enable bit or the Global
Interrupt Enable bit, GIE, of the INTCON
register. User software should ensure the
appropriate interrupt flag bits are clear
prior to enabling an interrupt.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7TMR1GIE: Timer1 Gate Interrupt Enable bit
1 = Enables the Timer1 gate acquisition interrupt
0 = Disables the Timer1 gate acquisition interrupt
bit 6ADIE: A/D Converter (ADC) Interrupt Enable bit
1 = Enables the ADC interrupt
0 = Disables the ADC interrupt
bit 5RCIE: USART Receive Interrupt Enable bit
1 = Enables the USART receive interrupt
0 = Disables the USART receive interrupt
bit 4TXIE: USART Transmit Interrupt Enable bit
1 = Enables the USART transmit interrupt
0 = Disables the USART transmit interrupt
bit 3SSP1IE: Synchronous Serial Port (MSSP) Interrupt Enable bit
1 = Enables the MSSP interrupt
0 = Disables the MSSP interrupt
bit 2Unimplemented: Read as ‘0’
bit 1TMR2IE: TMR2 to PR2 Match Interrupt Enable bit
1 = Enables the Timer2 to PR2 match interrupt
0 = Disables the Timer2 to PR2 match interrupt
bit 0TMR1IE: Timer1 Overflow Interrupt Enable bit
1 = Enables the Timer1 overflow interrupt
0 = Disables the Timer1 overflow interrupt
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7OSFIE: Oscillator Fail Interrupt Enable bit
1 = Enables the Oscillator Fail interrupt
0 = Disables the Oscillator Fail interrupt
bit 6C2IE: Comparator C2 Interrupt Enable bit
1 = Enables the Comparator C2 interrupt
0 = Disables the Comparator C2 interrupt
bit 5C1IE: Comparator C1 Interrupt Enable bit
1 = Enables the Comparator C1 interrupt
0 = Disables the Comparator C1 interrupt
bit 4Unimplemented: Read as ‘0’
bit 3BCL1IE: MSSP Bus Collision Interrupt Enable bit
1 = Enables the MSSP Bus Collision Interrupt
0 = Disables the MSSP Bus Collision Interrupt
bit 2USBIE: USB Interrupt Enable bit
1 = Enables the USB interrupt
0 = Disables the USB interrupt
bit 1ACTIE: Active Clock Tuning Interrupt Enable bit
1 = Enables the Active Clock Tuning interrupt
0 = Disables the Active Clock Tuning interrupt
bit 0Unimplemented: Read as ‘0’
—BCL1IEUSBIEACTIE—
Note:Bit PEIE of the INTCON register must be
set to enable any peripheral interrupt.
DS41639A-page 98Preliminary 2012 Microchip Technology Inc.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7TMR1GIF: Timer1 Gate Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 6ADIF: A/D Converter Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 5RCIF: USART Receive Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 4TXIF: USART Transmit Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 3SSP1IF: Synchronous Serial Port (MSSP) Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 2Unimplemented: Read as ‘0’
bit 1TMR2IF: Timer2 to PR2 Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 0TMR1IF: Timer1 Overflow Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
(1)
RCIFTXIFSSP1IF—TMR2IFTMR1IF
Note 1:PIC16(L)F1455/9 only.
Note:Interrupt flag bits are set when an interrupt
condition occurs, regardless of the state of
its corresponding enable bit or the Global
Interrupt Enable bit, GIE, of the INTCON
register. User software should ensure the
appropriate interrupt flag bits are clear prior
to enabling an interrupt.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is cleared
bit 7OSFIF: Oscillator Fail Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 6C2IF: Numerically Controlled Oscillator Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 5C1IF: Numerically Controlled Oscillator Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 4Unimplemented: Read as ‘0’
bit 3BCL1IF: MSSP Bus Collision Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 2USBIF: USB Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 1ACTIF: Active Clock Tuning Interrupt Flag bit
1 = Interrupt is pending
0 = Interrupt is not pending
bit 0Unimplemented: Read as ‘0’
—BCL1IFUSBIFACTIF—
Note:Interrupt flag bits are set when an interrupt
condition occurs, regardless of the state of
its corresponding enable bit or the Global
Interrupt Enable bit, GIE, of the INTCON
register. User software should ensure the
appropriate interrupt flag bits are clear prior
to enabling an interrupt.
DS41639A-page 100Preliminary 2012 Microchip Technology Inc.
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.