Note the following details of the code protection feature on Microchip devices:
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•Microchip is willing to work with the customer who is concerned about the integrity of their code.
•Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digit al Millennium Copyright Act. If suc h a c t s
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 t he lik e is provided only for your convenien ce
and may be su perseded by updates. It is you r 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 supp ort and/or safety ap plications is entir ely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless M icrochip from any and all dama ges, claims,
suits, or expenses re sulting from such use. No licens es are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MAT E, Pow erSm art , rfPIC and SmartS hunt are
registered trademarks of Microchip Technology Incorporated
in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB,
SEEVAL, SmartSensor and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, ECAN,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, Linear Active
Thermistor, Mindi, MiWi, MPASM, MPLIB, MPLINK, PIC kit,
PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartTel, Total
Endurance, UNI/O, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
Microchip received ISO/TS-16949:2002 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona, Gresham, Oregon and Mountain View, California. The
Company’s quality system processes and procedures are for its PIC
8-bit MCUs, KEELOQ
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.
10.0 Enhanced Capture/Compare/PWM (With Auto-Shutdown and Dead Band) Module (PIC12F615/HV615 only)........................ 75
11.0 Special Features of the CPU....................................... ............................................................................................................... 93
13.0 Instruction Set Summary.......................................................................................................................................................... 113
14.0 Development Support. ..............................................................................................................................................................123
16.0 DC and AC Characteristics Graphs and Tables.......................................................................................................................149
Appendix A: Data Sheet Revision History..........................................................................................................................................157
Appendix B: Migrating from other PIC® Devices...............................................................................................................................157
Index ........................................................................... ... .................................................................................................................... 159
The Microchip Web Site..................................................................................................................................................................... 163
It is our intention to provide our valued customers with the best docum entation possible to ensure s uccessful 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 t he 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.
The PIC12F609/615/12HV609/615 has a 13-bit program counter capable of addressing an 8K x 14 program memory space. Only the first 1K x 14 (0000h03FFh) for the PIC12F609/615/12HV609/615 is physically implemented. Accessing a location above these
boundaries will cause a wraparound within the first 1K
x 14 space. T he Rese t vec tor is at 0000 h and the int errupt vector is at 0004h (see Figure 2-1).
FIGURE 2-1:PROGRAM MEMORY MAP
AND STACK FOR THE
PIC12F609/615/12HV609/615
PC<12:0>
CALL, RETURN
RETFIE, RETLW
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
13
0000h
2.2Data Memory Organization
The data memory (see Figure 2-2) is partitioned into two
banks, which contain the General Purpose Registers
(GPR) and the Special Function Registers (SFR). The
Special Function Registers are located in the first 32
locations of each bank. Register locations 40h-7Fh in
Bank 0 are General Purpose Registers, implemented as
static RAM. Register locations F0h-FFh in Bank 1 point
to addresses 70h-7Fh in Bank 0. All other RAM is
unimplemented and returns ‘0’ when read. The RP0 bit
of the STATUS register is the bank select bit.
RP0
0→Bank 0 is selected
1→Bank 1 is selected
Note:The IRP and RP1 bits of the STATUS
register are reserved and should always be
maintained as ‘0’s.
2.2.1GENERAL PURPOSE REGISTER
FILE
The register file is organized as 64 x 8 in the
PIC12F609/615/12HV609/615. Each register is
accessed, either directly or indirectly, through the File
Select Register (FSR) (see Section 2.4 “IndirectAddressing, INDF and FSR Registers” ).
Interrupt Vector
On-chip Program
Memory
Wraps to 0000h-07FFh
0004h
0005h
03FFh
0400h
1FFFh
2.2.2SPECIAL FUNCTION REGISTERS
The Special Function Registers are registers used by
the CPU and peripheral functions for controlling the
desired operation of the device (see Table2-1). These
registers are static RAM.
The special registers can be classified into two sets:
core and peripheral. The Special Function Registers
associated with the “core” are described in this section.
Those related to the operation of the peripheral features
are described in the section of that peripheral feature.
TABLE 2-1:PIC12F609/HV609 SPECIAL FUNCTION REGISTERS SUMMARY BANK 0
AddrNameBit 7Bit 6Bit 5Bit 4Bit 3B it 2 Bit 1Bit 0
Bank 0
00hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx 22, 100
01hTMR0Timer0 Module’s Registerxxxx xxxx 41, 100
02hPCLProgram Counter’s (PC) Least Significant Byte0000 0000 22, 100
03hSTA TUSIRP
04hFSRIndirect Data Memory Address Pointerxxxx xxxx 22, 100
05hGPIO
06h—Unimplemented——
07h—Unimplemented——
08h—Unimplemented——
09h—Unimplemented——
0AhPCLATH
0BhINTCONGIE PEIE T0IE INTE GPIET0IF INTFGPIF0000 0000 17, 100
0ChPIR1
0Dh—Unimplemented——
0EhTMR1LHolding Register for the Least Significant Byte of the 16-bit TMR1 Registerxxxx xxxx 45, 100
0FhTMR1HHolding Register for the Most Significant Byte of the 16-bit TMR1 Registerxxxx xxxx 45, 100
10hT1CONT1GINVTMR1GE T1CKPS1 T1CKPS0 T1OSCEN T1SYNC
11h—Unimplemented——
12h—Unimplemented——
13h—Unimplemented——
14h—Unimplemented——
15h—Unimplemented——
16h—Unimplemented——
17h—Unimplemented——
18h—Unimplemented——
19hVRCONCMVREN
1AhCMCON0CMONCOUTCMOECMPOL
1Bh—————
1ChCMCON1
1Dh—Unimplemented——
1Eh—Unimplemented——
1Fh—Unimplemented——
Legend:– = Unimplemented locations rea d as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:IRP and RP1 bits are reserved, always maintain these bits clear.
(1)
——GP5GP4GP3GP2GP1GP0--x0 x000 31, 100
———Write Buffer for upper 5 bits of Program Counter---0 0000 22, 100
TABLE 2-2:PIC12F615/HV615 SPECIAL FUNCTION REGISTERS SUMMARY BANK 0
AddrNameBit 7B it 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Bank 0
00hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx 22, 101
01hTMR0Timer0 Module’s Registerxxxx xxxx 41, 101
02hPCLProgram Counter’s (PC) Least Significant Byte0000 0000 22, 101
03hSTA TUSIRP
04hFSRIndirect Data Memory Address Pointerxxxx xxxx 22, 101
05hGPIO
06h—Unimplemented——
07h—Unimplemented——
08h—Unimplemented——
09h—Unimplemented——
0AhPCLATH
0BhINTCONGIE PEIE T0IE INTE GPIET0IF INTF GPIF0000 0000 17, 101
0ChPIR1
0Dh—Unimplemented——
0EhTMR1LHolding Register for the Least Significant Byte of the 16-bit TMR1 Registerxxxx xxxx 45, 101
0FhTMR1HHolding Register for the Most Significant Byte of the 16-bit TMR1 Registerxxxx xxxx 45, 101
10hT1CONT1GINVTMR1GE T1CKPS1 T1CKPS0 T1OSCEN T1SYNC
11hTMR2Timer2 Module Register0000 0000 51, 101
12hT2CON
13hCCPR1LCapture/Compare/PWM Register 1 Low ByteXXXX XXXX 76, 101
14hCCPR1HCapture/Compare/PWM Register 1 High ByteXXXX XXXX 76, 101
15hCCP1CONP1M
16hPWM1CONPRSENPDC6PDC5PDC4PDC3PDC2PDC1PDC00000 0000 91, 101
17hECCPASECCPASE ECCPAS2 ECCPAS1 ECCPAS0 PSSAC1PSSAC0PSSBD1PSSBD0 0000 0000 88, 101
18h—Unimplemented——
19hVRCONCMVREN
1AhCMCON0CMONCOUTCMOECMPOL
1Bh—————
1ChCMCON1
1Dh—Unimplemented——
1EhADRESHMost Significant 8 bits of the left shifted A/D result or 2 bits of right shifted result xxxx xxxx 71, 101
1FhADCON0ADFMVCFG
Legend:– = Unimplemented locations rea d as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:IRP and RP1 bits are reserved, always maintain these bits clear.
(1)
——GP5GP4GP3GP2GP1GP0--x0 x000 31, 101
———Write Buffer for upper 5 bits of Program Counter---0 0000 22, 101
TABLE 2-3:PIC12F609/HV609 SPECIAL FUNCTION REGISTERS SUMMARY BANK 1
AddrNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Bank 1
80hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx 22, 101
81hOPTION_REGGPPU
82hPCLProgram Counter’s (PC) Least Significant Byte0000 0000 22, 101
83hSTATUSIRP
84hFSRIndirect Data Memory Address Pointerxxxx xxxx 22, 101
85hTRISIO
86h—Unimplemented——
87h—Unimplemented——
88h—Unimplemented——
89h—Unimplemented——
8AhPCLATH
8BhINTCONGIEPEIET0IEINTEGPIET0IFINTFGPIF
8ChPIE1
8Dh—Unimplemented——
8EhPCON
8Fh—Unimplemented——
90hOSCTUNE
91h—Unimplemented——
92h—Unimplemented——
93h—Unimplemented——
94h—Unimplemented——
95hWPU
96hIOC
97h—Unimplemented——
98h—Unimplemented——
99h—Unimplemented——
9Ah—Unimplemented——
9Bh—Unimplemented——
9Ch—Unimplemented——
9Dh—Unimplemented——
9Eh—Unimplemented——
9FhANSEL
Legend:– = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:IRP and RP1 bits are reserved, always maintain these bits clear.
(2)
2:GP3 pull-up is enabled when MCLRE is ‘1’ in the Configuration Word register.
3:MCLR
exists.
4:TRISIO3 always reads as ‘1’ since it is an input only pin.
——TRISIO5TRISIO4 TRISIO3
———Write Buffer for upper 5 bits of Program Counter---0 0000 22, 101
TABLE 2-4:PIC12F615/HV615 SPECIAL FUNCTION REGISTERS SUMMARY BANK 1
AddrNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Bank 1
80hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx 22, 101
81hOPTION_REGGPPU
82hPCLProgram Counter’s (PC) Least Significant Byte0000 0000 22, 101
83hSTATUSIRP
84hFSRIndirect Data Memory Address Pointerxxxx xxxx 22, 101
85hTRISIO
86h—Unimplemented——
87h—Unimplemented——
88h—Unimplemented——
89h—Unimplemented——
8AhPCLATH
8BhINTCONGIEPEIET0IEINTEGPIET0IFINTFGPIF
8ChPIE1
8Dh—Unimplemented——
8EhPCON
8Fh—Unimplemented——
90hOSCTUNE
91h—Unimplemented——
92hPR2Timer2 Module Period Register1111 1111 51, 101
93hAPFCON
94h—Unimplemented——
95hWPU
96hIOC
97h—Unimplemented——
98h—Unimplemented——
99h—Unimplemented——
9Ah—Unimplemented——
9Bh—Unimplemented——
9Ch—Unimplemented——
9Dh—Unimplemented——
9EhADRESLLeast Significant 2 bits of the left shifted result or 8 bits of the right shifted resultxxxx xxxx 71, 101
9FhANSEL
Legend:– = Unimplemented locations rea d as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:IRP and RP1 bits are reserved, always maintain these bits clear.
(2)
2:GP3 pull-up is enabled when MCLRE is ‘1’ in the Configuration Word register.
3:MCLR
4:TRISIO3 always reads as ‘1’ since it is an input only pin.
and WDT Reset does not affect the previous value data latch. The GPIF bit will clear upon Reset but will set again if the mismatch
exists.
INTEDGT0CST0SEPSAPS2PS1PS01111 1111 16, 101
(1)
——TRISIO5TRISIO4 TRISIO3
———Write Buffer for upper 5 bits of Program Counter---0 0000 22, 101
The STATUS registe r, shown in Register 2-1, contains:
• the arithmetic status of the ALU
• the Reset status
• the bank select bits for data memory (RAM)
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 bit s are set or cleared ac cording to the
device logic. Furthermore, the TO
writable. Therefore, the result of an instruction with the
STATUS regis ter as destina tion may be differ ent than
intended.
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).
and PD bits are not
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, see the Section 13.0 “Instruction
Set Summary”.
Note 1: Bits IRP and RP1 of the ST ATUS register
are not used by the PIC12F609/615/
12HV609/615 and should be maintained
as clear. Use of these bits is not recommended, since this may affect upward
compatibility with future products.
2: The C and DC bits operate as a Borrow
and Digit Borrow out bit, respectively, in
subtraction. See the SUBLW and SUBWF
instructions for examples.
REGISTER 2-1:STATUS: STATUS REGISTER
ReservedReservedR/W-0R-1R-1R/W-xR/W-xR/W-x
IRPRP1RP0T OPDZDCC
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7IRP: This bit is reserved and should be maintained as ‘0’
bit 6RP1: This bit is reserved and should be maintained as ‘0’
bit 5RP0: Register Bank Select bit (used for direct addressing)
1 = Bank 1 (80h – FFh)
0 = Bank 0 (00h – 7Fh)
bit 4TO
bit 3PD
bit 2Z: Zero bit
bit 1DC: Digit Carry/Borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions), For Borrow, the polarity is
bit 0C: Carry/Bo
: 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 b y 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
reversed.
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)
rrow bit
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
rrow, the polarity is reversed. A subtraction is executed by adding the two’s complement of the
second operand. For rotate (RRF, RLF) instructi ons, this bit is loa ded with either the high-orde r or low-o rder
bit of the source register.
PIC12F609/615/12HV609/615
2.2.2.2OPTION Register
The OPTION register is a readable and writable register, which contains various control bits to configure:
• Timer0/WDT prescaler
• External GP2/INT interrupt
•Timer0
• Weak pull-ups on GPIO
REGISTER 2-2:OPTION_REG: OPTION REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
GPPU
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
INTEDGT0CST0SEPSAPS2PS1PS0
Note:To achieve a 1:1 prescaler assignment for
Timer0, assign the prescaler to the WDT
by setting PSA bit to ‘1’ of the OPTION
register. See Section 5.1.3 “SoftwareProgrammable Prescaler”.
bit 7GPPU
: GPIO Pull-up Enable bit
1 = GPIO pull-ups are disabled
0 = GPIO pull-ups are enabled by individual PORT latch values
bit 6INTEDG: Interrupt Edge Select bit
1 = Interrupt on rising edge of GP2/INT pin
0 = Interrupt on falling edge of GP2/INT pin
bit 5T0CS: Timer0 Clock Source Select bit
1 = Transition on GP2/T0CKI pin
0 = Internal instruction cyc le clock (F
bit 4T0SE: Timer0 Source Edge Select bit
1 = Increment on high-to -low transition on GP2/T0CKI pin
0 = Increment on low-to-high transition on GP2/T0CKI pin
bit 3PSA: Prescaler Assignment bit
1 = Prescaler is assigned to the WDT
0 = Prescaler is assigned to the Timer0 module
The INTCON register is a readable and writable
register , which c ontains the various en able and fl ag bit s
for TMR0 register ove rflo w, GPIO change and externa l
GP2/INT pin interrupts.
Note:Interrupt flag bits are set w hen an in terrupt
condition occurs, regar dless of the st ate of
its corresponding enable bit or the Global
Enable bit, GIE of the INTCON register.
User software should ensure the
appropriate interrupt flag bits are clear
prior to enabling an interrupt.
REGISTER 2-3:INTCON: INTERRUPT CONTROL REGISTER
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
GIEPEIET0IEINTEGPIET0IFINTFGPIF
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7GIE: Global Interrupt Enable bit
1 = Enables all unmasked interrupts
0 = Disables all interrupts
bit 6PEIE: Peripheral Interrupt Enable bit
1 = Enables all unmasked peripheral interrupts
0 = Disables all peripheral interrupts
bit 5T0IE: Timer0 Overflow Interru pt Enab le bit
1 = Enables the Timer0 interrupt
0 = Disables the Timer0 interrupt
bit 4INTE: GP2/INT External Interrupt Enable bit
1 = Enables the GP2/INT external interrupt
0 = Disables the GP2/INT external interrupt
bit 3GPIE: GPIO Change Interrupt Enable bit
1 = Enables the GPIO change interrupt
0 = Disables the GPIO change interrupt
bit 2T0IF: Timer0 Overflow Interrupt Flag bit
1 = Timer0 register has overflowed (must be cleared in software)
0 = Timer0 register did not overflow
bit 1INTF: GP2/INT External Interrupt Flag bit
1 = The GP2/INT external interrupt occurred (must be cleared in software)
0 = The GP2/INT external interrupt did not occur
bit 0GPIF: GPIO Change Interrupt Flag bit
1 = When at least one of the GPIO <5:0> pins changed state (must be cleared in software)
0 = None of the GPIO <5:0> pins have changed state
(1)
(2)
Note 1:IOC register must also be enabled.
2: T0IF bit is set when TMR0 rolls over. TMR0 is unchanged on Reset and should be initialized before
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7Unimplemented: Read as ‘0’
bit 6ADIF: A/D In terrupt Flag bit
1 = A/D conversion complete
0 = A/D conversion has not completed or has not been started
bit 5CCP1IF: CCP1 Interrupt Flag bit
Capture mode:
1 = A TMR1 register capture occurred (must be cleared in software)
0 = No TMR1 register captu re occurred
Compare mode
1 = A TMR1 register compare match occurred (must be cleared in software)
0 = No TMR1 register compare match occurred
PWM mode
Unused in this mode
bit 4Unimplemented: Read as ‘0’
bit 3CMIF: Comparator Interrupt Flag bit
1 = Comparator output has changed (must be cleared in software)
0 = Comparator output has not changed
bit 2Unimplemented: Read as ‘0’
bit 1TMR2IF: Timer2 to PR2 Match Interrupt Flag bit
1 = Timer2 to PR2 match occurred (must be cleared in software)
0 = Timer2 to PR2 match has not occurred
bit 0TMR1IF: Timer1 Overflow Interrupt Flag bit
1 = Timer1 register overflowed (must be cleared in software)
0 = Timer1 has not overflowed
(1)
CCP1IF
:
:
(1)
—CMIF —TMR2IF
(1)
(1)
Note:Interrupt flag bits are set when an interrupt
condition occurs, regardless of the state of
its corresponding enable bit or the Global
Enable bit, GIE of the INTCON register.
User software should ensure the
appropriate interrupt flag bits are clear prior
to enabling an interrupt.
(1)
TMR1IF
(1)
Note 1: PIC12F615/HV615 only. PIC12F609/HV609 unimplemented, read as ‘0’.
The Alternate Pin Function Control (APFC ON) reg ist er
is used to steer specific peripheral input and output
functions between different pins. For this device, the
P1A, P1B and Timer1 Gate functions can be moved
between different pins.
The APFCON register bits are shown in Register 2-7.
REGISTER 2-7:APFCON: POWER CONTROL REGISTER
U-0U-0U-0R/W-0U-0U-0R/W-0R/W-0
———T1GSEL——P1BSELP1ASEL
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7-5Unimplemented: Read as ‘0’
bit 4T1GSEL: TMR1 Input Pin Select bit
1 = T1G function is on GP3/T1G
0 = T1G function is on GP4/AN3/CIN1-/T1G/P1B
bit 3-2Unimplemented: Read as ‘0’
bit 1P1BSEL: P1B Output Pin Select bit
1 = P1B function is on GP4/AN3/CIN1-/T1G
0 = P1B function is on GP0/AN0/CIN+/P1B/ICSPDAT
bit 0P1ASEL: P1A Output Pin Select bit
1 = P1A function is on GP5/T1CKI/P1A
0 = P1A function is on GP2/AN2/T0CKI/INT/COUT/CCP1/P1A
The Program Counter (PC) is 13 bits wide. The lo w byte
comes from the PCL register, which is a readable and
writable register . The hig h byte (PC<12:8>) is not directl y
readable or writable and comes from PCLATH. On any
Reset, the PC is cleared. Figure 2-4 shows the two
situations for the loading of the PC. The upper example
in Figure 2-4 shows how the PC is loaded on a write to
PCL (PCLATH<4:0> → PCH). The lower example in
Figure 2-4 shows h ow the PC is l oaded during a CALL or
GOTO instruction (PCLATH<4:3> → PCH).
FIGURE 2-4:LOADING OF PC IN
DIFFERENT SITUATIONS
PCHPCL
128 70
PC
PCLATH<4:0>
5
PCLATH
PCHPCL
12 11 100
PC
2
87
PCLATH<4:3>
PCLATH
8
11
2.3.1MODIFYING PCL
Executing any instruction with the PCL register as the
destination simultaneously causes the Program
Counter PC< 12:8> bits (PCH) to be replaced by the
contents of the PCLATH register . Th is allo ws the enti re
contents of the program counter to be changed by
writing the desired up per 5 bit s to the PCLATH register .
When the lower 8 bits are written to the PCL regis ter , all
13 bits of the program counter will chan ge to the values
contained in the PCLATH register and those being
written to the PCL register.
A computed GOTO is accomplish ed by adding an offset
to the program counter (ADDWF PCL). Care should be
exercised when jumping into a look-up table or
program b ranch table (computed GOTO) by modifying
the PCL register. Assuming that PCLATH is set to the
table start address, if the table length is greater than
255 instructions or if the lower 8 bits of the memory
address rolls over from 0xFF to 0x00 in the middle of
the table, then PCLATH must be incremented for each
address rollover that occurs between the table
beginning and the target location within the table.
For more information refer to Application Note AN556,
“Implementing a Table Read” (DS00556).
Instruction wit
PCL a
Destinatio
ALU Result
GOTO, CALL
OPCODE <10:0
2.3.2STACK
The PIC12F609/615/12HV609/615 Family has an 8level x 13-bit wide hardware stack (see Figure 2-1).
The stack space is not part of either program or data
space and the S ta ck Pointer i s not rea dable or writa ble.
The PC is PUSHed onto the stack when a CALL
instruction is execute d or an interrupt ca uses a branc h.
The stack is POPed in the even t of a RETURN, RETLW
or a RETFIE instruction execution. PCLATH is not
affected by a P USH or POP operation.
The stack operat es as a circular buf fer . This means th at
after the stack has been PUSHed eight times, the ninth
push overwrites the va lue tha t was s tored fro m the first
push. The tenth pus h ov erwr i tes the se co nd push (and
so on).
Note 1: There are no Status bits to indicate stack
overflow or stack underflow conditions.
2: There are no instructions/mnemonics
called PUSH or POP. These are actions
that occur from the execution of the
CALL, RETURN, RETLW and RETFIE
instructions or the vectoring to an
interrupt address.
2.4Indirect Addressing, INDF and
FSR Registers
The INDF register is not a physica l register . Addr essing
the INDF register will cause indirect addressing.
Indirect addressing is possible by using the INDF
register. Any instruction using the INDF register
actually accesses data pointed to by the File Select
Register (FSR). Reading INDF itself indirectly will
produce 00h. Writing to the INDF register indirectly
results in a no operation (although Status bits may be
affected). An effective 9-bit address is obtained by
concatenating the 8-bit FSR and the IRP bit of the
STATUS register, as shown in Figure 2-5.
A simple program to clear RAM location 40h-7Fh using
indirect addressing is shown in Example 2-1.
EXAMPLE 2-1:INDIRECT ADDRESS ING
MOVLW0x40;initialize pointer
MOVWFFSR;to RAM
NEXTCLRFINDF;clear INDF register
INCFFSR;inc pointer
BTFSSFSR,7;all done?
GOTONEXT;no clear next
The Oscillator mod ule can be c onfigured in one of eig ht
clock modes.
3.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 applicati ons while maximiz ing performance and minimizing power consumption. Figure 3-1
illustrates a block diagram of the Oscillator module.
Clock sources can be configured from external
oscillators, quartz cryst al resonators , ceramic resonators
and Resistor-Capacitor (RC) circuits. In addition, the
system clock source can be configured with a choice of
two selectable speeds: internal or external system clock
source.
1.EC – External clock w ith I/O on OSC2/C LKOUT.
2.LP – 32 kHz Low-Power Crystal mode.
3.XT – Medium Gain Crystal or Ceramic Resonator
Oscillator mode.
4.HS – High Gain Crystal or Ceramic Resonator
mode.
5.RC – External Resistor-Capacitor (RC) with
OSC/4 output on OSC2/CLKOUT.
F
6.RCIO – External Resistor-Capacitor (RC) with
I/O on OSC2/CLKOUT.
7.INTOSC – Internal oscillator with F
on OSC2 and I/O on OSC1/CLKIN.
8.INTOSCIO – Internal oscillator with I/O on
OSC1/CLKIN and OSC2/CLKOUT.
Clock Source modes are configured by the FOSC <2:0>
bits in the Configuration Word register (CONFIG). The
Internal Oscillator mo dule provides a select able system
clock mode of either 4 MHz (Postscaler) or 8 MHz
(INTOSC).
Clock Source modes can be classified as external or
internal.
• External Clock mod es rely on e xternal circui try fo r
the clock source. 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 internally
within the Oscillator module. The Oscillator
module has two selectable clock frequencies:
4 MHz and 8 M Hz
The system clock can be selected between external or
internal clock sources via the FOSC<2:0> bits of the
Configuration Word register.
3.3External Clock Modes
3.3.1OSCILLATOR 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. The
OST ensures that the oscillator circuit, using a quartz
crystal resonator o r ce ramic res onator, has started and
is providing a stable system clock to the Oscillator
module. When switching between clock sources, a
delay is required to allow the new clock to stabilize.
These oscillator delays are shown in Table 3-1.
The External Clock (EC) mode allows an externally
generated logic level as the system clock source. When
operating in this mode, an external clock source is
connected to the OSC1 input and the OSC2 is available
for general purpose I/O. Figure 3-2 shows the pin
connections for EC mode.
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
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.
The LP, XT and HS modes support the use of quartz
crystal resonators or ceram ic resonators connected to
OSC1 and OSC2 (Figu re 3-3). The mod e selects 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. T his 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 medi um 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 resonato rs that req uire a hi gh
drive setting.
Figure 3-3 and Figure 3-4 show typical circuits for
quartz crystal and ceramic resonators, respectively.
Note 1: Quartz crystal char acteristics vary a ccording
to type, package and manufacturer. The
user should consult the manu facturer data
sheets for sp ecifi catio ns an d reco mmen ded
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)
FIGURE 3-4:CERAMIC RESONATOR
OPERATION
(XT OR HS MODE)
FIGURE 3-3:QUARTZ CRYSTAL
OPERATION (LP, XT OR
HS MODE)
PIC® MCU
OSC1/CLKIN
C1
Quartz
Crystal
C2
Note 1: A series resistor (RS) may be required for
2: The value of R
(1)
S
R
quartz crystals with low drive level.
selected (typically between 2 MΩ to 10 MΩ).
F varies with the Oscillator mode
(2)
RF
OSC2/CLKOUT
To Internal
Logic
Sleep
PIC® MCU
OSC1/CLKIN
C1
(3)
RP
C2
Ceramic
Resonator
Note 1: A series resistor (RS) may be required for
ceramic resonators with low drive level.
2: The value of R
selected (typically between 2 MΩ to 10 MΩ).
3: An additional parallel feedback resistor (R
may be required for proper ceramic resonator
operation.
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. There are two modes: RC and RCIO.
In RC mode, the RC circuit connects to OSC1.
OSC2/CLKOUT outputs the RC oscillator frequency
divided by 4. This signal may be us ed to provide a cl ock
for external circuitry, synchronization, calibration, test
or other application requirements. Figure 3-5 shows
the external RC mode connections.
FIGURE 3-5:EXTERNAL RC MODES
REXT
CEXT
VSS
VDD
OSC/4 or
F
(2)
I/O
OSC1/CLKIN
OSC2/CLKOUT
PIC® MCU
Internal
Clock
(1)
3.4Internal Clock Modes
The Oscillator module provides a selectable system
clock source of either 4 MHz or 8 MHz. The selectable
frequency is configured through the IOSCFS bit of the
Configuration Word.
The frequency of the int erna l os ci llator can be trimmed
with a calibration value in the OSCTUNE register.
3.4.1INTOSC AND INTOSCIO MODES
The INTOSC and INTOSCIO modes configure the
internal oscillators as the system clock source when
the device is progra mmed usi ng the osc illator se lectio n
or the FOSC<2:0> bits in the Configuration Word
register (CONFIG). See Section 11.0 “SpecialFeatures of the CPU” for more information.
In INTOSC mode, OSC1/CLKIN is available for general
purpose I/O. OSC2/CLKOUT outputs the selected
internal oscillator fre quency divide d by 4. The CLKO UT
signal may be used to provide a clock for external
circuitry, synchronization, calibration, test or other
application requirements.
In INTOSCIO mode, OSC1/CLKIN and OSC2/CLKOUT
are available for general purpose I/O.
Recommended values: 10 kΩ ≤ REXT ≤ 100 kΩ, <3V
3 kΩ ≤ R
C
Note 1:Alternate pin functions are listed in
Section 1.0 “Device Overview”.
2:Output depends upon R C or RCIO Clock
mode.
EXT≤ 100 kΩ, 3-5V
EXT > 20 pF, 2-5V
In RCIO mode, the RC circuit is connected to OSC1.
OSC2 becomes an additional general purpose I/O pin.
The RC oscillator frequency is a function of the supply
voltage, the resistor (REXT) and capacito r (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