Professional Documents
Culture Documents
Data Sheet
Flash-Based, 8-Bit CMOS
Microcontrollers with nanoWatt Technology
DS40044G
DS40044G-page 2
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 Microchips
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 Microchips 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.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC,
KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART,
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, PIC32 logo, 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.
2009, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
PIC16F627A/628A/648A
18-pin Flash-Based, 8-Bit CMOS Microcontrollers
with nanoWatt Technology
High-Performance RISC CPU:
Low-Power Features:
Standby Current:
- 100 nA @ 2.0V, typical
Operating Current:
- 12 A @ 32 kHz, 2.0V, typical
Low-voltage programming
Brown-out Reset
Power-on Reset
Peripheral Features:
Device
PIC16F62
7A
PIC16F62
8A
PIC16F64
Progra
m
Memor
Flash
(words
)
1024
2048
4096
8A
2009 Microchip Technology Inc.
Data Memory
SRAM
(bytes)
224
224
256
EEPRO
M
(bytes)
128
128
256
I/
O
1
6
1
6
1
CC
P
(PW
M)
1
1
1
USA
RT
Comparato
rs
Y
Y
2
2
Time
rs
8/16bit
2/1
2/1
2/1
6
DS40044G-page 3
PIC16F627A/628A/648A
Pin
Diagrams
PDIP, SOIC
2
3
4
VSS
RB0/INT
RB1/RX/DT
RB2/TX/CK
RB3/CCP1
1
8
27A 1
7
/ 1
628
A 6
1
/
64
8A 5
1
4
1
3
1
2
1
1
1
28
-Pi
RA0/AN0 RA7/OSC1/CLKIN
19RA1/AN1
20
RA1/AN1
RA0/AN0
PIC16F627A/628A/648A
RA3/AN3/CMP
1
RA4/T0CKI/CM
P2
RA5/MCLR/VPP
RA7/OSC1/CLKIN
RA6/OSC2/CLKOUT
VDD
RB7/T1OSI/PGD
RB6/T1OSO/T1CKI/PGC
RB5
RB4/PGM
FN
N
C
RB0/INT
N
C
NC
NC
RA1/AN1 RA0/AN0
21
20
19
PIC16F627A/628A
4
PIC16F648A
18
5
6
16
17
7
15
9
VSS
1
2
3
NC 14
VSS
N
C
RB4/PGM
NC 11
RA5/MCLR/
VPP
10
PIC16F627A/628A/648A
28
RA3/AN3/CMP1
RA2/AN2/VREF
RB1/RX/DT 8RA4/T0CKI/CMP2 27
RB2/TX/CK RB3/CCP1
2 1
SSOP
RA2/AN2/VREF
RA7/OSC1/CLKIN
RA6/OSC2/CLKOUT
VDD
N
C
VDD
RB7/T1OSI/PGD
RB6/T1OSO/T1CKI/P
Table of Contents
1.0 General Description............................................................................................................................................................................7
2.0 PIC16F627A/628A/648A Device Varieties.........................................................................................................................................9
3.0 Architectural Overview......................................................................................................................................................................11
4.0 Memory Organization.......................................................................................................................................................................17
5.0 I/O Ports............................................................................................................................................................................................33
6.0 Timer0 Module..................................................................................................................................................................................47
7.0 Timer1 Module..................................................................................................................................................................................50
8.0 Timer2 Module..................................................................................................................................................................................54
9.0 Capture/Compare/PWM (CCP) Module...........................................................................................................................................57
10.0 Comparator Module........................................................................................................................................................................63
11.0 Voltage Reference Module..............................................................................................................................................................69
12.0 Universal Synchronous Asynchronous Receiver Transmitter (USART) Module............................................................................73
13.0 Data EEPROM Memory..................................................................................................................................................................91
14.0 Special Features of the CPU..........................................................................................................................................................97
15.0 Instruction Set Summary...............................................................................................................................................................117
16.0 Development Support...................................................................................................................................................................131
17.0 Electrical Specifications................................................................................................................................................................135
18.0 DC and AC Characteristics Graphs and Tables...........................................................................................................................151
19.0 Packaging Information..................................................................................................................................................................163
Appendix A: Data Sheet Revision History............................................................................................................................................171
Appendix B: Device Differences...........................................................................................................................................................171
Appendix C: Device Migrations............................................................................................................................................................172
Appendix D: Migrating from other PIC Devices..................................................................................................................................172
The Microchip Web Site........................................................................................................................................................................173
Customer Change Notification Service.................................................................................................................................................173
Customer Support.................................................................................................................................................................................173
Reader Response.................................................................................................................................................................................174
Product Identification System...............................................................................................................................................................179
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:
Microchips 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.
DS40044G-page 5
NOTES:
1.1
GENERAL DESCRIPTION
1.2
TABLE 1-1:
Clock
Memory
PIC16F64
PIC16LF62
PIC16LF628A
8A
7A
20
20
1024
20
2048
20
4096
20
1024
2048
4096
224
224
256
224
224
256
128
128
256
128
128
256
TMR0,
TMR1,
TMR2
2
TMR0,
TMR1,
TMR2
2
TMR0,
TMR1,
TMR2
2
TMR0,
TMR1,
TMR2
2
TMR0,
TMR1,
TMR2
2
TMR0,
TMR1,
TMR2
2
Capture/Compare/
PWM modules
Serial
Communications
Internal Voltage
Reference
USART
USART
USART
USART
USART
USART
Yes
Yes
Yes
Yes
Yes
Yes
Interrupt Sources
10
10
10
10
10
10
I/O Pins
16
16
16
16
16
16
3.0-5.5
3.0-5.5
3.0-5.5
2.0-5.5
2.0-5.5
2.0-5.5
Yes
Yes
Yes
Yes
Yes
Comparator(s)
Features
PIC16F627
A
20
8A
Maximum
Frequency of
Operation (MHz)
Flash
Program
Memory
RAM Data
Memory (bytes)
EEPROM
Data
Memory
Timer module(s)
Peripher
als
Development Support
Voltage Range
(Volts)
Brown-out Reset
Packages
18-pin
18-pin
18-pin
18-pin
18-pin
DIP,
DIP,
DIP,
DIP,
DIP,
SOIC,
SOIC,
SOIC,
SOIC,
SOIC,
20-pin
20-pin
20-pin
20-pin
20-pin
SSOP,
SSOP,
SSOP,
SSOP,
SSOP,
All PIC family devices have Power-on Reset, selectable Watchdog Timer, selectable code-protect and high I/O current capability.
All PIC16F627A/628A/648A family devices use serial programming with clock pin RB6 and data pin RB7.
Yes
18-pin
DIP,
SOIC,
20-pin
SSOP,
NOTES:
2.0
PIC16F627A/628A/648A
DEVICE VARIETIES
2.1
Flash Devices
2.2
Quick-Turnaround-Production
(QTP) Devices
2.3
NOTES:
DS40044G-page 10
3.1
ARCHITECTURAL OVERVIEW
TABLE 3-1:
Device
PIC16F627A
Flas
h
Progra
1024 x 14
PIC16F628A
2048 x 14
PIC16F648A
4096 x 14
PIC16LF627
A
PIC16LF628
A
PIC16LF648
A
1024 x 14
2048 x 14
4096 x 14
Memo
ry
RA
M
Data
224 x
8 x
224
8
256 x
8
224 x
8
224 x
8
256 x
8
EEPRO
M
Data
128 x 8
128 x 8
256 x 8
128 x 8
128 x 8
256 x 8
FIGURE 3-1:
BLOCK DIAGRAM
13
Bus
Program Data
Counter
Program
Bus
14
PORTA
Addr MUX
RA0/AN0
RA1/AN1 RA2/AN2/VREF RA3/AN3/CMP1 RA4/T0CK1/CMP2 RA5/MCLR/VPP RA6/OSC2/CLKOUT RA7/OSC1/CLKIN
Indirect
8Addr
FSR Reg
Instruction Reg
Direct Addr7
Status Reg
8
3
PORTB
RB0/INT
RB1/RX/DT RB2/TX/CK RB3/CCP1 RB4/PGM RB5
RB6/T1OSO/T1CKI/PGC RB7/T1OSI/PGD
MUX
Timing Generation
OSC1/CLKIN OSC2/CLKOUT
MCLR
Comparator
VREF
Note
Timer0
CCP1
VDD, VSS
Power
ALU
-up
Tim
8
Oscillato
r Start-up
Timer
Power
-on
Res
Watchdo
g
Timer
Brownout
Res
LowVoltage
Programmi
Timer1
USART
W Reg
Timer2
Data EEPROM
DS40044G-page 12
TABLE 3-2:
RA0/AN0
Na
me
RA1/AN1
RA2/AN2/VREF
RA3/AN3/CMP1
RA4/T0CKI/CMP2
RA5/MCLR/VPP
RA6/OSC2/CLKOUT
Functio
n
RA0
AN0
Input
Type
ST
AN
Output
Type
CMOS
Descripti
on
Bidirectional I/O port
Analog comparator input
RA1
ST
CMOS
AN1
AN
RA2
ST
CMOS
AN2
AN
VREF
AN
VREF output
RA3
ST
CMOS
AN3
AN
CMP1
CMOS
Comparator 1 output
RA4
ST
OD
T0CKI
ST
CMP2
OD
Comparator 2 output
RA5
ST
Input port
MCLR
ST
VPP
RA6
ST
CMOS
OSC2
XTAL
CLKOUT
CMOS
RA7/OSC1/CLKIN
RB0/INT
RA7
ST
CMOS
OSC1
XTAL
CLKIN
ST
RB0
TTL
CMOS
RB2/TX/CK
RB3/CCP1
Legend:
TTL
= Output
= Not
used
=
TTL
Input
INT
ST
RB1
TTL
CMOS
External interrupt
RX
ST
DT
ST
CMOS
RB2
TTL
CMOS
TX
CMOS
CK
ST
CMOS
RB3
TTL
CMOS
CCP1
ST
CMOS
Capture/Compare/PWM I/O
CM
IOS
OD
= CMOS Output
= Input
= Open Drain Output
P = Power
ST = Schmitt Trigger Input
AN = Analog
TABLE 3-2:
Input
Type
TTL
Output
Type
CMOS
PGM
ST
RB5
RB5
TTL
CMOS
RB6/T1OSO/T1CKI/PG
C
RB6
TTL
CMOS
T1OSO
XTAL
T1CKI
ST
RB4/PGM
Na
me
RB7/T1OSI/PGD
VSS
VDD
Legend:
TTL
PGC
ST
RB7
TTL
CMOS
T1OSI
XTAL
PGD
ST
CMOS
VSS
Power
Power
VDD
= Output
= Not
used
=
TTL
Input
Descripti
on
Bidirectional I/O port. Interrupt-on-pin
change. Can be software programmed for
internal weak pull-up.
Low-voltage programming input pin.
When low-voltage programming is
enabled, the interrupt-on-pin change
and weak pull-up resistor are disabled.
CM
IOS
OD
= CMOS Output
= Input
= Open Drain Output
P = Power
ST = Schmitt Trigger Input
AN = Analog
3.2
Clocking Scheme/Instruction
Cycle
3.3
Instruction Flow/Pipelining
FIGURE 3-2:
Q1
CLOCK/INSTRUCTION CYCLE
Q2Q3
Q4
Q2Q3
Q1
Q4
Q2Q3
Q1
Q4
OSC1
Q1 Q2 Q3 Q4 PC
CLKOUT
Internal phase clock
PC
Fetch INST
Execute INST (PC 1)
EXAMPLE 3-1:
MOVLW 55h
MOVWF PORTB
CALLSUB_1
BSFPORTA, 3
PC + 1
PC + 2
Execute
1
Fetch 2
Execute
2
Fetch 3
Execute
3
Fetch 4
Flush
Fetch
SUB_1
Execute
SUB_1
Note:All instructions are single cycle except for any program branches. These take two cycles since the fetch
instruction is flushed from the pipeline while the new instruction is being fetched and then executed.
NOTES:
4.1
MEMORY ORGANIZATION
4.2
FIGURE 4-1:
CALL, RETURN
RETFIE, RETLW
TABLE 4-1:
Bank0
Bank1
20-7Fh
A0h-FF
Bank2
120h-14Fh, 170h17Fh
1F0h-1FFh
Bank3
PIC16F64
8A
20-7Fh
A0h-FF
120h-17Fh
1F0h1FFh
Addresses F0h-FFh, 170h-17Fh and 1F0h-1FFh are
implemented as common RAM and mapped back to
addresses 70h-7Fh.
PC<12:0>
13
Stack Level 1
Stack Level 2
Stack Level 8
Reset Vector
4.3
TABLE 4-2:
000h
Interrupt Vector
0004
On-chip Program Memory
0005
PIC16F627A, PIC16F628A and PIC16F648A
4.3.1
03FFh
On-chip Program Memory
PIC16F628A and PIC16F648A
07FFh
On-chip Program
Memory
PIC16F648A only
0FFFh
1FFFh
ACCESS TO BANKS OF
REGISTERS
Ba
nk
0
1
R
P
0
0
RP0
0
1
FIGURE 4-2:
(1)
100h
101h
Indirect
addr.(1)
OPTION
180h
81h
Indirect
(1)
addr.
TMR0
TMR0
01h
Indirect
addr.(1)
OPTION
P
C
STATUS
02h
PCL
82h
PCL
102h
PCL
182h
03h
STATUS
83h
STATUS
103h
STATUS
183h
FSR
104h
FSR
184h
Indirect addr.
00h
80h
F
S
PORTA
04h
FSR
84h
05h
TRISA
85h
PORTB
06h
07h
08h
09h
86h
87h
187h
88h
108h
188h
89h
109h
PCLATH
18Ah
0Bh
8Bh
INTCON
10Bh
INTCON
18Bh
0Ch
PIE1
8Ch
10Ch
18Ch
8Dh
10Dh
18Dh
8Eh
10Eh
18Eh
10Fh
18Fh
0Dh
0Eh
PCON
0Fh
8Fh
10h
90h
TMR2
11h
T2CON
12h
91h
92h
PR2
13h
93h
14h
94h
CCPR1L
15h
95h
CCPR1H
16h
96h
CCP1CON
17h
RCSTA
18h
TXSTA
98h
TXREG
19h
99h
RCREG
1Ah
SPBRG
EEDATA
1Bh
EEADR
9Bh
1Ch
EECON1
9Ch
1Dh
EECON2(1)
9Dh
97h
1Eh
1Fh
6Fh
70h
7Fh
9Ah
9Eh
VRCON
20h
Bank 0
16 Bytes
189h
10Ah
T1CON
80 Bytes
186h
107h
TMR1H
Gen
eral
Purp
ose
Regi
ster
185h
TRISB
PCLATH
INTCON
CMCON
106h
8Ah
0Ah
TMR1L
PORTB
PCLATH
INTCON
PCLATH
PI
R
TRISB
105h
181h
9Fh
A0h
Gen
eral
Purp
ose
Regis
ter 80
Bytes
EFh
F0h
acces
ses
70hBank 1
FFh
ead as 0.
Gen
eral
Purp
ose
Regis
acces
ses
70hBank 2
11Fh
120h
14Fh
150h
16Fh
170h
17Fh
1EFh
1F0h
acces
ses
70hBank 3
1FFh
FIGURE 4-3:
Indirect addr.
(1)
TM
R0
PCL
STATUS
00h
01h
02h
03h
FSR
04h
POR
TA
POR
05h
TB
07h
08h
09h
06h
PCLATH
0Ah
INTCON
0Bh
PIR1
0Ch
(1)
100h
Indirect
addr.(1)
OPTION
180h
101h
OPTION
81h
Indirect
(1)
addr.
TMR0
P
C
STATUS
82h
PCL
102h
PCL
182h
83h
STATUS
103h
STATUS
183h
F
S
TRISA
84h
FSR
104h
FSR
184h
Indirect addr.
TRISB
80h
105h
85h
86h
PORTB
106h
87h
187h
88h
108h
188h
89h
109h
PCLATH
10Ah
PCLATH
18Ah
INTCON
8Bh
INTCON
10Bh
INTCON
18Bh
PI
8Ch
10Ch
18Ch
8Dh
10Dh
18Dh
18Eh
18Fh
8Eh
8Fh
10Fh
10h
90h
ON
TM
R2
T2C
11h
91h
ON
13h
PCON
P
R
92h
93h
14h
94h
CCPR1L
15h
95h
CCPR1H
16h
96h
CCP1CON
17h
97h
RCS
TA
TXR
18h
TXSTA
98h
19h
1Ah
SPBRG
EEDATA
99h
EG
RCREG
1Bh
EEADR
9Bh
1Ch
EECON1
9Ch
1Dh
EECON2(1
9Dh
1Eh
CMCON
1Fh
80 Bytes
6Fh
70h
7Fh
16Ban
Bytes
k0
9Ah
9Eh
VRCON
20h
Gen
eral
Purp
ose
Regi
ster
189h
8Ah
0Fh
12h
186h
107h
10Eh
TMR
1L
TMR
1H
T1C
185h
TRISB
PCLATH
0Dh
0Eh
181h
9Fh
11Fh
120h
A0h
Gen
eral
Purp
ose
Regis
ter 80
Bytes
acces
ses
70hBank 1
EFh
F0h
FFh
Gen
eral
Purp
ose
Regis
ter 80
Bytes
acces
ses
70hBank 2
16Fh
170h
17Fh
1EFh
1F0h
acces
ses
70hBank 3
1FFh
4.3.2
The SFRs are registers used by the CPU and Peripheral functions for controlling the desired operation of
the device (Table 4-3). These registers are static
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:
Addre
ss
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Bank 0
Value
on
POR
Reset(1
Deta
ils
on
00h
INDF
01h
TMR0
Addressing this location uses contents of FSR to address data memory (not a physical
register)
Timer0 Modules Register
02h
PCL
03h
STATUS
IRP
04h
FSR
05h
PORTA
RA7
RA6
RA5
06h
PORTB
RB7
RB6
RB5
07h
Unimplemented
xxxx
xxxx
xxxx
xxxx
0000
0000
0001
1xxx
xxxx
xxxx
xxxx
0000
xxxx
xxxx
08h
Unimplemented
09h
Unimplemented
0Ah
PCLATH
30
0Bh
INTCON
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0Ch
PIR1
RCIF
TXIF
0Dh
EEI
CMIF
F
Unimplemented
CCP1I
F
TMR2I
F
TMR1I
F
---0
0000
0000
000x
0000
-000
0Eh
TMR1L
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
0Fh
TMR1H
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
10h
T1CON
11h
TMR2
12h
T2CON
13h
TOUTP
S3
Unimplemented
14h
Unimplemented
15h
CCPR1L
16h
18h
CCPR1
H
CCP1C
ON
RCSTA
19h
RP1
RP0
DC
RA4
RA3
RA2
RA1
RA0
RB4
RB3
RB2
RB1
RB0
TO
T1CKP
S1
T1CKP
S0
T1OSC
EN
T1SY
NC
TMR1
CS
TMR1
ON
TOUTP
S2
TOUTP
S1
TOUTP
S0
TMR2
ON
T2CK
PS1
T2CK
PS0
PD
xxxx
xxxx
xxxx
xxxx
--00
0000
0000
0000
-000
0000
30
47
30
24
30
33
38
26
28
50
50
50
54
54
57
CCP1X
CCP1Y
SPE
RX9
SREN
N
USART Transmit Data Register
CREN
TXREG
1Ah
RCREG
1Bh
Unimplemented
xxxx
xxxx
xxxx
xxxx
--00
0000
0000
000x
0000
0000
0000
0000
1Ch
Unimplemented
1Dh
Unimplemented
1Eh
Unimplemented
1Fh
CMCON
17h
Legend:
Note 1:
CCP1
M3
ADEN
CCP1
M2
FERR
CCP1
M1
OERR
CCP1
M0
RX9D
57
57
74
79
82
C2O
C1OUT
C2INV
C1INV
CIS
CM2
CM1
CM0
63
0000
0000
UT
- = Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
DS40044G-page 20
TABLE 4-4:
Addre
ss
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Bank 1
80h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical
register)
81h
OPTION
82h
PCL
INTE
T0CS
T0SE
RBPU
DG
Program Counters (PC) Least Significant Byte
83h
STATUS
84h
FSR
85h
TRISA
86h
TRISB
IRP
RP1
PSA
PS2
PS1
PS0
TO
PD
DC
TRISA
4
TRISB
4
TRISA
3
TRISB
3
TRIS
A2
TRIS
B2
TRIS
A1
TRIS
B1
TRIS
A0
TRIS
B0
RP0
Deta
ils
on
xxxx
xxxx
30
1111
1111
0000
0000
0001
1xxx
xxxx
xxxx
1111
1111
1111
1111
25
30
24
30
87h
TRISA
TRIS
7
A6
TRISB
TRIS
7
B6
Unimplemented
88h
Unimplemented
89h
Unimplemented
8Ah
PCLATH
30
8Bh
INTCON
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
8Dh
CCP
1IE
TMR
2IE
TMR
1IE
---0
0000
0000
000x
0000
-000
POR
BOR
8Eh
Unimplemented
OSCF
38
26
27
Unimplemented
---- 10x
29
90h
Unimplemented
91h
Unimplemented
54
PR2
33
8Fh
92h
PCON
TRISA
5
TRISB
5
Value
on
POR
Reset(1
93h
Unimplemented
1111
1111
94h
Unimplemented
95h
Unimplemented
96h
Unimplemented
97h
Unimplemented
0000
-010
0000
0000
xxxx
xxxx
xxxx
xxxx
---x000
------
73
98h
TXSTA
CSRC
99h
SPBRG
9Ah
EEDATA
9Bh
EEADR
9Ch
EECON1
9Dh
EECON2
9Eh
9Fh
VRCON
Legend:
Note 1:
TX9
TXEN
VREN
WRE
RR
EEPROM Control Register 2 (not a physical register)
Unimplemented
SYNC
BRG
H
WRE
N
TRM
T
WR
TX9
D
RD
75
91
92
92
92
VRO
VRR
VR3
VR2
VR1
VR0
69
0000000
E
- = Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
TABLE 4-5:
Addre
ss
Bit 7
Bank 2
Bi
t
6
Bit 5
Bit
4
Bit
3
Bit 2
Bit 1
Bit 0
100h
INDF
101h
TMR0
Addressing this location uses contents of FSR to address data memory (not a physical
register)
Timer0 Modules Register
102h
PCL
103h
STATUS
104h
FSR
IRP
R
RP0
TO
P
Indirect Data Memory Address Pointer
105h
106h
PORTB
107h
R
B
Unimplemented
108h
109h
10Ah
PCLATH
10Bh
INTCON
10Ch
GIE
P
EI
Unimplemented
10Dh
10Eh
PD
DC
Unimplemented
RB1
RB0
24
30
Unimplemented
---0
0000
0000
000x
30
26
Unimplemented
Unimplemented
10Fh
Unimplemented
110h
Unimplemented
111h
Unimplemented
112h
Unimplemented
113h
Unimplemented
114h
Unimplemented
115h
Unimplemented
116h
Unimplemented
117h
Unimplemented
118h
Unimplemented
119h
Unimplemented
11Ah
Unimplemented
11Bh
Unimplemented
11Ch
Unimplemented
11Dh
Unimplemented
11Eh
Unimplemented
11Fh
Unimplemented
T0IE
RB2
30
RB3
47
Unimplemented
RB4
30
38
RB5
xxxx
xxxx
xxxx
xxxx
0000
0000
0001
1xxx
xxxx
xxxx
Deta
ils
on
xxxx
xxxx
Legend:
Note 1:
RB7
Value
on
POR
Reset(1
RBI
E
T0IF
INTF
RBIF
- = Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented.
For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
DS40044G-page 22
TABLE 4-6:
Addre
ss
Bit 7
Bit 6
Bit
5
Bit
4
Bit 3
Bit 2
Bit 1
Bit 0
Bank 3
180h
INDF
181h
OPTION
182h
PCL
183h
STATUS
184h
FSR
185h
186h
IRP
RP1
RP0
TO
PD
DC
Unimplemented
189h
Unimplemented
18Ah
PCLATH
30
18Bh
INTCON
18Ch
Unimplemented
---0
0000
0000
000x
18Dh
Unimplemented
18Eh
Unimplemented
18Fh
Unimplemented
190h
Unimplemented
191h
Unimplemented
192h
Unimplemented
193h
Unimplemented
194h
Unimplemented
195h
Unimplemented
196h
Unimplemented
197h
Unimplemented
198h
Unimplemented
199h
Unimplemented
19Ah
Unimplemented
19Bh
Unimplemented
19Ch
Unimplemented
19Dh
Unimplemented
19Eh
Unimplemented
19Fh
Unimplemented
PEIE
T0I
E
TRISB
1
TRISB
0
GIE
TRISB
2
30
TRISB
3
30
24
188h
TRIS
B4
30
25
187h
TRIS
B5
xxxx
xxxx
1111
1111
0000
0000
0001
1xxx
xxxx
xxxx
Deta
ils
on
TRIS
TRIS
B7
B6
Unimplemented
Legend:
Note 1:
TRISB
Addressing this location uses contents of FSR to address data memory (not a physical
register)
INTE
T0C
T0S
PSA
PS2
PS1
PS0
RBPU
DG
S
E
Program Counters (PC) Least Significant Byte
Value
on
POR
Reset(1
RBIE
T0IF
INTF
RBIF
1111
1111
38
26
- = Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
For the initialization condition for registers tables, refer to Table 14-6 and Table 14-7.
4.3.2.1
Status Register
REGISTER 4-1:
For example, CLRF STATUS will clear the upperthree 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
Status register because these instructions do not
affect 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.
R/W-0
R/W-0
RP1
RP0
R-1
TO
R-1
R/W-x
bit 6-5
1 = Bank 2, 3 (100h-1FFh)
0 = Bank 0, 1 (00h-FFh)
RP<1:0>: Register Bank Select bits (used for direct addressing)
bit 4
R/W-x
C
bit 0
bit 7
00
01
10
11
R/W-x
= Bank 0 (00h-7Fh)
= Bank 1 (80h-FFh)
= Bank 2 (100h-17Fh)
= Bank 3 (180h-1FFh)
bit 3
instruction bit 2
Z: Zero bit
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero
bit 1
DC: Digit Carry/Borrow 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
bit 0
W = Writable
bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
4.3.2.2
OPTION Register
Note: To achieve a 1:1 prescaler assignment for
TMR0, assign the prescaler to the WDT
(PSA = 1). See Section 6.3.1
Switching Prescaler Assignment.
REGISTER 4-2:
bit 7
R/W-1
INTED
R/W-1
R/W-1
T0C
T0SE
R/W-1
P
R/W-1
R/W-1
PS2
PS1
R/W-1
PS0
bit 0
(CLKOUT) bit 4
T0SE: TMR0 Source Edge Select
bit
1 = Increment on high-to-low transition on RA4/T0CKI/CMP2 pin
0 = Increment on low-to-high transition on RA4/T0CKI/CMP2
pin bit 3
1:1
1:2
1:4
1:8
1:
16:
1
32:
1
64:
1
128
Legend:
R = Readable bit
-n = Value at POR
W = Writable
bit
1 = Bit is set
x = Bit is unknown
4.3.2.3
INTCON Register
Note: Interrupt flag bits get set when an interrupt
condition occurs regardless of the state
of its corresponding enable bit or the
global enable bit, GIE (INTCON<7>).
REGISTER 4-3:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-x
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
bit 7
bit 7
bit 0
bit 6
bit 5
bit 4
4.3.2.4
PIE1 Register
REGISTER 4-4:
R/W-0
R/W-0
R/W-0
EEIE
CMIE
RCIE
TXIE
bit 7
bit 7
U-0
R/W-0
CCP1I
E
R/W-0
TMR2I
E
R/W-0
TMR1I
E
bit 0
bit 4
bit 1
4.3.2.5
PIR1 Register
REGISTER 4-5:
R/W-0
R-0
R-0
EEIF
CMIF
RCIF
TXIF
U-0
bit 7
bit 7
R/W-0
CCP1
IF
R/W-0
TMR2I
F
R/W-0
TMR1I
F
bit 0
full bit 3
Unimplemented: Read as 0
bit 2
bit 1
bit 0
W = Writable
bit
1 = Bit is set
x = Bit is unknown
4.3.2.6
PCON Register
REGISTER 4-6:
bit 7
U-0
U-0
U-0
bit 7-4
Unimplemented: Read as 0
bit 3
R/W-1
OSCF
U-0
R/W-0
R/W-x
POR
BOR
bit 0
1 = 4 MHz typical
0 = 48 kHz typical
bit 2
Unimplemented: Read as 0
bit 1
4.3
FIGURE 4-4:
LOADING OF PC IN
DIFFERENT SITUATIONS
4.4
PCH
128
PCL
70
Instruction with
PCL as Destination
PC
5
PCLATH<4:0>
ALU result
PCLATH
PCH
12 11 10
PCL
8 7
PCGOTO, CALL
Opcode <10:0>
2
PCLATH<4:3>
11
PCLATH
EXAMPLE 4-1:
4.3.1
COMPUTED GOTO
4.3.2
NEXT
INDIRECT ADDRESSING
MOVLW 0x20
pointer MOVWF
CLRF
INDF
register INCF
BTFSS FSR,4
GOTO
NEXT
next
;initialize
FSR
;to RAM
;clear INDF
FSR
;inc pointer
;all done?
;no clear
;yes continue
STACK
DS40044G-page 31
FIGURE 4-5:
Status Register
Direct Addressing
RP1 RP0
from opcode
6
bank select
Status Register
Indirect Addressing
IRP
7
FSR Register
location select
00
00h
bank select
01
10
11
180h
RAM
File Registers
7Fh
1FFh
Bank 0Bank 1Bank 2Bank 3
location select
NOTES:
DS40044G-page 32
5.1
I/O PORTS
5.2
EXAMPLE 5-1:
INITIALIZING PORTA
CLRFPORTA
;Initialize PORTA by
;setting
;output data latches
;Turn comparators of and
;enable pins for I/O
;functions
MOVLW0x07
MOVWFCMCON
BCF
BSF
MOVLW
STATUS, RP1
STATUS, RP0 ;Select Bank1
0x1F
;Value used to initialize
;data direction
;Set RA<4:0> as inputs
MOVWFTRISA
;TRISA<5> always
;read as 1.
;TRISA<7:6>
;depend on oscillator
;mode
FIGURE 5-1:
BLOCK DIAGRAM OF
RA0/AN0:RA1/AN1 PINS
Data Bus
Q
VDD
WR PORTA
CK
Data Latch
DQ
I/O Pin
WR TRISA
CKQ
TRIS Latch Analog Input Mode
(CMCON Reg.)
RD TRISA
D
EN
RD PORTA
To Comparator
VSS
FIGURE 5-2:
BLOCK DIAGRAM OF
RA2/AN2/VREF PIN
Data Bus
D
VDD
WR PORTA
CKQ
Data Latch DQ
RA2 Pin
WR TRISA
CKQ
TRIS Latch
RD TRISA
VSS
D
EN
RD PORTA
To Comparator
VROE
VREF
FIGURE 5-3:
Data Bus
WR PORTA
Q
CKQ
Data Latch
VDD
Comparator Output
1
0
DQ
WR TRISA
CKQ
TRIS Latch
RA3 Pin
Analog Input Mode (CMCON Reg.)
VSS
RD TRISA
D
EN
RD PORTA
To Comparator
FIGURE 5-4:
Data Bus
WR PORTA
Comparator Output
1
CKQ
Data Latch
DQ
WR TRISA
RA4 Pin
CKQ
TRIS Latch
Vss
Vss
D
EN
RD PORTA
FIGURE 5-5:
THE
BLOCK DIAGRAM OF
FIGURE 5-6:
BLOCK DIAGRAM OF
RA6/OSC2/CLKOUT PIN
From OSC1
OSC
Circuit
RA5/MCLR/VPP PIN
CLKOUT(FOSC/4)
VDD
1
0
DQ
WR
PORTA
CKQ
Data Latch
FOSC = 101, 111 (2)
VSS
WRDQ
TRISACKQ
TRIS Latch
RD TRISA
FOSC =
011, 100, 110
QD
EN
RD PORTA
Note 1: INTOSC with RA6 = I/O or RC with RA6 = I/O.
2: INTOSC with RA6 = CLKOUT or RC with RA6 = CLKOUT.
MCLR
circuit
MCLR Filter
ProgramSchmitt Trigger
modeInput Bufer
HV Detect
RA5/MCLR/VPP
Data Bus
VSS
RD TRISA
VSS
QD
EN
RD PORTA
FIGURE 5-7:
To Clock Circuits
Data Bus
WR PORTA
VDD
Q
RA7/OSC1/CLKIN Pin
CK
Data Latch
VSS
WR TRISA
CKQ
TRIS Latch
RD TRISA
FOSC = 100, 101(1)
D
Schmitt Trigger Input Bufer
EN
RD PORTA
Note 1:
TABLE 5-1:
PORTA FUNCTIONS
Functi
on
RA0
AN0
In
pu
t
ST
AN
Out
put
Typ
CMO
S
RA1/AN1
RA1
ST
AN1
AN
CMO
S
RA2/AN2/VREF
RA2
ST
AN2
AN
CMO
S
VREF
AN
RA3
ST
AN
CMO
S
AN3
CMO
ODS
Comparator 1 output
Na
me
RA0/AN0
RA3/AN3/CMP1
Addre
ss
05h
85h
1Fh
9Fh
Legend:
Note 1:
ST
T0CKI
ST
CMP2
OD
Comparator 2 output
RA5
ST
Input port
MCLR
ST
VPP
HV
RA6
ST
OSC2
CLKO
UT
CMO
S
CMO
S
RA7/OSC1/CLKIN
RA7
ST
OSC1
XT
AL
CLKIN
ST
= Output
= Not used
= TTL Input
TABLE 5-2:
RA4
RA5/MCLR/VPP
Legend:
TTL
CMP1
RA4/T0CKI/CMP2
RA6/OSC2/CLKOU
T
Descripti
on
CMO
XTALS
CM
IOS
OD
= CMOS Output
= Input
= Open Drain Output
P = Power
ST = Schmitt Trigger Input
AN = Analog
Nam
e
Bit
7
Bit 6
Bit 5
Bit
4
Bit 3
Bit 2
Bit 1
Bit 0
PORT
A
TRISA
RA
7
TRIS
RA6
RA5(
TRIS
A5
C2IN
RA
4
TRIS
RA3
RA2
RA1
RA0
TRIS
A3
CIS
TRIS
A2
CM2
TRIS
A1
CM1
TRIS
A0
CM0
A7
C2O
UT
VRE
TRIS
A6
C1O
A4
C1IN
V
Value
on
POR
xxxx
0000
1111
Value
on All
Other
Reset
qqqu
0000
1111
1111
1111
0000
0000
0000
0000
UT
V
VRO
VRR
VR3
VR2
VR1
VR0
0000000000
N- = Unimplemented
N
E
locations read as 0, u = unchanged, x = unknown, q = value depends on condition.0000
Shaded
cells are not used for PORTA.
MCLRE configuration bit sets RA5 functionality.
CMCO
N
VRCO
5.3
FIGURE 5-8:
BLOCK DIAGRAM OF
RB0/INT PIN
VDD
P Weak Pull-up VDD
RBPU
Data Bus
WR PORTB
RB0/INT
CKQ
VSS
Data Latch
WR TRISB
CKQ
TRIS Latch
TTL
Input Bufer
RD TRISB
QD
EN
EN
RD PORTB
INT
Schmitt Trigger
FIGURE 5-9:
OF
BLOCK DIAGRAM
FIGURE 5-10:
BLOCK DIAGRAM OF
RB2/TX/CK PIN
RB1/RX/DT PIN
VDD
Weak P Pull-up
VDD
RBPU
SPEN
1
RB2/
TX/CK
DQ
CKQ
VSS
Data Latch
DQ
WR TRISB
CKQ
Peripheral OE(1)
TRIS Latch
TTL
Input Bufer
RD TRISB
QD
EN
RD PORTB
VDD
Weak
P Pull-up VDD
RBPU
SPEN
1
0
DQ
RB1/
RX/DT
CKQ
VSS
Data Latch
DQ
WR TRISB
CKQ
Peripheral OE(1)
TRIS Latch
TTL
Input Bufer
RD TRISB
QD
EN
RD PORTB
FIGURE 5-12:
RBPU
P weak pull-up
Data Bus
WR PORTB
DQ
VDD
CKQ
Data Latch DQ
RB4/PGM
WR TRISB
CKQ
VSS
TRIS Latch
RD TRISB
RD PORTB
PGM input
TTL
input bufer
Schmitt
Trigger
QD
Q1
EN
Set RBIF
From other
RB<7:4> pins
QD
EN
Q3
Note:The low-voltage programming disables the interrupt-on-change and the weak pull-ups on RB4.
FIGURE 5-13:
RBPU
P weak VDD
pull-up
Data Bus
DQ
RB5 pin
WR PORTB
CKQ
Data Latch
VSS
DQ
WR TRISB
CKQ
TTL
input bufer
TRIS Latch
RD TRISB
RD PORTB
EN
Q1
Set RBIF
From other
RB<7:4> pins
QD
EN
DS40044G-page 42
Q3
FIGURE 5-14:
RBPU
P weak pull-up
Data Bus
WR PORTB
DQ
VDD
CKQ
Data Latch DQ
RB6/
T1OSO/ T1CKI/ PGC
pin
WR TRISB
CKQ
VSS
TRIS Latch
RD TRISB
T1OSCEN
TTL
input bufer
RD PORTB
TMR1 Clock
From RB7
Schmitt
Trigger
TMR1 oscillator
QD
Q1
EN
Set RBIF
From other
RB<7:4> pins
QD
EN
Q3
FIGURE 5-15:
RBPU
P weak pull-up
TMR1 oscillator
To RB6
VDD
Data Bus
WR PORTB
DQ
RB7/T1OSI/
PGD pin
CKQ
Data Latch
DQVSS
WR TRISB
CKQ
TRIS Latch
RD TRISB
T10SCEN
TTL
input bufer
RD PORTB
Serial Programming Input
Schmitt
Trigger
QD
Q1
EN
Set RBIF
From other
RB<7:4> pins
QD
EN
Q3
TABLE 5-3:
PORTB FUNCTIONS
Na
me
RB0/INT
RB1/RX/DT
RB2/TX/CK
Functi
on
RB0
Input
Type
TTL
Out
put
Typ
CM
OS
INT
ST
External interrupt
RB1
TTL
CM
OS
RX
ST
DT
ST
TTL
CM
OS
CM
RB2
OS
CM
OS
CM
TX
CK
ST
Descripti
on
Bidirectional I/O port. Can be software programmed
for internal weak pull-up.
OS
TTL
CM
OS
CCP1
ST
RB4
TTL
CM
OS
CM
OS
PGM
ST
Low-voltage programming input pin. When lowvoltage programming is enabled, the interrupt-on-pin
change and weak pull-up resistor are disabled.
RB5
RB5
TTL
CM
OS
RB6/T1OSO/T1C
KI/ PGC
RB6
TTL
CM
OS
T1OS
O
T1CKI
XTA
L
ST
RB3/CCP1
RB3
RB4/PGM
RB7/T1OSI/PGD
Legend:
TTL
Addre
ss
06h,
106h
86h,
186h
81h,
Legend:
Note 1:
PGC
ST
RB7
TTL
CM
OS
T1OSI
XTAL
PGD
ST
= Output
= Not used
= TTL Input
TABLE 5-4:
Nam
e
Capture/Compare/PWM/I/O
CM
IOS
OD
CM
ICSP Data I/O
OSCMOS Output
P = Power
ST = Schmitt Trigger Input
AN = Analog
Input
Open Drain Output
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
PORT
RB
RB6
RB5
RB3
RB2
RB4(
B
7
TRIS
TRIS
TRISB
TRIS
TRIS
TRIS
TRIS
B
B7
6
B5
B4
B3
B2
RBP
OPTIO
INTE
T0C
T0S
PSA
PS2
U x = unknown. Shaded cells are not used for PORTB.
u = unchanged,
LVP configuration bit sets RB4 functionality.
Bit 1
Bit 0
RB1
TRIS
B1
PS1
RB0
TRIS
B0
PS0
Value
on
POR
xxxx
1111
1111
1111
Value
on All
Other
Reset
uuuu
1111
1111
1111
5.4
5.4.1
EXAMPLE 5-2:
FIGURE 5-16:
READ-MODIFY-WRITE
INSTRUCTIONS ON AN
I/O PORT
5.4.2
Q1
Q2 Q3 Q4
MOVF PORTB, W
MOVWF
Write to PORTB
PORTBRead to PORTB
Q2 Q3 Q4 Q1
PC + 2 PC + 3
PC
NOPNOP
Instruction fetched
Q2 Q3
Q4
Execute MO
Note 1:This example shows write to PORTB followed by a read from PORTB.
2:Data setup time = (0.25 TCY - TPD) where TCY = instruction cycle and TPD = propagation delay of Q1 cycle to output va
6.1
TIMER0 MODULE
8-bit timer/counter
Read/write capabilities
8-bit software programmable prescaler
Internal or external clock select
Interrupt on overflow from FFh to 00h
Edge select for external clock
Figure 6-1 is a simplified block diagram of the Timer0
module. Additional information is available in the PIC
Mid-Range MCU Family Reference Manual
(DS33023).
Timer mode is selected by clearing the T0CS bit
(OPTION<5>). In Timer mode, the TMR0 register
value will increment every instruction cycle (without
prescaler). If the TMR0 register is written to, the
increment is inhibited for the following two cycles. The
user can work around this by writing an adjusted
value to the TMR0 register.
Counter mode is selected by setting the T0CS bit. In
this mode the TMR0 register value will increment
either on every rising or falling edge of pin
RA4/T0CKI/CMP2. The incrementing edge is
determined by the source edge (T0SE) control bit
(OPTION<4>). Clearing the T0SE bit selects the rising
edge. Restrictions on the external clock input are
discussed in detail in Section 6.2 Using Timer0
with External Clock.
The prescaler is shared between the Timer0 module
and the Watchdog Timer. The prescaler assignment is
controlled in software by the control bit PSA
(OPTION<3>). Clearing the PSA bit will assign the
prescaler to Timer0. The prescaler is not readable or
writable. When the prescaler is assigned to the
Timer0 module, prescale value of 1:2, 1:4,..., 1:256
are selectable. Section 6.3 Timer0 Prescaler
details the operation of the prescaler.
6.2
Timer0 Interrupt
6.3
6.2.1
EXTERNAL CLOCK
SYNCHRONIZATION
6.3
Timer0 Prescaler
FIGURE 6-1:
FOSC/4
8
0
T0CKI
pin
SYNC 2
Cycles
1
1
TMR0 Reg
T0SE
T0CS
P
Watchdog Timer
SA
PSA
8
8-to-1MUX
PS<2:0>
WDT
0 Time-out
PSA
Note:T0SE, T0CS, PSA., PS<2:0> are bits in the Option Register.
6.3.1
SWITCHING PRESCALER
ASSIGNMENT
EXAMPLE 6-1:
PRESCALER
BCF
CLRW
DT
CLRF
BSF
MOVL
W
MOVW
F
CLRW
DT
MOVL
W
MOVW
F
BCF
Addres
s
01h,
101h
0Bh,
8Bh,
10Bh,
81h,
181h
85h
Legend:
Note 1:
EXAMPLE 6-2:
CLRWDT
CHANGING
STATUS,
RP0
(TIMER0
WDT)
;Skipif
already
in
;Bank 0
;Clear WDT
;Clear TMR0 and
;Prescaler
;Bank 1
;These 3 lines
;(5, 6, 7)
;are required only
;if desired PS<2:0>
;are
;000 or 001
;Set Postscaler to
;desired WDT rate
;Return to Bank 0
TMR0
STATUS,
RP0
'00101111
b
OPTION_REG
'00101xxx
b
OPTION_REG
STATUS,
RP0
TABLE 6-1:
CHANGING PRESCALER
(WDT TIMER0)
;Clear WDT and
;prescaler
BSF
MOVLW
STATUS, RP0
b'xxxx0xxx
MOVW
F
BCF
OPTION_REG
STATUS, RP0
TMR0
INTCO
N
OPTIO
(2)
N
TRISA
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
INTE
RBIE
T0IF
INTF
RBIF
PEIE
T0IE
Value
on
POR
xxxx
Value
on All
Other
Reset
uuuu
0000
0000
000x
000u
INTE
T0C
T0S
PSA
PS2
PS1
PS0
1111
1111
RBP
1111
1111
DG
S
E
U
TRIS
TRIS
TRIS
TRIS
TRIS
TRIS
TRIS
TRIS
1111
1111
1111
1111
A7
A6
A5
A4
A3
A2
A1
A0
- = Unimplemented locations, read as 0, u = unchanged, x = unknown. Shaded cells are not used for Timer0.
7.1
TIMER1 MODULE
As a timer
As a counter
The Operating mode is determined by the clock select
bit, TMR1CS (T1CON<1>).
REGISTER 7-1:
bit 7
U-0
R/W-0
T1CKP
R/W-0
T1CKP
R/W-0
T1OSCE
bit 7-6
Unimplemented: Read as 0
bit 5-4
bit 3
R/W-0
T1SY
NC
R/W-0
TMR1
R/W-0
TMR1
bit 0
bit 2
0. bit 1
bit 0
Legend:
R = Readable bit
-n = Value at POR
DS40044G-page 50
W = Writable
bit
1 = Bit is set
x = Bit is unknown
7.2
7.3
Timer1
Operation
Synchronized Counter Mode
in
FIGURE 7-1:
7.2.1
TMR1
TMR1H
Synchronized
Clock Input
TMR1L
1
TMR1ON
T1SYNC
T1OSC
RB6/T1OSO/T1CKI/PGC
RB7/T1OSI/PGD
1
T1OSCEN
FOSC/4
Enable Oscillator(1)
Internal0 Clock
Prescaler
1, 2, 4, 8
2
T1CKPS<1:0>
Synchronize
det
Sleep Input
TMR1CS
Note
1: When the T1OSCEN bit is cleared, the inverter and feedback resistor are turned of. This eliminates power drain.
7.3
Timer1
Operation
in
Asynchronous Counter Mode
EXAMPLE 7-1:
;
; TMR1L may have rolled over between the
; read of the high and low bytes. Reading
; the high and low bytes now will read a good
; value.
;
MOVFTMR1H, W;Read high byte MOVWFTMPH;
7.3.1
EXTERNAL CLOCK INPUT TIMING
MOVFTMR1L, W;Read low byte MOVWFTMPL;
WITH UNSYNCHRONIZED CLOCK
; Re-enable the Interrupts (if required) CONTINUE;Continue with your
;code
If control bit T1SYNC is set, the timer will increment
7.3.2
DS40044G-page 52
7.4
Timer1 Oscillator
7.5
TABLE 7-1:
Freq
C1
C2
32.768 kHz
15
15 pF
pF
Note: These values are for design guidance only.
Consult Application Note AN826 Crystal
Oscillator Basics and Crystal Selection for
rfPIC and PIC Devices (DS00826) for
further information on Crystal/Capacitor
Selection.
7.6
7.7
Timer1 Prescaler
TABLE 7-2:
Address
Name
0Bh,
8Bh,
10Bh,
0Ch
INTC
ON
8Ch
0Eh
0Fh
10h
Legend:
PIR1
Bi
t6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
P
EI
E
C
T0IE
INTE
RBIE
T0IF
INTF
RBIF
E
RCIF
TXIF
CCP1I
TMR2I
EI
MI
F
F
E
C
RCIE
TXIE
CCP1I
TMR2I
EI
MI
E
E
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
TMR1I
F
TMR1I
E
Value
on
POR
0000
000x
0000
-000
0000
-000
TMR1
xxxx
L
xxxx
TMR1
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
xxxx
H
xxxx
T1CO
T1CKP
T1CKP
T1OSCE
TMR1C
TMR1
--00
T1SY
0000
N
S1
S0
N
S
ON
NC
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by the Timer1 module.
PIE1
Value
on
all
othe
0000
000u
0000
-000
0000
-000
uuuu
uuuu
uuuu
uuuu
--uu
uuuu
8.1
TIMER2 MODULE
8.2
8.3
TMR2 Output
FIGURE 8-1:
Sets flag
bit TMR2IF TMR2
output
Reset
FOSC/4
Postscaler
1:1 to 1:16 EQ Comparator
4
TOUTPS<3:0>
PR2 Reg
2
T2CKPS<1:0>
REGISTER 8-1:
bit 7
R/W-0
R/W-0
TOUTP
S3
TOUTP
S2
R/W-0
R/W-0
TOUTP
S1
TOUTPS
0
bit 7
Unimplemented: Read as 0
bit 6-3
R/W-0
TMR2
ON
R/W-0
T2CKP
S1
R/W-0
T2CKP
S0 bit 0
bit 1-0
TABLE 8-1:
Addres
s
0Bh,
8Bh,
10Bh,
0Ch
8Ch
11h
12h
92h
Legend:
Nam
e
INTC
ON
W = Writable bit
1 = Bit is set
x = Bit is unknown
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
Value
on
POR
0000
000x
0000
-000
0000
PIE1
EEIE
CMIE
RCIE
TXIE
-000
0000
TMR2
Timer2 Modules Register
0000
-000
T2CO
TOUTP
TOUTP
TOUTP
TOUTP
TMR2
T2CKP
T2CKP
0000
N
S3
S2
S1
S0
ON
S1
S0
1111
PR2
Timer2 Period Register
1111
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by the Timer2 module.
PIR1
EEIF
CMIF
RCIF
TXIF
CCP1I
F
CCP1I
E
TMR2I
F
TMR2I
E
TMR1I
F
TMR1I
E
Value
on
all
othe
0000
000u
0000
-000
0000
-000
0000
0000
-000
0000
1111
1111
NOTES:
9.1
CAPTURE/COMPARE/PWM
(CCP) MODULE
TABLE 9-1:
CCP MODE TIMER
RESOURCE
CCP Mode
Timer Resource
Capture
Compare
Timer1
Timer1
PWM
Timer2
CCP1 Module
Capture/Compare/PWM Register1 (CCPR1) is
comprised of two 8-bit registers: CCPR1L (low byte)
and CCPR1H (high byte). The CCP1CON register
controls the operation of CCP1. All are readable and
writable.
Additional information on the CCP module is available
in the PIC Mid-Range MCU Family Reference Manual (DS33023).
REGISTER 9-1:
U-0
bit 7
R/W-0
CCP1
X
R/W-0
CCP1
Y
R/W-0
CCP1M3
R/W-0
CCP1
M2
R/W-0
CCP1
M1
bit 7-6
Unimplemented: Read as 0
bit 5-4
R/W-0
CCP1
M0 bit 0
W = Writable
bit
1 = Bit is set
x = Bit is unknown
9.2
Capture Mode
9.2.4
In Capture mode, CCPR1H:CCPR1L captures the 16bit value of the TMR1 register when an event occurs
on pin RB3/CCP1. An event is defined as:
9.2.1
EXAMPLE 9-1:
9.2
CAPTURE MODE
OPERATION BLOCK
DIAGRAM
Prescaler
1, 4, 16
RB3/CCP1
pin
CCPR1HCCPR1L
and
edge detect
Capture
Enable
CHANGING BETWEEN
CAPTURE PRESCALERS
CLRF
CCP1CON
;Turn CCP module of
MOVLW
NEW_CAPT_PS ;Load the W reg with
; the new prescaler
; mode value and CCP ON
MOVWF CCP1CON
;Load CCP1CON with this
; value
FIGURE 9-1:
CCP PRESCALER
Compare Mode
Driven high
Driven low
Remains unchanged
The action on the pin is based on the value of control
bits CCP1M<3:0> (CCP1CON<3:0>). At the same
time, interrupt flag bit CCP1IF is set.
TMR1HTMR1L
Qs
9.2.2
CCP1CON<3:0>
Timer1 must be running in Timer mode or Synchronized Counter mode for the CCP module to use the
capture feature. In Asynchronous Counter mode, the
capture operation may not work.
9.2.3
SOFTWARE INTERRUPT
FIGURE 9-2:
COMPARE MODE
OPERATION BLOCK
DIAGRAM
Set flag bit CCP1IF
(PIR1<2>)
CCPR1H CCPR1L
Q SOutput Logic
R
match
RB3/CCP1
pin
TRISB<3>
Output Enable CCP1CON<3:0>
Mode Select
Comparator
TMR1H
TMR1L
9.2.1
9.2.4
9.2.2
Timer1 must be running in Timer mode or Synchronized Counter mode if the CCP module is using the
compare feature. In Asynchronous Counter mode, the
compare operation may not work.
9.2.3
Note: Removing the match condition by changing the contents of the CCPR1H,
CCPR1L register pair between the clock
edge that generates the special event
trigger and the clock edge that generates
the TMR1 Reset will preclude the Reset
from occuring.
TABLE 9-2:
Addres
s
0Bh,
8Bh,
10Bh,
0Ch
8Ch
86h,
186h
0Eh
0Fh
10h
15h
16h
17h
Legend:
In this mode (CCP1M<3:0>=1011), an internal hardware trigger is generated, which may be used to
initiate an action. See Register 9-1.
INTCO
N
PIR1
Bit
7
GI
E
Bit
6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
PE
IE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
Value
on
POR
0000
000x
Value
on all
other
Reset
0000
000u
0000
0000
-000
-000
0000
0000
PIE1
-000
-000
TRISB
1111
1111
1111
1111
xxxx
uuuu
TMR1L
Holding Register for the Least Significant Byte of the 16-bit TMR1 Register
xxxx
uuuu
TMR1H
Holding Register for the Most Significant Byte of the 16-bit TMR1 Register
xxxx
uuuu
xxxx
uuuu
T1SY
T1CON
T1CKP
T1CKP
T1OSC
TMR1
TMR1
--00
--uu
NC
S1
S0
EN
CS
ON
CCPR1
Capture/Compare/PWM
Register1
(LSB)
xxxx
uuuu
xxxx
uuuu
L
xxxx
uuuu
CCPR1
Capture/Compare/PWM Register1 (MSB)
xxxx
uuuu
H
CCP1C
--00
--00
CCP1X
CCP1Y
CCP1M
CCP1
CCP1
CCP1
0000
0000
ON
3
M2
M1
M0
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by Capture and Timer1.
EE
C
RCIF
TXIF
IF
MI
EE
C
RCIE
TXIE
IE
MI
PORTB Data Direction Register
CCP1I
F
CCP1I
E
TMR2I
F
TMR2I
E
TMR1I
F
TMR1I
E
9.3
PWM Mode
FIGURE 9-4:
PWM OUTPUT
Period
Duty Cycle
TMR2 = PR2
TMR2 = Duty Cycle
FIGURE 9-3:
TMR2 = PR2
9.3.1
CCP1CON<5:4>
CCPR1H (Slave)
RQ
Comparator
TMR2
PWM PERIOD
CCPR1L
(1)
TMR2 is cleared
The CCP1 pin is set (exception: if PWM
duty cycle = 0%, the CCP1 pin will not be
PR2
set)
The
PWM
1:8-bit timer is concatenated with 2-bit internal Q clock or 2 bits of the prescaler to create
10-bitduty
timecycle
base.is latched from CCPR1L
into CCPR1H
Comparator
Clear Timer, CCP1 pin and latch D.C.
Note
TRISB<3>
DS40044G-page 60
9.3.2
9.3.3
1.
3.
TABLE 9-3:
2.
4.
1.22
kHz
16
0xFF
10
4.88
kHz
4
0x
FF
10
19.53
kHz
1
0x
FF
10
78.12
kHz
1
0x
3F
8
156.3
kHz
1
0x
1F
7
208.3
kHz
1
0x
17
6.
5
TABLE 9-4:
Addres
s
Na
me
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit
0
INTC
ON
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBI
F
CCP1I
F
CCP1I
E
TRISB
2
TMR2I
F
TMR2I
E
TRISB
1
0Bh,
8Bh,
10Bh,
0Ch
PIR1
EEIF
CMIF
RCIF
TXIF
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
86h,
186h
11h
92h
12h
15h
16h
17h
Legend:
bits
TMR1
IF
TMR1
IE
TRIS
B0
Value
on
POR
0000
000x
0000
-000
0000
-000
TRISB
TRIS
TRISB
TRISB
TRISB
TRISB
1111
1111
B7
6
5
4
3
TMR2
Timer2 Modules Register
0000
0000
PR2
Timer2 Modules Period Register
1111
1111
T2CO
TOUTP
TOUTP
TOUTP
TOUTP
TMR2
T2CK
T2CK
-000
0000
N
S3
S2
S1
S0
ON
PS1
PS0
CCPR
Capture/Compare/PWM Register 1 (LSB)
xxxx
xxxx
1L
CCPR
Capture/Compare/PWM Register 1 (MSB)
xxxx
xxxx
1H
CCP1C
CCP1X
CCP1Y
CCP1
CCP1
CCP1
CCP1
--00
0000
ON
M3
M2
M1
M0
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by PWM and Timer2.
Value
on
all
other
0000
000u
0000
-000
0000
-000
1111
1111
0000
0000
1111
1111
uuuu
uuuu
uuuu
uuuu
uuuu
uuuu
--00
0000
NOTES:
DS40044G-page 62
10.1
COMPARATOR MODULE
REGISTER 10-1:
bit 7
R-0
C2OU
T7
bit
C1OU
T
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
C2IN
V
C1IN
V
CI
S
CM2
CM1
CM0
bit 6
bit 5
bit 4
1 = C2 Output inverted
0 = C2 Output not inverted
C1INV: Comparator 1 Output Inversion bit
1 = C1 Output inverted
0 = C1 Output not inverted
bit 3
bit 2-0
Legend:
bit 0
R = Readable bit
-n = Value at POR
W = Writable
bit = Bit is set
1
x = Bit is unknown
10.2
Comparator Configuration
FIGURE 10-1:
A
A
RA3/AN3/CMP1
0)
RA1/AN1
VIN+
C1
Off (Read as
VIN-
VIN+
RA2/AN2/VREF A
0)
Two Independent Comparators
CM<2:0> = 100
A
RA0/AN0
C2
Off (Read as
C1V
A OUT VIN+
RA1/AN1
VIN+
VINVIN+
Off (Read as
C1
VIN-
Off (Read as
C2
VIN+
D
RA2/AN2/VREF
0)
Four Inputs Multiplexed to Two Comparators
CM<2:0> = 010
RA0/AN0
C1
RA2/AN2/VREF
C2
RA3/AN3/CMP1 A
A
RA1/AN1
VIN-
RA3/AN3/CMP1
0)
RA1/AN1
VIN-
RA3/AN3/CMP1
RA2/AN2/VREF
RA0/AN0
VIN-
CIS = 0
VIN-
CIS = 1
C1VOUT VIN+ C1
CIS = 0
CIS = 1
C2VOUT
C2VOUT
VINV +
C2
I
N
From
Two Common Reference Comparators
CM<2:0> = 011
RA0/AN0
VIN-
VIN+
RA1/AN1
VIN-
RA2/AN2/VREF
VIN+
RA3/AN3/CMP1
C1
C2
C1V
OUT
C2VOUT
RA1/AN1
VIN-
RA2/AN2/VREF
VIN+
C2V
C2
OUT
VINVIN+
RA3/AN3/CMP1 D
0)
RA0/AN0
C1
Off (Read as
RA3/AN3/CMP1 A
C1VOUT
V
S
S
RA1/AN1
CIS = 0
CIS = 1
VIN-
VIN+zerosC2
A = Analog REF
Input, A
port reads
always.
RA2/AN2/V
RA1/AN1
VINV +
C1
I
N
VIN-
C2VOUT
C2
VIN+
RA2/AN2/VREF A
D = Digital Input.
CIS (CMCON<3>) is the Comparator Input Switch.
OUT
C2V
EXAMPLE 10-1:
FIGURE 10-2:
SINGLE COMPARATOR
VIN++
Result
VIN-
INITIALIZING
COMPARATOR MODULE
FLAG_REG
EQU
0X20
CLRF CLRF MOVF ANDLW IORWF
FLAG_REG
MOVLW
PORTA
MOVWF
CMCON,
BSF ;Init
MOVLW
W 0xC0
flag MOVWF
register
VIN- VIN+
;Init PORTA
;Load comparator bits
;Mask comparator bits
FLAG_REG,F ;Store bits in flag register
Result
0x03 CMCON ;Init comparator mode
;CM<2:0> = 011
STATUS,RP0 ;Select Bank1
0x07 TRISA ;Initialize data direction
;Set RA<2:0> as inputs
;RA<4:3> as outputs
;TRISA<7:5> always read 0
BCF
STATUS,RP0 ;Select Bank 0
;10s delay
CALL MOVF DELAY10
10.4.1
EXTERNAL REFERENCE SIGNAL
;Read CMCONto end change
CMCON,F
;condition
When external voltage references are used, the
BCF
PIR1,CMIF ;Clear pending interrupts
Comparator module can be configured to have the
BSFSTATUS,RP0
BSF BCF BSF;Select
BSF Bank 1
PIE1,CMIE ;Enable comparator interrupts STATUS,RP0 ;Select Bank 0 comparators operate from the same or different
INTCON,PEIE ;Enable peripheral interrupts INTCON,GIE ;Global interruptreference
enable
sources. However, threshold detector
10.4.2
10.3
Comparator Operation
10.4
Comparator Reference
10.4
10.5
Comparator Outputs
FIGURE 10-3:
CnINV
To RA3/AN3/CMP1 or RA4/T0CK1/CMP2 pin
To Data Bus CMCON<7:6>
CnVOUT
Q
D
Q3
EN
RD CMCON
QD
EN CL
From other Comparator
Q1
Reset
10.6
Comparator Interrupts
10.7
Comparator
During Sleep
Operation
10.8
Effects of a Reset
10.9
FIGURE 10-4:
RS < 10 K
AIN
CPIN
5 pF
VA
V T = 0.6V
RIC
ILEAKAGE
500 nA
VSS
Legend: CPIN
=
Input Capacitance
VT Current
=
Threshold Voltage Leakage
at the Pin Interconnect Resistance Source Impedance
Analog Voltage
ILEAKAGE =
RIC RS VA=
=
=
TABLE 10-1:
Addres
s
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
C2O
UT
GIE
C1O
UT
PEIE
C2IN
V
T0IE
C1N
V
INTE
CIS
CM2
CM1
CM0
0000
Value
on All
Other
Reset
0000
RBIE
T0IF
INTF
RBIF
CCP
1IF
CCP
TMR
2IF
TMR
TMR
1IF
TMR
1IE
TRIS
TRIS
TRIS
TRIS
TRIS
TRIS
A7u = Unchanged,
A6
A5= Unimplemented,
A4
A3read as 0
A2
x = Unknown,
-
2IE
TRIS
A1
1IE
TRIS
A0
0000
000x
0000
-000
0000
0000
000u
0000
-000
0000
-000
1111
1111
-000
1111
1111
Nam
e
1Fh
0Bh,
8Bh,
10Bh,
0Ch
CMC
ON
INTC
ON
PIR1
EEIF
CMIF
RCIF
TXIF
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
85h
Legend:
TRISA
Value
on
POR
11.1
VOLTAGE REFERENCE
MODULE
11.2
REGISTER 11-1:
R/W-0
VREN
VRO
E
bit 7
bit 7
R/W-0
VRR
U-0
R/W-0
V
R
R/W-0
R/W-0
R/W-0
VR2
VR1
VR0
bit 0
bit 4
Unimplemented: Read as 0
bit 3-0
FIGURE 11-1:
VREN
16 Stages
8R
R
8R
VSS
VREF
VRR
VSS
VR3
(From VRCON<3:0>) VR0
Note:R is defined in .
EXAMPLE 11-1:
VOLTAGE REFERENCE
CONFIGURATION
MOVLW
0x02
;4 Inputs Muxed
MOVWF BSF MOVLW MOVWF MOVLW
CMCON
MOVWF BCF
;to CALL
2 comps.
STATUS,RP0 ;go to Bank 1
0x07 TRISA 0xA6
VRCON
;RA3-RA0
are
;outputs
;enable VREF
;low range set VR<3:0>=6
STATUS,RP0 ;go to Bank 0
DELAY10
;10s delay
11.3
11.4
11.6
Connection Considerations
11.5
Effects of a Reset
DS40044G-page 71
FIGURE 11-2:
VREF +
R(1)
Op Amp
RA2
VREF Output
Module
Voltage
Reference Output Impedance
Note
1:
TABLE 11-1:
Addre
ss
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
9Fh
1Fh
VRE
N
C2O
UT
TRIS
VRO
E
C1OU
T
TRIS
VRR
C2IN
V
TRIS
C1IN
V
TRIS
VR3
CIS
VR2
CM2
VR1
CM1
VR0
CM0
85h
VRC
ON
CMC
ON
TRI
Legend:
SA- = Unimplemented,
A7
A6read as A5
0.
TRIS
A3
TRIS
A2
TRIS
A1
TRIS
A0
A4
0000000
0000
1111
Value
On All
Other
Reset
0000000
0000
1111
1111
1111
Value
On
POR
NOTES:
DS40044G-page 72
12.1
UNIVERSAL SYNCHRONOUS
ASYNCHRONOUS RECEIVER
TRANSMITTER
(USART)
MODULE
REGISTER 12-1:
Asynchronous (full-duplex)
Synchronous Master (half-duplex)
Synchronous Slave (half-duplex)
Bit SPEN (RCSTA<7>) and bits TRISB<2:1> have to be
set in order to configure pins RB2/TX/CK and
RB1/RX/DT
as
the
Universal
Synchronous
Asynchronous Receiver Transmitter.
Register 12-1 shows the Transmit Status and Control
Register (TXSTA) and Register 12-2 shows the
Receive Status and Control Register (RCSTA).
R/W-0
R/W-0
R/W-0
CSRC
TX9
TXEN
SYNC
U-0
bit 7
bit 7
R/W-0
BRG
H
R-1
R/W-0
TRMT
TX9D
bit 0
bit 1
Unimplemented: Read as 0
BRGH: High Baud Rate Select
bit Asynchronous mode
1 = High speed
0 = Low speed
Synchronous mode
Unused in this mode
TRMT: Transmit Shift Register Status bit
1 = TSR empty
0 = TSR full
bit 0
Legend:
R = Readable bit
-n = Value at POR
W = Writable
bit = Bit is set
1
x = Bit is unknown
REGISTER 12-2:
R/W-0
SPEN
RX9
bit 7
bit 7
R/W-0
R/W-0
R/W-0
R-0
R-0
SRE
N
CREN
ADEN
FER
R
OER
R
R-x
RX9
D bit 0
bit 6
bit 5
bit 4
bit 1
bit 0
Legend:
R = Readable bit
-n = Value at POR
W = Writable
bit = Bit is set
1
x = Bit is unknown
12.2
EQUATION 12-1:
CALCULATING BAUD
RATE ERROR
+ 1
= 9615
SYNC = 0
TABLE 12-1:
SYNC
0
1
Legend:
TABLE 12-2:
Addres
s
98h
18h
99h
Legend:
Value
on
POR
TXST
BRG
TRMT
0000
A
H
RCST
ADEN
FERR
OER
0000
000x
A
R
SPBR
0000
0000
xG = unknown, - = unimplemented read as 0. Shaded cells are not used for the BRG.
Name
Bit 7
Bi
Bit
Bit 4
t
5
CSR
T
TXE
SYNC
C
X
N
SPE
R
SRE
CREN
N Rate X
N Register
Baud
Generator
Bit 3
Bit 2
Bit 1
Bit
0
TX9
D
RX9
D
Value on
all other
Resets
0000
0000
000x
0000
0000
TABLE 12-3:
0.3
1.2
NA
NA
SPBR
G
value
(decima
2.4
NA
BAUD
RATE
(K)
FOSC = 20 MHz
KBAUD
16 MHz
NA
KBAU
D
NA
NA
9.6
NA
NA
19.
2
76.
19.53
+1.7
3%
+0.1
2
5
6
19.23
4
5
1
1
76.92
ERR
OR
SPBR
G
value
(decima
10 MHz
ERR
OR
SPBR
G
value
(decima
NA
+1.7
3%
+0.1
KBAU
D
NA
NA
9.766
+0.1
6%
+0.1
207
19.23
51
75.76
41
96.15
307.69
6%
0.79
+2.5
12
312.5
6%
1.36
+0.1
6%
+4.1
500
6%
0
500
7%
0
76.92
255
129
32
8
96
96.15
30
0
50
294.1
6%
+0.1
6%
-1.96
500
6
9
0
HI
G
LO
5000
4000
2500
19.53
2
5
15.625
255
9.766
255
SPBR
G
value
(decima
4 MHz
BAUD
RATE
(K)
0.3
1.2
SPBR
G
value
(decima
KBAUD
NA
NA
95.24
5.0688
MHz
KBAUD
NA
NA
ERRO
R
KBAU
D
NA
NA
ERR
OR
25
7
4
SPBR
G
value
(decima
2.4
NA
NA
NA
9.6
9.62
2
19.2
+0.23
%
+0.23
1
8
9
9.6
131
65
+0.1
6%
+0.1
103
19.2
9.61
5
19.2
4
77.8
2
94.2
%+1.32
79.2
31
75.9
23
100
6%
+0.1
6%
+4.1
12
97.48
+3.13
%
+1.54
15
-1.88
2
2
2
1
0
298.
3
NA
-0.57
8
5
316.8
0
NA
7%
NA
%
5.60
%
NA
1267
100
2
5
4.950
255
3.90
6
255
1 MHz
SPBR
G
value
(decima
19.
2
76.
8
96
30
0
50
0
HI
G
LO
W
BAUD
RATE
(K)
0.3
1.2
2.4
9.6
19.
2
76.
8
96
30
0
50
0
HI
G
LO
W
178
9.8
6.99
1
FOSC = 3.579545
MHz
KBAUD
NA
NA
NA
KBAU
D
NA
1.202
2.404
12
3
32.768
kHz
51
9
ERR
OR
+0.1
6%
+0.1
SPBR
G
value
(decima
2
0
1
NA
6%
+0.1
6%
+0.1
0
2
5
1
ERR
OR
+1.1
4%
2.48
NA
NA
2
2
NA
NA
KBAUD
0.303
1.170
SPBR
G
value
(decima
26
6
9.6
22
19.
+0.2
3%
-
9
2
4
9.615
04
74.
57
99.
43
29
8.3
NA
0.83
2.90
+3.5
7%
0.57
%
6
1
1
8
83.34
NA
6%
+8.5
1%
NA
NA
NA
NA
89
4.9
3.4
96
250
8.192
2
5
0.976
6
2
5
0.032
255
19.24
TABLE 12-4:
NA
1.2
21
2.4
+1.73
%
+0.16
SPBR
G
value
(decima
2
5
1
04
9.4
69
19.
%
1.36
+1.73
2
3
2
1
19.23
%
+1.73
%
+8.51
5
3
83.33
8
96
53
78.
13
10
NA
30
0
50
4.2
31
2.5
NA
%
+4.17
%
NA
NA
NA
NA
0
HI
G
LO
31
2.5
1.2
250
0.977
255
21
2
5
2
5
156.
3
0.61
BAUD
RATE
(K)
0.3
1.2
2.4
9.6
19.
2
76.
FOSC = 20 MHz
KBAUD
KBAU
D
NA
1.202
2.404
9.615
NA
1.2
03
2.3
+0.2
3%
-
SPBR
G
value
(decima
9
2
4
80
9.3
22
18.
0.83
2.90
-
6
1
1
5
19.8
64
NA
2.90
79.2
8
96
NA
30
0
50
NA
NA
0
HI
G
LO
11
1.9
0.4
37
BAUD
RATE
(K)
0.3
1.2
2.4
9.6
19.
2
76.
BAUD
RATE
(K)
16 MHz
KBAUD
10 MHz
ERR
OR
+0.1
6%
+0.1
SPBR
G
value
(decima
2
0
1
KBAU
D
NA
1.20
2
2.40
ERR
OR
+0.1
6%
+0.1
6%
+0.1
6%
+0.1
0
2
5
1
4
9.76
6
19.5
6%
+1.7
3%
+1.7
6%
+8.5
1%
2
2
3
78.1
3
NA
3V
+1.7
3%
5.0688
MHz
KBAUD
0.31
1.2
ERR
OR
+3.1
3%
0
SPBR
G
value
(decima
2
5
6
5
3
04
4 MHz
KBAU
D
0.30
05
1.20
2
2.40
ERR
OR
0.17
+1.6
7%
+1.6
SPBR
G
value
(decima
207
51
2
7
4
NA
7%
NA
NA
NA
3%
+3.1
3%
NA
NA
NA
NA
NA
79.2
2
5
0.3094
2
5
62.5
00
3.90
255
FOSC = 3.579545
MHz
SPBR
G
value
(decima
1
8
4
6
2
1 MHz
KBAU
D
0.300
1.202
SPBR
G
value
(decima
5
1
1
2
6
2.232
2
9.32
2
18.6
2%
2.90
-
2
5
NA
6.99
NA
4
NA
2.90
NA
8
96
NA
NA
30
0
50
NA
NA
NA
NA
0
HI
G
LO
55.9
3
0.21
15.63
85
2
5
0.061
0
19.
2
76.
+3.1
3%
+3.1
+0.2
3%
0.83
+1.3
9.6
15
9.9
ERR
OR
+0.1
6%
+0.1
6%
-
2.4
64
2.4
KBAUD
0.30
1
1.19
0
2.43
0.3
1.2
SPBR
G
value
(decima
129
25
32.768
kHz
SPBR
G
value
(decima
1
KBAUD
0.256
NA
ERR
OR
14.67
NA
NA
NA
NA
NA
NA
NA
0.512
2
5
0.0020
255
TABLE 12-5:
9.615
19.23
0
37.87
+0.1
6%
+0.1
6%
-
SPBR
G
value
(decima
1
2
6
4
3
115200
8
56.81
8
113.6
1.36
1.36
-
2
2
1
1
1
58.82
3
111.1
6%
+2.1
2%
-
250000
36
250
1.36
0
0
4
11
250
3.55
0
NA
%
1.36
+8.5
1%
625000
625
NA
625
1250000
1250
NA
NA
ERR
OR
0.160
%
0.160
%
-
SPBR
G
value
(decima
2
5
1
62
6.994
8.507
%
8.507
BAUD
RATE
(K)
9600
19200
38400
57600
BAUD
RATE
(K)
9600
19200
FOSC = 20 MHz
KBAUD
SPBR
G
value
(decima
4
6
2
2
1
9.520
19.45
4
37.28
0.83
+1.3
2%
2.90
2.90
-
1
7
115200
6
55.93
0
111.8
250000
60
NA
2.90
38400
57600
16 MHz
KBAU
D
9.615
19.23
0
38.46
4 MHz
-%
8.348
-
29
62500
8.348
26.700
%
12500
0
25000
0
NA
%
0.000
%
NA
ERR
OR
NA
NA
SPBR
G
value
(decima
N
A
N
A
N
1250000
NA
NA
1 MHz
SPBR
G
value
(decima
6
2
32.768
kHz
KBAU
D
8.928
2083
3.3
3125
ERRO
R
6.994
8.507
%
-
NA
NA
18.620
+8.507
NA
NA
NA
NA
KBAUD
NA
NA
9725.5
43
18640.
63
37281.
1.308
%
2.913
-
25
55921.
88
11124
2.913
2.913
-
3
1
0
6250
0
NA
2.913
10.525
NA
NA
NA
625000
3.8
22368
7.5
NA
NA
NA
NA
1250000
NA
NA
NA
NA
38400
57600
115200
250000
5
1
40
75
52791.
67
10558
9600
19200
62
56.8
18
125
KBAU
D
9615.3
85
19230.
77
35714.
KBAUD
5
1
6
8
ERRO
R
0.016
-%
2.956
3.109
NA
SPBR
G
value
(decima
22
11
ERR
OR
+0.1
6%
1.36
+1.7
SPBR
G
value
(decima
32
16
SPBR
G
value
(decima
6
4
3
2
1
KBAU
9598.4
85
18632.
35
39593.
625000
KBAU
D
9.61
5
18.9
39
39.0
5.068
MHz
3.3
31675
0
NA
BAUD
RATE
(K)
10 MHz
ERR
OR
+0.1
6%
+0.1
6%
+0.1
SPBR
G
value
(decima
1
0
5
1
2
3
0
A
N
A
N
A
N
A
N
A
N
A
12.3
In this mode, the USART uses standard non-return-tozero (NRZ) format (one Start bit, eight or nine data
bits and one Stop bit). The most common data format
is 8-bit. A dedicated 8-bit baud rate generator is used
to derive baud rate frequencies from the oscillator.
The USART transmits and receives the LSb first. The
USARTs transmitter and receiver are functionally
independent, but use the same data format and baud
rate. The baud rate generator produces a clock either
x16 or x64 of the bit shift rate, depending on bit BRGH
(TXSTA<2>). Parity is not supported by the hardware,
but can be implemented in software (and stored as
the ninth data bit). Asynchronous mode is stopped
during Sleep.
Asynchronous mode is selected by clearing bit SYNC
(TXSTA<4>).
The USART Asynchronous module consists of the
following important elements:
12.3.1
USART
ASYNCHRONOUS
TRANSMITTER
FIGURE 12-1:
TXIF
TXIE
8
MSb
(
8
Interrupt
LSb
TSR register
SPEN
SPBRG
Baud Rate Generator
TX9
TX9D
2.
3.
4.
5.
6.
7.
8.
FIGURE 12-2:
DS40044G-page 80
ASYNCHRONOUS TRANSMISSION
Write to TXREG
Word 1
Start bit
bit 0
bit 1
Word 1
Word 1
TRMT bit
(Transmit shift reg. empty flag) Transmit Shift Reg.
DS40044G-page 81
FIGURE 12-3:
Write to TXREG
Word 1Word 2
Start bit
bit 0
bit 1
Word 1
Start bit
Word 2
Word 2
Transmit Shift Reg.
TABLE 12-6:
Addre
ss
Nam
e
0Ch
18h
Bit
6
Bit
5
Bit
4
Bit 2
Bit 1
Bit 0
AD
EN
CCP1
IF
FERR
TMR2
IF
OER
R
TMR1
IF
RX9D
0000
0000
000x
0000
Value
on all
other
Rese
0000
0000
000x
0000
CCP1
IE
BRG
TMR2
IE
TRMT
TMR1
IE
TX9D
0000
0000
-000
0000
0000
0000
-000
0000
-010
0000
0000
-010
0000
0000
19h
PIR1
RCS
TA
TXR
8Ch
EG
PIE1
98h
TXS
TA
H
SPB
RG
x = unknown, - = unimplemented locations read as 0.
Shaded cells are not used for Asynchronous Transmission.
99h
Legend:
EEI
C
RCI
TXI
F
MI
F
F
SP
RX
SR
CRE
EN
9
EN
USART Transmit Data Register N
Bit
3
EEI
E
CS
C
RCI
TXI
MI
E
E
TX
TX
SYN
RC
9
EN
Baud Rate Generator Register C
Value
on
POR
bit 0
12.3.2
USART
ASYNCHRONOUS
RECEIVER
FIGURE 12-4:
OERR
64 or
16
MSb
Stop (8)
RSR register
LSb
0 Start
RB1/RX/DT
Pin Bufer and Control
Data Recovery
RX9
8
SPEN
RX9
ADEN
Enable Load of
Receive Bufer
RX9DRCREG register
FI
FO
RX9DRCREG register
8
Interrupt
RCIF
Data Bus
RCIE
DS40044G-page 82
FIGURE 12-5:
RB1/RX/DT (Pin)
bit 1
Start
bit 8 Stop bit bitbit 0
Read RCV
Bufer Reg RCREG
RCIF
(interrupt flag)
1
ADEN = 1
(Address Match Enable)
Note:This timing diagram shows a data byte followed by an address byte. The data byte is not read into the RCREG
(Receive Bufer) because ADEN = 1 and bit 8 = 0.
FIGURE 12-6:
RB1/RX/DT (pin)
bit 1
bit 8
Start
Stopbit bit
bit 0
Note:This timing diagram shows an address byte followed by an data byte. The data byte is not read into the RCREG
(receive bufer) because ADEN was not updated (still = 1) and bit 8 = 0.
FIGURE 12-7:
bit 1
bit 8
Start
Stopbit
bit 0
bit
RCIF
(Interrupt Flag)
ADEN
(Address Match Enable)
Note: This timing diagram shows an address byte followed by an data byte. The data byte is read into the RCREG (Receive Bufer) because ADEN was up
TABLE 12-7:
Addre
ss
Nam
e
0Ch
PIR1
18h
RCST
A
RCRE
G
PIE1
1Ah
8Ch
98h
99h
Legend:
Bit
6
EEI
F
SP
CMI
FRX
Bit
5
Bit 4
RCI
TXIF
F
SRE
CRE
EN
9
N
N
USART Receive Data Register
Bit
3
Bit 2
Bit 1
Bit 0
CCP
1IF
FER
TMR2
IF
OER
TMR1
IF
RX9D
Value
on
POR
00
00
00
0x
00
0x
R
R
00
00
00
00
00
00
00
00
EEI
CMI
RCI
TXIE
CCP
TMR2
TMR1
00
00
00
00
00
00
E
E
E
1IE
IE
IE
TXST
CS
TX
TXE
SYN
BRG
TRMT
TX9D
00
00
00
01
00
01
A
RC
9
N
C
H
SPBR
Baud Rate Generator Register
00
00
00
00
00
00
00
00
G
x = unknown, - = unimplemented locations read as 0. Shaded cells are not used for asynchronous reception.
AD
EN
00
00
00
Value
on all
other
Reset
00
00
00
00
00
12.4
12.4.1
The ADEN bit will only take effect when the receiver is
configured in 9-bit mode (RX9 = 1). When ADEN is
disabled (= 0), all data bytes are received and the 9th
bit can be used as the parity bit.
12.3.1.1
Nam
e
Bit
7
Bit
6
Bit 5
0Ch
PIR1
RCS
TA
RCR
EG
PIE1
EEI
F
SP
CM
IF
RX
RCIF
18h
98h
99h
Legend:
TXST
A
SPBR
G
bit
CREN
Addre
ss
8Ch
setting
1.
1Ah
by
TABLE 12-8:
enabled
Bit
4
TXI
F
SRE
CRE
EN
9
N
N
USART Receive Data Register
EEI
CM
RCIE
TXI
E
IE
E
CS
TX
TXEN
SYN
RC
9
C
Baud Rate Generator Register
Bit 3
Bit 2
CCP
1IF
FER
ADE
N
R
CCP
1IE
BRG
H
Bit
1
TMR2
IF
OER
R
TMR2
IE
TRM
T
Bit 0
TMR
1IF
RX9
D
TMR
1IE
TX9D
Value on
POR
Value
on all
other
Reset
00
-
00
00
00
00
00
00
00
00
00
00
00
0x
00
00
00
01
00
00
00
00
00
00
00
00
00
000
00
0x
00
00
00
01
00
00
00
00
x = unknown, - = unimplemented locations read as 0. Shaded cells are not used for
asynchronous reception.
12.4
12.4.1
5.
6.
7.
2.
3.
4.
8.
TABLE 12-9:
Addre
ss
Nam
e
0Ch
18h
Bit
6
Bit
5
Bit
4
PIR1
EEIF
RCS
TA
TXR
EG
PIE1
SPEN
CM
IF
RX
RCI
F
SR
TXI
F
CR
Bit 3
Bit 2
Bit 1
Bit 0
CCP1
IF
FERR
TMR
2IF
OER
TMR
1IF
RX9
ADE
N
Value
on
PO
0000
Value on
all other
Resets
0000
0000
0000
000x
000x
0000
0000
0000
0000
8Ch
EEIE
CM
RCI
TXI
CCP1
TMR
TMR
0000
0000
-000
-000
IE
E
E
IE
2IE
1IE
98h
TXST
CSR
TX
TX
SY
BRG
TRM
TX9D
0000
0000
-010
-010
A
C
9
EN
NC
H
T
99h
SPB
Baud Rate Generator Register
0000
0000
0000
0000
RG
Legend:
x = unknown, - = unimplemented, read as 0. Shaded cells are not used for synchronous master transmission.
19h
FIGURE 12-8:
9
EN
EN
USART Transmit Data Register
SYNCHRONOUS TRANSMISSION
Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q3Q4
Q1Q2Q3Q4 Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4
Word 2
TRMTbit
TRMT
1
TXEN bit
FIGURE 12-9:
RB1/RX/DT pin
RB2/TX/CK pin
TRMT bit
TXEN bit
bit 0
bit 1
bit 2
bit 6
bit 7
12.4.2
1.
Nam
e
Bit 7
0Ch
18h
PIR1
RCST
A
RCR
EG
PIE1
EEIF
SPEN
1Ah
8Ch
98h
99h
Legend:
TXST
A
SPB
Bit
4
Bit 3
Bit
2
Bit 1
Bit 0
C
RCI
TXI
MI
F
F
RX
SR
CR
9
EN
EN
USART Receive Data Register
ADE
N
CCP1
IFFER
R
TMR
2IF
OER
R
TMR1
IF
RX9D
CCP1
IE
BRG
H
TMR2
IE
TRM
T
TMR1
IE
TX9D
EPIE
Bit
6
Bit
5
CM
RCI
TXI
IE
E
E
CSR
TX
TX
SY
C Rate Generator
9
ENRegister
NC
Baud
Value
on:
POR
0000
0000
000x
0000
0000
-000
0000
0000
-010
0000
Value on
all other
Resets
0000
0000
000x
0000
0000
-000
-000
0000
-010
0000
0000
0000
RG
x = unknown, - = unimplemented read as 0. Shaded cells are not used for synchronous master reception.
FIGURE 12-10:
bit 0
bit 1
bit 2
bit 3
bit 4
bit 5
bit 6
bit 7
RB2/TX/CK pin
WRITE to
Bit SREN
SREN bit
CREN bit
RCIF bit
(Interrupt)
Read
RXREG
Note:
12.5
Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRG =
12.5.1
e)
2.
3.
4.
5.
6.
7.
8.
12.5.2
1.
2.
3.
4.
5.
6.
7.
8.
9.
Nam
e
0Ch
PIR1
18h
RCST
A
TXRE
G
PIE1
Bit 7
Bit
6
EEIF
CMI
RXF
Bit
5
Bit
4
RCI
TXI
F
F
SR
CRE
9
EN
N
USART Transmit Data Register
SPEN
Bit 3
ADE
N
Bit
2
CCP1
FERIF
R
Bit 1
Bit 0
TMR2
IF
OER
TMR1
IF
RX9D
Value
on
PO
0000
-000
0000
Value on
all other
Resets
0000
-000
0000
000x
000x
0000
0000
0000
0000
8Ch
EEIE
CMI
RCI
TXI
CCP1
TMR2
TMR1
0000
0000
-000
-000
E
E
E
IE
IE
IE
98h
TXST
CSR
TX
TXE
SYN
BRG
TRMT
TX9D
0000
0000
-010
-010
A
C
9
N
C
H
99h
SPBR
Baud Rate Generator Register
0000
0000
0000
0000
G
Legend:
x = unknown, - = unimplemented read as 0. Shaded cells are not used for synchronous slave transmission.
19h
Name
Bit 7
0Ch
PIR1
EEIF
18h
RCS
TA
RCR
EG
PIE1
Bit
6
Bit
5
Bit
4
C
RCI
TXI
MI
F
F
SPE
RX
SR
CR
N
9
EN
EN
USART Receive Data Register
Bit 3
Bit
2
Bit 1
Bit 0
CCP1
IFFER
TMR
2IF
OER
TMR1
IF
RX9D
ADE
N
Value
on
POR
0000
Value on
all other
Resets
0000
0000
0000
000x
000x
0000
0000
0000
0000
8Ch
EEIE
C
RCI
TXI
CCP1
TMR
TMR1
0000
0000
-000
-000
MI
E
E
IE
2IE
IE
98h
TXST
CSR
TX
TX
SY
BRG
TRM
TX9D
0000
0000
-010
-010
A
C
9
EN
NC
H
T
99h
SPB
Baud Rate Generator Register
0000
0000
0000
0000
RG
Legend: x = unknown, - = unimplemented read as 0. Shaded cells are not used for synchronous slave reception.
1Ah
DS40044G-page 90
13.1
EECON1
EECON2 (Not a physically implemented register)
EEDATA
EEADR
REGISTER 13-1:
bit 7-0
R/W-x
EEDAT
7 7
bit
EEDAT
6
R/W-x
EEDA
T5
R/W-x
EEDAT
4
R/W-x
EEDAT3
R/W-x
EEDA
T2
R/W-x
EEDA
T1
R/W-x
EEDA
T0 bit 0
EEDATn: Byte value to Write to or Read from data EEPROM memory location.
Legend:
R = Readable bit
-n = Value at POR
REGISTER 13-2:
x = Bit is unknown
bit 7
W = Writable
bit
1 = Bit is set
R/W-x
EADR
6
R/W-x
EADR
5
R/W-x
EADR
4
R/W-x
EADR3
R/W-x
EADR
2
R/W-x
EADR
1
R/W-x
EADR
0 bit 0
PIC16F627A/628A
Unimplemented Address: Must be set to 0
PIC16F648A
EEADR: Set to 1 specifies top 128 locations (128-255) of EEPROM Read/Write
Legend:
R = Readable bit
-n = Value at POR
W = Writable
bit
1 = Bit is set
x = Bit is unknown
13.2
EEADR
13.3
REGISTER 13-3:
U-0
U-0
U-0
bit 7
bit 7-4
Unimplemented: Read as 0
bit 3
R/W-x
WRERR
R/W-0
WRE
N
R/S-0
WR
R/S-0
RD
bit 0
1 = A write operation is prematurely terminated (any MCLR Reset, any WDT Reset during
normal operation or BOR Reset)
0 = The write operation
completed bit 2
WREN: EEPROM
Write Enable bit
1 = Allows write cycles
0 = Inhibits write to the data EEPROM
bit 1
DS40044G-page 92
W = Writable
bit = Bit is set
1
x = Bit is unknown
13.4
Reading the
Data Memory
EEPROM
EXAMPLE 13-1:
BSF
STATUS, RP0
1 MOVLW CONFIG_ADDR
MOVWF
EEADR
read BSF
;EE Read
MOVF
EEDATA, W
EEDATA BCF
13.5
;Bank
;
;Address to
EECON1, RD
;W =
STATUS,
Writing to the
Data Memory
EEPROM
EXAMPLE 13-2:
Required Sequence
BSF
STATUS, RP0
;Bank 1
BSF BCF BTFSC GOTO EECON1,
MOVLW MOVWF
WREN INTCON,
MOVLW MOVWF
GIE INTCON,GIE
;Enable
BSF write
$-2 55h EECON2
;Disable INTs.
AAh EECON2 EECON1,WR
;See AN576
;
;Write 55h
;
;Write AAh
;Set WR bit
;begin write
;Enable INTs.
13.6
Write Verify
EXAMPLE 13-3:
WRITE VERIFY
SUB
WF
BTF
SS
GOT
O
:
:
13.7
EEDATA,
W
STATUS,
Z
WRITE_E
RR
;
;Is difference
0?
;NO,
Write
error Good
;YES,
write
;Continue
13.8
EXAMPLE 13-4:
BANKSE
L
CLRF
BCF
BTFS
C
GOTO
LoopBSF
BSF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BTFSC
GOTO
#IFDEF
GIE
GIE
;select Bank1
;start at address 0
;disable interrupts
;see AN576
;enable EE writes
RD
WR
WR
16F648A
EEADR, f
INCFSZ
#ELSE
INCF BTFSS EEADR, f EEADR, 7
#ENDIF
GOTO
Loop
BCF
BSF
13.9
Data
EEPROM
Operation
During Code-Protect
TABLE 13-1:
Value
on
Bi
Bi
Bi
Bi
Bit 3
Bit
Bit
Bit
t
t
t
t
2
1
0
Power7
6
5
4
on
9Ah
EEDATA
EEPROM Data Register
xxxx
9Bh
EEADR
EEPROM Address Register
xxxx
9Ch
EECON1
WRE
WRE
WR
RD
---RR
N
EECON2
9Dh
EEPROM Control Register 2
---(1)
Legend:
x = unknown, u = unchanged, - = unimplemented read as 0, q = value depends upon condition.
Shaded cells are not used by data EEPROM.
Note 1: EECON2 is not a physical register.
Addre
ss
Name
Value on
all other
Resets
uuuu
uuuu
-------
NOTES:
14.0
OSC selection
Reset
3. Power-on Reset (POR)
4. Power-up Timer (PWRT)
5. Oscillator Start-Up Timer (OST)
6. Brown-out Reset (BOR)
7. Interrupts
8. Watchdog Timer (WDT)
9. Sleep
10. Code protection
11. ID Locations
12. In-Circuit Serial Programming (ICSP)
The PIC16F627A/628A/648A has a Watchdog Timer
which is controlled by configuration bits. It runs off its
own RC oscillator for added reliability. There are two
timers that offer necessary delays on power-up. One
is the Oscillator Start-up Timer (OST), intended to
keep the chip in Reset until the crystal oscillator is
stable. The other is the Power-up Timer (PWRT),
which provides a fixed delay of 72 ms (nominal) on
power-up only, designed to keep the part in Reset
while the power supply stabilizes. There is also
circuitry to reset the device if a brown-out occurs.
With these three functions on-chip, most applications
need no external Reset circuitry.
The Sleep mode is designed to offer a very low
current Power-down mode. The user can wake-up
from Sleep through external Reset, Watchdog Timer
wake-up or through an interrupt. Several oscillator
options are also made available to allow the part to fit
the application. The RC oscillator option saves system
cost while the LP crystal option saves power. A set of
configuration bits are used to select various options.
14.1
Configuration Bits
REGISTER 14-1:
CP
CP
D
bit 13
bit 13:
LVP
BOR
EN
MCL
RE
FOS
C2
PWR
TE
WDT
E
F0S
C1
F0SC
0
bit 7:
bit 6:
bit 5:
bit 3:
bit 2:
bit 4, 1-0:
1:
2:
3:
4:
(1)
Enabling Brown-out Reset does not automatically enable the Power-up Timer (PWRT) the way it does on
the PIC16F627/628 devices.
The code protection scheme has changed from the code protection scheme used on the PIC16F627/628 devices.
The entire Flash program memory needs to be bulk erased to set the CP bit, turning the code protection off. See
PIC16F627A/628A/648A EEPROM Memory Programming Specification (DS41196) for details.
The entire data EEPROM needs to be bulk erased to set the CPD bit, turning the code protection off. See
PIC16F627A/ 628A/648A EEPROM Memory Programming Specification (DS41196) for details.
When MCLR is asserted in INTOSC mode, the internal clock oscillator is disabled.
Legend:
R = Readable bit
W = Writable
-n = Value at POR
bit 1 = bit is
as 0 0 = bit is cleared
set
x = bit is unknown
bit 0
14.2
14.2.1
Oscillator Configurations
OSCILLATOR TYPES
LP
Low Power Crystal
XT
Crystal/Resonator
HS
High Speed Crystal/Resonator
RC
External Resistor/Capacitor (2 modes)
INTOSC Internal Precision Oscillator (2 modes)
EC
External Clock In
14.2.2
TABLE 14-1:
Mod
e
XT
HS
Note:
FIGURE 14-1:
CRYSTAL OPERATION
(OR CERAMIC RESONATOR)
(HS, XT OR LP OSC
CONFIGURATION)
OSC1
C1(2)
XTAL
OSC2
RS(1)
RF
Sleep
FOSC
C2(2)
PIC16F627A/628A/648A
Note 1: A series resistor may be required for AT strip cut crystals.
2: See and for recommended values of C1 and C2.
Freq
Mode
Freq
LP
32 kHz
200
kHz
100
kHz
2 MHz
4
8 MHz
MHz
HS
Note:
OSC2(C2
)
22-100 pF
15-68 pF
15-68 pF
10-68 pF
10-22 pF
455 kHz
2.0
MHz
4.0
8.0
MHz
16.0
Higher capacitance increases the stability
of the oscillator, but also increases the
start-up time. These values are for design
guidance only. Since each resonator has
its own characteristics, the user should
consult the resonator manufacturer for
appropriate values of external components.
TABLE 14-2:
XT
OSC1(C1
)
22-100 pF
15-68 pF
15-68 pF
10-68 pF
10-22 pF
OSC1(C1
)
15-30 pF
0-15 pF
68-150
pF
15-30 pF
15-30
15-30 pF
pF
OSC2(C2
)
15-30 pF
0-15 pF
150-200
pF
15-30 pF
15-30
15-30 pF
pF
10
15-30 pF
15-30 pF
MHz
15-30 pF
15-30 pF
20 capacitance increases the stability
Higher
of the oscillator, but also increases the
start-up time. These values are for design
guidance only. A series resistor (RS) may
be required in HS mode, as well as XT
mode, to avoid overdriving crystals with
low drive level specification. Since each
crystal has its own characteristics, the
user should consult the crystal manufacturer for appropriate values of external
components.
14.2.3
FIGURE 14-2:
EXTERNAL PARALLEL
RESONANT CRYSTAL
OSCILLATOR CIRCUIT
+5V
To other Devices
10K
4.7K
74AS04
74AS04
PIC16F627A/628A/648A
CLKIN
FIGURE 14-3:
330 K
EXTERNAL SERIES
RESONANT CRYSTAL
OSCILLATOR CIRCUIT
330 K
To other
Devices
74AS0474AS0474AS04
CLKIN
0.1 pF
PIC16F627A/ 628A/648A
XTAL
14.2.4
14.2.5
EXTERNAL CLOCK IN
10K
XTAL
FIGURE 14-4:
10K
C1
C2
Clock from
ext. system
RA7/OSC1/CLKIN
PIC16F627A/628A/648A
RA6 RA6/OSC2/CLKOUT
DS40044G-page 101
14.2.6
RC OSCILLATOR
14.2.8
Supply voltage
Resistor (REXT) and capacitor (CEXT) values
Operating temperature
The oscillator frequency will vary from unit-to-unit due
to normal process parameter variation. The difference
in lead frame capacitance between package types will
also affect the oscillation frequency, especially for low
CEXT values. The user also needs to account for the
tolerance of the external R and C components.
Figure 14-5 shows how the R/C combination is
connected.
FIGURE 14-5:
VDD
RC OSCILLATOR MODE
PIC16F627A/628A/648A
REXT
RA7/OSC1/
CLKIN
14.3
Internal
Clock
FOSC/4
RA6/OSC2/CLKOUT
14.2.7
CLKOUT
Reset
CEXT
VSS
c)
d)
e)
FIGURE 14-6:
MCLR/
VPP Pin
WDT WDT
Time-out Reset
Module
VDD Rise
Detect
Power-on Reset
VDD
Brown-out
Reset
BOREN
OST/PWRT
OST
Chip_Reset
10-bit Ripple-counter
OSC1/
CLKIN
Pin
PWRT
On-chip(1) OSC 10-bit Ripple-counter
Enable PWRT
Enable OST
Note
1:
DS40044G-page 102
14.4
14.4.1
14.4.3
14.4.4
14.4.2
FIGURE 14-7:
VBOR
TBOR
Internal
Reset
72 ms
VDD
Internal
Reset
VBOR
<72 ms
72 ms
VDD
Internal
Reset
VBOR
72 ms
14.4.5
14.4.6
TABLE 14-3:
Brown-out Reset
Wake-up
from
Oscillator
Configuration
PWRTE = 0
PWRTE = 1
PWRTE = 0
PWRTE = 1
XT, HS,
LP
RC, EC
72 ms +
1024TOSC
72 ms
1024TO
1024TO
1024TO
SC
SC
INTOSC
72 ms
72 ms +
1024TOSC
72
ms
72
6 s
SC
ms
TABLE 14-4:
POR
BOR
TO
PD
Power-on Reset
Brown-out Reset
WDT Reset
WDT Wake-up
1
Legend:
u = unchanged, x = unknown
Conditi
on
TABLE 14-5:
Addr
ess
Note
Value on
Value
all other
Bi
Bit 5
Bit 4
Bit
Bit 2
Bit 1
Bit 0
on POR
t
3
Resets(1)
Reset
6
STAT
IRP
R
RPO
Z
DC
C
0001
000q
TO
P
1xxx
quuu
US
P
D
1
POR
BOR
PCON
OS
---- 1---- ux = unknown, u = unchanged, - = unimplemented read as 0, q = value depends upon condition.
Shaded cells are not used by Brown-out Reset.
Other (non Power-up) Resets include MCLR Reset, Brown-out Reset and Watchdog Timer Reset during normal operation.
Name
03h,
83h,
103h,
8Eh
Legend:
1:
TABLE 14-6:
Bit
7
Program
Counter
Power-on Reset
000h
000h
000h
WDT Reset
WDT Wake-up
Brown-out Reset
Interrupt Wake-up from Sleep
000h
PC + 1
000h
PC + 1(1)
Statu
s
Regis
0001
000u
uuuu
0001
0uuu
0000
uuuu
uuu0
0uuu
000x
xuuu
uuu1
0uuu
PCON
Register
---- 1---- 1uu
---- 1uu 1---uu u---uu 1---u0
---- uuu
TABLE 14-7:
Register
Address
Power-on
Reset
00h, 80h,
100h,
180h101h
01h,
xxxx xxxx
uuuu uuuu
uuuu uuuu
xxxx xxxx
uuuu uuuu
uuuu uuuu
0000 0000
0000 0000
PC + 1(3)
FSR
02h, 82h,
102h,
182h
03h, 83h,
103h,
183h
04h, 84h,
PORTA
104h,
184h
05h
W
INDF
TMR0
PCL
STATUS
000q
uuuq
quuu(4)
0uuu(4)
xxxx xxxx
uuuu uuuu
uuuu uuuu
0001 1xxx
xxxx 0000
xxxx 0000
uuuu uuuu
PORTB
06h, 106h
xxxx xxxx
uuuu uuuu
uuuu uuuu
PCLATH
0Ah, 8Ah,
10Ah,
18Ah
0Bh, 8Bh,
10Bh,18B
h
0Ch
---0 0000
---0 0000
---u uuuu
0000 000x
0000 000u
INTCON
uuuu
uqqq(2)
0000 -000
0000 -000
TMR1L
0Eh
xxxx xxxx
uuuu uuuu
qqqq
(2)
-qqquuuu
uuuu
TMR1H
0Fh
xxxx xxxx
uuuu uuuu
uuuu uuuu
T1CON
10h
--00 0000
--uu uuuu
TMR2
11h
0000 0000
--uu
(6)
uuuu0000
0000
T2CON
12h
-000 0000
-000 0000
-uuu uuuu
CCPR1L
15h
xxxx xxxx
uuuu uuuu
uuuu uuuu
CCPR1H
16h
xxxx xxxx
uuuu uuuu
uuuu uuuu
CCP1CON
17h
--00 0000
--00 0000
--uu uuuu
RCSTA
18h
0000 000x
0000 000x
uuuu uuuu
TXREG
19h
0000 0000
0000 0000
uuuu uuuu
RCREG
1Ah
0000 0000
0000 0000
uuuu uuuu
CMCON
1Fh
0000 0000
0000 0000
uu-- uuuu
OPTION
81h,181h
1111 1111
1111 1111
uuuu uuuu
TRISA
85h
1111 1111
1111 1111
uuuu uuuu
TRISB
86h, 186h
1111 1111
1111 1111
uuuu uuuu
PIE1
8Ch
0000 -000
uuuu -uuu
PCON
8Eh
---- 1-0x
0000 -000
---- 1-
PR2
92h
1111 1111
uq(1,5)
1111
1111
TXSTA
98h
0000 -010
0000 -010
uuuu -uuu
SPBRG
99h
0000 0000
0000 0000
uuuu uuuu
EEDATA
9Ah
xxxx xxxx
uuuu uuuu
uuuu uuuu
EEADR
9Bh
xxxx xxxx
uuuu uuuu
uuuu uuuu
EECON1
9Ch
---- x000
---- q000
---- uuuu
EECON2
9Dh
VRCON
9Fh
000- 0000
000- 0000
uuu- uuuu
PIR1
Legend:
Note 1:
2:
3:
4:
5:
6:
7:
uuuu uuuu
---- u-uu
uuuu uuuu
FIGURE 14-8:
VDD
MCLR
Internal POR
TPWRT
TOST
FIGURE 14-9:
VDD
MCLR
Internal POR
TPWRT
TOST
FIGURE 14-10:
VDD
MCLR
Internal POR
TPWRT
TOST
FIGURE 14-11:
VDD
EXTERNAL POWER-ON
RESET CIRCUIT (FOR
SLOW VDD POWER-UP)
EXTERNAL BROWN-OUT
PROTECTION CIRCUIT 2
VDD
VDD
D
FIGURE 14-13:
VDD
R1
Q1
MCLR
PIC16F627A/628A/648A
R1
MCLR
R2
40k PIC16F627A/628A/648A
FIGURE 14-12:
OUT
VDD
VDD
33k
10k
MCLR
40k PIC16F627A/628A/648A
14.5
Interrupts
FIGURE 14-14:
TMR1IF
TMR1IE TMR2IF TMR2IE
CCP1IF CCP1IE CMIF CMIE
TXIF TXIE
RCIF RCIE EEIF
EEIE
INTERRUPT LOGIC
T0IF
T0IE
INTF INTE
RBIF RBIE
Interrupt to CPU
Note 1:
PEIE
GIE
Some peripherals depend upon the system clock for operation. Since the system clock is
suspended during Sleep, only those peripherals which do not depend upon the system clock will wake the part from Sleep. See .
14.5.1
RB0/INT INTERRUPT
14.5.3
14.5.2
PORTB INTERRUPT
14.5.4
COMPARATOR INTERRUPT
TMR0 INTERRUPT
FIGURE 14-15:
Q2
Q3
Q4
Q1
Q2
Q3
Q4
Q1
Q2
Q3
Q4
Q1
Q2
Q3
Q4
Q1
Q2
Q3 Q4
OSC1
CLKOUT
(3)
(4)
INT pin
(1)
(1)
(5)
PC
Inst (PC)
Instruction Executed
Inst (PC - 1)
PC + 1
Inst (PC + 1)
Inst (PC)
0004h
PC + 1
0005h
Inst (0004h)
Dummy Cycle
Dummy Cycle
Inst (0005h)
Inst (0004h)
DS40044G-page 110
TABLE 14-8:
Addre
ss
Name
0Bh,
8Bh,
0Ch
8Ch
INTC
ON
PIR1
PIE1
Bi
t7
Bit
6
Bit 5
Bit
4
Bit 3
Bit 2
Bit 1
Bit 0
Value
on POR
Reset
0000
000x
0000
0000
Value on
all other
Resets(1)
GI
PEI
T0IE
INT
RBIE
T0IF
INTF
RBIF
0000
000u
E
E
E
E
CM
RCIF
TXI
CCP
TMR
TMR
0000
EI
IF
F
1IF
2IF
1IF
E
CM
RCIE
TXI
CCP
TMR
TMR
0000
EI
IE
E
1IE
2IE
1IE
Note 1: Other (non Power-up) Resets include MCLR Reset, Brown-out Reset and Watchdog Timer Reset during normal
operation.
14.6
EXAMPLE 14-1:
MOVWFW_TEMP
14.7
14.7.1
WDT PERIOD
14.7.2
WDT PROGRAMMING
CONSIDERATIONS
FIGURE 14-16:
M 0
UX
1
Watchdog Timer
WDT Postscaler/
TMR0 Prescaler
8
8 to 1 MUX
PSA
PS<2:0>
WDT
Enable Bit
To TMR0
(F-1)
MUX
1PSA
WDT
Time-out
Note:T0SE, T0CS, PSA, PS0-PS2 are bits in the OPTION register.
TABLE 14-9:
Addre
ss
Name
Bit
7
Bit 6
Bit 5
Bit 4
Bit 3
Bit
2
2007h
Bit 1
Bit 0
Value
on POR
Reset
CON
LV
BOR
MCL
FOS
WDT
FOS
FOS
uuuu
PWRT
FIG
P
EN
RE
C2
E
C1
C0
RB
81h,
OPTI
INTE
T0C
T0S
PSA
PS
PS1
PS0
1111
Legend: x = unknown, PU
u = unchanged, - = unimplemented read as 0, q = value depends upon condition.
Note: Shaded cells are not used by the Watchdog Timer.
14.8
Value
on all
other
Rese
uuuu
1111
DS40044G-page 112
14.8.1
FIGURE 14-17:
OSC1
CLKOUT(4)
INT pin INTF flag
(INTCON<1>)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
TOST(1,2)
Processor in
Sleep
Instruction Flow
PC PC + 1 PC + 2 PC + 2 PC + 20004h(3) 0005h
PC
Instruction Fetched
Inst(PC) = Sleep Inst(PC + 1)
Instruction Executed
Inst(PC - 1)
Sleep
Inst(PC + 2)
Inst(PC + 1)
Dummy cycle
Inst(0004h)
Inst(0005h)
Dummy cycle
Inst(0004h)
14.9
Code Protection
14.11 In-Circuit
Serial
Programming (ICSP)
The PIC16F627A/628A/648A microcontrollers can be
serially programmed while in the end application
circuit. This is simply done with two lines for clock and
data, and three other lines for power, ground and the
programming voltage. This allows customers to
manufacture boards with unprogrammed devices and
then program the microcontroller just before shipping
the product. This also allows the most recent firmware
or custom firmware to be programmed.
The device is placed into a Program/Verify mode by
holding the RB6 and RB7 pins low while raising the
MCLR (VPP) pin from VIL
to VIHH. See
PIC16F627A/
628A/648A
EEPROM Memory Programming
Specification (DS41196) for details. RB6 becomes the
programming clock and RB7 becomes the
programming data. Both RB6 and RB7 are Schmitt
Trigger inputs in this mode.
After Reset, to place the device into Programming/Verify
mode, the Program Counter (PC) is at location 00h. A
6-bit command is then supplied to the device.
Depending on the command, 14 bits of program data
are then supplied to or from the device, depending if
the command was a load or a read. For complete
details of serial programming, please refer to
PIC16F627A/628A/648A
EEPROM
Memory
Programming Specification (DS41196).
A typical In-Circuit Serial Programming connection is
shown in Figure 14-18.
FIGURE 14-18:
External
Connector Signals
+5V
0V VPP
TYPICAL IN-CIRCUIT
SERIAL PROGRAMMING
CONNECTION
To Normal
Connections
PIC16F627A/628A/648A
VDD
VSS RA5/MCLR/VPP
CLK
RB6/PGC
Data I/O
RB7/PGD
VDD
To Normal
Connections
ICDCLK, ICDDATA
1 level
Address 0h must be
NOP
300h-3FEh
The PIC16F648A-ICD device with header is supplied
as an assembly. See Microchip Part Number
AC162053.
NOTES:
15.1
15.2
Read-Modify-Write Operations
TABLE 15-1:
Fiel
d
OPCODE FIELD
DESCRIPTIONS
Descripti
on
f
W
TO
Time-out bit
PD
Power-down bit
Byte-oriented operations
Bit-oriented operations
Literal and control operations
All instructions are executed within one single
instruction cycle, unless a conditional test is true or
the program counter is changed as a result of an
instruction. In this case, the execution takes two
instruction cycles with the second cycle executed as a
NOP. One instruction cycle consists of four oscillator
periods. Thus, for an oscillator frequency of 4 MHz,
the normal instruction execution time is 1 s. If a
conditional test is true or the program counter is
changed as a result of an instruction, the instruction
execution time is 2 s.
Table 15-2 lists the instructions recognized by the
MPASM assembler.
Figure 15-1 shows the three general formats that the
instructions can have.
Note 1: Any unused opcode is reserved. Use of
any reserved opcode may cause unexpected operation.
2: To maintain upward compatibility with
future PIC MCU products, do not use the
OPTION and TRIS instructions.
All examples use the following format to represent a
hexadecimal number:
0xhh
where h signifies a hexadecimal digit.
FIGURE 15-1:
f (FILE #)
d = 0 for destination W
d = 1 for destination f
f = 7-bit file register address
Bit-oriented file register operations
1310 97 6 b (BIT
OPCODE
#)
f (FILE #)
TABLE 15-2:
Mnemonic,
Operands
ADDWF
ANDWF
CLRF
CLRW
COMF
DECF
DECFSZ
INCF
INCFSZ
IORWF
MOVF
MOVWF
NOP
RLF
RRF
SUBWF
SWAPF
XORWF
f
f,
f,
f
f,
f,
,f
f,
f,
,f
f,
f
f,
,f
f,
f,
,
BCF
BSF
BTFSC
BTFSS
f
f,
f
f
,
Descripti
on
Cycl
es
14-Bit Opcode
1
1
1
1
(
LITERAL AND CONTROL
OPERATIONS
1
1
2
1
2
1
1
2
2
2
1
1
1
Stat
us
Affec
MSb
0
1
0
0
0
1
00b
b
01b
10b
11b
b
d
f
d
f
l
f
0
x
d
f
d
d
f
d
d
f
d
f
d
f
l
f
0
x
d
f
d
f
d
f
d
f
d
f
ff
ff
ff
ff
xx
xx
ff
ff
ff
ff
ff
ff
ff
ff
ff
00
00
ff
ff
ff
ff
ff
ff
b
f
b
b
b
f
ff
ff
ff
ff
ff
C,DC,
Z
Z
Z
Z
Z
Z
Z
Z
C
C
C,DC,
Z
Z
Not
es
1, 2
1, 2
2
1, 2
1, 2
1, 2, 3
1, 2
1, 2, 3
1, 2
1, 2
1, 2
1, 2
1, 2
1, 2
1, 2
1, 2
1, 2
3
3
1
111
k
kk
C,DC,
1
x
k
kk
Z
100
1
0kk
k
kk
TO,PD
0
000
0
01
1
1kk
k
kk
Z
1
100
k
kk
1
00x
k
kk
0
000
0
10
1
01x
k
kk
0
000
0
10
TO,PD
0
000
0
00
C,DC,
1
110
k
kk
Z
1
101
k
kk
1
0
k
kk
Note 1: When an I/O register is modified as a function of itself (e.g., MOVF PORTB, 1), the value used will be that value present on the
pins themselves. For example, if the data latch is 1 for a pin configured as input and is driven low by an external device, the
data will be written back with a 0.
2: If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared if assigned to the
Timer0 Module.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The second cycle is
executed as a NOP.
ADDLW
ANDLW
CALL
CLRWDT
GOTO
IORLW
MOVLW
RETFIE
RETLW
RETURN
SLEEP
SUBLW
XORLW
k
k
k
k
k
k
k
k
15.3
Instruction Descriptions
ADDLW
Syntax:
[ label ] ADDLW
Operands:
0 k 255
Operation:
(W) + k (W)
Status Affected:
C, DC, Z
Encoding:
11
Description:
Words:
Cycles:
Example
ADDLW
111
x
kkkk
kkk
k
0x15
Before Instruction
W = 0x10
After Instruction
W = 0x25
ADDWF
Add W and f
Syntax:
[ label ] ADDWF
Operands:
0 f 127
ANDLW
Syntax:
[ label ] ANDLW
Operands:
0 k 255
Operation:
Status Affected:
Encoding:
11
100
1
kkkk
Description:
Words:
Cycles:
Example
ANDLW
0x5F
Before Instruction
W = 0xA3
After Instruction
W = 0x03
f,d
d 0,1
ANDWF
AND W with f
Syntax:
[ label ] ANDWF
Operands:
0 f 127
d 0,1
f,d
Operation:
Status Affected:
C, DC, Z
Status Affected:
Encoding:
00
Encoding:
00
Description:
Operation:
Words:
Cycles:
Example
ADDWF
011
1
kkk
k
dfff
REG1, 0
Before Instruction
W
= 0x17
REG1 = 0xC2
After Instruction
W = 0xD9
REG1 = 0xC2
Z
=0
C
=0
DC
=0
fff
f
010
1
dfff
fff
f
Description:
Words:
Cycles:
Example
ANDWF
REG1, 1
Before Instruction
W
= 0x17
REG1 = 0xC2
After Instruction
W
= 0x17
REG1 = 0x02
BCF
Bit Clear f
BTFSC
Syntax:
[ label ] BCF
Syntax:
Operands:
0 f 127
0b7
Operands:
0 f 127
0b7
Operation:
0 (f<b>)
Operation:
skip if (f<b>) = 0
Status
Affected:
Encoding:
None
Status
Affected:
Encoding:
None
Description:
the
01
00b
b
f,b
bfff
fff
f
Description:
Words:
Cycles:
Example
BCF
Before Instruction
REG1 = 0xC7
After Instruction
REG1 = 0x47
Bit Set f
Syntax:
[ label ] BSF
Operands:
0 f 127
0b7
f,b
Operation:
1 (f<b>)
Status Affected:
None
Encoding:
01
Description:
Words:
Cycles:
Example
BSF
01b
b
bfff
10bb
bfff
fff
f
REG1, 7
BSF
01
fff
f
Words:
Cycles:
1(2)
Example
HERE
FALSE
TRUE
BTFSC
GOTO
REG1
PROCESS_CODE
Before Instruction
PC = address HERE
After Instruction
if REG<1> = 0,
PC = address TRUE
if REG<1> =1,
PC = address FALSE
REG1, 7
Before Instruction
REG1 = 0x0A
After Instruction
REG1 = 0x8A
DS40044G-page 120
BTFSS
Syntax:
Operands:
0 f 127
0b<7
Operation:
Status Affected:
Call Subroutine
Syntax:
[ label ] CALL k
Operands:
0 k 2047
Operation:
(PC)+ 1 TOS,
k PC<10:0>,
skip if (f<b>) = 1
(PCLATH<4:3>) PC<12:11>
None
Encoding:
Description:
CALL
01
Status Affected:
11bb
bfff
fff
f
Words:
Cycles:
1(2)
Example
HERE
FALSE
TRUE
BTFSS
GOTO
None
Encoding:
Description:
REG1
PROCESS_CODE
10
0kk
k
kkkk
kkk
k
Words:
Cycles:
Example
HERE
CALL
THERE
Before Instruction
PC = Address HERE
After Instruction
PC = Address THERE
TOS = Address HERE+1
Before Instruction
PC = address HERE
After Instruction
if FLAG<1> = 0,
PC = address FALSE
if FLAG<1> = 1,
PC = address TRUE
CLRF
Syntax:
Clear f
[ label ] CLRF
Operands:
0 f 127
Operation:
00h (f)
1Z
Status Affected:
Encoding:
00
Description:
000
1
1fff
Words:
Cycles:
Example
CLRF
fff
f
REG1
Before Instruction
REG1 = 0x5A
After Instruction
REG1 = 0x00
Z
= 1
DS40044G-page 121
CLRW
Clear W
Syntax:
[ label ] CLRW
Operands:
None
Operation:
00h (W)
Status Affected:
Encoding:
00
Description:
Cycles:
Example
CLRW
Complement f
Syntax:
[ label ] COMF
Operands:
0 f 127
Operation:
(f) (dest)
Status Affected:
Z Encoding:
Description:
000
1
0000
001
1
Words:
Cycles:
Example
COMF
Syntax:
Clear Watchdog Timer
Syntax:
[ label ] CLRWDT
Operands:
None
Operands:
00h WDT
1 WDT prescaler, 1
TO
2 PD
TO, PD
Encoding:
00
Description:
Words:
Cycles:
Example
CLRWDT
0110
Before Instruction
WDT counter = ?
After Instruction
WDT counter =
WDT prescaler =
TO
=
PD
=
DS40044G-page 120
010
0
Decrement f
[ label ] DECF f,d
0 f 127
d [0,1]
Operation:
(f) - 1 (dest)
Status Affected:
Encoding:
Status Affected:
000
0
REG1, 0
Before Instruction
REG1 = 0x13
After Instruction
REG1 = 0x13
W
= 0xEC
DECF
CLRWDT
00
100 of register
dfff ffff
The contents
are
1
f
complemented. If d is 0, the
result is stored in W. If d is 1,
the result is stored back in
register f.
Before Instruction
W = 0x5A
After Instruction
W = 0x00 Z
= 1
Operation:
f,d
d [0,1]
1Z
Words:
COMF
0
0
001
1
dfff
fff
f
Description:
Decrement register f. If d is
0. the result is stored in the W
register. If d is 1, the result is
stored back in register f.
Words:
Cycles:
Example
DECF
CNT, 1
Before Instruction
CNT = 0x01 Z
= 0
After Instruction
CNT = 0x00 Z
= 1
0x00
0
1
1
DECFSZ
Decrement f, Skip if 0
Syntax:
Operands:
0 f 127
d [0,1]
Operation:
(f) - 1 (dest);
skip if result =
GOTO
Unconditional Branch
Syntax:
[ label ]
Operands:
0 k 2047
Operation:
k PC<10:0> PCLATH<4:3>
PC<12:11>
0
Status Affected:
Description:
Status Affected:
None
Encoding:
GOTO k
00
101
1
dff
f
fff
f
Words:
Cycles:
1(2)
Example
HERE
DECFSZ
GOTO
CONTINUE
None
Encoding:
Description:
10
1kk
k
kkkk
kkk
k
GOTO is an unconditional
branch. The eleven-bit immediate value is loaded into PC bits
<10:0>. The upper bits of PC
are loaded from PCLATH<4:3>.
GOTO is a two-cycle instruction.
Words:
Cycles:
Example
GOTO THERE
After Instruction
PC = Address THERE
REG1, 1
LOOP
Before Instruction
PC
= address HERE
After Instruction
REG1 = REG1 - 1
if REG1 = 0,
PC = address CONTINUE
if REG1 0,
PC
= address HERE+1
DS40044G-page 121
INCF
Increment f
Syntax:
[ label ]
INCF
0
f 127
d [0,1]
Operands:
Operation:
Status
Affected:
Encoding:
INCFSZ
f,d
(f) + 1
(dest)
Z
00
101
0
dfff
fff
f
Description:
The contents of register f are
incremented. If d is 0, the result is placed in the W
register. If d is 1, the result is placed back in register
f.
Words:
Cycles:
Example
INCF
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operation:
Status
Affected:
Encoding:
00
INCFSZ f,d
111
1
dfff
fff
f
Description:
Words:
Cycles:
1(2)
Example
HERE
REG1, 1
Before Instruction
REG1 = 0xFF
Z
= 0
After Instruction
REG1 = 0x00 Z
= 1
Increment f, Skip if 0
INCFSZ
GOTO
CONTINUE
REG1, 1
LOOP
Before Instruction
PC
= address HERE
After Instruction
REG1 = REG1 + 1 if
CNT = 0,
PC = address CONTINUE
if REG1 0,
PC
= address HERE +1
DS40044G-page 120
IORLW
Syntax:
[ label ]
Operands:
0 k 255
IORLW k
Operation:
Status Affected:
Encoding:
Description:
MOVLW
Move Literal to W
Syntax:
[ label ]
Operands:
0 k 255
Operation:
k (W)
Status Affected:
None
Encoding:
11
100
0
kkkk
kkk
k
Words:
Cycles:
Example
IORLW
Description:
MOVLW k
11
00x
x
kkkk
kkk
k
Words:
Cycles:
Example
MOVLW
0x5A
After Instruction
W = 0x5A
0x35
Before Instruction
W = 0x9A
After Instruction
W = 0xBF
Z =0
IORWF
Inclusive OR W with f
MOVF
Move f
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 f 127
Operands:
0 f 127
d [0,1]
IORWF
f,d
d [0,1]
Operation:
Status Affected:
Encoding:
00
010
0
dfff
fff
f
Description:
Words:
Cycles:
Example
IORWF
REG1, 0
Before Instruction
REG1 = 0x13
W
= 0x91
After Instruction
REG1 = 0x13
W
= 0x93
Z
= 1
MOVF f,d
Operation:
(f) (dest)
Status Affected:
Z Encoding:
Description:
dfff
The00
contents100
of register
f is fff
0
f
moved to a destination
dependent upon the status of d.
If d = 0, destination is W
register. If d = 1, the destination
is file register f itself. d = 1 is
useful to test a file register since
status flag Z is affected.
Words:
Cycles:
Example
MOVF
REG1, 0
After Instruction
W= value in REG1 register Z
= 1
DS40044G-page 121
MOVWF
Move W to f
[ label ]
Syntax:
[ label ]
Operands:
0 f 127
Operands:
None
(W) (f)
Operation:
(W)
Status Affected:
None
Encoding:
00
Description:
000
0
Syntax:
Operation:
MOVWF
OPTION
1fff
Words:
Cycles:
Example
MOVWF
fff
f
No Operation
Syntax:
[ label ]
Operands:
None
NOP
Operation:
No operation
Status Affected:
None
Encoding:
00
Description:
No operation.
1
Cycles:
Example
NOP
Description:
are
000
0
0xx0
0110
0010
Before Instruction
REG1 = 0xFF W
= 0x4F
After Instruction
REG1 = 0x4F W
= 0x4F
Words:
REG1
NOP
OPTION
000
0
Words:
Cycles:
Example
To maintain upward
compatibil- ity with future
PIC MCU products, do not
use this
instruction.
RETFIE
Syntax:
[ label ]
Operands:
None
Operation:
TOS PC,
1 GIE
Status Affected:
Encoding:
Description:
RETFIE
None
00
000
0
0000
100
1
Words:
Cycles:
Example
RETFIE
After Interrupt
DS40044G-page 120
P
C
= TOS GIE =
1
DS40044G-page 121
RETLW
Syntax:
[ label ]
Operands:
0 k 255
Operation:
k (W);
RETLW k
RLF
Syntax:
[ label ]
Operands:
0 f 127
RLF
d [0,1]
Operation:
TOS
PC
Status Affected:
00
110
1
C Encoding:
Status Affected:
11
None Encoding:
Description:
01x
x
kkkk
kkk
k
Description:
Words:
Cycles:
Example
TABLE
f,d
dfff
fff
f
Words:
Cycles:
Example
RLF
REGISTER F
REG1, 0
Before Instruction
REG1=1110 0110
C
= 0
After Instruction
REG1=1110 0110
W = 1100 1100
C
= 1
Before Instruction
W = 0x07
After Instruction
W = value of k8
RETURN
Syntax:
[ label ]
Operands:
None
Operation:
TOS
PC Status Affected:
None
Encoding:
Description:
Words:
DS40044G-page 120
00
RETURN
000
0
0000
100
0
1
2009 Microchip Technology Inc.
Cycles:
Example
RETURN
After Interrupt
PC = TOS
DS40044G-page 121
RRF
Carry
Syntax:
[ label ]
Operands:
0 f 127
Operation:
SUBLW
Syntax:
[ label ]
Operands:
0 k 255
d [0,1]
Operation:
k - (W) W)
See description
Status
Affected:
C, DC, Z
RRF f,d
00
110
0
dfff
fff
f
Description:
The contents of register f are
rotated one bit to the right through the Carry Flag. If
d is 0, the result is placed in the W register. If d is
1, the result is placed back in register f.
Words:
Cycles:
Example
RRF
REGISTER F
REG1, 0
Before Instruction
REG1 = 1110 0110
C
= 0
After Instruction
REG1 = 1110 0110
W
= 0111 0011
C
= 0
SLEEP
Syntax:
[ label ] SLEEP
Operands:
None
Operation:
00h WDT,
0 WDT prescaler,
1 TO,
0 PD
Status Affected:
TO, PD
Encoding:
00
Description:
PD
000
0
01
10
001
1
Cycles:
Encoding:
Example:
11
SUBLW k
110x
SLEEP
kkkk
kkkk
Description:
Words:
Cycles:
Example 1:
SUBLW
C = 1; result is positive
Example 2:
Before Instruction
W = 2
C = ?
After Instruction
W = 0
C = 1; result is zero
0x02
Before Instruction
W = 1
C = ?
After Instruction
W = 1
Example 3:
Before Instruction
W=3
C = ?
After Instruction
W = 0xFF
C = 0; result is negative
SUBWF
Subtract W from f
Syntax:
[ label ]
Operands:
0 f 127
SWAPF
SUBWF f,d
d [0,1]
Syntax:
[ label ]
Operands:
0 f 127
Status
Affected:
C, DC, Z
Operation:
(f<3:0>) (dest<7:4>),
(f<7:4>) (dest<3:0>)
Status Affected:
Encoding:
Description:
SWAPF f,d
d [0,1]
Operation:
00
Swap Nibbles in f
0010
dfff
fff
Subtract (2s complementf
method)
W register from register f. If d is 0, the result is
stored in the W register. If d is 1, the result is stored
back in register f.
Encoding:
None
00
Words:
Cycles:
Cycles:
Example 1:
SUBWF
Example
SWAPF
REG1 = 3
W
= 2
C
= ?
After Instruction
fff
f
Before Instruction
dff
f
Description:
Words:
REG1, 1
111
0
REG1, 0
Before Instruction
REG1 = 0xA5
After Instruction
REG1 = 0xA5
W
= 0x5A
RE
G1
W
C
DC
Z
Example 2:
1
2
1; result is
1
positive
0
Before Instruction
REG1 = 2
W
C
= 2
= ?
TRIS
Syntax:
[ label ] TRIS
Operands:
5f7
Operation:
(W) TRIS
Example 3:
0
2
1; result is zero
DC = 1
Before Instruction
REG1 = 1
W
= 2
C
= ?
After Instruction
REG1 = 0xFF
W
= 2
C
= 0; result is negative
Z
= DC = 0
0110
0fff
Description:
Words:
Cycles:
After Instruction
REG1 =
W
=
C
=
Z
=
Example
To maintain upward
compatibil- ity with future
PIC MCU products, do not
use this
instruction.
XORLW
Syntax:
[ label ]
Operands:
0 k 255
Operation:
(W) .XOR. k W)
XORLW k
Encoding:
11
Description:
Cycles:
Example:
XORLW
kkk
k
0xAF
Before Instruction
W = 0xB5
After Instruction
W = 0x1A
Syntax:
[ label ]
Operands:
0 f 127
Operation:
Words:
Exclusive OR W with f
XORWF
f,d
d [0,1]
Status Affected:
101
0
XORWF
kk
kk
Status Affected:
Encoding:
00
011
0
dfff
fff
f
Description:
Words:
Cycles:
Example
XORWF
REG1, 1
Before Instruction
REG1 = 0xAF
W
= 0xB5
After Instruction
REG1 = 0x1A
W
= 0xB5
DS40044G-page 130
16.1
DEVELOPMENT SUPPORT
16.2
Debug using:
- Source files (C or assembly)
- Mixed C and assembly
- Machine code
MPLAB IDE supports multiple debugging tools in a
single development paradigm, from the cost-effective
simulators, through low-cost in-circuit debuggers, to
full-featured emulators. This eliminates the learning
curve when upgrading to tools with increased
flexibility and power.
16.3
MPLAB
C
Compilers
Various Device Families
for
16.6
16.4
16.7
16.5
MPASM Assembler
DS40044G-page 132
16.8
16.9
16.12 PICkit
2
Development
Programmer/Debugger and
PICkit 2 Debug Express
16.14 Demonstration/Development
Boards, Evaluation Kits, and
Starter Kits
17.1
ELECTRICAL SPECIFICATIONS
NOTICE: Stresses above those listed under Absolute Maximum Ratings may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above
those indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
Note: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up. Thus, a series resistor of 5
FIGURE 17-1:
6.0
5.5
5.0
VDD4.5
(VOLTS)
4.0
3.5
3.0
2.5
10
FREQUENCY (MHz)
20
25
Note:The shaded region indicates the permissible combinations of voltage and frequency.
FIGURE 17-2:
6.0
5.5
5.0
VDD
(VOLTS)
4.5
4.0
3.5
3.0
2.5
2.0
0
10
FREQUENCY (MHz)
20
25
Note:The shaded region indicates the permissible combinations of voltage and frequency.
17.2
PIC16LF627A/628A/648A
(Industrial)
PIC16F627A/628A/648A
(Industrial, Extended)
Par
a
m
Sy
m
VD
D
D00
1
D00
2
VD
D00
3
VPO
D00
4
SVD
D00
5
VBO
R
R
Legend:
Characteristic/Device
Mi
n
Ty
p
Max
Unit
s
2.
0
3.
5.5
5.5
1.5
*
VS
0.
05
*
V/ms
3.65
4.0
Power- on Reset
(POR), Power-up Timer
(PWRT), Oscillator
Start-up Timer (OST)
and Brown-out Reset
(BOR) on Power-on
Reset
forconfiguration
details
BOREN
bit
3.65
4.0
Supply Voltage
PIC16LF627A/628A/648
PIC16F627A/628A/648A
Brown-out Reset
Voltage
4.
35
Conditions
is set
BOREN configuration bit
is set, Extended
4.
4 improved readability.
Rows with standard voltage device data only are shaded for
V
Data in Typ column is at 5.0V, 25C, unless otherwise stated. These parameters are for design
guidance only and are not tested.
Note 1:
This is the limit to which VDD can be lowered in Sleep mode without losing RAM data.
17.3
DC CHARACTERISTICS
Par
LF and F
a
Device
m
Characteristi
Supply Voltage (VDD)
L
D0
F
L
01
F/
Power-down Base Current (IPD)
Ty
p
Ma
x
Unit
s
2.0
5.5
3.0
5.5
F
D0
L
20
F/
F
(1)
Peripheral Module Current (IMOD)
0.0
1
0.0
0.8
0
0.8
2.0
5
2.7
3.0
1
0.0
2
5.0
VDD
L
F
L
F/
F
L
F/
F
L
F
L
2.0
2.0
3.4
3.0
5.0
29
17.
0
52
4.5
30
55
5.0
15
22
2.0
22
37
3.0
F/
F
L
F
L
44
68
5.0
34
55
2.0
50
75
3.0
F/
F
L
F
L
80
5.0
1.2
11
0
2.0
2.0
1.3
2.2
3.0
F/
F
Supply Current (IDD)
1.8
2.9
5.0
L
F
L
F/
F
L
F
L
10
15
2.0
15
25
3.0
28
48
5.0
12
5
17
19
0
34
2.0
5
32
0
25
0
52
0
35
3.0
F/
F
L
F
L
5.0
3.0
F/
F
L
F
L
0
60
0
99
2.0
0
45
0
71
5
46
5
78
5.0
0
39
5
56
2.0
D0
21
D0
22
D0
23
D0
24
D0
25
D0
10
D0
11
D0
12
D01
2A
D0
13
Note 1:
Conditio
ns
N
ot
WDT Current
BOR Current
Comparator Current
(Both comparators enabled)
VREF Current
T1OSC Current
FOSC = 32 kHz
LP Oscillator Mode
FOSC = 1 MHz
XT Oscillator Mode
FOSC = 4 MHz
XT Oscillator Mode
FOSC = 4
MHz
INTOSC
A
3.0
F/
5
5
0.8
1.3
mA
5.0
F
95
L
2.5
2.9
mA
4.5
FOSC = 20 MHz
F/
HS Oscillator Mode
2.7
3.3
mA
5.0
F
5
The current is the additional current consumed when this peripheral is enabled. This current should
be added to the base IDD or IPD measurement. Max values should be used when calculating total current
consumption.
17.4
DC CHARACTERISTICS
Par
Device
a
Characteristics
m
Supply Voltage (VDD)
D0
01
Power-down Base Current (IPD)
3.0
5.5
D020
E
Peripheral Module Current (IMOD)(1)
0.0
1
0.0
3.0
5.0
D021
E
D022
E
D023
E
D024
E
3.0
20
5.0
2
9
3
52
4.5
55
5.0
0
2
2
4
37
3.0
68
5.0
Comparator Current
(Both comparators enabled)
4
5
0
8
75
3.0
VREF Current
11
0
4
5.0
3.0
5.0
1
5
28
28
3.0
54
5.0
17
5
32
34
0
52
3.0
0
65
0
1.1
5.0
0
45
0
0.7
3.0
mA
5.0
10
56
5
0.8
78
5
1.3
3.0
mA
5.0
95
2.
5
2.7
2.9
mA
4.5
D025
E
Supply Current (IDD)
D010
E
D011
E
D012
E
D012
AE
D013
E
Note 1:
3
1.
3
1.
8
VDD
Unit
s
Ma
x
Conditio
ns
N
ot
Mi
n
BOR Current
T1OSC Current
FOSC = 32 kHz
LP Oscillator Mode
FOSC = 1 MHz
XT Oscillator Mode
FOSC = 4 MHz
XT Oscillator Mode
FOSC = 4
MHz
INTOSC
FOSC = 20 MHz
HS Oscillator Mode
3.5
mA
5.0
5 consumed when this peripheral is enabled. This current should
The current is the additional current
be added to the base IDD or IPD measurement. Max values should be used when calculating total current
consumption.
17.5
DC CHARACTERISTICS
Par
a
m.
Sy
m
VIL
I/O ports
with TTL buffer
with Schmitt Trigger
input(4)
MCLR, RA4/T0CKI,OSC1
(in RC mode)
OSC1 (in HS)
OSC1
(in LPVoltage
and XT)
Input High
VIH
I/O ports
with TTL buffer
with Schmitt Trigger
input(4) MCLR RA4/T0CKI
OSC1 (XT and LP)
OSC1 (in RC mode)
OSC1 (in HS mode)
IPUR
B
IIL
D
0
6
0
D
D08
0
Ty
p
VO
Max
U
ni
Conditio
ns
VO
D10
COS
VSS
VSS
2.0V
.25 VDD +
0.8V
0.8
VDD
0.8
V1.3
DD
0.9
VDD
0.7
V50
DD
2
0
0
0.8
0.15
V0.2
DD
VDD
0.2
VDD
0.3
V0.6
DD
V
V
V
V
VDD
VDD
VDD
VDD
VDD
VDD
VDD
V
V
V
V
V
V
V
400
(Note1)
V
V
(Note1)
1.0
0.5
1.0
5.0
VSS VPIN VDD, pin at highVSS VPIN VDD, pin at highVSS VPIN VDD
VSS VPIN VDD, XT, HS and LP
oscillator configuration
0.6
0.6
V
V
VDD 0.7
VDD 0.7
V
V
8.5*
RA4 pin
PIC16F627A/628A/648A,
PIC16LF627A/628A/648A
15
p
F
p
F
D15
0
VSS
VSS
VSS
VSS
VO
D09
0
Min
D03
0
D03
1
D03
2
D03
3
D04
0
D04
1
D04
2
D04
3
D04
3A
D04
3B
D07
Characteristic/Device
0*
C2
All I/O pins/OSC2 (in RC
50
mode)
* These parameters
are characterized but not tested.
D10
CI in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested.
Data
Note 1: In RC oscillator configuration, the OSC1 pin is a Schmitt Trigger input. It is not recommended that the PIC16F627A/628A/648A
be driven with external clock in RC mode.
2: The leakage current on the MCLR pin is strongly dependent on applied voltage level. The specified levels represent normal
operating conditions. Higher leakage current may be measured at different input voltages.
3: Negative current is defined as coming out of the pin.
4: Includes OSC1 and OSC2 when configured as I/O pins, CLKIN or CLKOUT.
DS40044G-page 140
TABLE 17-1:
DC CHARACTERISTICS
Parame
ter
No.
Sy
m
D120
D120A
D121
ED
ED
VDR
Characteristic
Min
Typ
Max
Un
its
100K
10K
VMIN
1M
100K
5.5
E/
W
E/
W
V
40
8*
Number of Total
Cycles before Refresh(1)
1M
10M
ms
Ye
ar
E/
D122
D123
TDE
W
TRE
TD
D124
TRE
Conditions
-40C TA 85C
85C TA 125C
VMIN = Minimum operating
voltage
Provided no other
specifications are violated
-40C to +85C
EP
EP
VPR
Endurance
Endurance
VDD for read
10K
1000
VMIN
100K
10K
5.5
E/
W
E/
W
V
D132
D132A
VIE
VPE
4.5
VMIN
5.5
5.5
V
V
40
4
2
8*
4*
ms
ms
ye
ar
D133
D133A
D134
TIE
TPE
WRE
T
TP
-40C TA 85C
85C TA 125C
VMIN = Minimum operating
voltage
VMIN = Minimum operating
voltage
VDD > 4.5V
Provided no other
specifications are violated
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance
only and are not tested.
Note 1:
Refer to Section 13.7 Using the Data EEPROM for a more detailed discussion on data
EEPROM endurance.
TABLE 17-2:
COMPARATOR SPECIFICATIONS
Operating Conditions: 2.0V VDD 5.5V, -40C < TA < +125C, unless otherwise stated.
Par
a
m
D300
D301
Characteristics
D302
D303
D304
Sym
Min
Typ
Max
Unit
s
VIOF
F
VICM
5.0
mV
V
CMR
R
TRES
55*
10
VDD
1.5*
300
400*
ns
400
600*
ns
400
600*
ns
300
10*
db
TMC2
Comments
OV
VDD = 3.0V to
5.5V
-40 to +85C
VDD = 3.0V to
5.5V
-85 to +125C
VDD = 2.0V to
3.0V
-40 to +85C
Response time measured with one comparator input at (VDD 1.5)/2, while the other input transitions
from VSS to VDD.
TABLE 17-3:
Operating Conditions: 2.0V < VDD < 5.5V, -40C < TA < +125C, unless otherwise stated.
Spec
No.
Characteristics
Sym
D310
Resolution
VRES
D311
Absolute Accuracy
VRAA
D312
D313
VRUR
Mi
n
Ty
p
TSET
Settling Time
* These parameters are characterized but not tested.
2k
*
Max
VDD/2
4
V1/4
DD(2)
/3
*
(2)
1/2
10*
Unit
s
L
S
b
L
S
b
Comments
Low Range (VRR =
1) High Range
(VRR
= 0) (VRR =
Low Range
1) High Range
(VRR = 0)
Note 1: Settling time measured while VRR = 1 and VR<3:0> transitions from 0000 to 1111.
2: When VDD is between 2.0V and 3.0V, the VREF output voltage levels on RA2 described by the equation:
[VDD/2 (3 VDD)/2] may cause the Absolute Accuracy (VRAA) of the VREF output signal on RA2 to be
greater than the stated max.
DS40044G-page 142
17.6
The timing parameter symbols have been created with one of the following formats:
1. TppS2ppS
2. TppS
T
F
Frequency
Time
CLKOUT
osc
OSC1
i
o
mc
I/O port
t0
T0CKI
Fall
Period
High
Rise
Invalid (High-impedance)
Valid
Low
High-Impedance
MCLR
Uppercase letters and their meanings:
S
FIGURE 17-3:
LOAD CONDITIONS
Load Condition 1
Load Condition 2
VDD/2
RL
CL
Pin
CL
Pin
VSS
RL = 464
CL = 50 pF for all pins except OSC2 15 pF for OSC2 output
VSS
17.7
FIGURE 17-4:
Q1
Q3
Q2
Q4
Q1
OSC1
1
2
CLKOUT
TABLE 17-4:
Parame
ter
No.
Characteristic
External CLKIN
Frequency(1)
Oscillator Frequency(1)
TO
(1)
SC
Oscillator Period(1)
TC
Y
To
sL,
To
R
Min
Typ
Max
Uni
ts
Conditions
DC
MH
DC
20
200
MH
z
kH
DC
z
MH
z
MH
z
MH
z
kH
z
MH
HS Osc mode
LP Osc mode
INTOSC mode (slow)
LP Osc mode
0.1
20
200
48
250
z
kH
z
ns
50
ns
LP Osc mode
250
ns
RC Osc mode
250
XT Osc mode
10,00
0
1,00
ns
50
ns
HS Osc mode
LP Osc mode
250
ns
21
200
TCY
DC
ns
TCY = 4/FOSC
100*
ns
External Biased
RC Frequency
10
kHz*
4
MHz
VDD = 5.0V
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance
only and are not tested.
Note 1:
Instruction cycle period (TCY) equals four times the input oscillator time-based period. All specified values
are based on characterization data for that particular oscillator type under standard operating conditions
with the device executing code. Exceeding these specified limits may result in an unstable oscillator
oper- ation and/or higher than expected current consumption. All devices are tested to operate at Min
values with an external clock applied to the OSC1 pin. When an external clock input is used, the Max
cycle time limit is DC (no clock) for all devices.
TABLE 17-5:
Parame
ter
No.
F10
F13
Sym
FIOSC
IOSC
F14*
TIOSC
ST
Characteristic
Oscillator Center frequency
Oscillator Accuracy
Min
Typ
Max
Uni
ts
3.96
4.04
MH
z
MH
3.92
4.08
z
MH
3.80
4.20
MH
z
+85C
VDD = 3.0V, -40C to
+85C
VDD = 5.0V, -40C to
+85C
FIGURE 17-5:
Conditions
Q4
Q2
OSC1
Q3
11
10
22
23
CLKOUT
13
19
14
12
18
16
I/O Pin
(input)
15
17
I/O Pin
(output)
New Value
Old Value
20, 21
TABLE 17-6:
Parame
ter
No.
1
0
TOSH2C
KL
OSC1 to CLKOUT
1
1
1
TOSH2C
KH
OSC1 to CLKOUT
1
1
2
Sym
TCKR
1
1
3
TCKF
Characteristic
Min
Typ
M
a
Units
PIC16F62X
A
PIC16LF62
75
ns
ns
XA
PIC16F62X
A
PIC16LF62
75
2
0
4
0
2
ns
XA
PIC16F62X
A
PIC16LF62
35
0
4
0
1
ns
XA
PIC16F62X
A
PIC16LF62
35
0
2
0
1
ns
ns
ns
ns
ns
0
2
0
2
TOSC+200
ns*
TOSC
+400
0*
ns
XA
ns*
0
ns
PIC16F62X
50
1
5
3
ns
A
PIC16LF62
to Port out valid
XA
1
TOSH2IO
OSC1 (Q2 cycle) to Port input
8
I
invalid (I/O in hold time)
* These parameters are characterized but not tested.
ns
1
1
4
1
TCKL2IO
V
TIOV2CK
1
6
1
TCKH2IO
ITOSH2IO
XA
PIC16F62X
A
PIC16LF62
100*
200*
ns
ns
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance
only and are not tested.
FIGURE 17-6:
VDD
MCLR
30
Internal POR
PWRT
Time out
33
32
OST
Time out
Internal Reset
Watchdog
Timer Reset
34
I/O Pins
31
34
FIGURE 17-7:
VBOR
VDD
35
TABLE 17-7:
Parame
ter
No.
Characteristic
M
in
Typ
Ma
x
Uni
ts
3
0
3
1
TMC
L
TWD
20
00
7*
18
33*
ns
ms
3
2
3
TOST
TPW
28
*
1024
T72
OSC
3
3
4
RT
TIOZ
3
5
Legend:
TBO
10
0*
TBD = To Be Determined.
Conditions
ms
132
*
2.0*
s
VDD VBOR (D005)
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance only and are
not tested.
FIGURE 17-8:
RA4/T0CKI/CMP2
40
41
45
46
42
RB6/T1OSO/T1CKI/PGC
4748
TMR0 OR
TMR1
TABLE 17-8:
Par
a
m
4
0
Sym
4
1
4
2
Un
its
n
s
n
sn
0.5TCY +
20*
10*
TT0L
Prescaler
No
Prescaler
With
0.5TCY +
20*
10*
TT1P
T0CKI Period
T1CKI
High
Time
T1CKI
Low
Time
T1CKI
input
period
Prescaler
Synchronous, No
Prescaler
Synchrono
PIC16F62X
us, with
Prescaler
Asynchrono
us
Greater
of: 20 or TCY +
40*
0.5TCY +N
A
PIC16LF62
XA
PIC16F62X
A
PIC16LF62
XA
Synchronous, No
Prescaler
Synchrono
us, with
Prescaler
Asynchrono
us
PIC16F62X
A
PIC16LF62
Synchrono
us
XA
PIC16F62X
A
XA
PIC16F62X
A
PIC16LF62
PIC16LF62
XA
Asynchrono
us
4
8
Ma
x
No
Prescaler
With
TT1L
4
7
Ty
p
TT1H
4
6
Min
TT0H
TT0P
4
5
Characteristic
25*
30*
50*
0.5TCY +
20*
15*
25*
30*
50*
n
s
n
sn
N=
prescale
value (2,
4,
sn
sn
sn
s
n
sn
sn
sn
sn
N=
prescale
value (1,
2,
60* N
100*
of: 20 or
+ 40*
PIC16F62X
A
PIC16LF62
20*
15*
Greater
of: 20 or TCY
+ 40*
N
Greater
sn
sn
Condition
s
TCY
FT 1
XA range
Timer1 oscillator input frequency
(oscillator enabled by setting bit
T1OSCEN)
32.
7(1)
TCKEZTM
R1
2TOSC
7TO
n
sn
ks
H
z
SC
Data in Typ column is at 5V, 25C unless otherwise stated. These parameters are for design guidance
only and are not tested.
Note 1:
This oscillator is intended to work only with 32.768 kHz watch crystals and their manufactured tolerances.
Higher value crystal frequencies may not be compatible with this crystal driver.
FIGURE 17-9:
CAPTURE/COMPARE/PWM TIMINGS
RB3/CCP1
(CAPTURE MODE)
50
51
52
RB3/CCP1
(COMPARE OR PWM MODE)
53
TABLE 17-9:
Par
a
m
5
0
Sy
m
TC
CL
5
1
TC
CH
CAPTURE/COMPARE/PWM REQUIREMENTS
CCP
input low time
CCP
input high
time
Characteris
tic
No Prescaler
With
Prescaler
No Prescaler
Min
Ty
p
M
a
Un
its
ns
PIC16F62XA
0.5TCY +
20*
10*
ns
PIC16LF62XA
20*
ns
0.5TCY +
20*
ns
10*
ns
PIC16F62XA
With
Prescaler
CCP input period
PIC16LF62XA
20*
ns
ns
PIC16F62XA
3TCY +
40*
N
10
2
5*
4
5*
2
ns
5
2
TC
CP
5
3
TC
CR
5
4
TC
CF
54
PIC16LF62XA
25
PIC16F62XA
10
PIC16LF62XA
25
5*
4
5*
Conditions
N=
prescale
value (1,4 or
ns
ns
ns
Data in Typ column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only
and are not tested.
NOTES:
DS40044G-page 150
18.0
The graphs and tables provided in this section are for design guidance and are not tested.
In some graphs or tables, the data presented are outside specified operating range (i.e., outside specified VDD
range). This is for information only and devices are ensured to operate properly only within the specified range.
The data presented in this section is a statistical summary of data collected on units from different lots over a period
of time and matrix samples. Typical represents the mean of the distribution at 25C. Max or Min represents (mean
+ 3) or (mean - 3) respectively, where is standard deviation, over the whole temperature range.
FIGURE 18-1:
160
140
IPD (nA)
120
100
80
60
40
40
+2
5C
20
0
2.0
0C
2.5
3.0
3.5
4.0
VDD (Volts)
4.5
5.0
5.5
FIGURE 18-2:
300
280
260
IPD (nA)
240
220
200
180
+85C
160
140
120
100
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (Volts)
FIGURE 18-3:
2.4
IPD (A)
2.2
2.0
1.8
+125C
1.6
1.4
1.2
1.0
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
VDD (Volts)
DS40044G-page 152
FIGURE 18-4:
40
38
36
IPD (A)
34
32
125
C
85
C
25
C
30
28
26
24
22
20
4.5
FIGURE 18-5:
4.6
4.7
4.8
4.95.05.1
VDD (Volts)
5.2
5.3
5.4
5.5
30
IPD (A)
25
20
125C
85C
25C
0C
-40C
15
10
0
2
2.5
3.5
VDD (Volts)
4.5
5.5
FIGURE 18-6:
100
90
IPD (A)
80
125
C
85
C
25
C
70
60
50
40
2.0
2.5
3.0
30
3.5
4.0
4.5
5.0
5.5
VDD (Volts)
20
FIGURE 18-7:
16
IPD (A)
14
12
125C
85C
25C
0C
-40C
10
86
2
2.0
0
2.5
3.0
3.5
4.0
VDD (Volts)
4.5
5.0
5.5
FIGURE 18-8:
AVERAGE IPD_TIMER1
IPD (uA)
-40C
0C
25C
85C
125
0
2
2.5
3.5
4.5
5.5
VDD (V)
FIGURE 18-9:
5.0%
4.0%
3.0%
2.0%
1.0%
0.0%
-1.0%
-2.0%
-3.0%
-4.0%
-5.0%
-40
25
85
Temperature (C)
125
FIGURE 18-10:
5.0%
4.0%
3.0%
2.0%
1.0%
0.0%
-1.0%
-2.0%
-40
25
85
125
Temperature (C)
-3.0%
FIGURE 18-11:
-4.0%
5.0%
-5.0%
4.0%
3.0%
2.0%
1.0%
0.0%
-1.0%
-2.0%
-3.0%
-4.0%
-5.0%
-40
25
85
Temperature (C)
125
FIGURE 18-12:
5.0%
4.0%
3.0%
2.0%
1.0%
0.0%
-1.0%
-2.0%
2.5
3.5
4.5
5.5
VDD (V)
-3.0%
FIGURE-4.0%
18-13:
-5.0%
5.0%
4.0%
3.0%
2.0%
1.0%
0.0%
-1.0%
-2.0%
2.5
3.5
4
VDD (V)
-3.0%
-4.0%
-5.0%
4.5
5.5
FIGURE 18-14:
1.40
1.20
IDD (mA)
1.00
0.80
0.60
0.40
0.20
0.00
2
2.5
3.5
4.5
5.5
VDD (V)
FIGURE 18-15:
60
55
50
45
40
35
30
2
2.5
3.5
4
VDD (V)
4.5
5.5
FIGURE 18-16:
180
160
IPD (A)
140
120
100
80
60
2
2.5
3.5
4.5
5.5
VDD (V)
40
20
FIGURE 18-17:
SUPPLY CURRENT (IDD vs. VDD, FOSC = 1 MHz (XT OSCILLATOR MODE)
500
450
IPD (A)
400
350
125
C
85
C
25
C
300
250
200
150
100
2.0
2.5
3.0
3.5
4.0
VDD (Volts)
4.5
5.0
5.5
FIGURE 18-18:
SUPPLY CURRENT (IDD vs. VDD, FOSC = 4 MHz (XT OSCILLATOR MODE)
1000
900
IPD (A)
800
125
C
85
C
25
C
700
600
500
400
2.0
2.5
3.0
3.5
4.5
5.0
5.5
VDD (Volts)
300
FIGURE200
18-19:
4.0
SUPPLY CURRENT (IDD) vs. VDD, FOSC = 20 MHz (HS OSCILLATOR MODE)
IDD (mA)
4.0
3.5
125C
85C
25C
0C
-40C
3.0
2.5
2.0
4.5
4.6
4.7
4.8
4.9
5.0
5.1
5.2
5.3
5.4
5.5
VDD (Volts)
DS40044G-page 160
FIGURE 18-20:
Time (mS)
WDT Time-out
50
45
40
35
30
25
20
15
10
5
0
-40
0
25
85
125
2.5
3.5
DD
(V)
4.5
5.5
NOTES:
DS40044G-page 162
19.1
PACKAGING INFORMATION
19.2
Example
PIC16F627A
-I/Pe3
0410017
Example
PIC16F628A
-E/SO e3
0410017
20-Lead SSOP
XXXXXXXXXXX XXXXXXXXXXX
YYWWNNN
28-Lead QFN
Example
PIC16F648A
-I/SS e3
0410017
Example
16F628A
-I/ML e3
0410017
Note: In the event the full Microchip part number cannot be marked on one line, it will be carried over to the next line, thus limiting the
For the most current package drawings, please see the Microchip Packaging Specification located
at http://www.microchip.com/packaging
NOTE 1
E1
3
D
E
A2
L
A1
b1
b
eB
Units
INCHE
S
Dimension
MI
N
M
Limits
N
O
A
Number of Pins
N
18
Pitch
e
.100
BSC
Top to Seating Plane
A
.
21
Molded Package Thickness
A
.
.
.
2
11
13
19
Base to Seating Plane
A
.
01
Shoulder to Shoulder Width
E1
.
.
.
30
31
32
Molded Package Width
E
.
.
.
24
25
28
Overall Length
D1
.
.
.
88
90
92
Tip to Seating Plane
L
.
.
.
11
13
15
Lead Thickness
c
.
.
.
00
01
01
Upper Lead Width
b
.
.
.
04
06
07
Lower Lead Width
b1
.
.
.
01
01
02
Overall Row Spacing
e
.
B
43
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Significant Characteristic.
3. Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010" per side.
4. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
For the most current package drawings, please see the Microchip Packaging Specification located
at http://www.microchip.com/packaging
D
N
E
E1
NOTE 1
1
2 3
e
b
A2
c
L1
A1
Number of Pins
Pitch
Overall Height
Molded Package Thickness
Standoff
Overall Width
Molded Package Width
Overall Length
Chamfer (optional)
Foot Length
Footprint
Foot Angle
Lead Thickness
Lead Width
Mold Draft Angle Top
Mold Draft Angle Bottom
Units
Dimension
Limits
N
e
A
A
2
A
E1
E
D1
h
L
L
1
c
b
MI
N
2.
05
0.
10
0.
25
0.
40
0
0.
20
0.
31
5
5
MILLIMETERS
N
MAX
O
18
1.27 BSC
2.65
10.30 BSC
7.50 BSC
11.55 BSC
0.30
0.75
1.27
1.40 REF
8
0.33
0.51
15
15
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Significant Characteristic.
3. Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed 0.15 mm per side.
4. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
For the most current package drawings, please see the Microchip Packaging Specification located
at http://www.microchip.com/packaging
D
N
E
E1
NOTE 1
1 2
e
b
A2
A1
L1
Number of Pins
Pitch
Overall Height
Molded Package Thickness
Standoff
Overall Width
Molded Package Width
Overall Length
Foot Length
Footprint
Lead Thickness
Foot Angle
Lead Width
Units
Dimension
Limits
N
e
A
A
2
A
E1
E
D1
L
L
c1
MI
N
1.
65
0.
05
7.
40
5.
00
6.
90
0.
55
MILLIMETERS
N
O
20
0.65 BSC
1.
75
7.
80
5.
30
7.
20
0.
75 REF
1.25
M
A
2.
00
1.
85
8.
20
5.
60
7.
50
0.
95
0.
0.
09
25
0
8
0.
0.
22
38
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed 0.20 mm per side.
3. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
28-Lead Plastic Quad Flat, No Lead Package (ML) 6x6 mm Body [QFN]
with 0.55 mm Contact Length
Note:
For the most current package drawings, please see the Microchip Packaging Specification located
at http://www.microchip.com/packaging
D2
EXPOSED
PAD
e
E
E2
2
N
NOTE 1
L
BOTTOM VIEW
TOP VIEW
A3
A1
Number of Pins
Pitch
Overall Height
Standoff
Contact Thickness
Overall Width
Exposed Pad Width
Overall Length
Exposed Pad Length
Contact Width
Contact Length
Contact-to-Exposed Pad
Units
Dimension
Limits
N
e
A
A
1
A
3E
E
2D
D
2b
L
K
MI
N
0.
80
0.
00
3.
65
MILLIMETERS
N
O
28
0.65 BSC
0.
90
0.
02 REF
0.20
6.00 BSC
3.
70 BSC
6.00
3.
70
0.
30
0.
55
3.
65
0.
23
0.
50
0.
20
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Package is saw singulated.
3. Dimensioning and tolerancing per ASME Y14.5M.
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
M
A
1.
00
0.
05
4.
20
4.
20
0.
35
0.
70
For the most current package drawings, please see the Microchip Packaging Specification located
at http://www.microchip.com/packaging
NOTES:
DS40044G-page 171
APPENDIX A:
DATA SHEET
REVISION HISTORY
Revision A
DEVICE
DIFFERENCES
Revision B
TABLE B-1:
Revision C
General revisions throughout. Revisions to Section
14.0 Special Features of the CPU. Section 18,
modified graphs.
Revision D
Revise Example 13-2, Data EEPROM Write
Revise Sections 17.2, Param No. D020 and 17.3,
Param No. D020E
Revise Section 18.0 graphs
Revision E
Section 19.0 Packaging Information:
package drawings and added note.
APPENDIX B:
Replaced
Revision F (03/2007)
Replaced Package Drawings (Rev. AM); Replaced
Development Support Section; Revised Product ID
System.
Revision G (10/2009)
Corrected 28-lead QFN Package in Section 19.1.
Device
PIC16F627
A
PIC16F628
A
PIC16F648
A
DEVICE DIFFERENCES
Flas
h
Progr
1024 x 14
2048 x 14
4096 x 14
Memo
ry
RA
M
Dat
224 x
8 x
224
8 x
256
8
EEPR
OM
Data
128 x 8
128 x 8
256 x 8
APPENDIX C:
DEVICE MIGRATIONS
C.1
1.
PIC16F627/628 to a
PIC16F627A/ 628A
DS40044G-page 172
APPENDIX D:
MIGRATING FROM
OTHER PIC
DEVICES
D.1
PIC16C62X/CE62X
to
PIC16F627A/ 628A/648A Migration
See
Microchip
web
(www.microchip.com).
D.2
for
availability
PIC16C622A to PIC16F627A/628A/
648A Migration
See
Microchip
web
(www.microchip.com).
Note:
site
site
for
availability
CUSTOMER SUPPORT
Distributor or Representative
Local Sales Office
Field Application Engineer (FAE)
Technical Support
Development Systems Information Line
Customers
should
contact
their
distributor,
representative or field application engineer (FAE) for
support. Local sales offices are also available to help
customers. A listing of sales offices and locations is
included in the back of this document.
Technical support is available through the web site
at: http://support.microchip.com
DS40044G-page 173
READER RESPONSE
It is our intention to provide you with the best documentation possible to ensure successful use of your Microchip
prod- uct. If you wish to provide your comments on organization, clarity, subject matter, and ways in which our
documentation can better serve you, please FAX your comments to the Technical Publications Manager at (480) 7924150.
Please list the following information, and use this outline to provide us with your comments about this document.
To:
RE:
Reader Response
From: Name
Company
Address
City / State / ZIP / Country
Telephone: (
FAX: (
Application (optional):
Would you like a reply?
Device: PIC16F627A/628A/648A
Questions:
1. What are the best features of this document?
2. How does this document meet your hardware and software development needs?
3. Do you find the organization of this document easy to follow? If not, why?
4. What additions to the document do you think would enhance the structure and subject?
5. What deletions from the document could be made without affecting the overall usefulness?
INDEX
A
A/D
Special Event Trigger (CCP)........................................59
Absolute Maximum Ratings...............................................135
ADDLW Instruction.............................................................119
ADDWF Instruction.............................................................119
ANDLW Instruction.............................................................119
ANDWF Instruction.............................................................119
Architectural Overview..........................................................11
Assembler
MPASM Assembler....................................................132
B
Baud Rate Error...................................................................75
Baud Rate Formula..............................................................75
BCF Instruction...................................................................120
Block Diagrams
Comparator
I/O Operating Modes............................................64
Modified Comparator Output...............................66
I/O Ports
RB0/INT Pin.........................................................38
RB1/RX/DT Pin....................................................39
RB2/TX/CK Pin....................................................39
RB3/CCP1 Pin.....................................................40
RB4/PGM Pin.......................................................41
RB5 Pin................................................................42
RB6/T1OSO/T1CKI Pin.......................................43
RB7/T1OSI Pin....................................................44
RC Oscillator Mode....................................................101
USART Receive...........................................................82
USART Transmit..........................................................80
BRGH bit..............................................................................75
Brown-Out Reset (BOR)....................................................103
BSF Instruction...................................................................120
BTFSC Instruction..............................................................120
BTFSS Instruction..............................................................121
C
C Compilers
MPLAB C18...............................................................132
CALL Instruction.................................................................121
Capture (CCP Module).........................................................58
Block Diagram..............................................................58
CCP Pin Configuration.................................................58
CCPR1H:CCPR1L Registers.......................................58
Changing Between Capture Prescalers.......................58
Prescaler......................................................................58
Software Interrupt.........................................................58
Timer1 Mode Selection................................................58
Capture/Compare/PWM (CCP)............................................57
Capture Mode. See Capture
CCP1............................................................................57
CCPR1H Register................................................57
CCPR1L Register................................................57
CCP2............................................................................57
Compare Mode. See Compare
PWM Mode. See PWM
Timer Resources..........................................................57
CCP1CON Register.............................................................57
CCP1M Bits..................................................................57
CCP1X:CCP1Y Bits.....................................................57
CCP2CON Register
CCP2M<3:2> Bits........................................................57
CCP2X:CCP2Y Bits.....................................................57
Clocking Scheme/Instruction Cycle.....................................15
CLRF Instruction................................................................121
CLRW Instruction...............................................................122
CLRWDT Instruction..........................................................122
CMCON Register.................................................................63
Code Examples
Data EEPROM Refresh Routine..................................94
Code Protection..................................................................113
COMF Instruction...............................................................122
Comparator
Block Diagrams
I/O Operating Modes............................................64
Modified Comparator Output...............................66
Comparator Module.....................................................63
Configuration................................................................64
Interrupts......................................................................67
Operation......................................................................65
Reference.....................................................................65
Compare (CCP Module).......................................................58
Block Diagram..............................................................58
CCP Pin Configuration.................................................59
CCPR1H:CCPR1L Registers.......................................58
Software Interrupt.........................................................59
Special Event Trigger...................................................59
Timer1 Mode Selection................................................59
CONFIG Register.................................................................98
Configuration Bits.................................................................97
Crystal Operation.................................................................99
Customer Change Notification Service..............................173
Customer Notification Service............................................173
Customer Support..............................................................173
D
Data EEPROM Memory.......................................................91
EECON1 Register........................................................91
EECON2 Register........................................................91
Operation During Code Protection...............................95
Reading........................................................................93
Spurious Write Protection............................................93
Using............................................................................94
Write Verify...................................................................93
Writing to......................................................................93
Data Memory Organization..................................................17
DECF Instruction................................................................122
DECFSZ Instruction...........................................................123
Development Support........................................................131
Device Differences.............................................................171
Device Migrations...............................................................172
Dual-speed Oscillator Modes.............................................101
E
EECON1 Register................................................................92
EECON1 register..................................................................92
EECON2 register..................................................................92
Errata......................................................................................5
External Crystal Oscillator Circuit.......................................100
F
Fuses. See Configuration Bits
G
General-Purpose Register File.............................................17
GOTO Instruction...............................................................123
I
I/O Ports...............................................................................33
Bidirectional..................................................................46
Block Diagrams
RB0/INT Pin.........................................................38
RB1/RX/DT Pin....................................................39
RB2/TX/CK Pin....................................................39
RB3/CCP1 Pin.....................................................40
RB4/PGM Pin.......................................................41
RB5 Pin................................................................42
RB6/T1OSO/T1CKI Pin.......................................43
RB7/T1OSI Pin....................................................44
PORTA.........................................................................33
PORTB.........................................................................38
Programming Considerations......................................46
Successive Operations................................................46
TRISA...........................................................................33
TRISB...........................................................................38
ID Locations........................................................................113
INCF Instruction.................................................................124
INCFSZ Instruction.............................................................124
In-Circuit Serial Programming.........................................114
Indirect Addressing, INDF and FSR Registers....................30
Instruction Flow/Pipelining...................................................15
Instruction Set
ADDLW.......................................................................119
ADDWF......................................................................119
ANDLW.......................................................................119
ANDWF......................................................................119
BCF............................................................................120
BSF............................................................................120
BTFSC........................................................................120
BTFSS........................................................................121
CALL..........................................................................121
CLRF..........................................................................121
CLRW.........................................................................122
CLRWDT....................................................................122
COMF.........................................................................122
DECF..........................................................................122
DECFSZ.....................................................................123
GOTO.........................................................................123
INCF...........................................................................124
INCFSZ......................................................................124
IORLW........................................................................125
IORWF.......................................................................125
MOVF.........................................................................125
MOVLW......................................................................125
MOVWF......................................................................126
NOP............................................................................126
OPTION.....................................................................126
RETFIE.......................................................................126
RETLW.......................................................................127
RETURN....................................................................127
RLF.............................................................................127
RRF............................................................................128
SLEEP........................................................................128
SUBLW.......................................................................128
SUBWF......................................................................129
SWAPF.......................................................................129
TRIS...........................................................................129
XORLW......................................................................130
XORWF......................................................................130
Instruction Set Summary....................................................117
INT Interrupt........................................................................110
INTCON Register.................................................................26
Internet Address.................................................................173
Interrupt Sources
Capture Complete (CCP).............................................58
Compare Complete (CCP)...........................................59
TMR2 to PR2 Match (PWM)........................................60
Interrupts............................................................................109
Interrupts, Enable Bits
CCP1 Enable (CCP1IE Bit)..........................................58
Interrupts, Flag Bits
CCP1 Flag (CCP1IF Bit)..............................................58
IORLW Instruction..............................................................125
IORWF Instruction..............................................................125
M
Memory Organization
Data EEPROM Memory.................................. 91, 93, 95
Microchip Internet Web Site...............................................173
Migrating from other PICmicro Devices.............................172
MOVF Instruction...............................................................125
MOVLW Instruction............................................................125
MOVWF Instruction............................................................126
MPLAB ASM30 Assembler, Linker, Librarian.....................132
MPLAB Integrated Development Environment Software.. 131
MPLAB PM3 Device Programmer.....................................134
MPLAB REAL ICE In-Circuit Emulator System..................133
MPLINK Object Linker/MPLIB Object Librarian.................132
N
NOP Instruction..................................................................126
O
OPTION Instruction............................................................126
OPTION Register.................................................................25
OPTION_REG Register.......................................................25
Oscillator Configurations......................................................99
Oscillator Start-up Timer (OST)..........................................103
P
Package Marking Information............................................163
Packaging Information.......................................................163
PCL and PCLATH................................................................30
Stack............................................................................30
PCON Register.....................................................................29
PIE1 Register.......................................................................27
Pin Functions
RC6/TX/CK............................................................7389
RC7/RX/DT............................................................7389
PIR1 Register.......................................................................28
PORTA..................................................................................33
PORTB.................................................................................38
PORTB Interrupt.................................................................110
Power Control/Status Register (PCON).............................104
Power-Down Mode (Sleep)................................................112
Power-On Reset (POR).....................................................103
Power-up Timer (PWRT)....................................................103
PR2 Register ................................................................ 54, 60
Program Memory Organization............................................17
PWM (CCP Module).............................................................60
Block Diagram..............................................................60
Simplified PWM....................................................60
CCPR1H:CCPR1L Registers.......................................60
Duty Cycle....................................................................61
Example Frequencies/Resolutions..............................61
Period...........................................................................60
Set-Up for PWM Operation..........................................61
TMR2 to PR2 Match.....................................................60
Q
Q-Clock.................................................................................61
Quick-Turnaround-Production (QTP) Devices.......................9
R
RC Oscillator......................................................................101
RC Oscillator Mode
Block Diagram............................................................101
Reader Response..............................................................174
Registers
CCP1CON (CCP Operation)........................................57
CMCON (Comparator Configuration)..........................63
CONFIG (Configuration Word).....................................98
EECON1 (EEPROM Control Register 1).....................92
INTCON (Interrupt Control)..........................................26
Maps
PIC16F627A ................................................. 18,
19
PIC16F628A ................................................. 18,
19
OPTION_REG (Option)...............................................25
PCON (Power Control)................................................29
PIE1 (Peripheral Interrupt Enable 1)............................27
PIR1 (Peripheral Interrupt Register 1).........................28
Status...........................................................................24
T1CON Timer1 Control)...............................................50
T2CON Timer2 Control)...............................................55
Reset..................................................................................101
RETFIE Instruction.............................................................126
RETLW Instruction.............................................................127
RETURN Instruction...........................................................127
Revision History.................................................................171
RLF Instruction...................................................................127
RRF Instruction..................................................................128
S
Serial Communication Interface (SCI) Module, See USART
Serialized Quick-Turnaround-Production (SQTP) Devices...
9 SLEEP Instruction...........................................................128
Software Simulator (MPLAB SIM)......................................133
Special Event Trigger. See Compare
Special Features of the CPU................................................97
Special Function Registers..................................................20
Status Register.....................................................................24
SUBLW Instruction.............................................................128
SUBWF Instruction.............................................................129
SWAPF Instruction.............................................................129
T
T1CKPS0 bit.........................................................................50
T1CKPS1 bit.........................................................................50
T1CON Register...................................................................50
T1OSCEN bit........................................................................50
T2CKPS0 bit.........................................................................55
T2CKPS1 bit.........................................................................55
T2CON Register...................................................................55
Timer0
Block Diagrams
Timer0/WDT.........................................................48
External Clock Input.....................................................47
Interrupt........................................................................47
Prescaler......................................................................48
Switching Prescaler Assignment..................................49
Timer0 Module.............................................................47
Timer1
Asynchronous Counter Mode......................................52
Capacitor Selection......................................................53
U
Universal Synchronous Asynchronous Receiver Transmitter
(USART).......................................................................73
Asynchronous Receiver
Setting Up Reception...........................................85
Asynchronous Receiver Mode
Address Detect....................................................85
Block Diagram......................................................85
USART
Asynchronous Mode....................................................79
Asynchronous Receiver...............................................82
Asynchronous Reception.............................................84
Asynchronous Transmission........................................80
Asynchronous Transmitter...........................................79
Baud Rate Generator (BRG)........................................75
Block Diagrams
Transmit...............................................................80
USART Receive...................................................82
BRGH bit......................................................................75
Sampling......................................................... 76, 77, 78
Synchronous Master Mode..........................................86
Synchronous Master Reception...................................88
Synchronous Master Transmission..............................86
Synchronous Slave Mode............................................89
Synchronous Slave Reception.....................................90
V
Voltage
Reference
Configuration................................................................69
Voltage Reference Module...........................................69
W
Watchdog Timer (WDT)......................................................111
WWW Address...................................................................173
WWW, On-Line Support.........................................................5
X
XORLW Instruction.............................................................130
XORWF Instruction............................................................130
/XX
XXX
Temperature
Range
Package
Pattern
Device:
Temperature
Range:
I
E
= -40C to +85C
= -40C to+125C
Package:
P
SO
SS
ML
=
=
=
=
PDIP
SOIC (Gull Wing, 7.50 mm body)
SSOP (5.30 mm
QFN (28 Lead)
Examples:
a)
DS40044G-page 180
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
India - Bangalore
Tel: 91-80-3090-4444
Fax: 91-80-3090-4080
India - New Delhi
Tel: 91-11-4160-8631
Fax: 91-11-4160-8632
Austria - Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829
India - Pune
Tel: 91-20-2566-1512
Fax: 91-20-2566-1513
France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Japan - Yokohama
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
China - Beijing
Tel: 86-10-8528-2100
Fax: 86-10-8528-2104
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-536-4803
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
China - Chengdu
Tel: 86-28-8665-5511
Fax: 86-28-8665-7889
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
UK - Wokingham
Tel: 44-118-921-5869
Fax: 44-118-921-5820
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
03/26/09