Note the following details of the code protection feature on Microchip devices:
•Microchip products meet the specification contained in their particular Microchip Data Sheet.
•Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
•There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
•Microchip is willing to work with the customer who is concerned about the integrity of their code.
•Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digit al Millennium Copyright Act. If suc h a c t s
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device
applications and t he lik e is provided only for your convenience
and may be su perseded by upda t es . It is y our responsibility to
ensure that your application meets with your specifications.
MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR
IMPLIED, WRITTEN OR ORAL, STATUTORY OR
OTHERWISE, RELATED TO THE INFORMATION,
INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR
FITNESS FOR PURPOSE. Microchip disclaims all liability
arising from this information and its use. Use of Microchip
devices in life supp ort and/or safety ap plications is entir ely at
the buyer’s risk, and the buyer agrees to defend, indemnify and
hold harmless M icrochip from any and all dama ges, claims,
suits, or expenses re sulting from such use. No licens es are
conveyed, implicitly or otherwise, under any Microchip
intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, K
EELOQ, KEELOQ logo, microID, MPLAB, PIC,
PICmicro, PICSTART, PRO MATE, PowerSmart, rfPIC, an d
SmartShunt are registered trademarks of Microchip
Technology Incorporated in the U.S.A. and other countries.
AmpLab, FilterLab, Linear Active Thermistor, Migratable
Memory, MX DEV, MXLAB, PS logo, SEEVAL, SmartSensor
and The Embedded Control Solutions Company are
registered trademarks of Microchip Technology Incorporated
in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, ECAN,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB,
In-Circuit Serial Programming, ICSP, ICEPIC, Mindi, MiWi,
MPASM, MPLAB Certified logo, MPLIB, MPLINK, PICkit,
PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB,
rfPICDEM, Select Mode, Smart Serial, SmartT el, Total
Endurance, UNI/O, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
Microchip received ISO/TS-16949:2002 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona, Gresham, Oregon and Mountain View, California. The
Company’s quality system processes and procedures are for its PIC
MCUs and dsPIC® DSCs, KEELOQ
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.
13.0 Data EEPROM Memory................... ......................................................................................................................................... 89
14.0 Special Features of the CPU..................................... ................................................................................................................ 95
15.0 Instruction Set Summary......................................................................................................................................................... 115
16.0 Development Support.............................................................................................................................................................. 129
18.0 DC and AC Characteristics Graphs and Tables...................................................................................................................... 149
Appendix D: Migration from Baseline to Mid-Range Devices ........................................................................................................... 168
The Microchip Web Site.................................................................................................................................................................... 169
Customer Change Notification Service ............................................................................................................................................. 169
It is our intention to provide our valued customers with t he best docume ntation possible to ensure successf ul use of your Mic rochip 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.
The PIC16F627A/628A/648A are 18-pin Flash-based
members of the versatile PIC16F627A/628A/648A
family of low-cost, high-performance, CMOS, fullystatic, 8-bit microcontrollers.
®
All PIC
architecture. The PIC16F627A/628A/648A have
enhanced core f eatures, a n eight-le vel dee p stac k, and
multiple internal and external interrupt sources. The
separate instruction and data buses of the Harvard
architecture allow a 14-bit wide instruction word with
the separate 8-bit wide data. The two-stage instruction
pipeline allows all instructions to execute in a singlecycle, except for program branche s (which require two
cycles). A to tal of 35 instruction s (reduced instr uction
set) are available, complemented by a large register
set.
PIC16F627A/628A/648A microcontrollers typically
achieve a 2:1 code compression and a 4:1 speed
improvement over other 8-bit microcontrollers in their
class.
PIC16F627A/628A/648A devices have integrated
features to reduce ex ternal com ponent s, th us redu cing
system cost, enha ncing system reliability an d re ducing
power consumption.
The PIC16F627A/628A/648A has 8 oscillator
configurations. The single-pin RC oscillator provides a
low-cost solution. The LP oscillator minimizes power
consumption, XT is a standard crystal, and INTOSC is
a self-contain ed precis ion two-spee d internal o scillator.
microcontrollers employ an advanced RISC
The HS mode is for High-Speed cryst als. The EC mode
is for an external clock source.
The Sleep (Power-down) mode offers power savings.
Users can wake-up the chip from Sleep through several
external interrupts, internal interrupts and Resets.
A highly reliable Watchdog Timer with its own on-chip
RC oscillator prov ides protection against softw are lockup.
Table 1-1 shows the features of the PIC16F627A/628A/
648A mid-range mi c r oc o n t ro l l e r f a m ily.
A simplified block diagram of the PIC16F627A/628A/
648A is shown in Figure 3-1.
The PIC16F627A/628A/648A se rie s fit s in app lic ati on s
ranging from battery chargers to low power remote
sensors. The Flash technology makes customizing
application programs (detection levels, pulse generation, timers, etc.) extremely fast and convenient. The
small footprint packages makes this microcontroller
series ideal for all applications with space limitations.
Low cost, low power, high performance, ease of use
and I/O flexibility make the PIC16F627A/628A/648A
very versatile.
1.1Development Support
The PIC16F627A/628A/648A family is supported by a
full-featured macr o assemble r , a software simulato r , an
in-circuit emul ator, a l ow c os t i n-c irc ui t d ebu gger, a l ow
cost development programmer and a full-featured
programmer. A Third Party “C” compiler support tool is
also available.
A variety of frequency ranges and packaging options
are available. Depen ding on applicati on and production
requirements, t he proper devic e option can be s elected
using the information in the PIC16F627A/628A/648A
Product Identification System, at the end of this data
sheet. When placing orders, please use this page of
the data sheet to specify the correct part number.
2.1Flash Devices
Flash devices can be erased and re-programmed
electrically. This allows the same devi ce to be used for
prototype develo pment, pil ot prog rams and prod uction.
A further advantage of t he electri cally erasab le Flash i s
that it can be erased a nd reprogrammed in-c ircuit, or by
device program mers, such as Mi crochip’s PIC START
Plus or PRO MATE® II programmers.
2.2Quick-Turnaround-Production
(QTP) Devices
PIC16F627A/628A/648A
®
Microchip offers a QTP Programming Service for
factory production orders. This service is made
available for users who chose not to program a medium
to high quantity o f un its and whose code patterns have
stabilized. T he devic es are st andard Flash dev ices, but
with all program locations and configuration options
already programmed by the factory. Certain code and
prototype verification procedures apply before
production shipments are available. Please contact
your Microchip Technology sales office for more
details.
2.3Serialized Quick-TurnaroundProduction (SQTP
Microchip offers a unique programming service where
a few user-defined locations in each device are
programmed with different serial numbers. The serial
numbers may be random, pseudo-random or
sequential.
Serial programming allows each device to have a
unique number, which can serve as an entry-code,
password or ID number.
The high performance of the PIC16F627A/628A/648A
family can be attributed to a number of architectural
features commonly fo und in RISC mic roproc esso rs. To
begin with, the PIC16F627A/628A/648A uses a
Harvard architecture in which program and data are
accessed from separate memories using separate
busses. This improves bandwidth over traditional Von
Neumann architecture where program and data are
fetched from the same memory. Separating program
and data memor y further allow s instructions to be sized
differently than 8-bit wide data word. Instruction
opcodes are 14-bits wide makin g it pos si ble to have all
single-word instructions. A 14-bit wide program memory access bus fetches a 14-bit instruction in a single
cycle. A two-stage pipeline overlaps fetch and execution of instructions. Consequently, all instructions (35)
execute in a single-cycle (200 ns @ 20 MHz) except for
program branches.
Table 3-1 lists device me mory sizes (Flash , Data and
EEPROM).
TABLE 3-1:DEVICE MEMORY LIST
Memory
Device
PIC16F627A1024 x 14224 x 8128 x 8
PIC16F628A2048 x 14224 x 8128 x 8
PIC16F648A4096 x 14256 x 8256 x 8
PIC16LF627A1024 x 14224 x 8128 x 8
PIC16LF628A2048 x 14224 x 8128 x 8
PIC16LF648A4096 x 14256 x 8256 x 8
Flash
Program
RAM
Data
EEPROM
Data
The PIC16F627A/628A/648A can directly or indirectly
address its register files or data memory. All Special
Function Registers (SFR), including the program
counter, are mapped in the data memory. The
PIC16F627A/628A/648A ha ve an orthogona l (symmetrical) instruction set that makes it possible to carry out
any operation, on any register, using any addressing
mode. This symmetrical nature and lack of ‘special
optimal situations’ makes programming with the
PIC16F627A/628A/648A simple yet efficient. In
addition, the learning curve is reduced significantly.
The PIC16F627A/628A/648A devices contain an 8-bit
ALU and working register. The ALU is a general
purpose arithmetic unit. It performs arithmetic and
Boolean functions be tween dat a in the work ing regist er
and any register file.
The ALU is 8-bits wide and capable of addition,
subtraction, shift and logical operations. Unless
otherwise me ntioned, arithmetic operations are two’s
complement in nature. In two-operand instructions,
typically one operand is the working register
(W register). The other operand is a file register or an
immediate const ant. In singl e operan d instru ction s, the
operand is either the W register or a file register.
The W register is an 8-bit workin g register used for ALU
operations. It is not an addressable register.
Depending on the instruction executed, the ALU may
affect the values of the Carry (C), Digit Carry (DC), and
Zero (Z) bits in the Status Register. The C and DC bits
operate as Borrow
respectively, in sub tractio n. See th e SUBLW and SUBWF
instructions for examples.
A simplified block diagram is shown in Figure 3-1, and
a description of the device pins in Table 3-2.
Two types of data memory are provided on the
PIC16F627A/628A/648A devices. Nonvolatile
EEPROM data memory is provided for long term
storage of data, such as calibration values, look-up
table data, and any other data which may require
periodic updating in the field. These data types are not
lost when power is removed. The other data memory
provided is regular RAM data memory. Regular RAM
data memory is provi de d for tempo r ary sto rage of data
during normal operation. Data is lost when power is
removed.
The clock input (RA7/OSC1/CLKIN pin) is internally
divided by four to generate four non-overlapping
quadrature clocks namely Q1, Q2, Q3 and Q4.
Internally, the Program Counter (PC) is incremented
every Q1, the instruction is fetched from the program
memory and latched into the instruction register in Q4.
The instruction is decoded and executed during the
following Q1 through Q4. The clocks and instruction
execution flow is shown in Figure 3-2.
FIGURE 3-2:CLOCK/INSTRUCTION CYCLE
OSC1
Q1
Q2
Q3
Q4
PC
CLKOUT
Q1
Q2Q3Q4
PCPC + 1PC + 2
Fetch INST (P C )
Execute INST (PC - 1)Fetch INST (PC + 1)
Q1
Q2Q3Q4
Execute INST (PC)Fetch INST (PC + 2)
3.2Instruction Flow/Pipelining
An instruction cycle consists of four Q cycles (Q1, Q2,
Q3 and Q4). The instruction fetch and execute are
pipelined such that fetch takes one instruction cycle
while decode and execute takes another instruction
cycle. However, due to the pipelining, each instruction
effectively executes in one cycle. If an instruction
causes the program counter to change (e.g., GOTO)
then two cycles are req uired to c omplete the ins truction
(Example 3-1).
A fetch cycle begins with the program counter
incrementing in Q1.
In the execution cy cle, the fetch ed instruction i s latched
into the Instruction Register (IR) in cycle Q1. This
instruction is then decoded and executed during the
Q2, Q3 and Q4 c ycles. Dat a m emory is read during Q2
(operand read) and written during Q4 (destination
write).
Q1
Q2Q3Q4
Execute INST (PC + 1)
Interna
phase
clock
EXAMPLE 3-1:INSTRUCTION PIPELINE FLOW
1. MOVLW 55hFetch 1Execute 1
2. MOVWF PORTBFetch 2Execute 2
3. CALL SUB_1Fetch 3Execute 3
4. BSF PORTA, 3Fetch 4
Note:All instructions are single cycle except for an y program branches. The se take two cycles since the fetch
instruction is “flushed” from th e pi peline while the new instruct io n is bei ng fetched and then execu t ed.
The PIC16F627A/628A/648A has a 13-bit program
counter capable of addressing an 8K x 14 program
memory space. Only the first 1K x 14 (0000h-03FFh)
for the PIC16F627A, 2K x 14 (0000h-07FFh) for the
PIC16F628A and 4Kx 14 (0000h-0FFFh) for the
PIC16F648A are physically implemented. Accessing a
location above these boundaries will cause a wraparound within the first 1K x 14 space (PIC16F627A),
2K x 14 space (PIC16F628A) or 4K x 14 space
(PIC16F648A). The Reset vector is at 0000h and the
interrupt vector is at 0004h (Figure 4-1).
FIGURE 4-1:PROGRAM MEMORY MAP
AND STACK
PC<12:0>
CALL, RETURN
RETFIE, RETLW
Stack Level 1
Stack Level 2
13
4.2Data Memory Organization
The data memory (Figure 4-2 and Figure 4-3) is
partitioned into four banks, which contain the General
Purpose Registers (GPRs) and the Special Function
Registers (SFRs). The SFRs are located in the first 32
locations of each bank. There are General Purpose
Registers implemented as static RAM in each bank.
Table 4-1 lists the General Purpose Register available
in each of the four banks.
Addresses F0h-FFh, 170h-17Fh and 1F0h-1FFh are
implemented as common RAM and mapped back to
addresses 70h-7Fh.
T abl e 4-2 lists how to acces s the four banks of regis ters
via the Status register bits RP1 and RP0.
Stack Level 8
Reset Vector
Interru pt Vector
On-chip Program
Memory
PIC16F627A,
PIC16F628A and
PIC16F648A
On-chip Program
Memory
PIC16F628A and
PIC16F648A
On-chip Program
Memory
PIC16F648A only
000h
0004
0005
03FFh
07FFh
0FFFh
TABLE 4-2:ACCESS TO BANKS OF
REGISTERS
BankRP1RP0
000
101
210
311
4.2.1GENERAL PURPOSE REGISTER
FILE
The register file is organized as 224 x 8 in the
PIC16F627A/628A and 256 x 8 in the PIC16F648A.
Each is accessed either directly or indirectly through
the File Select Register (FSR), See Section 4.4“Indirect Addressing, INDF and FSR Registers”.
The SFRs are registers used by the CPU and Peripheral functions for controlling the desired operation of
the device (Table4-3). These registers are st a tic RAM.
The special registers can be classified into two sets
(core and peripheral). The SFRs associated with the
“core” functions are described in this section. Those
related to the operation of the peripheral features are
described in the section of that peripheral feature.
TABLE 4-3:SPECIAL REGISTERS SUMMARY BANK0
AddressNameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2 Bit 1Bit 0
Bank 0
00hINDFAddressing this location uses contents of FSR to address data memory (not a physical register)xxxx xxxx28
01hTMR0Timer0 Module’s Registerxxxx xxxx45
02hPCLProgram Counter’s (PC) Least Significant Byte0000 000028
03hSTATUSIRPRP1RP0TO
04hF SRIndirect Data Memory Ad dr ess Pointerxxxx xxxx28
05hPORTA
06hPORTBRB7RB6RB5RB4RB3RB2RB1RB0xxxx xxxx36
07h—Unimplemented——
08h—Unimplemented——
09h—Unimplemented——
0AhPCLATH———Write Buffer for upper 5 bits of Program Counter---0 000028
0BhINTCONGIE PEIET0IEINTERBIET0IFINTFRBIF0000 000x24
0ChPIR1
0Dh—Unimplemented——
0EhTMR1LHolding Register for the Least Significant Byte of the 16-bit TMR1 Registerxxxx xxxx48
0FhTMR1HHolding Register for the Most Significant Byte of the 16-bit TMR1 Registerxxxx xxxx48
Legend: - = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
Legend:- = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
register)
INTEDGT0CST0SEPSAPS2PS1PS01111 111123
PDZDCC0001 1xxx22
———Write Buffer for upper 5 bits of Program Counter---0 000028
Legend:- = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented.
Note 1:For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
Timer0 Module’s Registerxxxx xxxx
PDZDCC0001 1xxx22
———Write Buffer for upper 5 bits of Program Counter---0 000028
Legend:- = Unimplemented locations read as ‘0’, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1:For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
INTEDGT0CST0SEPSAPS2PS1PS01111 111123
PDZDCC0001 1xxx22
———Write Buffer for upper 5 bits of Program Counter---0 000028
The St atus register , s hown in Register4-1, contains th e
arithmeti c statu s of th e ALU; the Re set sta tus an d 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 bit s are set or cleared ac cording to the
device logic. Further more, the T O
writable. Therefore, the result of an instruction with the
Status register as destination may be different than
intended.
and PD bits are non-
For example, CLRF STATUS will clear the upper-three
bits and set the Z bit. This leaves the Status register
as “000uu1uu” (where u = unchanged).
It is recommended, therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
Stat us register be cause the se instruct ions do not af fect
any Status bit. For other instructions, not affecting any
Status bits, see the “Instruction Set Summary”.
Note:The C and DC bits operate as a Borrow
and Digit Borrow out bit, respectively, in
subtraction. See the SUBLW and SUBWF
instructions for examples.
REGISTER 4-1:STATUS – STATUS REGISTER (ADDRESS: 03h, 83h, 103h, 183h)
R/W-0R/W-0R/W-0R-1R-1R/W-xR/W-xR/W-x
IRPRP1RP0TO
bit 7bit 0
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/Bo
bit 0C: Carry/Bo
: Time Out bit
1 = After power-up, CLRWDT instruction or SLEEP instruction
0 = A WDT time out occurred
: Power-down bit
1 = After power-up or 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
rrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) (for Borrow the polarity
is reversed)
1 = A carry-out from the 4th low order bit of the result occurred
0 = No carry-out from the 4th low order bit of the result
rrow 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
Note:For Bo
rrow, the polarity is reversed. A subtraction is executed by adding the two’s
complement of the second operand. For rotate (RRF, RLF) instructions, this bit is
loaded with either the high or low order bit of the source register.
PDZDCC
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
The Option register is a readable and writable register,
which contains various control bits to configure the
TMR0/WDT prescaler, the external RB0/INT interrupt,
TMR0 and the weak pull-ups on PORTB.
The INTCON register is a readable and writable
register , which c ontains the various en able and fl ag bit s
for all interrupt so urces excep t th e comp arator mo dule.
See Section 4.2.2.4 “PIE1 Register” and
Section 4.2.2.5 “PIR1 Register” for a description of
the comparator enable and flag bits.
Note:Interrupt flag bits get set when an interrupt
condition occurs regard less of the sta te of
its corresponding enable bit or the global
enable bit, GIE (INTCON<7>).
Note:Interrupt flag bits get set when an interrupt
condition occurs regardle ss of the sta te of
its corresponding enable bit or the global
enable bit, GIE (INTCON<7>). User
software should ensure the appropriate
interrupt flag bits are clear prior to
enabling an interrupt.
The PCON register contains flag bits to differentiate
between a Power-on Reset, an external MCLR
WDT Reset or a Brown-out Reset.
Reset,
Note:BOR is unknown on Power-on Reset. It
must then be set by the us er an d c hec ke d
on subsequent Resets to see if BOR is
cleared, indicating a brown-out has
occurred. T he BOR Status bit is a “don’t
care” and is not necessarily predictable if
the brown-out circuit is disabled (by
clearing the BOREN bit in the
Configuration Word).
REGISTER 4-6:PCON – POWER CONTROL REGISTER (ADDRESS: 8Eh)
U-0U-0U-0U-0R/W-1U-0R/W-0R/W-x
————OSCF—PORBOR
bit 7bit 0
bit 7-4Unimplemented: Read as ‘0’
bit 3OSCF: INTOSC Oscillator Frequency bit
1 = 4 MHz typical
0 = 48 kHz typical
bit 2Unimplemented: Read as ‘0’
bit 1POR
bit 0BOR
: Power-on Reset Status bit
1 = No Power-on Reset occurred
0 = A Power-on Reset occurred (must be set in software after a Power-on Reset occurs)
: Brown-out Reset Status bit
1 = No Brown-out Reset occurred
0 = A Brown-out Reset occurred (must be set in software after a Brown-out Reset occurs)
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
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 wri table and comes from PCLATH.
On any Reset, the PC is c leared. Figure 4-4 shows the
two situations for loading the PC. The upper example
in Figure 4-4 shows how the PC is loaded o n a w rite to
PCL (PCLATH<4:0> → PCH). The lower example in
Figure 4-4 shows how the PC is loaded during a CALL
or GOTO instruction (PCLATH<4:3> → PCH).
FIGURE 4-4:LOADING OF PC IN
DIFFERENT SITUATIONS
PCHPCL
128 70
PC
PCLATH<4:0>
5
PCLATH
PCHPCL
12 11 100
PC
2
87
PCLATH<4:3>
PCLATH
11
8
Instruction with
PCL as
Destination
ALU result
GOTO, CALL
Opcode <10:0>
The stack operat es as a circular buf fer . This means th at
after the stack has been PUSHed eight times, the ninth
PUSH overwrites the value that was stored from the
first PUSH. The tenth PUSH overwrites the second
PUSH (and so on).
Note 1: There are no Status bits to indicate stack
overflow or stack underflow conditions.
2: There are no instructions/mnemonics
called PUSH or POP. These are actions
that occur from the execution of the
CALL, RETURN, RETLW and RETFIE
instructions, or the vectoring to an
interrupt address.
4.4Indirect Addressing, INDF and
FSR Registers
The INDF register is not a physica l register . Addr essing
the INDF register will cause indirect addressing.
Indirect addressing is possible by using the INDF
register. Any instruction using the INDF register
actually accesses data pointed to by the File Select
Register (FSR). Reading INDF itself indirectly will
produce 00h. Writing to the INDF register indirectly
results in a no-operation (although Status bits may be
affected). An effective 9-bit address is obtained by
concatenating the 8-bit FSR register and the IRP bit
(STATUS<7>), as shown in Figure 4-5.
A simple program to clear RAM location 20h-2Fh using
indirect addressing is shown in Example 4-1.
4.3.1COMPUTED GOTO
A computed GOTO is accomplish ed by adding an offs et
to the progr am counter (ADDWF PCL). When doing a
table read using a computed GOTO method, care
should be exercise d i f the t able loca tio n cros ses a PCL
memory boundary (each 256-byte block). Refer to the
Application Note AN556 “Implementing a Table Read”
(DS00556).
4.3.2STACK
The PIC16F627A/628A/648A family has an 8-level
deep x 13-bit wide hardware stack (Figure 4-1). The
stack space i s no t p art o f eith er pro gram or da t a space
and the Stack Pointer is not readabl e or writable . The
PC is PUSHed onto the stack when a CALL instruction
is executed or an interrupt causes a b ranch. The stack
is POPed in the event of a RETURN, RETLW or a
RETFIE instruction exec uti on. PCLATH is not affect ed
by a PUSH or POP operation.
EXAMPLE 4-1:INDIR ECT ADDRESSING
MOVLW0x20;initialize pointer
MOVWFFSR;to RAM
NEXTCLRFINDF;clear INDF register
INCFFSR;inc pointer
BTFSSFSR,4;all done?
GOTONEXT;no clear next