Note the following details of the code protection feature on Microchip devices:
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•Microchip is willing to work with the customer who is concerned about the integrity of their code.
•Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and the like is provided only for your convenience
and may be superseded by updates. It is your responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life support and/or safety applications is entirely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless Microchip from any and all damages, claims,
suits, or expenses resulting from such use. No licenses are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, 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, 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, Octopus, 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.
Microchip received ISO/TS-16949:2002 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
DS41418A-page 2Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
40/44-Pin, Flash Microcontrollers with
nanoWatt XLP and mTouch™ Technology
Devices included in this data sheet:
•PIC16F707
• PIC16LF707
High-Performance RISC CPU:
• Only 35 Single-Word Instructions to Learn:
- All single-cycle instructions except branches
• Operating Speed:
- DC – 20 MHz clock input
- DC – 200 ns instruction cycle
• 8K x 14 Words of Flash Program Memory
• 363 Bytes of Data Memory (SRAM)
• Interrupt Capability
• 8-Level Deep Hardware Stack
• Direct, Indirect and Relative Addressing modes
• Processor Read Access to Program Memory
• Pinout Compatible to other 40-pin PIC16CXXX
and PIC16FXXX Microcontrollers
Special Microcontroller Features:
• Precision Internal Oscillator:
- 16 MHz or 500 kHz operation
- Factory calibrated to ±1%, typical
- Software selectable ÷1, ÷2, ÷4 or ÷8 divider
• 31 kHz Low-Power Internal Oscillator
• External Oscillator Block with:
- 3 crystal/resonator modes up to 20 MHz
- 3 external clock modes up to 20 MHz
• Power-on Reset (POR)
• Power-up Timer (PWRT)
• Oscillator Start-Up Timer (OST)
• Brown-out Reset (BOR):
- Selectable between two trip points
- Disabled in Sleep option
• Watchdog Timer (WDT)
• Programmable Code Protection
• In-Circuit Serial Programming™ (ICSP™) via two
pins
• In-Circuit Debug (ICD) via Two Pins
• Multiplexed Master Clear with Pull-up/Input Pin
• Industrial and Extended Temperature Range
• High-Endurance Flash Cell:
- 1,000 Write Flash Endurance (typical)
- Flash Retention: >40 years
- Power-Saving Sleep mode
• Operating Voltage Range:
- 1.8V to 3.6V (PIC16LF707)
• 1.8V to 5.5V (PIC16F707)
Extreme Low-Power Management
PIC16LF707 with nanoWatt XLP:
20.0 Program Memory Read........................................................................................................................................................... 179
22.0 In-Circuit Serial Programming™ (ICSP™) .............................................................................................................................. 185
23.0 Instruction Set Summary ......................................................................................................................................................... 187
24.0 Development Support.............................................................................................................................................................. 197
26.0 DC and AC Characteristics Graphs and Charts ...................................................................................................................... 231
Appendix A: Data Sheet Revision History ......................................................................................................................................... 273
Appendix B: Migrating From Other PIC® Devices ............................................................................................................................ 273
The Microchip Web Site.................................................................................................................................................................... 281
Customer Change Notification Service ............................................................................................................................................. 281
Customer Support ............................................................................................................................................................................. 281
DS41418A-page 8Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
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.
DS41418A-page 10Preliminary 2010 Microchip Technology Inc.
1.0DEVICE OVERVIEW
The PIC16F707/PIC16LF707 devices are covered by
this data sheet. They are available in 40/44-pin
packages. Figure 1-1 shows a block diagram of the
PIC16F707/PIC16LF707 devices. Table 1-1 shows the
pinout descriptions.
Legend: AN = Analog input or output CMOS = CMOS compatible input or outputOD = Open Drain
TTL = TTL compatible inputST= Schmitt Trigger input with CMOS levels I
HV = High VoltageXTAL = Crystallevels
Note:The PIC16F707 devices have an internal low dropout voltage regulator. An external capacitor must be
connected to one of the available V
Section 5.0 “Low Dropout (LDO) Voltage Regulator”. The PIC16LF707 devices do not have the voltage
regulator and therefore no external capacitor is required.
Output
Typ e
Typ e
CAP pins to stabilize the regulator. For more information, see
Description
2
C™ = Schmitt Trigger input with I2C
DS41418A-page 16Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
PC<12:0>
13
0000h
0004h
Stack Level 1
Stack Level 8
Reset Vector
Interrupt Vector
CALL, RETURN
RETFIE, RETLW
Stack Level 2
0005h
On-chip
1FFFh
Program
Memory
Page 0
Page 1
07FFh
0800h
0FFFh
1000h
Page 2
Page 3
17FFh
1800h
2.0MEMORY ORGANIZATION
2.1Program Memory Organization
The PIC16F707/PIC16LF707 has a 13-bit program
counter capable of addressing an 8K x 14 program
memory space. The Reset vector is at 0000h and the
interrupt vector is at 0004h.
FIGURE 2-1:PROGRAM MEMORY MAP
AND STACK FOR THE
PIC16F707/PIC16LF707
2.2Data Memory Organization
The data memory is partitioned into multiple banks
which contain the General Purpose Registers (GPRs)
and the Special Function Registers (SFRs). Bits RP0
and RP1 are bank select bits.
RP1
Each bank extends up to 7Fh (128 bytes). The lower
locations of each bank are reserved for the Special
Function Registers. Above the Special Function
Registers are the General Purpose Registers,
implemented as static RAM. All implemented banks
contain Special Function Registers. Some frequently
used Special Function Registers from one bank are
mirrored in another bank for code reduction and
quicker access.
2.2.1GENERAL PURPOSE REGISTER
The register file is organized as 363 x 8 bits. Each
register is accessed either directly or indirectly through
the File Select Register (FSR), (Refer to Section 2.5“Indirect Addressing, INDF and FSR Registers”).
RP0
00Bank 0 is selected
01Bank 1 is selected
10Bank 2 is selected
11Bank 3 is selected
FILE
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 (refer to Table 2-2).
These registers are static RAM.
The Special Function 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.
PIC16F707/PIC16LF707
Legend:= Unimplemented data memory locations, read as ‘0’,
*= Not a physical register
File Address
Indirect addr.
(*)
00hIndirect addr.
(*)
80hIndirect addr.
(*)
100hIndirect addr.
(*)
180h
TMR001hOPTION81hTMR0101hOPTION181h
PCL02hPCL82hPCL102hPCL182h
STATUS03hSTATUS83hSTATUS103hSTATUS183h
FSR04hFSR84hFSR104hFSR184h
PORTA05hTRISA85hTACON105h
ANSELA
185h
PORTB06hTRISB86h
CPSBCON0
106h
ANSELB
186h
PORTC07hTRISC87h
CPSBCON1
107hANSELC187h
PORTD08hTRISD88h
CPSACON0
108h
ANSELD
188h
PORTE09hTRISE89h
CPSACON1
109h
ANSELE
189h
PCLATH0AhPCLATH8AhPCLATH10AhPCLATH18Ah
INTCON0BhINTCON8BhINTCON10BhINTCON18Bh
PIR10ChPIE18ChPMDATL10ChPMCON118Ch
PIR20DhPIE28DhPMADRL10Dh
Reserved18Dh
TMR1L0EhPCON8EhPMDATH10Eh
Reserved18Eh
TMR1H0FhT1GCON8FhPMADRH10Fh
Reserved18Fh
T1CON10hOSCCON90hTMRA110h
General
Purpose
Register
16 Bytes
190h
TMR211hOSCTUNE91hTBCON111h191h
T2CON12hPR292hTMRB112h192h
SSPBUF13hSSPADD/SSPMSK 93hDACCON0113h193h
SSPCON14hSSPSTAT94hDACCON1114h194h
CCPR1L15hWPUB95h
General
Purpose
Register
11 Bytes
115h195h
CCPR1H16hIOCB96h116h196h
CCP1CON17hT3CON97h117h197h
RCSTA18hTXSTA98h118h198h
TXREG19hSPBRG99h119h199h
RCREG1AhTMR3L9Ah11Ah19Ah
CCPR2L1BhTMR3H9Bh11Bh19Bh
CCPR2H1ChAPFCON9Ch11Ch19Ch
CCP2CON1DhFVRCON9Dh11Dh19Dh
ADRES
1EhT3GCON9Eh11Eh19Eh
ADCON01FhADCON19Fh11Fh19Fh
General
Purpose
Register
96 Bytes
20h
7Fh
General
Purpose
Register
80 Bytes
A0h
EFh
General
Purpose
Register
80 Bytes
120h
16Fh
General
Purpose
Register
80 Bytes
1A0h
1EFh
Accesses
70h – 7Fh
F0h
FFh
Accesses
70h – 7Fh
170h
17Fh
Accesses
70h – 7Fh
1F0h
1FFh
BANK 0BANK 1BANK 2BANK 3
TABLE 2-1:DATA MEMORY MAP FOR PIC16F707/PIC16LF707
DS41418A-page 18Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
TABLE 2-2:SPECIAL FUNCTION REGISTER SUMMARY
AddressNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Bank 0
(2)
00h
01hTMR0Timer0 Module Register0000 0000 0000 0000
02h
03h
04h
05hPORTAPORTA Data Latch when written: PORTA pins when readxxxx xxxx uuuu uuuu
06hPORTBPORTB Data Latch when written: PORTB pins when readxxxx xxxx uuuu uuuu
07hPORTCPORTC Data Latch when written: PORTC pins when readxxxx xxxx uuuu uuuu
08hPORTDPORTD Data Latch when written: PORTD pins when readxxxx xxxx uuuu uuuu
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ‘0’, r = reserved.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose contents are transferred to the
INDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx xxxx xxxx
(2)
PCLProgram Counter (PC) Least Significant Byte0000 0000 0000 0000
(2)
STATUSIRPRP1RP0TOPDZDCC0001 1xxx 000q quuu
(2)
FSRIndirect Data Memory Address Pointerxxxx xxxx uuuu uuuu
(1),(2)
PCLATH———Write Buffer for the upper 5 bits of the Program Counter---0 0000 ---0 0000
9AhTMR3LHolding Register for the Least Significant Byte of the 16-bit TMR3 Registerxxxx xxxx uuuu uuuu
9BhTMR3HHolding Register for the Most Significant Byte of the 16-bit TMR3 Registerxxxx xxxx uuuu uuuu
9ChAPFCON
9DhFVRCONFVRRDYFVREN
9EhT3GCONTMR3GET3GPOLT3GTMT3GSPMT3GGO/
9FhADCON1
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ‘0’, r = reserved.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose contents are transferred to the
INDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx xxxx xxxx
(2)
PCLProgram Counter (PC) Least Significant Byte0000 0000 0000 0000
(2)
STATUSIRPRP1RP0TOPDZDCC0001 1xxx 000q quuu
(2)
FSRIndirect Data Memory Address Pointerxxxx xxxx uuuu uuuu
(1),(2)
PCLATH———Write Buffer for the upper 5 bits of the Program Counter---0 0000 ---0 0000
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ‘0’, r = reserved.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose contents are transferred to the
INDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx xxxx xxxx
(2)
PCLProgram Counter’s (PC) Least Significant Byte0000 0000 0000 0000
(2)
STATUSIRPRP1RP0TOPDZDCC0001 1xxx 000q quuu
(2)
FSRIndirect Data Memory Address Pointerxxxx xxxx uuuu uuuu
Legend:x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as ‘0’, r = reserved.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the PC<12:8>, whose contents are transferred to the
INDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx xxxx xxxx
(2)
PCLProgram Counter (PC) Least Significant Byte0000 0000 0000 0000
(2)
STATUSIRPRP1RP0TOPDZDCC0001 1xxx 000q quuu
(2)
FSRIndirect Data Memory Address Pointerxxxx xxxx uuuu uuuu
(1),(2)
PCLATH———Write Buffer for the upper 5 bits of the Program Counter---0 0000 ---0 0000
DS41418A-page 22Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
2.2.2.1STATUS Register
The STATUS register, shown in Register 2-1, contains:
• the arithmetic status of the ALU
• the Reset status
• the 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 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 23.0
“Instruction Set Summary”).
Note 1: The C and DC bits operate as Borrow and
Digit Borrow
subtraction.
out bits, respectively, in
REGISTER 2-1:STATUS: STATUS REGISTER
R/W-0R/W-0R/W-0R-1R-1R/W-xR/W-xR/W-x
IRPRP1RP0TOPDZDC
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
(1)
(1)
C
bit 7IRP: Register Bank Select bit (used for indirect addressing)
1 = Bank 2, 3 (100h-1FFh)
0 = Bank 0, 1 (00h-FFh)
bit 6-5RP<1:0>: Register Bank Select bits (used for direct addressing)
00 = Bank 0 (00h-7Fh)
01 = Bank 1 (80h-FFh)
10 = Bank 2 (100h-17Fh)
11 = Bank 3 (180h-1FFh)
bit 4TO
bit 3PD
bit 2Z: Zero bit
bit 1DC: Digit Carry/Digit Borrow
bit 0C: Carry/Borrow
: 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
bit (ADDWF, ADDLW,SUBLW,SUBWF instructions)
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
(1)
(1)
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.
The Program Counter (PC) is 13 bits wide. The low
byte comes from the PCL register, which is a readable
and writable register. The high byte (PC<12:8>) is not
directly readable or writable and comes from
PCLATH. On any Reset, the PC is cleared. Figure 2-2
shows the two situations for the loading of the PC. The
upper example in Figure 2-2 shows how the PC is
loaded on a write to PCL (PCLATH<4:0> PCH).
The lower example in Figure 2-2 shows how the PC is
loaded during a CALL or GOTO instruction
(PCLATH<4:3> PCH).
FIGURE 2-2:LOADING OF PC IN
DIFFERENT SITUATIONS
2.3.1COMPUTED 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).
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.4Program Memory Paging
All devices are capable of addressing a continuous 8K
word block of program memory. The CALL and GOTO
instructions provide only 11 bits of address to allow
branching within any 2K program memory page. When
doing a CALL or GOTO instruction, the upper 2 bits of
the address are provided by PCLATH<4:3>. When
doing a CALL or GOTO instruction, the user must ensure
that the page select bits are programmed so that the
desired program memory page is addressed. If a return
from a CALL instruction (or interrupt) is executed, the
entire 13-bit PC is POPed off the stack. Therefore,
manipulation of the PCLATH<4:3> bits is not required
for the RETURN instructions (which POPs the address
from the stack).
Note:The contents of the PCLATH register are
unchanged after a RETURN or RETFIE
instruction is executed. The user must
rewrite the contents of the PCLATH register for any subsequent subroutine calls or
GOTO instructions.
Example 2-1 shows the calling of a subroutine in
page 1 of the program memory. This example assumes
that PCLATH is saved and restored by the Interrupt
Service Routine
EXAMPLE 2-1:CALL OF A SUBROUTINE
(if interrupts are used).
IN PAGE 1 FROM PAGE 0
2.3.2STACK
All devices have an 8-level x 13-bit wide hardware
stack (refer to Figure 2-1). The stack space is not part
of either program or data space and the Stack Pointer
is not readable or writable. The PC is PUSHed onto the
stack when a CALL instruction is 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. This means that
after the stack has been PUSHed eight times, the ninth
PUSH overwrites the value that was stored from the
first PUSH. The tenth PUSH overwrites the second
PUSH (and so on).
DS41418A-page 26Preliminary 2010 Microchip Technology Inc.
INCFFSR;inc pointer
BTFSSFSR,4 ;all done?
GOTONEXT;no clear next
CONTINUE;yes continue
Note:For memory map detail, refer to Table 2-2.
Data
Memory
Indirect AddressingDirect Addressing
Bank SelectLocation Select
RP1RP06
0
From Opcode
IRPFile Select Register
7
0
Bank Select
Location Select
00011011
180h
1FFh
00h
7Fh
Bank 0Bank 1Bank 2Bank 3
2.5Indirect Addressing, INDF and
FSR Registers
The INDF register is not a physical register. Addressing
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 register and the IRP bit of
the STATUS register, as shown in Figure 2-3.
A simple program to clear RAM location 020h-02Fh
using indirect addressing is shown in Example 2-2.
DS41418A-page 28Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
MCLR/VPP
VDD
OSC1/
WDT
Module
POR
OST/PWRT
WDTOSC
WDT
Time-out
Power-on Reset
OST
10-bit Ripple Counter
PWRT
Chip_Reset
11-bit Ripple Counter
Reset
Enable OST
Enable PWRT
Sleep
Brown-out
(1)
Reset
BOREN
CLKIN
Note 1: Refer to the Configuration Word Register 1 (Register 8-1).
MCLRE
3.0RESETS
Most registers are not affected by a WDT wake-up
since this is viewed as the resumption of normal
The PIC16F707/PIC16LF707 differentiates between
various kinds of Reset:
a)Power-on Reset (POR)
b)WDT Reset during normal operation
c)WDT Reset during Sleep
d)MCLR
e)MCLR
Reset during normal operation
Reset during Sleep
f)Brown-out Reset (BOR)
operation. TO
and PD bits are set or cleared differently
in different Reset situations, as indicated in Table 3-3.
These bits are used in software to determine the nature
of the Reset.
A simplified block diagram of the On-Chip Reset Circuit
is shown in Figure 3-1.
The MCLR
Reset path has a noise filter to detect and
ignore small pulses. See Section 25.0 “ElectricalSpecifications” for pulse width specifications.
Some registers are not affected in any Reset condition;
their status is unknown on POR and unchanged in any
other Reset. Most other registers are reset to a “Reset
state” on:
• Power-on Reset (POR)
•MCLR
•MCLR
Reset
Reset during Sleep
•WDT Reset
• Brown-out Reset (BOR)
FIGURE 3-1:SIMPLIFIED BLOCK DIAGRAM OF ON-CHIP RESET CIRCUIT
Reset during Sleep or interrupt wake-up from Sleep
(1)
(2)
STATUS
Register
uuu1 0uuu---- --uu
PCON
Register
TABLE 3-2:RESET CONDITION FOR SPECIAL REGISTERS
Condition
Power-on Reset0000h0001 1xxx---- --0x
MCLR Reset during normal operation0000h000u uuuu---- --uu
Reset during Sleep0000h0001 0uuu---- --uu
MCLR
WDT Reset0000h0000 1uuu---- --uu
WDT Wake-upPC + 1uuu0 0uuu---- --uu
Brown-out Reset0000h0001 1uuu---- --u0
Interrupt Wake-up from SleepPC + 1
Legend: u = unchanged, x = unknown, - = unimplemented bit, reads as ‘0’.
Note 1: When the wake-up is due to an interrupt and global 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
DS41418A-page 30Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
VDD
PIC® MCU
MCLR
R1
10 k
C1
0.1 F
3.1MCLR
The PIC16F707/PIC16LF707 has a noise filter in the
Reset path. The filter will detect and ignore
MCLR
small pulses.
It should be noted that a Reset does not drive the
pin low.
MCLR
Voltages applied to the pin that exceed its specification
can result in both MCLR
beyond the device specification during the ESD event.
For this reason, Microchip recommends that the MCLR
pin no longer be tied directly to VDD. The use of an RC
network, as shown in Figure 3-2, is suggested.
An internal MCLR
MCLRE bit in the Configuration Word register. When
MCLRE = 0, the Reset signal to the chip is generated
internally. When the MCLRE = 1, the RE3/MCLR
becomes an external Reset input. In this mode, the
RE3/MCLR pin has a weak pull-up to VDD. In-Circuit
Serial Programming is not affected by selecting the
internal MCLR option.
FIGURE 3-2:RECOMMENDED MCLR
Resets and excessive current
option is enabled by clearing the
pin
CIRCUIT
3.3Power-up Timer (PWRT)
The Power-up Timer provides a fixed 64 ms (nominal)
time-out on power-up only, from POR or Brown-out
Reset. The Power-up Timer operates from the WDT
oscillator. For more information, see Section 7.3“Internal Clock Modes”. The chip is kept in Reset as
long as PWRT is active. The PWRT delay allows the
DD to rise to an acceptable level. A Configuration bit,
V
PWRTE
grammed) the Power-up Timer. The Power-up Timer
should be enabled when Brown-out Reset is enabled,
although it is not required.
The Power-up Timer delay will vary from chip-to-chip
and vary due to:
•V
• Temperature variation
• Process variation
See DC parameters for details (Section 25.0“Electrical Specifications”).
, can disable (if set) or enable (if cleared or pro-
DD variation
Note:The Power-up Timer is enabled by the
PWRTE
bit in the Configuration Word 1.
3.4Watchdog Timer (WDT)
3.2Power-on Reset (POR)
The on-chip POR circuit holds the chip in Reset until VDD
has reached a high enough level for proper operation. A
maximum rise time for V
Section 25.0 “Electrical Specifications” for details. If
the BOR is enabled, the maximum rise time specification
does not apply. The BOR circuitry will keep the device in
Reset until V
“Brown-Out Reset (BOR)”).
When the device starts normal operation (exits the
Reset condition), device operating parameters (i.e.,
voltage, frequency, temperature, etc.) must be met to
ensure operation. If these conditions are not met, the
device must be held in Reset until the operating
conditions are met.
For additional information, refer to Application Note
AN607, “Power-up Trouble Shooting” (DS00607).
DD reaches VBOR (see Section 3.5
DD is required. See
The WDT has the following features:
• Shares an 8-bit prescaler with Timer0
• Time-out period is from 17 ms to 2.2 seconds,
nominal
• Enabled by a Configuration bit
WDT is cleared under certain conditions described in
Table 3-3.
3.4.1WDT OSCILLATOR
The WDT derives its time base from 31 kHz internal
oscillator.
Note:When the Oscillator Start-up Timer (OST)
is invoked, the WDT is held in Reset,
because the WDT Ripple Counter is used
by the OST to perform the oscillator delay
count. When the OST count has expired,
the WDT will begin counting (if enabled).
The WDTE bit is located in the Configuration Word
Register 1. When set, the WDT runs continuously.
The PSA and PS<2:0> bits of the OPTION register
control the WDT period. See Section 12.0 “Timer0
Module” for more information.
FIGURE 3-3:WATCHDOG TIMER BLOCK DIAGRAM
TABLE 3-3:WDT STATUS
ConditionsWDT
WDTE = 0Cleared
CLRWDT Command
Exit Sleep + System Clock = EXTRC, INTOSC, EXTCLK
Exit Sleep + System Clock = XT, HS, LPCleared until the end of OST
DS41418A-page 32Preliminary 2010 Microchip Technology Inc.
3.5Brown-Out Reset (BOR)
64 ms
(1)
VBOR
V
DD
Internal
Reset
VBOR
V
DD
Internal
Reset
64 ms
(1)
< 64 ms
64 ms
(1)
VBOR
V
DD
Internal
Reset
Note 1: 64 ms delay only if PWRTE bit is programmed to ‘0’.
Brown-out Reset is enabled by programming the
BOREN<1:0> bits in the Configuration register. The
brown-out trip point is selectable from two trip points
via the BORV bit in the Configuration register.
Between the POR and BOR, complete voltage range
coverage for execution protection can be implemented.
Two bits are used to enable the BOR. When
BOREN = 11, the BOR is always enabled. When
BOREN = 10, the BOR is enabled, but disabled during
Sleep. When BOREN = 0X, the BOR is disabled.
FIGURE 3-4: BROWN-OUT SITUATIONS
PIC16F707/PIC16LF707
DD falls below VBOR for greater than parameter
If V
BOR) (see Section 25.0 “Electrical Specifica-
(T
tions”), the brown-out situation will reset the device.
This will occur regardless of VDD slew rate. A Reset is
not ensured to occur if V
than parameter (T
DD drops below VBOR while the Power-up Timer is
If V
running, the chip will go back into a Brown-out Reset
and the Power-up Timer will be re-initialized. Once V
rises above VBOR, the Power-up Timer will execute a
64 ms Reset.
Note:When erasing Flash program memory, the
BOR is forced to enabled at the minimum
BOR setting to ensure that any code
protection circuitry is operating properly.
On power-up, the time-out sequence is as follows: first,
PWRT time-out is invoked after POR has expired, then
OST is activated after the PWRT time-out has expired.
The total time-out will vary based on oscillator configuration and PWRTE
with PWRTE
time-out at all. Figure 3-5, Figure 3-6 and Figure 3-7
depict time-out sequences.
Since the time-outs occur from the POR pulse, if MCLR
is kept low long enough, the time-outs will expire. Then,
bringing MCLR
(see Figure 3-6). This is useful for testing purposes or
to synchronize more than one PIC16F707/
PIC16LF707 device operating in parallel.
Table 3-2 shows the Reset conditions for some special
registers.
bit status. For example, in EC mode
bit = 1 (PWRT disabled), there will be no
high will begin execution immediately
3.7Power Control (PCON) Register
The Power Control (PCON) register has two Status bits
to indicate what type of Reset that last occurred.
Bit 0 is BOR
Power-on Reset. It must then be set by the user and
checked on subsequent Resets to see if BOR = 0,
indicating that a brown-out has occurred. The BOR
Status bit is a “don’t care” and is not necessarily
predictable if the brown-out circuit is disabled
(BOREN<1:0> = 00 in the Configuration Word register).
Bit 1 is POR
Reset and unaffected otherwise. The user must write a
‘1’ to this bit following a Power-on Reset. On a
subsequent Reset, if POR
Power-on Reset has occurred (i.e., V
gone too low).
For more information, see Section 3.5 “Brown-OutReset (BOR)”.
(Brown-out Reset). BOR is unknown on
(Power-on Reset). It is a ‘0’ on Power-on
is ‘0’, it will indicate that a
DD may have
TABLE 3-4:TIME-OUT IN VARIOUS SITUATIONS
Oscillator Configuration
XT, HS, LP
RC, EC, INTOSCTPWRT—TPWRT——
PWRTE = 0PWRTE = 1PWRTE = 0PWRTE = 1
T
PWRT + 1024 •
Power-upBrown-out Reset
1024 • TOSCTPWRT + 1024 •
T
OSC
T
OSC
1024 • TOSC1024 • TOSC
Wake-up from
Sleep
FIGURE 3-5:TIME-OUT SEQUENCE ON POWER-UP (DELAYED MCLR): CASE 1
DS41418A-page 34Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
VDD
MCLR
Internal POR
PWRT Time-out
OST Time-out
Internal Reset
T
PWRT
TOST
TPWRT
TOST
VDD
MCLR
Internal POR
PWRT Time-out
OST Time-out
Internal Reset
FIGURE 3-6:TIME-OUT SEQUENCE ON POWER-UP (DELAYED MCLR): CASE 2
DD goes too low, Power-on Reset will be activated and registers will be affected differently.
- = unimplemented bit, reads as ‘0’, q = value depends on condition.
2:One or more bits in INTCON and/or PIR1 and PIR2 will be affected (to cause wake-up).
3:When the wake-up is due to an interrupt and the GIE bit is set, the PC is loaded with the interrupt
vector (0004h).
4:See Table 3-2 for Reset value for specific condition.
5:If Reset was due to brown-out, then bit 0 = 0. All other Resets will cause bit 0 = u.
Wake-up from Sleep through
Interrupt/Time-out
(3)
uuuq quuu
(4)
(2)
(2)
(2)
DS41418A-page 36Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
TABLE 3-5:INITIALIZATION CONDITION FOR REGISTERS (CONTINUED)
RegisterAddress
ADCON01Fh--00 0000--00 0000--uu uuuu
OPTION_REG81h/181h1111 11111111 1111uuuu uuuu
TRISA85h1111 11111111 1111uuuu uuuu
TRISB86h1111 11111111 1111uuuu uuuu
TRISC87h1111 11111111 1111uuuu uuuu
TRISD88h1111 11111111 1111uuuu uuuu
TRISE89h---- 1111---- 1111---- uuuu
PIE18Ch0000 00000000 0000uuuu uuuu
PIE28Dh0000 ---00000 ---0uuuu ---u
PCON8Eh---- --qq---- --uu
T1GCON8Fh0000 0x00uuuu uxuuuuuu uxuu
OSCCON90h--10 qq----10 qq----uu qq--
OSCTUNE91h--00 0000--uu uuuu--uu uuuu
PR292h1111 11111111 1111uuuu uuuu
SSPADD93h0000 00000000 0000uuuu uuuu
SSPMSK93h1111 11111111 1111uuuu uuuu
SSPSTAT94h0000 00000000 0000uuuu uuuu
WPUB95h1111 11111111 1111uuuu uuuu
IOCB96h0000 00000000 0000uuuu uuuu
T3CON97h0000 -0-00000 -0-0uuuu -u-u
TXSTA98h0000 -0100000 -010uuuu -uuu
SPBRG99h0000 00000000 0000uuuu uuuu
TMR3L9Ahxxxx xxxxuuuu uuuuuuuu uuuu
TMR3H9Bhxxxx xxxxuuuu uuuuuuuu uuuu
APFCON9Ch---- --00---- --00---- --uu
FVRCON9Dhq000 0000q000 0000q000 0000
ADCON19Fh-000 --00-000 --00-uuu --uu
TACO N10 5h0-00 00000-00 0000u-uu uuuu
CPSBCON0106h00-- 000000-- 0000uu-- uuuu
CPSBCON1107h---- 0000---- 0000---- uuuu
CPSACON0108h00-- 000000-- 0000uu-- uuuu
CPSACON1109h---- 0000---- 0000---- uuuu
PMDATL10Chxxxx xxxxxxxx xxxxuuuu uuuu
PMADRL10Dhxxxx xxxxxxxx xxxxuuuu uuuu
PMDATH10Eh--xx xxxx--xx xxxx--uu uuuu
PMADRH10Fh---x xxxx---x xxxx---u uuuu
TMRA110h0000 00000000 0000uuuu uuuu
Legend: u = unchanged, x = unknown,
Note 1:If V
2:One or more bits in INTCON and/or PIR1 and PIR2 will be affected (to cause wake-up).
3:When the wake-up is due to an interrupt and the GIE bit is set, the PC is loaded with the interrupt
4:See Table 3-2 for Reset value for specific condition.
5:If Reset was due to brown-out, then bit 0 = 0. All other Resets will cause bit 0 = u.
DD goes too low, Power-on Reset will be activated and registers will be affected differently.
vector (0004h).
Power-on Reset/
Brown-out Reset
- = unimplemented bit, reads as ‘0’, q = value depends on condition.
TABLE 3-5:INITIALIZATION CONDITION FOR REGISTERS (CONTINUED)
RegisterAddress
TBC ON111 h0-00 00000-00 0000u-uu uuuu
TMRB112h0000 00000000 0000uuuu uuuu
DACCON0113h000- 00--000- 00--uuu- uu--
DACCON1114h---0 0000---0 0000---u uuuu
ANSELA185h1111 11111111 1111uuuu uuuu
ANSELB186h1111 11111111 1111uuuu uuuu
ANSELC187h1111 11111111 1111uuuu uuuu
ANSELD188h1111 11111111 1111uuuu uuuu
ANSELE189h---- -111---- -111---- -uuu
PMCON118Ch1--- ---01--- ---0u--- ---u
Legend: u = unchanged, x = unknown,
Note 1:If V
2:One or more bits in INTCON and/or PIR1 and PIR2 will be affected (to cause wake-up).
3:When the wake-up is due to an interrupt and the GIE bit is set, the PC is loaded with the interrupt
4:See Table 3-2 for Reset value for specific condition.
5:If Reset was due to brown-out, then bit 0 = 0. All other Resets will cause bit 0 = u.
DD goes too low, Power-on Reset will be activated and registers will be affected differently.
vector (0004h).
Power-on Reset/
Brown-out Reset
- = unimplemented bit, reads as ‘0’, q = value depends on condition.
(1)
MCLR Reset/
WDT Reset
Wake-up from Sleep through
Interrupt/Time-out
TABLE 3-6:SUMMARY OF REGISTERS ASSOCIATED WITH RESETS
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
STATUSIRPRP1RP0TOPDZDCC0001 1xxx000q quuu
PCON
Legend:u = unchanged, x = unknown, - = unimplemented bit, reads as ‘0’, q = value depends on condition. Shaded cells are
Note 1:Other (non Power-up) Resets include MCLR
——————PORBOR---- --qq---- --uu
not used by Resets.
Reset and Watchdog Timer Reset during normal operation.
Value on
POR, BOR
Value on
all other
(1)
Resets
DS41418A-page 38Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
TMR0IF
TMR0IE
INTF
INTE
RBIF
RBIE
GIE
PEIE
Wake-up (If in Sleep mode)
(1)
Interrupt to CPU
TMR1GIE
TMR1GIF
ADIF
ADIE
IOC-RB0
IOCB0
IOC-RB1
IOCB1
IOC-RB2
IOCB2
IOC-RB3
IOCB3
CCP1IF
CCP1IE
IOC-RB4
IOCB4
IOC-RB5
IOCB5
IOC-RB6
IOCB6
IOC-RB7
IOCB7
RCIF
RCIE
TMR2IE
TMR2IF
SSPIE
SSPIF
TXIE
TXIF
TMR1IE
TMR1IF
Note 1:Some peripherals depend upon the
system clock for operation. Since the
system clock is suspended during
Sleep, these peripherals will not wake
the part from Sleep. See Section 21.1 “Wake-up from Sleep”.
CCP2IF
CCP2IE
TMRAIF
TMRAIE
TMR3IF
TMR3IE
TMR3GIF
TMR3GIE
TMRBIF
TMRBIE
4.0INTERRUPTS
The PIC16F707/PIC16LF707 device family features an
interruptible core, allowing certain events to preempt
normal program flow. An Interrupt Service Routine
(ISR) is used to determine the source of the interrupt
and act accordingly. Some interrupts can be configured
to wake the MCU from Sleep mode.
The PIC16F707 family has 16 interrupt sources,
differentiated by corresponding interrupt enable and
flag bits:
• Timer0 Overflow Interrupt
• External Edge Detect on INT Pin Interrupt
• PORTB Change Interrupt
• Timer1 Gate Interrupt
• A/D Conversion Complete Interrupt
FIGURE 4-1:INTERRUPT LOGIC
• AUSART Receive Interrupt
• AUSART Transmit Interrupt
• SSP Event Interrupt
• CCP1 Event Interrupt
• Timer2 Match with PR2 Interrupt
• Timer1 Overflow Interrupt
• CCP2 Event Interrupt
• TimerA Overflow Interrupt
• TimerB Overflow Interrupt
• Timer3 Overflow Interrupt
• Timer3 Gate Interrupt
A block diagram of the interrupt logic is shown in
Figure 4-1.
Latency is the same whether Inst (PC) is a single cycle or a 2-cycle instruction.
3: CLKOUT is available only in INTOSC and RC Oscillator modes.
4: For minimum width of INT pulse, refer to AC specifications in Section 25.0 “Electrical Specifications”.
5: INTF is enabled to be set any time during the Q4-Q1 cycles.
(1)
(2)
(3)
(4)
(5)
(1)
4.1Operation
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
• PC is loaded with the interrupt vector 0004h
The ISR determines 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 and setting the GIE bit.
For additional information on a specific interrupt’s
operation, refer to its peripheral chapter.
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.
4.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 3 instruction cycles. For asynchronous
interrupts, the latency is 3 to 4 instruction cycles,
depending on when the interrupt occurs. See Figure 4-2
for timing details.
FIGURE 4-2:INT PIN INTERRUPT TIMING
DS41418A-page 40Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
MOVWFW_TEMP;Copy W to W_TEMP register
SWAPFSTATUS,W;Swap status to be saved into W
;Swaps are used because they do not affect the status bits
BANKSEL STATUS_TEMP;Select regardless of current bank
MOVWFSTATUS_TEMP;Copy status to bank zero STATUS_TEMP register
MOVF PCLATH,W;Copy PCLATH to W register
MOVWF PCLATH_TEMP ;Copy W register to PCLATH_TEMP
:
:(ISR);Insert user code here
:
BANKSEL STATUS_TEMP;Select regardless of current bank
MOVF PCLATH_TEMP,W;
MOVWF PCLATH;Restore PCLATH
SWAPFSTATUS_TEMP,W;Swap STATUS_TEMP register into W
;(sets bank to original state)
MOVWFSTATUS;Move W into STATUS register
SWAPFW_TEMP,F;Swap W_TEMP
SWAPFW_TEMP,W;Swap W_TEMP into W
4.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 21.0 “Power-
Down Mode (Sleep)” for more details.
4.4INT Pin
The external interrupt, INT pin, causes an
asynchronous, edge-triggered interrupt. The INTEDG bit
of the OPTION 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. This interrupt is
disabled by clearing the INTE bit of the INTCON register.
4.5Context Saving
When an interrupt occurs, only the return PC value is
saved to the stack. If the ISR modifies or uses an
instruction that modifies key registers, their values
must be saved at the beginning of the ISR and restored
when the ISR completes. This prevents instructions
following the ISR from using invalid data. Examples of
key registers include the W, STATUS, FSR and
PCLATH registers.
Note:The microcontroller does not normally
require saving the PCLATH register.
However, if computed GOTO’s are used,
the PCLATH register must be saved at the
beginning of the ISR and restored when
the ISR is complete to ensure correct
program flow.
The code shown in Example 4-1 can be used to do the
following.
• Save the W register
• Save the STATUS register
• Save the PCLATH register
• Execute the ISR program
• Restore the PCLATH register
• Restore the STATUS register
• Restore the W register
Since most instructions modify the W register, it must
be saved immediately upon entering the ISR. The
SWAPF instruction is used when saving and restoring
the W and STATUS registers because it will not affect
any bits in the STATUS register. It is useful to place
W_TEMP in shared memory because the ISR cannot
predict which bank will be selected when the interrupt
occurs.
The processor will branch to the interrupt vector by
loading the PC with 0004h. The PCLATH register will
remain unchanged. This requires the ISR to ensure
that the PCLATH register is set properly before using
an instruction that causes PCLATH to be loaded into
the PC. See Section 2.3 “PCL and PCLATH” for
details on PC operation.
EXAMPLE 4-1: SAVING W, STATUS AND PCLATH REGISTERS IN RAM
The INTCON register is a readable and writable
register, which contains the various enable and flag bits
for TMR0 register overflow, PORTB change and
external RB0/INT/SEG0 pin interrupts.
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.
REGISTER 4-1:INTCON: INTERRUPT CONTROL REGISTER
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-x
GIEPEIETMR0IEINTERBIE
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 5TMR0IE: Timer0 Overflow Interrupt Enable bit
1 = Enables the Timer0 interrupt
0 = Disables the Timer0 interrupt
bit 4INTE: RB0/INT External Interrupt Enable bit
1 = Enables the RB0/INT external interrupt
0 = Disables the RB0/INT external interrupt
bit 3RBIE: PORTB Change Interrupt Enable bit
1 = Enables the PORTB change interrupt
0 = Disables the PORTB change interrupt
bit 2TMR0IF: Timer0 Overflow Interrupt Flag bit
1 = TMR0 register has overflowed (must be cleared in software)
0 = TMR0 register did not overflow
bit 1INTF: RB0/INT External Interrupt Flag bit
1 = The RB0/INT external interrupt occurred (must be cleared in software)
0 = The RB0/INT external interrupt did not occur
bit 0RBIF: PORTB Change Interrupt Flag bit
1 = When at least one of the PORTB general purpose I/O pins changed state (must be cleared in
software)
0 = None of the PORTB general purpose I/O pins have changed state
(1)
(2)
(1)
TMR0IF
(2)
INTFRBIF
Note 1:The appropriate bits in the IOCB register must also be set.
2:TMR0IF bit is set when Timer0 rolls over. Timer0 is unchanged on Reset and should be initialized before
clearing TMR0IF bit.
DS41418A-page 42Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
4.5.2PIE1 REGISTER
The PIE1 register contains the interrupt enable bits, as
shown in Register 4-2.
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 7TMR1GIF: Timer1 Gate Interrupt Flag bit
1 = Timer1 gate is inactive
0 = Timer1 gate is active
bit 6ADIF: A/D Converter Interrupt Flag bit
1 = A/D conversion complete (must be cleared in software)
0 = A/D conversion has not completed or has not been started
bit 5RCIF: USART Receive Interrupt Flag bit
1 = The USART receive buffer is full (cleared by reading RCREG)
0 = The USART receive buffer is not full
bit 4TXIF: USART Transmit Interrupt Flag bit
1 = The USART transmit buffer is empty (cleared by writing to TXREG)
0 = The USART transmit buffer is full
bit 3SSPIF: Synchronous Serial Port (SSP) Interrupt Flag bit
1 = The Transmission/Reception is complete (must be cleared in software)
0 = Waiting to Transmit/Receive
bit 2CCP1IF: CCP1 Interrupt Flag bit
Capture mode
1 = A Timer1 register capture occurred (must be cleared in software)
0 = No Timer1 register capture occurred
Compare mode
1 = A Timer1 register compare match occurred (must be cleared in software)
0 = No Timer1 register compare match occurred
PWM mode:
Unused in this mode
bit 1TMR2IF: Timer2 to PR2 Interrupt Flag bit
1 = A Timer2 to PR2 match occurred (must be cleared in software)
0 = No Timer2 to PR2 match occurred
bit 0TMR1IF: Timer1 Overflow Interrupt Flag bit
1 = The Timer1 register overflowed (must be cleared in software)
0 = The Timer1 register did not overflow
:
:
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.
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 7TMR3GIF: Timer3 Gate Interrupt Flag bit
1 = Timer3 gate is inactive
0 = Timer3 gate is active
bit 6TMR3IF: Timer3 Overflow Interrupt Flag bit
1 = Timer3 register overflowed (must be cleared in software)
0 = Timer3 register did not overflow
bit 5TMRBIF: TimerB Overflow Interrupt Flag bit
1 = TimerB register has overflowed (must be cleared in software)
0 = TimerB register did not overflow
bit 4TMRAIF: TimerA Overflow Interrupt Flag bit
1 = TimerA register has overflowed (must be cleared in software)
0 = TimerA register did not overflow
bit 3-1Unimplemented: Read as ‘0’
bit 0CCP2IF: CCP2 Interrupt Flag bit
Capture Mode
1 = A Timer1 register capture occurred (must be cleared in software)
0 = No Timer1 register capture occurred
Compare Mode
1 = A Timer1 register compare match occurred (must be cleared in software)
0 = No Timer1 register compare match occurred
PWM Mode
Unused in this mode
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.
DS41418A-page 46Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
TABLE 4-1:SUMMARY OF REGISTERS ASSOCIATED WITH INTERRUPTS
DS41418A-page 48Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
5.0LOW DROPOUT (LDO)
VOLTAGE REGULATOR
The PIC16F707 has an internal Low Dropout Regulator
(LDO) which provides operation above 3.6V. The LDO
regulates a voltage for the internal device logic while
permitting the V
voltage. There is no user enable/disable control
available for the LDO, it is always active. The
PIC16LF707 operates at a maximum V
does not incorporate an LDO.
A device I/O pin may be configured as the LDO voltage
output, identified as the V
required, an external low-ESR capacitor may be
connected to the VCAP pin for additional regulator
stability.
The VCAPEN<1:0> bits of Configuration Word 2
determines which pin is assigned as the V
Refer to Table 5-1.
TABLE 5-1:VCAPEN<1:0> SELECT BITS
VCAPEN<1:0>Pin
DD and I/O pins to operate at a higher
DD of 3.6V and
CAP pin. Although not
CAP pin.
00RA0
01RA5
10RA6
11No VCAP
On power-up, the external capacitor will load the LDO
voltage regulator. To prevent erroneous operation, the
device is held in Reset while a constant current source
charges the external capacitor. After the cap is fully
charged, the device is released from Reset. For more
information on recommended capacitor values and the
constant current rate, refer to the LDO Regulator
Characteristics Table in Section 25.0 “Electrical
DS41418A-page 50Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
QD
CK
Data Register
I/O pin
Read PORTx
Write PORT x
TRISx
Data Bus
To peripherals
ANSELx
VDD
VSS
6.0I/O PORTS
There are thirty-five general purpose I/O pins available.
Depending on which peripherals are enabled, some or
all of the pins may not be available as general purpose
I/O. In general, when a peripheral is enabled, the
associated pin may not be used as a general purpose
I/O pin.
Each port has two registers for its operation. These
registers are:
• TRISx registers (data direction register)
• PORTx registers (port read/write register)
Ports with analog functions also have an ANSELx
register which can disable the digital input and save
power. A simplified model of a generic I/O port, without
the interfaces to other peripherals, is shown in
Figure 6-1.
FIGURE 6-1:GENERIC I/O PORT
OPERATION
6.1Alternate Pin Function
The Alternate Pin Function Control (APFCON) register
is used to steer specific peripheral input and output
functions between different pins. The APFCON register
is shown in Register 6-1. For this device family, the
following functions can be moved between different
pins.
(Slave Select)
•SS
• CCP2
REGISTER 6-1:APFCON: ALTERNATE PIN FUNCTION CONTROL REGISTER
U-0U-0U-0U-0U-0U-0R/W-0R/W-0
——————SSSELCCP2SEL
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-2Unimplemented: Read as ‘0’.
bit 1SSSEL: SS
0 =SS function is on RA5/AN4/CPS7/SS/VCAP
1 =SS function is on RA0/AN0/SS/VCAP
bit 0CCP2SEL: CCP2 Input/Output Pin Selection bit
0 = CCP2 function is on RC1/T1OSI/CCP2
1 = CCP2 function is on RB3/CCP2
BANKSEL PORTA;
CLRFPORTA;Init PORTA
BANKSEL ANSELA;
CLRF ANSELA;digital I/O
BANKSEL TRISA;
MOVLW0Ch;Set RA<3:2> as inputs
MOVWFTRISA;and set RA<7:4,1:0>
;as outputs
6.2PORTA and TRISA Registers
PORTA is a 8-bit wide, bidirectional port. The
corresponding data direction register is TRISA
(Register 6-3). Setting a TRISA bit (= 1) will make the
corresponding PORTA pin an input (i.e., disable the
output driver). Clearing a TRISA bit (= 0) will make the
corresponding PORTA pin an output (i.e., enables
output driver and puts the contents of the output latch
on the selected pin). Example 6-1 shows how to
initialize PORTA.
Reading the PORTA register (Register 6-2) reads the
The TRISA register (Register 6-3) controls the PORTA
pin output drivers, even when they are being used as
analog inputs. The user should ensure the bits in the
TRISA register are maintained set when using them as
analog inputs. I/O pins configured as analog input
always read ‘0’.
Note:The ANSELA register must be initialized to
configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’.
EXAMPLE 6-1:INITIALIZING PORTA
status of the pins, whereas writing to it will write to the
PORT latch. All write operations are read-modify-write
operations. Therefore, a write to a port implies that the
port pins are read, this value is modified and then
written to the PORT data latch.
REGISTER 6-2:PORTA: PORTA REGISTER
R/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-x
RA7RA6RA5RA4RA3RA2RA1RA0
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-0RA<7:0>: PORTA I/O Pin bits
1 = Port pin is > V
0 = Port pin is < VIL
IH
REGISTER 6-3:TRISA: PORTA TRI-STATE REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
TRISA7TRISA6TRISA5TRISA4TRISA3TRISA2TRISA1TRISA0
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-0TRISA<7:0>: PORTA Tri-State Control bits
1 = PORTA pin configured as an input (tri-stated)
0 = PORTA pin configured as an output
DS41418A-page 52Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
6.2.1ANSELA REGISTER
The ANSELA register (Register 6-4) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELA bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELA bits has no affect on digital
output functions. A pin with TRIS clear and ANSEL set
will still operate as a digital output, but the Input mode
will be analog. This can cause unexpected behavior
when executing read-modify-write instructions on the
affected port.
REGISTER 6-4:ANSELA: PORTA ANALOG SELECT REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
ANSA7ANSA6ANSA5ANSA4ANSA3ANSA2ANSA1ANSA0
bit 7bit 0
Legend:
R = Readable bitW = Writable bit‘0’ = Bit is cleared
-n = Value at POR‘1’ = Bit is setx = Bit is unknown
bit 7-0ANSA<7:0>: Analog Select between Analog or Digital Function on pins RA<7:0>, respectively
0 = Digital I/O. Pin is assigned to port or digital special function.
1 = Analog input. Pin is assigned as analog input
Note 1:When setting a pin to an analog input, the corresponding TRIS bit must be set to Input mode in order to
allow external control of the voltage on the pin.
6.2.2PIN DESCRIPTIONS
Each PORTA pin is multiplexed with other functions. The
pins and their combined functions are briefly described
here. For specific information about individual functions
such as the A/D Converter (ADC), refer to the
appropriate section in this data sheet.
(1)
. Digital Input buffer disabled.
6.2.2.2RA1/AN1/CPSA0
The RA1 pin is configurable to function as one of the
following:
• General purpose I/O
• Analog input for the A/D
• Capacitive sensing input
6.2.2.1RA0/AN0/VCAP
The RA0 pin is configurable to function as one of the
following:
• General purpose I/O
• Analog input for the A/D
• Slave Select input for the SSP
• Voltage Regulator Capacitor pin (PIC16F707
only)
Note 1: SS pin location may be selected as RA5
or RA0.
(1)
6.2.2.3RA2/AN2/CPSA1/DACOUT
The RA2 pin is configurable to function as one of the
following:
DS41418A-page 54Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
BANKSEL PORTB;
CLRFPORTB;Init PORTB
BANKSEL ANSELB
CLRFANSELB;Make RB<7:0> digital
BANKSEL TRISB;
MOVLWB’11110000’ ;Set RB<7:4> as inputs
;and RB<3:0> as outputs
MOVWFTRISB;
6.3PORTB and TRISB Registers
PORTB is an 8-bit wide, bidirectional port. The
corresponding data direction register is TRISB
(Register 6-6). Setting a TRISB bit (= 1) will make the
corresponding PORTB pin an input (i.e., put the
corresponding output driver in a High-Impedance mode).
Clearing a TRISB bit (= 0) will make the corresponding
PORTB pin an output (i.e., enable the output driver and
put the contents of the output latch on the selected pin).
Example 6-2 shows how to initialize PORTB.
Reading the PORTB register (Register 6-5) reads the
status of the pins, whereas writing to it will write to the
PORT latch. All write operations are read-modify-write
operations. Therefore, a write to a port implies that the
port pins are read, this value is modified and then written
to the PORT data latch.
The TRISB register (Register 6-6) controls the PORTB
pin output drivers, even when they are being used as
analog inputs. The user should ensure the bits in the
TRISB register are maintained set when using them as
analog inputs. I/O pins configured as analog input always
read ‘0’. Example 6-2 shows how to initialize PORTB.
EXAMPLE 6-2:INITIALIZING PORTB
Note:The ANSELB register must be initialized to
configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’.
6.3.1ANSELB REGISTER
The ANSELB register (Register 6-9) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELB bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELB bits has no affect on digital
output functions. A pin with TRIS clear and ANSELB
set will still operate as a digital output, but the Input
mode will be analog. This can cause unexpected
behavior when executing read-modify-write
instructions on the affected port.
6.3.2WEAK PULL-UPS
Each of the PORTB pins has an individually configurable
internal weak pull-up. Control bits WPUB<7:0> enable or
disable each pull-up (see Register 6-7). Each weak pullup is automatically turned off when the port pin is
configured as an output. All pull-ups are disabled on a
Power-on Reset by the RBPU
bit of the OPTION register.
6.3.3INTERRUPT-ON-CHANGE
All of the PORTB pins are individually configurable as an
interrupt-on-change pin. Control bits IOCB<7:0> enable
or disable the interrupt function for each pin. Refer to
Register 6-8. The interrupt-on-change feature is
disabled on a Power-on Reset.
For enabled interrupt-on-change pins, the present value
is compared with the old value latched on the last read
of PORTB to determine which bits have changed or
mismatched the old value. The ‘mismatch’ outputs of
the last read are OR’d together to set the PORTB
Change Interrupt Flag bit (RBIF) in the INTCON
register.
This interrupt can wake the device from Sleep. The user,
in the Interrupt Service Routine, clears the interrupt by:
a)Any read or write of PORTB. This will end the
mismatch condition.
b)Clear the flag bit RBIF.
A mismatch condition will continue to set flag bit RBIF.
Reading or writing PORTB will end the mismatch
condition and allow flag bit RBIF to be cleared. The latch
holding the last read value is not affected by a MCLR
Brown-out Reset. After these Resets, the RBIF flag will
continue to be set if a mismatch is present.
time as a read operation on PORTB, the
RBIF flag will always be set. If multiple
PORTB pins are configured for the
interrupt-on-change, the user may not be
able to identify which pin changed state.
PIC16F707/PIC16LF707
REGISTER 6-5:PORTB: PORTB REGISTER
R/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-x
RB7RB6RB5RB4RB3RB2RB1RB0
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-0RB<7:0>: PORTB I/O Pin bit
1 = Port pin is > V
0 = Port pin is < VIL
REGISTER 6-6:TRISB: PORTB TRI-STATE REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
TRISB7TRISB6TRISB5TRISB4TRISB3TRISB2TRISB1TRISB0
bit 7bit 0
IH
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-0TRISB<7:0>: PORTB Tri-State Control bit
1 = PORTB pin configured as an input (tri-stated)
0 = PORTB pin configured as an output
REGISTER 6-7:WPUB: WEAK PULL-UP PORTB REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
WPUB7WPUB6WPUB5WPUB4WPUB3WPUB2WPUB1WPUB0
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-0WPUB<7:0>: Weak Pull-up Register bits
1 = Pull-up enabled
0 = Pull-up disabled
Note 1:Global RBPU
2:The weak pull-up device is automatically disabled if the pin is in configured as an output.
bit of the OPTION register must be cleared for individual pull-ups to be enabled.
DS41418A-page 56Preliminary 2010 Microchip Technology Inc.
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-0ANSB<7:0>: Analog Select between Analog or Digital Function on Pins RB<7:0>, respectively
0 = Digital I/O. Pin is assigned to port or digital special function.
1 = Analog input. Pin is assigned as analog input
Note 1:When setting a pin to an analog input, the corresponding TRIS bit must be set to Input mode in order to
allow external control of the voltage on the pin.
6.3.4PIN DESCRIPTIONS
Each PORTB pin is multiplexed with other functions. The
pins and their combined functions are briefly described
here. For specific information about individual functions
such as the SSP, I
section in this data sheet.
2
C or interrupts, refer to the appropriate
(1)
. Digital input buffer disabled.
6.3.4.2RB1/AN10/CPSB9
These pins are configurable to function as one of the
following:
• General purpose I/O
• Analog input for the ADC
• Capacitive sensing input
6.3.4.1RB0/AN12/CPSB8/INT
These pins are configurable to function as one of the
following:
• General purpose I/O
• Analog input for the ADC
• Capacitive sensing input
• External edge triggered interrupt
6.3.4.3RB2/AN8/CPSB10
These pins are configurable to function as one of the
following:
DS41418A-page 58Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
BANKSEL PORTC;
CLRFPORTC;Init PORTC
BANKSEL TRISC;
MOVLWB‘00001100’ ;Set RC<3:2> as inputs
MOVWFTRISC;and set RC<7:4,1:0>
;as outputs
6.4PORTC and TRISC Registers
PORTC is a 8-bit wide, bidirectional port. The
corresponding data direction register is TRISC
(Register 6-11). Setting a TRISC bit (= 1) will make the
corresponding PORTC pin an input (i.e., put the
corresponding output driver in a High-Impedance mode).
Clearing a TRISC bit (= 0) will make the corresponding
PORTC pin an output (i.e., enable the output driver and
put the contents of the output latch on the selected pin).
Example 6-3 shows how to initialize PORTC.
Reading the PORTC register (Register 6-10) reads the
status of the pins, whereas writing to it will write to the
PORT latch. All write operations are read-modify-write
operations. Therefore, a write to a port implies that the
port pins are read, this value is modified and then written
to the PORT data latch.
The TRISC register (Register 6-11) controls the PORTC
pin output drivers, even when they are being used as
analog inputs. The user should ensure the bits in the
TRISC register are maintained set when using them as
analog inputs. I/O pins configured as analog input always
read ‘0’.
EXAMPLE 6-3:INITIALIZING PORTC
The location of the CCP2 function is controlled by the
CCP2SEL bit in the APFCON register (see Register 6-1).
REGISTER 6-10:PORTC: PORTC REGISTER
R/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-x
RC7RC6RC5RC4RC3RC2RC1RC0
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-0RC<7:0>: PORTC General Purpose I/O Pin bits
1 = Port pin is > V
0 = Port pin is < VIL
IH
REGISTER 6-11:TRISC: PORTC TRI-STATE REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
TRISC7TRISC6TRISC5TRISC4TRISC3TRISC2TRISC1TRISC0
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-0TRISC<7:0>: PORTC Tri-State Control bits
1 = PORTC pin configured as an input (tri-stated)
0 = PORTC pin configured as an output
The ANSELC register (Register 6-12) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELC bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELC bits has no affect on digital
output functions. A pin with TRIS clear and ANSELC
set will still operate as a digital output, but the Input
mode will be analog. This can cause unexpected
behavior when executing read-modify-write instructions on the affected port.
Note:The ANSELC register must be initialized
to configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’.
REGISTER 6-12:ANSELC: PORTC ANALOG SELECT REGISTER
R/W-1R/W-1R/W-1U-0U-0R/W-1R/W-1R/W-1
ANSC7ANSC6ANSC5——ANSC2ANSC1ANSC0
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-5ANSC<7:5>: Analog Select between Analog or Digital Function on Pins RC<7:5>, respectively
0 = Digital I/O. Pin is assigned to port or digital special function.
1 = Analog input. Pin is assigned as analog input
bit 4-3Unimplemented: Read as ‘0’
bit 2-0ANSC<2:0>: Analog Select between Analog or Digital Function on Pins RC<2:0>, respectively
0 = Digital I/O. Pin is assigned to port or digital special function.
1 = Analog input. Pin is assigned as analog input
Note 1:When setting a pin to an analog input, the corresponding TRIS bit must be set to Input mode in order to
allow external control of the voltage on the pin.
6.4.2PIN DESCRIPTIONS
Each PORTC pin is multiplexed with other functions. The
pins and their combined functions are briefly described
here. For specific information about individual functions
such as the SSP, I
section in this data sheet.
2
C or interrupts, refer to the appropriate
6.4.2.1RC0/T1OSO/T1CKI/CPSB2
These pins are configurable to function as one of the
following:
• General purpose I/O
• Timer1 oscillator output
• Timer1 clock input
• Capacitive sensing input
(1)
. Digital input buffer disabled.
(1)
. Digital input buffer disabled.
6.4.2.2RC1/T1OSi/CCP2/CPSB3
These pins are configurable to function as one of the
following:
• General purpose I/O
• Timer1 oscillator input
• Capture 2 input, Compare 2 output, and PWM2
output
• Capacitive sensing input
Note:CCP2 pin location may be selected as
RB3 or RC1.
DS41418A-page 60Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
6.4.2.3RC2/CCP1/CPSB4/TBCKI
These pins are configurable to function as one of the
following:
• General purpose I/O
• Capture 1 input, Compare 1 output, and PWM1
output
• Capacitive sensing input
• TimerB Clock input
6.4.2.4RC3/SCK/SCL
These pins are configurable to function as one of the
following:
• General purpose I/O
• SPI clock
2
•I
C™ clock
6.4.2.5RC4/SDI/SDA
These pins are configurable to function as one of the
following:
• General purpose I/O
• SPI data input
2
C data I/O
•I
6.4.2.6RC5/SDO/CPSA9
These pins are configurable to function as one of the
following:
• General purpose I/O
• SPI data output
• Capacitive sensing input
6.4.2.7RC6/TX/CK/CPSA10
These pins are configurable to function as one of the
following:
• General purpose I/O
• Asynchronous serial output
• Synchronous clock I/O
• Capacitive sensing input
6.4.2.8RC7/RX/DT/CPSA11
These pins are configurable to function as one of the
following:
• General purpose I/O
• Asynchronous serial input
• Synchronous serial data I/O
• Capacitive sensing input
TABLE 6-3:SUMMARY OF REGISTERS ASSOCIATED WITH PORTC
BANKSEL PORTD;
CLRFPORTD;Init PORTD
BANKSEL ANSELD
CLRFANSELD;Make PORTD digital
BANKSEL TRISD;
MOVLWB‘00001100’ ;Set RD<3:2> as inputs
MOVWFTRISD;and set RD<7:4,1:0>
;as outputs
6.5PORTD and TRISD Registers
PORTD is a 8-bit wide, bidirectional port. The
corresponding data direction register is TRISD
(Register 6-14). Setting a TRISD bit (= 1) will make the
corresponding PORTD pin an input (i.e., put the
corresponding output driver in a High-Impedance mode).
Clearing a TRISD bit (= 0) will make the corresponding
PORTD pin an output (i.e., enable the output driver and
put the contents of the output latch on the selected pin).
Example 6-4 shows how to initialize PORTD.
Reading the PORTD register (Register 6-13) reads the
status of the pins, whereas writing to it will write to the
PORT latch. All write operations are read-modify-write
operations. Therefore, a write to a port implies that the
port pins are read, this value is modified and then written
to the PORT data latch.
The TRISD register (Register 6-14) controls the
PORTD pin output drivers, even when they are being
used as analog inputs. The user should ensure the bits
in the TRISD register are maintained set when using
them as analog inputs. I/O pins configured as analog
input always read ‘0’.
EXAMPLE 6-4:INITIALIZING PORTD
6.5.1ANSELD REGISTER
The ANSELD register (Register 6-15) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELD bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELD bits has no affect on digital
output functions. A pin with TRIS clear and ANSEL set
will still operate as a digital output, but the Input mode
will be analog. This can cause unexpected behavior
when executing read-modify-write instructions on the
affected port.
Note:The ANSELD register must be initialized
to configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’.
REGISTER 6-13:PORTD: PORTD REGISTER
R/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-xR/W-x
RD7RD6RD5RD4RD3RD2RD1RD0
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-0RD<7:0>: PORTD General Purpose I/O Pin bits
1 = Port pin is > V
0 = Port pin is < VIL
IH
DS41418A-page 62Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
REGISTER 6-14:TRISD: PORTD TRI-STATE REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
TRISD7TRISD6TRISD5TRISD4TRISD3TRISD2TRISD1TRISD0
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-0TRISD<7:0>: PORTD Tri-State Control bits
1 = PORTD pin configured as an input (tri-stated)
0 = PORTD pin configured as an output
REGISTER 6-15:ANSELD: PORTD ANALOG SELECT REGISTER
R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1R/W-1
ANSD7ANSD6ANSD5ANSD4ANSD3ANSD2ANSD1ANSD0
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-0ANSD<7:0>: Analog Select between Analog or Digital Function on Pins RD<7:0>, respectively
0 = Digital I/O. Pin is assigned to port or digital special function.
1 = Analog input. Pin is assigned as analog input
Note 1:When setting a pin to an analog input, the corresponding TRIS bit must be set to Input mode in order to
allow external control of the voltage on the pin.
6.5.2PIN DESCRIPTIONS
Each PORTD pin is multiplexed with other functions. The
pins and their combined functions are briefly described
here. For specific information about individual functions
such as the SSP, I
section in this data sheet.
2
C or interrupts, refer to the appropriate
6.5.2.1RD0/CPSB5/T3G
These pins are configurable to function as one of the
following:
• General purpose I/O
• Capacitive sensing input
• Timer3 Gate input
6.5.2.2RD1/CPSB6
These pins are configurable to function as one of the
following:
• General purpose I/O
• Capacitive sensing input
(1)
. Digital input buffer disabled.
6.5.2.3RD2/CPSB7
These pins are configurable to function as one of the
following:
• General purpose I/O
• Capacitive sensing input
6.5.2.4RD3/CPSA8
These pins are configurable to function as one of the
following:
• General purpose I/O
• Capacitive sensing input
6.5.2.5RD4/CPSA12
These pins are configurable to function as one of the
following:
DS41418A-page 64Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
BANKSEL PORTE;
CLRFPORTE;Init PORTE
BANKSEL ANSELE;
CLRFANSELE;digital I/O
BANKSEL TRISE;
MOVLWB‘00001100’ ;Set RE<2> as an input
MOVWFTRISE;and set RE<1:0>
;as outputs
6.6PORTE and TRISE Registers
PORTE is a 4-bit wide, bidirectional port. The
corresponding data direction register is TRISE. Setting a
TRISE bit (= 1) will make the corresponding PORTE pin
an input (i.e., put the corresponding output driver in a
High-Impedance mode). Clearing a TRISE bit (= 0) will
make the corresponding PORTE pin an output (i.e.,
enable the output driver and put the contents of the
output latch on the selected pin). The exception is RE3,
which is input only and its TRIS bit will always read as
‘1’. Example 6-5 shows how to initialize PORTE.
Reading the PORTE register (Register 6-16) reads the
status of the pins, whereas writing to it will write to the
PORT latch. All write operations are read-modify-write
operations. Therefore, a write to a port implies that the
port pins are read, this value is modified and then
written to the PORT data latch. RE3 reads ‘0’ when
MCLRE = 1.
The TRISE register (Register 6-17) controls the PORTE
pin output drivers, even when they are being used as
analog inputs. The user should ensure the bits in the
TRISE register are maintained set when using them as
analog inputs. I/O pins configured as analog input always
read ‘0’.
Note:The ANSELE register must be initialized to
configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’.
EXAMPLE 6-5:INITIALIZING PORTE
6.6.1ANSELE REGISTER
The ANSELE register (Register 6-18) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELE bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELE bits has no affect on digital
output functions. A pin with TRIS clear and ANSELE
set will still operate as a digital output, but the Input
mode will be analog. This can cause unexpected
behavior when executing read-modify-write
instructions on the affected port.
REGISTER 6-16:PORTE: PORTE REGISTER
U-0U-0U-0U-0R-xR/W-xR/W-xR/W-x
————
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
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-4Unimplemented: Read as ‘0’
bit 3TRISE3: RE3 Port Tri-state Control bit
This bit is always ‘1’ as RE3 is an input only
bit 2-0TRISE<2:0>: RE<2:0> Tri-State Control bits
1 = PORTE pin configured as an input (tri-stated)
0 = PORTE pin configured as an output
REGISTER 6-18:ANSELE: PORTE ANALOG SELECT REGISTER
TRISE3TRISE2TRISE1TRISE0
(1)
U-0U-0U-0U-0U-0R/W-1R/W-1R/W-1
—————
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-3Unimplemented: Read as ‘0’
bit 2-0ANSE<2:0>: Analog Select between Analog or Digital Function on Pins RE<2:0>, respectively
0 = Digital I/O. Pin is assigned to port or digital special function.
1 = Analog input. Pin is assigned as analog input
Note 1:When setting a pin to an analog input, the corresponding TRIS bit must be set to Input mode in order to
allow external control of the voltage on the pin.
6.6.2PIN DESCRIPTIONS
Each PORTE pin is multiplexed with other functions. The
pins and their combined functions are briefly described
here. For specific information about individual functions
such as the SSP, I
section in this data sheet.
2
C or interrupts, refer to the appropriate
6.6.2.1RE0/AN5/CPSA5
These pins are configurable to function as one of the
following:
• General purpose I/O
• Analog input for the ADC
• Capacitive sensing input
(1)
. Digital input buffer disabled.
6.6.2.2 RE1/AN6/CPSA6
These pins are configurable to function as one of the
following:
• General purpose I/O
• Analog input for the ADC
• Capacitive sensing input
6.6.2.3RE2/AN7/CPSA7
These pins are configurable to function as one of the
following:
• General purpose I/O
• Analog input for the ADC
• Capacitive sensing input
ANSE2ANSE1ANSE0
DS41418A-page 66Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
6.6.2.4RE3/MCLR/VPP
These pins are configurable to function as one of the
following:
• General purpose input
• Master Clear Reset with weak pull-up
• Programming voltage reference input
TABLE 6-5:SUMMARY OF REGISTERS ASSOCIATED WITH PORTE
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
ADCON0
ANSELE
CPSACON0 CPSAON CPSARM
CPSACON1
PORTE
TRISE
Legend:x = unknown, u = unchanged, – = unimplemented locations read as ‘0’. Shaded cells are not used by PORTE.
Note1:This bit is always ‘1’ as RE3 is input only.
DS41418A-page 68Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
(CPU and Peripherals)
OSC1
OSC2
Sleep
External Oscillator
LP, XT, HS, RC, EC
System Clock
Postscaler
MUX
MUX
16 MHz/500 kHz
8 MHz/250 kHz
4 MHz/125 kHz
2 MHz/62.5 kHz
IRCF<1:0>
11
10
01
00
FOSC<2:0>
(Configuration Word 1)
Internal Oscillator
(OSCCON Register)
500 kHz
INTOSC
32x
MUX
0
1
PLL
PLLEN
(Configuration Word 1)
7.0OSCILLATOR MODULE
Clock source modes are configured by the FOSC bits
in Configuration Word 1 (CONFIG1). The oscillator
7.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 7-1 illustrates a
block diagram of the oscillator module.
Clock sources can be configured from external
oscillators, quartz crystal resonators, ceramic resonators
and Resistor-Capacitor (RC) circuits. In addition, the
system can be configured to use an internal calibrated
high-frequency oscillator as clock source, with a choice
of selectable speeds via software.
module can be configured for one of eight modes of
operation.
1.RC – External Resistor-Capacitor (RC) with
OSC/4 output on OSC2/CLKOUT.
F
2.RCIO – External Resistor-Capacitor (RC) with
I/O on OSC2/CLKOUT.
3.INTOSC – Internal oscillator with F
on OSC2 and I/O on OSC1/CLKIN.
4.INTOSCIO – Internal oscillator with I/O on
OSC1/CLKIN and OSC2/CLKOUT.
5.EC – External clock with I/O on OSC2/CLKOUT.
6.HS – High Gain Crystal or Ceramic Resonator
mode.
7.XT – Medium Gain Crystal or Ceramic
Resonator Oscillator mode.
Clock source modes can be classified as external or
internal.
• Internal clock source (INTOSC) is contained
within the oscillator module and derived from a
500 kHz high precision oscillator. The oscillator
module has eight selectable output frequencies,
with a maximum internal frequency of 16 MHz.
• External clock modes rely on external circuitry for
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.
The system clock can be selected between external or
internal clock sources via the FOSC bits of the
Configuration Word 1.
7.3Internal Clock Modes
The oscillator module has eight output frequencies
derived from a 500 kHz high precision oscillator. The
IRCF bits of the OSCCON register select the
postscaler applied to the clock source dividing the
frequency by 1, 2, 4 or 8. Setting the PLLEN bit of the
Configuration Word 1 locks the internal clock source to
16 MHz before the postscaler is selected by the IRCF
bits. The PLLEN bit must be set or cleared at the time
of programming; therefore, only the upper or low four
clock source frequencies are selectable in software.
7.3.1INTOSC AND INTOSCIO MODES
The INTOSC and INTOSCIO modes configure the
internal oscillators as the system clock source when
the device is programmed using the oscillator selection
or the FOSC<2:0> bits in the CONFIG1 register. See
Section 8.0 “Device Configuration” for more
information.
In INTOSC mode, OSC1/CLKIN is available for general
purpose I/O. OSC2/CLKOUT outputs the selected
internal oscillator frequency divided by 4. The CLKOUT
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.
7.3.2FREQUENCY SELECT BITS (IRCF)
The output of the 500 kHz INTOSC and 16 MHz
INTOSC, with Phase Locked Loop enabled, connect to
a postscaler and multiplexer (see Figure 7-1). The
Internal Oscillator Frequency Select bits (IRCF) of the
OSCCON register select the frequency output of the
internal oscillator. Depending upon the PLLEN bit, one
of four frequencies of two frequency sets can be
selected via software:
If PLLEN = 1, frequency selection is as follows:
•16 MHz
• 8 MHz (Default after Reset)
•4 MHz
•2 MHz
If PLLEN = 0, frequency selection is as follows:
•500 kHz
• 250 kHz (Default after Reset)
•125 kHz
•62.5 kHz
Note:Following any Reset, the IRCF<1:0> bits of
the OSCCON register are set to ‘10’ and
the frequency selection is set to 8 MHz or
250 kHz. The user can modify the IRCF
bits to select a different frequency.
There is no start-up delay before a new frequency
selected in the IRCF bits takes effect. This is because
the old and new frequencies are derived from INTOSC
via the postscaler and multiplexer.
Start-up delay specifications are located in the
Table 25-4 in Section 25.0 “ElectricalSpecifications”.
DS41418A-page 70Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
7.4Oscillator Control
The Oscillator Control (OSCCON) register (Figure 7-1)
displays the status and allows frequency selection of the
internal oscillator (INTOSC) system clock. The
OSCCON register contains the following bits:
• Frequency selection bits (IRCF)
• Status Locked bits (ICSL)
• Status Stable bits (ICSS)
REGISTER 7-1:OSCCON: OSCILLATOR CONTROL REGISTER
U-0U-0R/W-1R/W-0R-qR-qU-0U-0
——IRCF1IRCF0ICSLICSS——
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
q = Value depends on condition
bit 7-6Unimplemented: Read as ‘0’
bit 5-4IRCF<1:0>: Internal Oscillator Frequency Select bits
bit 3ICSL: Internal Clock Oscillator Status Locked bit (2% Stable)
1 = 16 MHz/500 kHz Internal Oscillator (HFIOSC) is in lock.
0 = 16 MHz/500 kHz Internal Oscillator (HFIOSC) has not yet locked.
bit 2ICSS: Internal Clock Oscillator Status Stable bit (0.5% Stable)
1 = 16 MHz/500 kHz Internal Oscillator (HFIOSC) has stabilized to its maximum accuracy
0 = 16 MHz/500 kHz Internal Oscillator (HFIOSC) has not yet reached its maximum accuracy
The INTOSC is factory calibrated but can be adjusted
in software by writing to the OSCTUNE register
(Register 7-2).
The default value of the OSCTUNE register is ‘0’. The
value is a 6-bit two’s complement number.
When the OSCTUNE register is modified, the INTOSC
frequency will begin shifting to the new frequency. Code
execution continues during this shift. There is no
indication that the shift has occurred.
REGISTER 7-2:OSCTUNE: OSCILLATOR TUNING REGISTER
U-0U-0R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0
——TUN5TUN4TUN3TUN2TUN1TUN0
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-6Unimplemented: Read as ‘0’
bit 5-0TUN<5:0>: Frequency Tuning bits
01 1111 = Maximum frequency
01 1110 =
•
•
•
00 0001 =
00 0000 = Oscillator module is running at the factory-calibrated frequency.
11 1111 =
•
•
•
10 0000 = Minimum frequency
DS41418A-page 72Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
OSC1/CLKIN
OSC2/CLKOUT
(1)
I/O
Clock from
Ext. System
PIC
®
MCU
Note 1:Alternate pin functions are described in
Section 6.1 “Alternate Pin Function”.
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.
C1
C2
Quartz
R
S
(1)
OSC1/CLKIN
RF
(2)
Sleep
To Internal
Logic
PIC® MCU
Crystal
OSC2/CLKOUT
7.6External Clock Modes
7.6.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 on the OSC1 pin before the device is
released from Reset. 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 or ceramic resonator, has started and
is providing a stable system clock to the oscillator
module.
7.6.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 input and the OSC2 is available
for general purpose I/O. Figure 7-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.
®
MCU design is fully
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 7-3 and Figure 7-4 show typical circuits for
quartz crystal and ceramic resonators, respectively.
FIGURE 7-3:QUARTZ CRYSTAL
OPERATION (LP, XT OR
HS MODE)
FIGURE 7-2:EXTERNAL CLOCK (EC)
MODE OPERATION
7.6.3LP, 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 7-3). The mode selects a low,
medium or high gain setting of the internal inverteramplifier 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 resonators with a low drive level specification, for
example, tuning fork type crystals.
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)
PIC16F707/PIC16LF707
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.
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
OSC2/CLKOUT
(1)
CEXT
REXT
PIC® MCU
OSC1/CLKIN
F
OSC/4 or
Internal
Clock
VDD
VSS
Recommended values: 10 k REXT 100 k, <3V
3 k R
EXT 100 k, 3-5V
C
EXT > 20 pF, 2-5V
Note 1:Alternate pin functions are described in
Section 6.1 “Alternate Pin Function”.
2:Output depends upon RC or RCIO clock mode.
I/O
(2)
FIGURE 7-4:CERAMIC RESONATOR
OPERATION
(XT OR HS MODE)
7.6.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 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 used to provide a clock for
external circuitry, synchronization, calibration, test or
other application requirements. Figure 7-5 shows the
external RC mode connections.
FIGURE 7-5:EXTERNAL RC MODES
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 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 external RC components used.
TABLE 7-1:SUMMARY OF REGISTERS ASSOCIATED WITH CLOCK SOURCES
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
CONFIG1
OSCCON
OSCTUNE
Legend:x = unknown, u = unchanged, – = unimplemented locations read as ‘0’. Shaded cells are not used by oscillators.
Note 1:See Configuration Word 1 (Register 8-1) for operation of all bits.
DS41418A-page 74Preliminary 2010 Microchip Technology Inc.
(1)
—CPMCLREPWRTEWDTEFOSC2FOSC1FOSC0——
——IRCF1IRCF0ICSLICSS——--10 qq----10 qq--
——TUN5TUN4TUN3TUN2TUN1TUN0--00 0000--uu uuuu
Value on
POR, BOR
Value on
all other
(1)
Resets
PIC16F707/PIC16LF707
8.0DEVICE CONFIGURATION
Device Configuration consists of Configuration Word 1
and Configuration Word 2 registers, Code Protection
and Device ID.
8.1Configuration Words
There are several Configuration Word bits that allow
different oscillator and memory protection options.
These are implemented as Configuration Word 1
register at 2007h and Configuration Word 2 register at
2008h. These registers are only accessible during
programming.
REGISTER 8-1:CONFIG1: CONFIGURATION WORD REGISTER 1
R/P-1R/P-1U-1
——DEBUGPLLEN—BORVBOREN1BOREN0
bit 15bit 8
(4)
U-1
—CPMCLREPWRTEWDTEFOSC2FOSC1FOSC0
bit 7bit 0
Legend:P = Programmable bit
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 13DEBUG
bit 12PLLEN: INTOSC PLL Enable bit
bit 11Unimplemented: Read as ‘1’
bit 10BORV: Brown-out Reset Voltage Selection bit
bit 9-8BOREN<1:0>: Brown-out Reset Selection bits
bit 7Unimplemented: Read as ‘1’
bit 6CP
bit 5MCLRE: RE3/MCLR
bit 4PWRTE: Power-up Timer Enable bit
bit 3WDTE: Watchdog Timer Enable bit
R/P-1R/P-1R/P-1R/P-1R/P-1R/P-1R/P-1
: In-Circuit Debugger Mode bit
1 = In-Circuit Debugger disabled, RB6/ICSPCLK and RB7/ICSPDAT are general purpose I/O pins
0 = In-Circuit Debugger enabled, RB6/ICSPCLK and RB7/ICSPDAT are dedicated to the debugger
0 = INTOSC Frequency is 500 kHz
1 = INTOSC Frequency is 16 MHz (32x)
0 = Brown-out Reset Voltage (V
1 = Brown-out Reset Voltage (V
0x = BOR disabled (Preconditioned State)
10 = BOR enabled during operation and disabled in Sleep
11 = BOR enabled
: Code Protection bit
1 = Program memory code protection is disabled
0 = Program memory code protection is enabled
Pin Function Select bit
1 = RE3/MCLR pin function is MCLR
0 = RE3/MCLR pin function is digital input, MCLR internally tied to VDD
1 = PWRT disabled
0 = PWRT enabled
1 = WDT enabled
0 = WDT disabled
BOR) set to 2.5 V nominal
BOR) set to 1.9 V nominal
(1)
(2)
(3)
(4)
R/P-1R/P-1R/P-1
Note 1:Enabling Brown-out Reset does not automatically enable Power-up Timer.
2:The entire program memory will be erased when the code protection is turned off.
3:When MCLR
4:MPLAB
is asserted in INTOSC or RC mode, the internal clock oscillator is disabled.
®
IDE masks unimplemented Configuration bits to ‘0’.
PIC16F707/PIC16LF707
REGISTER 8-1:CONFIG1: CONFIGURATION WORD REGISTER 1 (CONTINUED)
bit 2-0FOSC<2:0>: Oscillator Selection bits
Note 1:Enabling Brown-out Reset does not automatically enable Power-up Timer.
2:The entire program memory will be erased when the code protection is turned off.
3:When MCLR
4:MPLAB
111 =RC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, RC on RA7/OSC1/CLKIN
110 =RCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, RC on RA7/OSC1/CLKIN
101 =INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
100 =INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
011 =EC: I/O function on RA6/OSC2/CLKOUT pin, CLKIN on RA7/OSC1/CLKIN
010 =HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
001 =XT oscillator: Crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
000 =LP oscillator: Low-power crystal on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
is asserted in INTOSC or RC mode, the internal clock oscillator is disabled.
®
IDE masks unimplemented Configuration bits to ‘0’.
REGISTER 8-2:CONFIG2: CONFIGURATION WORD REGISTER 2
(1)
U-1
————————
bit 15bit 8
(1)
U-1
——
bit 7bit 0
U-1
U-1
(1)
(1)
U-1
(1)
U-1
(1)
R/P-1R/P-1U-1
VCAPEN1VCAPEN0
U-1
(1)
(1)
U-1
U-1
(1)
(1)
U-1
U-1
(1)
(1)
————
U-1
U-1
(1)
(1)
Legend:P = Programmable bit
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 15-6Unimplemented: Read as ‘1’
bit 5-4VCAPEN<1:0>: Voltage Regulator Capacitor Enable bits
For the PIC16LF707
These bits are ignored. All V
For the PIC16F707
00 =V
01 =V
10 =V
11 = All V
CAP functionality is enabled on RA0
CAP functionality is enabled on RA5
CAP functionality is enabled on RA6
CAP functions are disabled (not recommended)
:
CAP pin functions are disabled.
:
bit 3-0Unimplemented: Read as ‘1’
®
Note 1:MPLAB
IDE masks unimplemented Configuration bits to ‘0’.
DS41418A-page 76Preliminary 2010 Microchip Technology Inc.
8.2Code Protection
If the code protection bit(s) have not been
programmed, the on-chip program memory can be
read out using ICSP™ for verification purposes.
Note:The entire Flash program memory will be
erased when the code protection is turned
off. See the “PIC16F707/PIC16LF707
Memory Programming Specification”
(DS41332) for more information.
8.3User ID
Four memory locations (2000h-2003h) are designated
as ID locations where the user can store checksum or
other code identification numbers. These locations are
not accessible during normal execution, but are readable and writable during Program/Verify mode. Only
the Least Significant 7 bits of the ID locations are
reported when using MPLAB IDE. See the
“PIC16F707/PIC16LF707 Memory ProgrammingSpecification” (DS41332) for more information.
DS41418A-page 78Preliminary 2010 Microchip Technology Inc.
9.0ANALOG-TO-DIGITAL
AN0
AN1
AN2
AN4
AVDD
VREF+
ADON
GO/DONE
ADREF = 10
ADREF = 0x
CHS<3:0>
VSS
AN5
AN6
AN7
AN3
AN8
AN9
AN10
AN11
AN12
AN13
Reserved
FV
REF
0000
0001
0010
0011
0100
0101
0111
0110
1000
1001
1010
1011
1100
1101
1110
1111
8
ADC
ADRES
ADREF = 11
CONVERTER (ADC) MODULE
The Analog-to-Digital Converter (ADC) allows
conversion of an analog input signal to a 8-bit binary
representation of that signal. This device uses analog
inputs, which are multiplexed into a single sample and
hold circuit. The output of the sample and hold is
connected to the input of the converter. The converter
generates a 8-bit binary result via successive
approximation and stores the conversion result into the
ADC result register (ADRES). Figure 9-1 shows the
block diagram of the ADC.
The ADC voltage reference is software selectable to be
either internally generated or externally supplied.
The ADC can generate an interrupt upon completion of
a conversion. This interrupt can be used to wake-up the
device from Sleep.
When configuring and using the ADC the following
functions must be considered:
• Port configuration
• Channel selection
• ADC voltage reference selection
• ADC conversion clock source
• Interrupt control
• Results formatting
9.1.1PORT CONFIGURATION
The ADC can be used to convert both analog and
digital signals. When converting analog signals, the I/O
pin should be configured for analog by setting the
associated TRIS and ANSEL bits. Refer to Section 6.0
“I/O Ports” for more information.
Note:Analog voltages on any pin that is defined
as a digital input may cause the input
buffer to conduct excess current.
9.1.2CHANNEL SELECTION
The CHS bits of the ADCON0 register determine which
channel is connected to the sample and hold circuit.
When changing channels, a delay is required before
starting the next conversion. Refer to Section 9.2“ADC Operation” for more information.
9.1.3ADC VOLTAGE REFERENCE
The ADREF bits of the ADCON1 register provides
control of the positive voltage reference. The positive
voltage reference can be either V
DD, an external
voltage source or the internal Fixed Voltage Reference.
The negative voltage reference is always connected to
the ground reference. See Section 10.0 “FixedVoltage Reference” for more details on the Fixed
Voltage Reference.
9.1.4 CONVERSION CLOCK
The source of the conversion clock is software selectable via the ADCS bits of the ADCON1 register. There
are seven possible clock options:
OSC/2
•F
•F
OSC/4
•FOSC/8
•FOSC/16
•F
OSC/32
•FOSC/64
•FRC (dedicated internal oscillator)
The time to complete one bit conversion is defined as
AD. One full 8-bit conversion requires 10 TAD periods
T
as shown in Figure 9-2.
For correct conversion, the appropriate T
specification must be met. Refer to the A/D conversion
requirements in Section 25.0 “ElectricalSpecifications” for more information. Table 9-1 gives
examples of appropriate ADC clock selections.
AD
Note:Unless using the FRC, any changes in the
system clock frequency will change the
ADC clock frequency, which may
adversely affect the ADC result.
TABLE 9-1:ADC CLOCK PERIOD (TAD) VS. DEVICE OPERATING FREQUENCIES
Legend: Shaded cells are outside of recommended range.
Note 1:The FRC source has a typical TAD time of 1.6 s for VDD.
2:These values violate the minimum required T
3:For faster conversion times, the selection of another clock source is recommended.
4:When the device frequency is greater than 1 MHz, the FRC clock source is only recommended if the
conversion will be performed during Sleep.
ADCS<2:0>20 MHz16 MHz8 MHz4 MHz1 MHz
100 ns
(2)
(2)
(2)
(1,4)
1.0-6.0 s
125 ns
250 ns
0.5 s
AD time.
(2)
(2)
(2)
(1,4)
250 ns
500 ns
(2)
(2)
(2)
500 ns
1.0 s4.0 s
1.0 s2.0 s8.0 s
(3)
1.0-6.0 s
(3)
(1,4)
1.0-6.0 s
16.0 s
(3)
(1,4)
2.0 s
32.0 s
64.0 s
1.0-6.0 s
(3)
(3)
(3)
(3)
(1,4)
DS41418A-page 80Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
TAD1TAD2TAD3TAD4TAD5TAD6TAD7TAD8TAD9
Set GO/DONE bit
Holding capacitor is disconnected from analog input (typically 100 ns)
b7b6b5b4b3b2b1b0
Tcy to TAD
Conversion Starts
ADRES register is loaded,
GO/DONE bit is cleared,
ADIF bit is set,
Holding capacitor is connected to analog input
TAD0
FIGURE 9-2:ANALOG-TO-DIGITAL CONVERSION TAD CYCLES
9.1.5 INTERRUPTS
The ADC module allows for the ability to generate an
interrupt upon completion of an Analog-to-Digital
conversion. The ADC interrupt flag is the ADIF bit in the
PIR1 register. The ADC Interrupt Enable is the ADIE bit
in the PIE1 register. The ADIF bit must be cleared in
software.
Note 1: The ADIF bit is set at the completion of
every conversion, regardless of whether
or not the ADC interrupt is enabled.
2: The ADC operates during Sleep only
when the F
This interrupt can be generated while the device is
operating or while in Sleep. If the device is in Sleep, the
interrupt will wake-up the device. Upon waking from
Sleep, the next instruction following the SLEEP instruction is always executed. If the user is attempting to
wake-up from Sleep and resume in-line code execution, the GIE and PEIE bits of the INTCON register
must be disabled. If the GIE and PEIE bits of the
INTCON register are enabled, execution will switch to
the Interrupt Service Routine.
Please refer to Section 9.1.5 “Interrupts” for more
information.
To enable the ADC module, the ADON bit of the
ADCON0 register must be set to a ‘1’. Setting the GO/
DONE bit of the ADCON0 register to a ‘1’ will start the
Analog-to-Digital conversion.
Note:The GO/DONE bit should not be set in the
same instruction that turns on the ADC.
Refer to Section 9.2.6 “A/D ConversionProcedure”.
9.2.2COMPLETION OF A CONVERSION
When the conversion is complete, the ADC module will:
• Clear the GO/DONE
• Set the ADIF interrupt flag bit
• Update the ADRES register with new conversion
result
9.2.3TERMINATING A CONVERSION
If a conversion must be terminated before completion,
the GO/DONE
ADRES register will be updated with the partially complete Analog-to-Digital conversion sample. Incomplete
bits will match the last bit converted.
Note:A device Reset forces all registers to their
Reset state. Thus, the ADC module is
turned off and any pending conversion is
terminated.
9.2.4ADC OPERATION DURING SLEEP
The ADC module can operate during Sleep. This
requires the ADC clock source to be set to the F
option. When the FRC clock source is selected, the
ADC waits one additional instruction before starting the
conversion. This allows the SLEEP instruction to be
executed, which can reduce system noise during the
conversion. If the ADC interrupt is enabled, the device
will wake-up from Sleep when the conversion
completes. If the ADC interrupt is disabled, the ADC
module is turned off after the conversion completes,
although the ADON bit remains set.
When the ADC clock source is something other than
RC, a SLEEP instruction causes the present conver-
F
sion to be aborted and the ADC module is turned off,
although the ADON bit remains set.
bit
bit can be cleared in software. The
RC
9.2.5SPECIAL EVENT TRIGGER
The Special Event Trigger of the CCP module allows
periodic ADC measurements without software intervention. When this trigger occurs, the GO/DONE
set by hardware and the Timer1 counter resets to zero.
Using the Special Event Trigger does not assure proper
ADC timing. It is the user’s responsibility to ensure that
the ADC timing requirements are met.
Refer to Section 17.0 “Capture/Compare/PWM(CCP) Module” for more information.
bit is
9.2.6A/D CONVERSION PROCEDURE
This is an example procedure for using the ADC to
perform an Analog-to-Digital conversion:
1.Configure Port:
• Disable pin output driver (Refer to the TRIS
register)
• Configure pin as analog (Refer to the ANSEL
register)
2.Configure the ADC module:
• Select ADC conversion clock
• Configure voltage reference
• Select ADC input channel
• Turn on ADC module
3.Configure ADC interrupt (optional):
• Clear ADC interrupt flag
• Enable ADC interrupt
• Enable peripheral interrupt
• Enable global interrupt
4.Wait the required acquisition time
5.Start conversion by setting the GO/DONE bit.
6.Wait for ADC conversion to complete by one of
the following:
• Polling the GO/DONE
• Waiting for the ADC interrupt (interrupts
enabled)
7.Read ADC Result.
8.Clear the ADC interrupt flag (required if interrupt
is enabled).
Note 1: The global interrupt can be disabled if the
user is attempting to wake-up from Sleep
and resume in-line code execution.
2: Refer to Section 9.3 “A/D Acquisition
Requirements”.
(1)
bit
(2)
.
DS41418A-page 82Preliminary 2010 Microchip Technology Inc.
MOVWFADCON1;
BANKSELTRISA;
BSFTRISA,0;Set RA0 to input
BANKSELANSELA;
BSFANSELA,0;Set RA0 to analog
BANKSELADCON0;
MOVLWB’00000001’;AN0, On
MOVWFADCON0;
CALLSampleTime ;Acquisiton delay
BSFADCON0,GO;Start conversion
BTFSCADCON0,GO;Is conversion done?
GOTO$-1;No, test again
BANKSELADRES;
MOVFADRES,W;Read result
MOVWFRESULT;store in GPR space
1 = A/D conversion cycle in progress. Setting this bit starts an A/D conversion cycle.
This bit is automatically cleared by hardware when the A/D conversion has completed.
0 = A/D conversion completed/not in progress
bit 0ADON: ADC Enable bit
1 = ADC is enabled
0 = ADC is disabled and consumes no operating current
REF)
DS41418A-page 84Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
REGISTER 9-2:ADCON1: A/D CONTROL REGISTER 1
U-0R/W-0R/W-0R/W-0U-0U-0R/W-0R/W-0
—
ADCS2ADCS1ADCS0
——
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 7Unimplemented: Read as ‘0’
bit 6-4ADCS<2:0>: A/D Conversion Clock Select bits
TACQAmplifier Settling Time Hold Capacitor Charging TimeTemperature Coefficient++=
T
AMPTCTCOFF++=
2µsT
CTemperature - 25°C0.05µs/°C++=
TCCHOLD R ICRSSRS++ ln(1/511)–=
10pF 1k
7k10k
++– ln(0.001957)=
1.12
=µs
T
ACQ2 µs1.12µs50°C- 25°C0.05µs/°C++=
4.42µs=
VAPPLIED 1e
Tc–
RC
---------
–
VAPPLIED 1
1
2
n1+
1–
--------------------------–
=
VAPPLIED 1
1
2
n1+
1–
--------------------------
–
VCHOLD=
VAPPLIED 1e
TC–
RC
----------
–
VCHOLD=
;[1] VCHOLD charged to within 1/2 lsb
;[2] V
CHOLD charge response to VAPPLIED
;combining [1] and [2]
The value for T
C can be approximated with the following equations:
Solving for T
C:
Therefore:
Temperature 50°C and external impedance of 10k
5.0V VDD=
Assumptions:
Note: Where n = number of bits of the ADC.
9.3A/D Acquisition Requirements
For the ADC to meet its specified accuracy, the charge
holding capacitor (C
charge to the input channel voltage level. The analog
input model is shown in Figure 9-3. The source
impedance (R
impedance directly affect the time required to charge
the capacitor CHOLD. The sampling switch (RSS)
impedance varies over the device voltage (V
to Figure 9-3. The maximum recommended
impedance for analog sources is 10 k. As the
EQUATION 9-1:ACQUISITION TIME EXAMPLE
HOLD) must be allowed to fully
S) and the internal sampling switch (RSS)
DD), refer
source impedance is decreased, the acquisition time
may be decreased. After the analog input channel is
selected (or changed), an A/D acquisition must be
done before the conversion can be started. To calculate
the minimum acquisition time, Equation 9-1 may be
used. This equation assumes that 1/2 LSb error is used
(256 steps for the ADC). The 1/2 LSb error is the
maximum error allowed for the ADC to meet its
specified resolution.
Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out.
2: The charge holding capacitor (C
3: The maximum recommended impedance for analog sources is 10 k. This is required to meet the pin
leakage specification.
HOLD) is not discharged after each conversion.
DS41418A-page 86Preliminary 2010 Microchip Technology Inc.
FIGURE 9-3:ANALOG INPUT MODEL
CPIN
VA
Rs
ANx
5 pF
V
DD
VT 0.6V
V
T 0.6V
I
LEAKAGE
(1)
RIC 1k
Sampling
Switch
SS
Rss
C
HOLD = 10 pF
V
SS/VREF-
6V
Sampling Switch
5V
4V
3V
2V
567891011
(k)
V
DD
Legend:
C
PIN
VT
I LEAKAGE
RIC
SS
C
HOLD
= Input Capacitance
= Threshold Voltage
= Leakage current at the pin due to
= Interconnect Resistance
= Sampling Switch
= Sample/Hold Capacitance
various junctions
RSS
Note 1: Refer to Section 25.0 “Electrical Specifications”.
q = value depends on condition. Shaded cells are not used for ADC
module.
Valu e o n
POR, BOR
Valu e o n
all other
Resets
DS41418A-page 88Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
ADFVR<1:0>
CDAFVR<1:0>
X1
X2
X4
X1
X2
X4
2
2
FVR BUFFER1
(To ADC Module)
FVR BUFFER2
(To Cap Sense, DAC)
+
_
FVREN
FVRRDY
1.024V Fixed
Reference
10.0FIXED VOLTAGE REFERENCE
The Fixed Voltage Reference, or FVR, is a stable
voltage reference independent of V
2.048V or 4.096V selectable output levels. The output
of the FVR can be configured to supply a reference
voltage to the following:
• ADC input channel
• ADC positive reference
• Digital-to-Analog Converter (DAC)
• Capacitive Sensing Modules (CSM)
The FVR can be enabled by setting the FVREN bit of
the FVRCON register.
DD with 1.024V,
10.1Independent Gain Amplifiers
The output of the FVR supplied to the ADC and
CSM/DAC modules is routed through the two
independent programmable gain amplifiers. Each
amplifier can be configured to amplify the reference
voltage by 1x, 2x or 4x.
The ADFVR<1:0> bits of the FVRCON register are
used to enable and configure the gain amplifier settings
for the reference supplied to the ADC module. Reference Section 9.0 “Analog-to-Digital Converter(ADC) Module” for additional information on selecting
the appropriate input channel.
The CDAFVR<1:0> bits of the FVRCON register are
used to enable and configure the gain amplifier settings
for the reference supplied to the capacitive sensing and
digital-to-analog converter modules. Reference
Section 16.0 “Capacitive Sensing Module” and
Section 11.0 “Digital-to-Analog Converter (DAC)
Module” for additional information.
10.2FVR Stabilization Period
When the Fixed Voltage Reference module is enabled, it
requires time for the reference and amplifier circuits to
stabilize. Once the circuits stabilize and are ready for
use, the FVRRDY bit of the FVRCON register will be set.
See Section 25.0 “Electrical Specifications” for the
minimum delay requirement.
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
q = Value depends on condition
(2)
CDAFVR0
(2)
ADFVR1
(2)
ADFVR0
(2)
bit 7FVRRDY: Fixed Voltage Reference Ready Flag bit
(1)
0 = Fixed Voltage Reference output is not active or stable
1 = Fixed Voltage Reference output is ready for use
bit 6FVREN: Fixed Voltage Reference Enable bit
0 = Fixed Voltage Reference is disabled
1 = Fixed Voltage Reference is enabled
bit 5-4Reserved: Read as ‘0’. Maintain these bits clear
bit 3-2CDAFVR<1:0>: Cap Sense and D/A Converter Fixed Voltage Reference Selection bit
00 = CSM and D/A Converter Fixed Voltage Reference Peripheral output is off.
01 = CSM and D/A Converter Fixed Voltage Reference Peripheral output is 1x (1.024V)
10 = CSM and D/A Converter Fixed Voltage Reference Peripheral output is 2x (2.048V)
11 = CSM and D/A Converter Fixed Voltage Reference Peripheral output is 4x (4.096V)
bit 1-0ADFVR<1:0>: A/D Converter Fixed Voltage Reference Selection bit
(2)
00 = A/D Converter Fixed Voltage Reference Peripheral output is off.
01 = A/D Converter Fixed Voltage Reference Peripheral output is 1x (1.024V)
10 = A/D Converter Fixed Voltage Reference Peripheral output is 2x (2.048V)
11 = A/D Converter Fixed Voltage Reference Peripheral output is 4x (4.096V)
Note 1:FVRRDY is always ‘1’ on PIC16F707 devices.
2:Fixed Voltage Reference output cannot exceed V
DD.
TABLE 10-1:REGISTERS ASSOCIATED WITH VOLTAGE REFERENCE
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
FVRCON FVRRDY FVREN
Legend:Shaded cells are not used by the voltage reference module.
DS41418A-page 90Preliminary 2010 Microchip Technology Inc.
PIC16F707/PIC16LF707
VOUTVSOURCE VSOURCE – x
DACR[4:0]
2
5
------------- ------------ ----
VSOURCE+=
-
IF DACEN = 1
IF DACEN = 0 & DACLPS = 1 & DACR[4:0] = 11111
VOUTVSOURCE =
+
IF DACEN = 0 & DACLPS = 0 & DACR[4:0] = 00000
VOUTVSOURCE =
-
VSOURCE+ = VDD, VREF, or FVR BUFFER 2
V
SOURCE- = VSS
+
-
11.0DIGITAL-TO-ANALOG
CONVERTER (DAC) MODULE
The Digital-to-Analog Converter supplies a variable
voltage reference, ratiometric with V
selectable output levels. The output of the DAC can be
configured to supply a reference voltage to the
following:
• DACOUT device pin
• Capacitive sensing modules
The Digital-to-Analog Converter (DAC) can be enabled
by setting the DACEN bit of the DACCON0 register.
EQUATION 11-1:
DD, with 32
11.1Output Voltage Selection
The DAC has 32 voltage level ranges. The 32 levels
are set with the DACR<4:0> bits of the DACCON1
register.
The DAC output voltage is determined by the following
equation:
11.2Output Clamped to VSS
The DAC output voltage can be set to VSS with no
power consumption by setting the DACEN bit of the
DACCON0 register to ‘0’.
11.3Output Ratiometric to VDD
The DAC is VDD derived and therefore, the DAC output
changes with fluctuations in V
accuracy of the DAC can be found in Section 25.0“Electrical Specifications”.
DD. The tested absolute
11.4Voltage Reference Output
The DAC can be output to the device DACOUT pin by
setting the DACOE bit of the DACCON0 register to ‘1’.
Selecting the reference voltage for output on the
DACOUT pin automatically overrides the digital output
buffer and digital input threshold detector functions of
that pin. Reading the DACOUT pin when it has been
configured for reference voltage output will always
return a ‘0’.
Due to the limited current drive capability, a buffer must
be used on the voltage reference output for external
connections to DACOUT. Example 11-1 shows an
example buffering technique.
11.5Operation During Sleep
When the device wakes up from Sleep through an
interrupt or a Watchdog Timer time-out, the contents of
the DACCON0 register are not affected. To minimize
current consumption in Sleep mode, the voltage
reference should be disabled.
The Timer0 module can be used as either an 8-bit timer
or an 8-bit counter.
12.1.18-BIT TIMER MODE
The Timer0 module will increment every instruction
cycle, if used without a prescaler. 8-bit Timer mode is
selected by clearing the TMR0CS bit of the OPTION
register.
When TMR0 is written, the increment is inhibited for
two instruction cycles immediately following the write.
Note:The value written to the TMR0 register can
be adjusted, in order to account for the two
instruction cycle delay when TMR0 is
written.
12.1.28-BIT COUNTER MODE
In 8-bit Counter mode, the Timer0 module will increment
on every rising or falling edge of the T0CKI pin. 8-bit
Counter mode using the T0CKI pin is selected by setting
the TMR0CS bit of the OPTION register to ‘1’.
The rising or falling transition of the incrementing edge
for either input source is determined by the TMR0SE bit
in the OPTION register.
12.1.3SOFTWARE PROGRAMMABLE
PRESCALER
A single software programmable prescaler is available
for use with either Timer0 or the Watchdog Timer
(WDT), but not both simultaneously. The prescaler
assignment is controlled by the PSA bit of the OPTION
register. To assign the prescaler to Timer0, the PSA bit
must be cleared to a ‘0’.
There are 8 prescaler options for the Timer0 module
ranging from 1:2 to 1:256. The prescale values are
selectable via the PS<2:0> bits of the OPTION register.
In order to have a 1:1 prescaler value for the Timer0
module, the prescaler must be assigned to the WDT
module.
The prescaler is not readable or writable. When the
prescaler is enabled or assigned to the Timer0 module,
all instructions writing to the TMR0 register will clear the
prescaler.
Note:When the prescaler is assigned to WDT, a
CLRWDT instruction will clear the prescaler
along with the WDT.
12.1.4TIMER0 INTERRUPT
Timer0 will generate an interrupt when the TMR0
register overflows from FFh to 00h. The TMR0IF
interrupt flag bit of the INTCON register is set every
time the TMR0 register overflows, regardless of
whether or not the Timer0 interrupt is enabled. The
TMR0IF bit can only be cleared in software. The
Timer0 interrupt enable is the TMR0IE bit of the
INTCON register.
Note:The Timer0 interrupt cannot wake the
processor from Sleep since the timer is
frozen during Sleep.
12.1.5USING TIMER0 WITH AN
EXTERNAL CLOCK
When Timer0 is in Counter mode, the synchronization
of the T0CKI input and the Timer0 register is
accomplished by sampling the prescaler output on the
Q2 and Q4 cycles of the internal phase clocks.
Therefore, the high and low periods of the external
clock source must meet the timing requirements as
shown in Section 25.0 “Electrical Specifications”.
12.1.6TIMER ENABLE
Operation of Timer0 is always enabled and the module
will operate according to the settings of the OPTION
register.
12.1.7OPERATION DURING SLEEP
Timer0 cannot operate while the processor is in Sleep
mode. The contents of the TMR0 register will remain
unchanged while the processor is in Sleep mode.
DS41418A-page 96Preliminary 2010 Microchip Technology Inc.
Note 1: ST Buffer is high speed type when using TxCKI.
2: Timer1/3 register increments on rising edge.
3: Synchronize does not operate while in Sleep.
4: Timer1 gate source is TimerA. Timer3 gate source is TimerB. Refer to Table 13-1.
5: Timer1 clock source is CPSAOSC. Timer3 clock source is CPSBOSC. Refer to Table 13-1.
6: Timer3 does not have a T3OSC circuit. There is no T3OSCEN bit. Timer3 can operate from T1OSC.
TxG
T1OSC
F
OSC
Internal
Clock
T1OSO/T1CKI
T1OSI
T1OSCEN
1
0
TxCKI
TMRxCS<1:0>
(1)
Synchronize
(3)
det
Sleep input
TMRxGE
0
1
00
01
10
11
From TimerA/B
From Timer2
TxGPOL
D
Q
CK
Q
0
1
TxGVAL
TxGTM
Single Pulse
Acq. Control
TxGSPM
TxGGO/DONE
TxGSS<1:0>
EN
OUT
11
10
00
00
FOSC/4
Internal
Clock
From WDT
Overflow
Match PR2
Overflow
(4)
R
DENQ
Q1
RD
TXGCON
Data Bus
det
Interrupt
TMRxGIF
Set
TxCLK
FOSC/2
Internal
Clock
D
EN
Q
TxG_IN
(6)
Cap. Sense
(5)
Oscillator A/B
PIC16F707/PIC16LF707
FIGURE 13-1:TIMER1/TIMER3 BLOCK DIAGRAM
TABLE 13-1:CPSOSC/TIMER
ASSOCIATION
Period
Measurement
Timer1CPS ATimerA
Timer3CPS BTimerB
Cap Sense
Oscillator
Divider Timer
(Gate Source)
DS41418A-page 100Preliminary 2010 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.