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 impro ving the cod e 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 intended through suggestion only
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
No representation or warranty is given and no liability is
assumed by Microchip Technology Incorporated with respect
to the accuracy or use of such information, or infringement of
patents or other intellectual property rights arising from such
use or otherwise. Use of Microchip’s products as critical
components in life support systems is not authorized except
with express written approval by Microchip. No licenses are
conveyed, implicitly or otherwise, under any intellectual
property rights.
Trademarks
The Microchip name and logo, the Microchip logo,Accuron,dsPIC, K
EELOQ, MPLAB, PIC, PICmicro, PICSTART,
PROMATE, PowerSmartand rfPICare registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
AmpLab, FilterLab, microID, MXDEV,MXLAB,PICMASTER,SEEVAL, SmartShuntand The Embedded Control SolutionsCompany are registered trademarks of Microchip TechnologyIncorporated in the U.S.A.
Application Maestro, dsPICDEM, dsPICDEM.net,dsPICworks, ECAN, ECONOMONITOR, FanSense,FlexROM,fuzzyLAB, In-Circuit Serial Programming, ICSP,ICEPIC,Migratable Memory,MPASM, MPLIB, MPLINK,MPSIM, PICkit, PICDEM, PICDEM.net,PICtail,PowerCal,PowerInfo, PowerMate, PowerTool, rfLAB, SelectMode,SmartSensor, SmartTel and Total Endurance are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
Serialized Quick TurnProgramming (SQTP) is a service markof Microchip TechnologyIncorporated inthe U.S.A.
All other trademarks mentioned herein are property of their respective companies.
Microchip received ISO/TS-16949:2002 quality system certification forits worldwideheadquarters, design and wafer fabricationfacilities inChandler andTempe, Arizona and Mountain View, Californiain October
2003. The Company’s quality system processes and procedures areforits PICmicroEEPROMs, microperipherals, nonvolatile memory and analogproducts. In addition, Microchip’s quality system forthe design andmanufacture of development systems is ISO 9001:2000 certified.
®
8-bit MCUs, KEELOQ
®
code hopping devices, Serial
DS41211B-page iiPreliminary 2004 Microchip Technology Inc.
PIC12F683
8-Pin Flash-Based, 8-Bit CMOS Microcontrollers with
nanoWatt Technology
High-Performance RISC CPU
• Only 35 instructions to learn:
- All single-cycle instructions except branches
• Operating speed:
- DC – 20 MHz oscillator/clock input
- DC – 200 ns instruction cycle
• Interrupt capability
• 8-level deep hardware stack
• Direct, Indirect and Relative Addressing modes
Special Microcontroller Features
• Precision Internal Oscillator:
- Factory calibrated to ±1%
- Software selectable frequency range of
8 MHz to 31kHz
- Two-speed Start-up mode
- Crystal fail detect for critical applications
- Clock mode switching during operation for
power savings
• Power-saving Sleep mode
• Wide operating voltage range. (2.0V-5.5V)
• Industrial and Extended tempera ture range
• Power-on Reset (POR)
• Power-up Timer (PWRT) and Oscillator Start-up
Timer (OST)
• Multiplexed Master Clear with pull-up/input pin
• Programmable code protection
• High Endurance Flash/EEPROM cell:
- 100,000 write Flash endurance
- 1,000,000 write EEPROM endurance
- Flash/Data EEPROM Retention: > 40 years
Low-Power Features
• Standby Current:
- 1 nA @ 2.0V, typical
• Operating Current:
-8.5µA @ 32 kHz, 2.0V, typical
-100µA @ 1 MHz, 2.0V, typical
• Watchdog Timer Current:
-1µA @ 2.0V, typical
Peripheral Features
• 6 I/O pins with individual direction control:
- High current source/sink for direct LED drive
- Interrupt-on-pin change
- Individually programmable weak pull-ups
- Ultra Low-Power Wake-up on GP0
• Analog comparator module with:
- One analog comparator
- Programmable on-chip voltage reference
(CV
REF) module (% of VDD)
- Comparator inputs and output externally
accessible
• A/D Converter:
- 10-bit resolution and 4 channels
• Timer0: 8-bit timer/counter with 8-bit
programmable prescaler
• Enhanced Timer1:
- 16-bit timer/counter with prescaler
- External Gate Input mode
- Option to use OSC1 and OSC2 in LP mode as
Timer1 oscillator if INTOSC mode selected
• Timer2: 8-bit timer/counter with 8-bit period
register, prescaler and postscaler
• Capture, Compare, PWM mo dul e:
- 16-bit Capture, max resolution 12.5 ns
- Compare, max resolution 200 ns
- 10-bit PWM, max frequency 20 kHz
• In-Circuit Serial Programming™ (ICSP™) via
two pins
12.0 Special Features of the CPU....................................... .......................................... .....................................................................75
13.0 Instruction Set Summary............................................................................................................................................................ 95
14.0 Development Support............................................................................................................................................................... 103
16.0 DC and AC Characteristics Graphs and Tables....................................................................................................................... 131
Appendix A: Data Sheet Revision History.......................................................................................................................................... 137
Appendix B: Migrating From Other PICmicro® Devices .................................................................................................................... 137
Index ..................................................................................................................................................................................................139
Systems Information and Upgrade Hot Line...................................................................................................................................... 143
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 c omm ents regarding t his publication, p lease c ontact the M arket ing Co mmunications Department via
E-mail at docerrors@mail.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)
• The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, 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/cn to receive the most current information on all of our products.
DS41211B-page 4Preliminary 2004 Microchip Technology Inc.
PIC12F683
1.0DEVICE OVERVIEW
This documen t conta i ns dev ic e spec if i c in for m at i on fo r
the PIC12F683. Addition al informa tion may b e found in
the “PICmicro® Mid-Range MCU Family Reference
Manual” (DS33023), which may be obtained from your
local Microchip Sales Representative or downloaded
from the Microchip web site. The reference manual
should be considered a complementary document to
FIGURE 1-1:PIC12F683 BLOCK DIAGRAM
INT
Program Counter
8-Level Stack
(13-bit)
Direct Addr
7
Program
Bus
Configuration
13
Flash
2k x 14
Program
Memory
14
Instruction reg
this data sheet and is highly recommended reading for
a better understanding of the device architecture and
operation of the peripheral modules.
The PIC12F683 is covered by this data sheet. It is
available in 8-pin PDIP, SOIC and DFN-S packages.
Figure 1-1 shows a block diagram of the PIC12F683
device. Table 1-1 shows the pinout description.
TTL = TTL compatible inputST= Schmitt Trigger input with CMOS levels
HV = High VoltageXTAL = Crystal
Input
Type
Output
Type
ST—Timer1 gate
OSC/4 output
ST—Master Clear w/internal pull-up
Description
DS41211B-page 6Preliminary 2004 Microchip Technology Inc.
PIC12F683
2.0MEMORY ORGANIZATION
2.1Program Memory Organization
The PIC12F683 has a 13-bit program counter capable
of addressing an 8k x 14 pr ogram mem ory spac e. Only
the first 2k x 14 (0000h-07FFh) for the PIC12F683 is
physically implemented. Accessing a location above
these boundaries will cause a wrap around within the
first 2k x 14 space. The Reset vector is at 0000h and
the interrupt vector is at 0004h (see Figure 2-1).
FIGURE 2-1:PROGRAM MEMORY MAP
AND STACK FOR THE
PIC12F683
PC<12:0>
CALL, RETURN
RETFIE, RETLW
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
13
000h
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 20h-7Fh
in Bank 0 and A0h-BFh in Bank 1 are general purpose
registers, implemented as static RAM. Register locations F0h-FFh in Bank 1 point to addresses 70 h-7Fh in
Bank 0. All other RAM is u nimplemented and re turns ‘0’
when read. RP0 (Status<5>) is the bank select bit.
•RP0 = 0: Bank 0 is selected
•RP0 = 1: Bank 1 is selected
Note:The IRP and RP1 bits (Status<7:6>) are
reserved and should always be
maintained as ‘0’s.
2.2.1GENERAL PURPOSE REGISTER
FILE
The register file is organized as 128 x 8 in the
PIC12F683. Each register is accessed, either directly
or indirectly, through the Fi le Sel ec t Register FSR (see
Section 2.4 “Indirect Addressing, INDF and FSR
Registers”).
The Special Function Registers are registers used by
the CPU and peripheral functions for controlling the
desired operation of the device (see Table 2-1). These
registers are static RAM.
The special re gisters can be classifi ed into two sets:
core and peripheral. The Special Function Registers
associated with the “c ore” are des cribed in this sect ion.
Those related to the operation of the peripheral
features are described in the section of that peripheral
feature.
DS41211B-page 8Preliminary 2004 Microchip Technology Inc.
PIC12F683
TABLE 2-1:PIC12F683 SPECIAL REGISTERS SUMMARY BANK 0
AddrNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Bank 0
00hINDFAddressing this loca tion uses content s of FSR to address dat a memory (not a physical register) xxxx xxxx 17, 83
01hTMR0Timer0 Module’s Registerxxxx xxxx 39, 83
02hPCLProgram Counter’s (PC) Least Significant Byte0000 0000 17, 83
03hSTATUSIRP
04hFSRIndirect Data Memory Addr ess Point erxxxx xxxx 17, 83
05hGPIO
06h—Unimplemented——
07h—Unimplemented——
08h—Unimplemented——
09h—Unimplemented——
0AhPCLATH
0BhINTCON GIE PEIET0IEINTEGPIET0IFINTFGPIF0000 0000 13, 83
0ChPIR1
0Dh—Unimplemented——
0EhTMR1LHolding Register for the Least Significant Byte of the 16-bit TMR1xxxx xxxx 41, 83
0FhT MR1HHolding Register for the Most Significant Byte of the 16-bit TMR1xxxx xxxx 41, 83
10hT1CONT1GINV TMR1GE T1CKPS1 T1CKPS0 T1OSCEN T1SYNC
11h
TMR2Timer2 Module Register0000 0000 45, 83
12h
T2CON—TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 45, 83
13hCCPR1LCap ture/Com pare/PWM Register 1 Low Bytexxxx xxxx 70, 83
14hCCPR1H Capture/Compare/PWM Register 1 High Bytexxxx xxxx 70, 83
15hCCP1CON
16h—Unimplemented——
17h—Unimplemented——
18hWDTCON
19hCMCON0
1AhCMCON1
1Bh—Unimplemented——
1Ch—Unimplemented——
1Dh—Unimplemented——
1EhADRESH Most Significant 8 bits of the left shifted A/D result or 2 bits of right shifted result xxxx xxxx 57,83
1FhADCON0ADFMVCFG
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.
(1)
——GP5GP4GP3GP2GP1GP0--xx xxxx 31, 83
———Write Buffer for upper 5 bits of Program Counter---0 0000 17, 83
TABLE 2-2:PIC12F683 SPECIAL FUNCTION REGISTERS SUMMARY BANK 1
AddrNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Bank 1
80h INDFAddressing this location uses contents of FSR to address data memory (not a physical register) xxxx xxxx 17, 83
OPTION_RE G
81h
82h PCLProgram Counter’s (PC) Least Significant Byte0000 0000 17, 83
83h STATUSIRP
84h FSRIndirect Data Memory Address Pointerxxxx xxxx 17, 83
85h TRISIO
86h—Unimplemented——
87h—Unimplemented——
88h—Unimplemented——
89h—Unimplemented——
8Ah PCLATH
8Bh INTCONGIEPEIET0IEINTEGPIET0IFINTFGPIF0000 0000 13, 83
8Ch PIE1EEIEADIECCP1IE
8Dh—Unimplemented——
8Eh PCON
8Fh OSCCON
90h OSCTUNE
91h—Unimplemented——
92h PR2Timer2 Module Period Register1111 1111 45, 83
93h—Unimplemented——
94h—Unimplemented——
95h WPU
96h IOC
97h—Unimplemented——
98h—Unimplemented——
99h VRCONVREN
9Ah EEDATEEDAT7EEDAT6EEDAT5 EEDAT4 EEDAT3EEDAT2EEDAT1EEDAT0 0000 0000 65, 83
9Bh EEADREEADR7 EEADR6 EEADR5 EEADR4 EEADR3 EEADR2 EEADR1 EEADR0 0000 0000 65, 83
9Ch EECON1
9Dh EECON2EEPROM Control Register 2 (not a physical register)---- ---- 66, 84
9Eh ADRESLLeast Significant 2 bits of the left shifted result or 8 bits of the right shifted resultxxxx xxxx 57, 84
9Fh A NSEL
Legend:— = unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition,
Note 1:IRP and RP1 bits are reserved, always maintain these bits clear.
(3)
shaded = unimplemented
2:OSCCON<OSTS> bit reset to ‘0’ with Dual Speed Start-up and LP, HS or XT selected as the oscillator.
3:GP3 pull-up is enabled when MCLRE is ‘1’ in the Configuration Word register.
DS41211B-page 10Preliminary 2004 Microchip Technology Inc.
PIC12F683
2.2.2.1Status Register
The Status register, shown in Register 2-1, contains:
• Arithmetic status of the ALU
• Reset status
• Bank select bits for data memory (SRAM)
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 register as destination may be different than
intended.
and PD bits are not
For example, CLRF STATUS, w ill c lear the upper three
bits and set the Z bit. Thi s leav es the Status regis ter as
000u u1uu (where u = unchanged).
It is recommended, therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
Stat us register , beca use these instru ctions do not af fect
any Status bits. For other instructions not affecting any
Status bits, see the “Instruction Set Summary”.
Note 1: Bits IRP and RP1 (Status<7:6>) are not
used by the PIC12F683 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
REGISTER 2-1:STATUS – STATUS REGISTER (ADDRESS: 03h OR 83h)
Note 1: A dedicated 16-bit WDT postscaler is available for the PIC12F683. See
Section 12.6 “Watchdog Timer (WDT)” for more information.
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
DS41211B-page 12Preliminary 2004 Microchip Technology Inc.
PIC12F683
2.2.2.3INTCON Register
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 chan ge a nd external
GP2/INT pin interrupts.
Note:Interrupt flag bits are set when an interrupt
condition occurs, regard less of the st ate of
its corresponding enable bit or the global
enable bit, GIE (INTCON<7>). User
software should ensure the appropriate
interrupt flag bits are clear prior to
enabling an interrupt.
REGISTER 2-3:INTCON – INTERRUPT CONTROL REGISTER (ADDRESS: 0Bh OR 8Bh)
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
GIEPEIET0IEINTEGPIET0IFINTFGPIF
bit 7bit 0
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: TMR0 Overflow Interrupt Enable bit
1 = Enables the TMR0 interrupt
0 = Disables the TMR0 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: TMR0 Overflow Interrupt Flag bit
1 = TMR0 regis ter has over flowed (must be cleared in software)
0 = TMR0 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
Note 1: IOC register must also be enabled.
2: T0IF bit is set when Timer0 rolls over. Timer0 is unchanged on Reset and should
be initialized before clearing T0IF bit.
(1)
(2)
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 7EEIF: EEPROM Write Operation Interrupt Flag bit
1 = The write operation completed (must be cleared in software)
0 = The write operation has not completed or has not been started
bit 6ADIF: A/D Interrupt 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 mod
1 = A TMR1 register capture occurred (must be clea red in software)
0 = No TMR1 regi ster capture 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 1 output has changed (must be cleared in software)
0 = Comparator 1 output has not changed
bit 2OSFIF: Oscillator Fail Interrupt Flag bit
1 = System oscilla tor failed, clock inpu t h as ch ang ed to INTOSC (must be cleared in software)
0 = System clock operating
bit 1TMR2IF: Timer 2 to PR2 Match Interrupt Flag bit
1 = Timer 2 to PR2 match occurred (must be cleared in software)
0 = Timer 2 to PR2 match has not occurred
bit 0TMR1IF: Timer 1 Overflow Interrupt Flag bit
1 = Timer 1 register overflowed (must be cleared in software)
0 = Timer 1 has not overflowed
e:
:
Note:Interrupt f lag bit s are set when an in terrupt
condition occurs, regar dless of the st ate of
its corresponding enable bit or the global
enable bit, GIE (INTCON<7>). User
software should ensure the appropriate
interrupt flag bits are clear prior to
enabling an interrupt.
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
1 = No Power-on Reset occurred
0 = A Power-on Reset occurred (must be set in software after a Power-on Reset occurs)
: Brown-out Detect Status bit
1 = No Brown-out Detect occurred
0 = A Brown-out Detect occurred (must be set in software after a Brown-out Detect occurs)
Note 1: BODEN<1:0> = 01 in the Configuration W ord register for this bit to control the BO D.
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
DS41211B-page 16Preliminary 2004 Microchip Technology Inc.
PIC12F683
FIGURE 2-4:DIRECT/INDIRECT ADDRESSING PIC12F683
For memory map detail, see Figure 2-2.
Note 1:The RP1 and IRP bits are reserved; always maintain these bits clear.
DS41211B-page 18Preliminary 2004 Microchip Technology Inc.
PIC12F683
3.0CLOCK SOURCES
3.1Overview
The PIC12F683 has a wide variety of clo ck sources and
selection features to allow it to be used in a wide range
of applications while maximizing performance and minimizing power consumption. Figure 3-1 illustrates a block
diagram of the PIC12F683 clock sources.
Clock sources can be configured from external oscillators, quartz crys ta l reso nat ors, cera mi c reson ato rs and
Resistor-Capacitor (RC) circuits. In addition, the system clock source can be configured from one of two
internal oscillators, with a choice of speeds selectable
via softwar e. Additional clock feat ures include:
• Selectable system clock source between external
or internal via software.
• Two-Speed Clock Start-up mode, which
minimizes latency between external oscillator
start-up and code execu t io n.
• Fail-Safe Clock Monitor (FSCM) designed to
detect a failure of the external clock source (LP,
XT, HS, EC or RC modes) and switch to the
internal oscillator.
The PIC12F683 can b e conf igured in one of ei ght cloc k
modes.
1.EC – External clock with I/O on GP4.
2.LP – Low gain crystal or Ceramic Resonator
Oscillator mode.
3.XT – Medium gain c rysta l or Cera mic Resonat or
Oscillator mode.
4.HS – High gain crystal or Ceramic Resonator
mode.
5.RC – External Resistor-Capacitor (RC) with
OSC/4 output on GP4
F
6.RCIO – External Resistor-Capacitor with I/O on
GP4.
7.INTRC – Internal oscillator with F
OSC/4 output
on GP4 and I/O on GP5.
8.INTRCIO – Internal oscillator with I/O on GP4
and GP5.
Clock source modes are configured by the FOSC<2:0>
bits in the Configuration Word register (see
Section 12.0 “Special Features of the CPU”). The
internal clock can be generated by two oscillators. The
HFINTOSC is a high-frequency calibrated oscillator . The
LFINTOSC is a low-frequency uncalibrated oscillator.
Clock source modes can be classified as external or
internal.
• External clock modes rely on external circuitry
for the clock source. Examples are oscillator
modules (EC mode), quartz cryst al res ona tors or
ceramic resonators (LP, XT and HS modes) and
Resistor-Capacitor (RC mode) circuits.
• Internal clock sources are contained internally
within the PIC12F683. The PIC12F683 has two
internal oscillators: the 8 MHz High-Frequency
Internal Oscillator (HFINTOSC) and 31 kHz
Low-Frequency Internal Oscillator (LFINTOSC).
The system clock can be selected between external or
internal clock sources via the System Clock Selection
(SCS) bit (see Section 3 .5 “Clock Switching”).
3.3External Clock Modes
3.3.1OSCILLATOR START-UP TIMER
(OST)
If the PIC12F683 is co nfigured for LP, XT or HS modes,
the Oscillator Start-up Timer (OST) counts 1024 oscillations from the OSC1 pin, followi ng a Power-on Res et
(POR) and the Power-up T i mer (PWR T ) has ex pired ( if
configured), or a wake -up from Sleep. D urin g this t ime,
the program counter does not increment and program
execution is suspended. The OST ensures that the
oscillator circuit, using a quartz crystal resonator or
ceramic resonator, has s tarted an d is provid ing a st able
system clock to the PIC12F683. 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.
In order to minimize latency between external oscillator
start-up and code execution, the T wo-Speed Clock S tartup mode can be selected (see Section 3.6 “Two-Speed
Note 1: The 5 µs–10 µs start-up delay is based on a 1 MHz system clock.
LFINTOSC
HFINTOSC
31 kHz
125 kHz-8 MHz
5 µs–10µs (approx.) CPU
Start-up
(1)
3.3.2EC MODE
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 pin and the GP5 pin 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 PIC12F683 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.
DS41211B-page 20Preliminary 2004 Microchip Technology Inc.
FIGURE 3-2:EXTERNAL CLOCK (EC)
MODE OPERATION
Clock from
Ext. System
GP4
OSC1/CLKIN
PIC12F683
I/O (OSC2)
PIC12F683
r
r
)
r
3.3.3LP, XT, HS MODES
The LP, XT and HS modes support the use of quartz
crystal resonators or ceramic resonators connected to
the OSC1 and OSC2 pins (Figure 3-1). The mode
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. This mode is
best suited to drive resonator s with a low drive lev el
specification, for example, tuning fork type 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 suit e d t o dr i ve re so na tor s wi th a me dium
drive level specification, for example, AT-cut quartz
crystal resonators.
HS Oscillator mode selects the highest gain setting of
the internal inverter-amplifier. HS mode current consumption is the highest of the thre e mo des . This mode
is best suited for resonators that require a high drive
setting, for example, AT-cut quartz crystal res onators or
ceramic resonators.
Figure 3-3 and Figure 3-4 show typical circuits for
quartz crystal and ceramic resonators, respectively.
FIGURE 3-3:QUARTZ CRYSTAL
OPERATION (LP, XT OR
HS MODE)
PIC12F683
OSC1
C1
Quartz
Crystal
OSC2
(1)
S
C2
Note 1: A series resistor (R S) may be required for
2: The value of R
R
quartz crystals with low drive level.
mode selected (typically between 2 MΩ to
10 MΩ).
(2)
RF
F varies with the oscillator
Note 1: Quartz crystal characteristics vary
according to type, package and manufacturer. The user should consult the manufacturer data sh eets for speci fications and
recommended application.
2: Al ways veri fy os ci lla tor pe rform an ce over
DD and temperature range that is
the V
expected for the application.
To Internal
Logic
Sleep
FIGURE 3-4:CERAMIC RESONATOR
OPERATION
(XT OR HS MODE)
PIC12F683
OSC1
C1
(3)
RP
C2
Ceramic
Resonator
Note 1: A series resistor (RS) may be required fo
ceramic resonators with low drive level.
2: The value of R
mode selected (typically between 2 MΩ to
10 MΩ).
3: An additional parallel feedback resistor (R
may be required for proper ceramic resonato
operation (typical value 1 MΩ).
OSC2
R
S
(1)
(2)
RF
F varies with the oscillato
To Internal
Logic
Sleep
P
3.3.4EXTERNAL RC MODES
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 cost s to a mi nimum w hen clock accuracy is not
required. There are two modes, RC and RCIO.
In RC mode, the RC circuit connects to the OSC1 pin.
The OSC2/CLKOUT pin outputs the RC oscillator frequency divided by 4. Th is signal may be use d to provide
a clock for external circuitry, synchronization, calibration, test or other application requirements. Figure 3-5
shows the RC mode connections.
FIGURE 3-5: RC MODE
VDD
REXT
OSC1
CEXT
VSS
F
Recommended values:3 kΩ ≤ REXT ≤ 100 kΩ
OSC/4
OSC2/CLKOUT
EXT > 20 pF
C
In RCIO mode, the RC circuit is connected to the OSC1
pin. The OSC2 pin becomes an add itiona l general purpose I/O pin. The I/O pin becomes bit 4 of GPIO (GP4).
Figure 3-6 shows the RCIO mode connections.
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 capacitances
3.4Internal Clock Modes
The PIC12F683 has two independent, internal oscillators that can be configured or selected as the system
clock source.
1.The HFINTOSC (High-Frequency Internal Oscillator) is factory calibrated and operates at 8 MHz.
The frequency of the HFINTOSC can be user
adjusted ±12% via software usi ng the OSCTUNE
register (Register 3-1).
2.The LFINTOSC (Low-Frequency Internal
Oscillator) is uncalibrated and operates at
approximately 31 kHz.
The system clock speed can be selected via software
using the Internal Oscillator Frequency Select (IRCF)
bits.
The system clock can be selected between external or
internal clock sources via the System Clock Selection
(SCS) bit (see Section 3 .5 “Clock Switching”).
3.4.1INTRC AND INTRCIO MODES
The INTRC and INTRCIO m odes conf igure the int ernal
oscillators as th e sys tem cl ock so urce when the dev ice
is programmed using the Oscillator Selection (FOSC)
bits in the Configuration Word register (Register 12-1).
In INTRC mode, the OSC1 pin is available for general
purpose I/O. The OSC2/CLKOUT pin outputs the
selected internal os ci lla tor freq uen cy div ide d by 4. The
CLKOUT signal may be used to provide a clock for
external circuitry, synchronization, calibration, test or
other application require me nt s .
In INTRCIO mode, the OSC1 and OSC2 pins are
available for general purpose I/O.
3.4.2HFINTOSC
The High-Frequency Int ernal Oscillato r (HFINT OSC) is
a factory calibrated 8 MHz internal clock source. The
frequency of the HFINTOSC can be altered approximately ± 12% via software using the OSCT UNE register
(Register 3-1).
The output of the HFINTOSC connects to a postscaler
and multiplexer (see Figure 3-1). One of seven frequencies can be selected via software using the IRCF
bits (see Section 3.4.4 “Frequency Select Bits(IRCF)”).
The HFINTOSC is enabled by selecting any frequency
between 8 MHz and 125 kHz (IRCF ≠ 000) as the
system clock s ource (SCS = 1), or when Two-Speed
Start-up is enabled (IESO = 1 and IRCF ≠ 000).
The HF Internal Oscillator (HTS) bit (OSCCON<2>)
indicates whether the HFINTOSC is stable or not.
DS41211B-page 22Preliminary 2004 Microchip Technology Inc.
PIC12F683
3.4.2.1OSCTUNE Register
The HFINTOSC is factory calibrated but can be
adjusted in software by writing to the OSCTUNE
register (Register3-1).
The OSCTUNE register has a tuning range of ±12%.
The default value of the OSCTUNE register is ‘0’. The
value is a 5-bit two’s complement number. Due to process variation, the monotonicity and frequency step
cannot be specified.
When the OSCTUNE register is modified, the
HFINTOSC freque ncy will be gin s hifting to th e new frequency . The HFINT OSC clock will st abilize with in 1 ms.
Code execution contin ues duri ng thi s sh ift. 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.
The Low-Frequency Internal Oscillator (LFINTOSC) is
an uncalibrated (approximate) 31 kHz internal clock
source.
The output of the LFINTOSC connects to a postscaler
and multiplexer (see Figure3-1). 31 kHz can be
selected via software using the IRCF bits (see
Section 3.4.4 “Frequency Select Bits (IRCF)”). 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 = 000) as the system clock so urce (SCS = 1), or
when any of the following are enabled:
• Two-Speed Start-up (IESO = 1 and IRCF = 000)
• Power-up Timer (PWRT)
• Watchdog Timer (WDT)
• Fail-Safe Clock Monitor (FSCM)
The LF Internal Oscillator (LTS) bit (OSCCON<1>)
indicates whether the LFINTOSC is stable or not.
3.4.4FREQUENCY SELECT BITS (IRCF)
The output of the 8 MHz HFINTOSC and 31 kHz
LFINTOSC connects to a postscaler and multiplexer
(see Figure 3-1). The Internal Oscillator Frequency
select bits, IRCF<2:0> (OSCCON<6:4>), select the
frequency output of the internal oscillators. One of eight
frequencies can be selected via software:
•8 MHz
• 4 MHz (Default after Reset)
•2 MHz
•1 MHz
• 500 kHz
• 250 kHz
• 125 kHz
•31 kHz
Note:Follow ing a ny Re set, the IRCF bit s are set
to ‘110’ and the frequency selection is set
to 4 MHz. The user can modify the IRCF
bits to select a different frequency.
3.4.5HF AND LF INTOSC CLOCK
SWITCH TIMING
When switching between the LFINTOSC and the
HFINTOSC, the new oscillator may already be shut
down to save power. If this is the case , there is a 10µs
delay after the IRCF bits are modified before the frequency selection takes place. The LTS/HTS bits will
reflect the current active status of the LFINTOSC and
the HFINTOSC oscillators. The timing of a frequency
selection is as follows:
1.IRCF bits are modified.
2.If the new clock is shut down, a 10 µs clock
start-up delay is started.
3.Clock switch circuitry waits for a falling edge of
the current clock.
4.CLKOUT is held low and the clock switch
circuitry waits fo r a ris ing edge in the new clock.
5.CLKOUT is now connected with the new clock.
HTS/LTS bits are updated as required.
6.Clock switch is complete.
If the internal oscillator speed selected is between
8 M Hz and 125 kHz, there is no start-up delay before
the new frequency is selected. This is because the old
and the new frequencies are derived from the
HFINTOSC via the postscaler and multiplexer.
3.5Clock Switching
The system clock source can be switched between
external and internal clock sources via software using
the System Clock Select (SCS) bit.
3.5.1SYSTEM CLOCK SELECT (SCS) BIT
The System Clock Select (SCS) bit (OSCCON<0>)
selects the system clock source that is used for the
CPU and peripherals.
• When SCS = 0, the system clock source is
determined by configuration of the FOSC<2:0>
bits in the Configuration Word register (CONFIG).
• When SCS = 1, the system clock source is
chosen by the internal oscillator frequency
selected by the IRCF bits. After a Reset, SCS is
always cleared.
Note:Any automatic clock switch, which may
occur from Two-Speed Start-up or FailSafe Clock Monitor, does not update the
SCS bit. The user can monitor the OSTS
(OSCCON<3>) to determine the current
system clock source.
DS41211B-page 24Preliminary 2004 Microchip Technology Inc.
PIC12F683
3.5.2OSCILLAT OR START-UP TIME-OUT
STATUS BIT
The Oscillator Start-up Time-out Status (OSTS) bit
(OSCCON<3>) indicates whether the system clock is
running from the external clock source, as defined by
the FOSC bits, or from internal clock source. In particular, OSTS indicates that the Oscillator Start-up Timer
(OST) has timed out for LP, XT or HS modes.
3.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 us e of the Sleep mode, Two-Speed
Star t-up will remove the extern al 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 f ew inst ructio ns using th e I NTO SC as
the clock source and go back to Sleep without waiting
for the primary oscillator to become stable.
Note:Executing a SLEEP instruction will abort
the oscillator start-up time and will cause
the OSTS bit (OSCCON<3>) to remain
clear.
When the PIC12F683 is configured for LP, XT or HS
modes, the Oscillator Start-up Timer (OST) is enabled
(see Section 3.3.1 “Oscillator Start-up Timer(OST)”). The OST timer will suspend program execution until 1024 oscillations are counted. Two-Speed
Start-up mode minimizes the delay in code execution
by operating from the internal oscillator as the OST is
counting. When the OST count reaches 1024 and the
OSTS bit (OSCCON<3>) is set, program execution
switches to the external oscillator.
3.6.1TWO-SPEED START-UP MODE
CONFIGURATION
Two-Speed Start-up mode is configured by the
following settings:
• IESO = 1 (CONFIG<10>) Internal/External Switch
Over bit.
•SCS = 0.
• FOSC configured for LP, XT or HS mode.
Two-Speed Start-up mode is entered after:
• Power-on Reset (POR) and, if enabled, afte r
PWRT has expired, or
• Wake-up from Sleep.
If the external clock oscillator is configured to be anything other than LP, XT or HS mode, then Two-Speed
Start-up is disabled. This is becaus e t he ex tern al cl oc k
oscillator does not require any stabilization time after
POR or an exit from Sleep.
3.6.2TWO-SPEED START-UP
SEQUENCE
1.Wake-up from Power-on Reset or Sleep.
2.Instructions begin execution by the internal
oscillator at the frequency set in the IRCF bits
(OSCCON<6:4>).
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 fal ling edg e
Checking the state of the OSTS bit (OSCCON<3>) will
confirm if the PIC12F683 is running from the external
clock source as defined by the FOSC bits in the
Configuration Word register (CONFIG) or the internal
oscillator.
FIGURE 3-7:TWO-SPEED START-UP
Q1Q2Q3Q4Q1Q2Q3Q4Q1
INTOSC
T
TOST
OSC1
OSC2
Program Counter
System Clock
011022 1023
PCPC + 1PC + 2
DS41211B-page 26Preliminary 2004 Microchip Technology Inc.
PIC12F683
3.7Fail-Safe Clock Monitor
The Fail-Safe Clock Monitor (FSCM) is designed to
allow the device to continue to operate in the event of
an oscillator failure. The FSCM can detect oscillator
failure at any point after the device has exited a Reset
or Sleep condition and the Oscillator Start-up Timer
(OST) has expired.
FIGURE 3-8:FSCM BLOCK DIAGRAM
Primary
Clock
LFINTOSC
Oscillator
The FSCM function is enabled by setting the FCMEN
bit in the Confi guration Word regist er (CONFIG). It is
applicable to all ex ternal clo ck options (LP, XT , HS, EC,
RC or IO modes).
In the event of an external clock failure, the FSCM will
set the OSFIF bit (PIR1< 2>) and g enerate an os cilla tor
fail interrupt if the OSFIE bit (PIE1<2>) is set. The
device will then switch the system clock to the internal
oscillator. The system clock will continue to come from
the internal oscill ator unless the external clock recovers
and the Fail-Safe condition is exited.
The frequency of the internal oscillator will depend
upon the value contained in the IRCF bits
(OSCCON<6:4>). Upon entering the Fail-Safe
condition, the OSTS bit (OSCCON<3>) is automatically cleared to reflect that the internal oscillator is
÷ 64
Clock
Fail
Detector
Clock
Failure
Detected
active and the WDT is cleared. The SCS bit
(OSCCON<0 >) is not upda ted. Enabling FSCM does
not affect the LTS bit.
The FSCM sample clock is generated by dividing the
INTRC clock by 64. This will allow enough time
between FSCM sample clocks for a system clock edge
to occur. Figure 3-8 shows the FSCM block diagram.
On the rising edge of the sample clock, the monitoring
latch (CM = 0) will be cleared. On a falling edge of the
primary system clock, the monitoring latch will be set
(CM = 1). In the event that a fal lin g e dge o f th e s am pl e
clock occurs and the monitoring latch is not set, a clock
failure has been detected. The assigned internal oscillator is enabled when FSCM is ena bled, as reflec ted by
the IRCF.
Note:Two-Speed Start-up is automatically
enabled when the Fail-Safe Clock Mo nit or
mode is enabled.
Note:Primary cl ocks with a freque ncy ≤
3.7.1FAIL-SAFE CONDITION CLEARING
The Fail-Safe condition is cleared after a Reset, the
execution of a SLEEP instruction, or a modification of
the SCS bit. While in Fail-Safe condition, the
PIC12F683 uses the internal oscillator as the system
clock sourc e. The IRCF bits (OSCCON< 6:4>) can be
modified to adjust the internal oscillator frequency
without exiting the Fail-Safe condition.
The Fail-Safe condition must be cleared before the
OSFIF flag can be cleared.
The FSCM is design ed to detect osc illator failu re at any
point after the device has exited a Reset or Sleep condition and the Oscillator Start-up Timer (OST) has
expired. If the external clock is EC or RC mode,
monitoring will begin immediately following these
events.
For LP, XT or HS mode the external oscillator may
require a start-up time considerably longer than the
FSCM sample cloc k time or a fals e clock fai lure may be
detected (see Figure 3-9). To prevent this, the internal
oscillator is automatically configured as the system
clock and functions until the external clock is stab le (the
OST has timed out). This is identical to Two-Speed
Start-up mode. Once the external oscillator is stable,
the LFINTOSC returns to its role as the FSCM source.
Note:Due to the wide ran ge of osc illator st art-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 u se r sho uld check the
OSTS bit (OSCCON<3>) to verify the
oscillator start-up and system clock
switchover has successfully completed.
REGISTER 3-2:OSCCON – OSCILLATOR CONTROL REGISTER (ADDRESS: 8Fh)
U-0 R/W-1 R/W-1 R/W-0 R-1 R-0 R-0 R/W-0
—IRCF2IRCF1IRCF0OSTS
bit 7bit 0
bit 7Unimplemented: Read as ‘0’
bit 6-4IRCF<2:0>: Internal Oscillator Frequency Select bits