Professional Documents
Culture Documents
Data Sheet
Flash-Based 8-Bit CMOS
Microcontrollers with nanoWatt Technology
Preliminary
DS40044B
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip's Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break 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, Accuron,
dsPIC, KEELOQ, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart and rfPIC are registered
trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
AmpLab, FilterLab, microID, MXDEV, MXLAB, PICMASTER,
SEEVAL, SmartShunt and The Embedded Control Solutions
Company are registered trademarks of Microchip Technology
Incorporated in the U.S.A.
Application Maestro, dsPICDEM, dsPICDEM.net,
dsPICworks, ECAN, ECONOMONITOR, FanSense,
FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP,
ICEPIC, Migratable Memory, MPASM, MPLIB, MPLINK,
MPSIM, PICkit, PICDEM, PICDEM.net, PICtail, PowerCal,
PowerInfo, PowerMate, PowerTool, rfLAB, Select Mode,
SmartSensor, SmartTel and Total Endurance are trademarks
of Microchip Technology Incorporated in the U.S.A. and other
countries.
Serialized Quick Turn Programming (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.
2004, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
DS40044B-page ii
Preliminary
PIC16F627A/628A/648A
18-pin Flash-Based 8-Bit CMOS Microcontrollers
with nanoWatt Technology
High Performance RISC CPU:
Standby Current:
- 100 nA @ 2.0V, typical
Operating Current:
- 12 A @ 32 kHz, 2.0V, typical
- 120 A @ 1 MHz, 2.0V, typical
Watchdog Timer Current
- 1 A @ 2.0V, typical
Timer1 oscillator current:
- 1.2 A @ 32 kHz, 2.0V, typical
Dual Speed Internal Oscillator:
- Run-time selectable between 4 MHz and
37 kHz
- 4 s wake-up from Sleep, 3.0V, typical
Device
Program
Memory
Peripheral Features:
16 I/O pins with individual direction control
High current sink/source for direct LED drive
Analog comparator module with:
- Two analog comparators
- Programmable on-chip voltage reference
(VREF) module
- Selectable internal or external reference
- Comparator outputs are externally accessible
Timer0: 8-bit timer/counter with 8-bit
programmable prescaler
Timer1: 16-bit timer/counter with external crystal/
clock capability
Timer2: 8-bit timer/counter with 8-bit period
register, prescaler and postscaler
Capture, Compare, PWM module
- 16-bit Capture/Compare
- 10-bit PWM
Addressable Universal Synchronous/Asynchronous
Receiver/Transmitter USART/SCI
Data Memory
I/O
CCP
(PWM)
USART
Comparators
Timers
8/16-bit
128
16
2/1
128
16
2/1
256
16
2/1
Flash
(words)
SRAM
(bytes)
EEPROM
(bytes)
PIC16F627A
1024
224
PIC16F628A
2048
224
PIC16F648A
4096
256
Preliminary
DS40044B-page 1
PIC16F627A/628A/648A
Pin Diagrams
PDIP, SOIC
18
RA1/AN1
RA3/AN3/CMP1
17
RA0/AN0
16
RA7/OSC1/CLKIN
15
RA6/OSC2/CLKOUT
14
VDD
13
RB7/T1OSI/PGD
RA5/MCLR/VPP
RB0/INT
RB1/RX/DT
12
RB6/T1OSO/T1CKI/PGC
RB2/TX/CK
11
RB5
RB3/CCP1
10
RB4/PGM
RA5/MCLR/VPP
8
9
10
NC 11
12
RB4/PGM
13
RB5
NC 14
1
21
NC 2
20
VSS
3
19
NC 4 PIC16F627A/628A 18 NC
PIC16F648A
VSS
17
5
NC 6
16
RB0/INT
7
15
DS40044B-page 2
RA7/OSC1/CLKIN
RA6/OSC2/CLKOUT
VDD
VDD
RB7/T1OSI/PGD
RB6/T1OSO/T1CKI/PGC
RB1/RX/DT
RB2/TX/CK
RB3/CCP1
RA2/AN2/VREF
RA3/AN3/CMP1
RA4/TOCKI/CMP2
RA5/MCLR/VPP
VSS
VSS
RB0/INT
RB1/RX/DT
RB2/TX/CK
RB3/CCP1
1
2
3
4
5
6
7
8
9
10
PIC16F627A/628A/648A
28
27
26
25 NC
24
23
22 NC
RA4/T0CKI/CMP2
RA3/AN3/CMP1
RA2/AN2/VREF
28-Pin QFN
20
19
18
17
16
15
14
13
12
11
RA1/AN1
RA0/AN0
RA7/OSC1/CLKIN
RA6/OSC2/CLKOUT
VDD
VDD
RB7/T1OSI/PGD
RB6/T1OSO/T1CKI/PGC
RB5
RB4/PGM
VSS
RA1/AN1
RA0/AN0
RA4/TOCKI/CMP2
PIC16F627A/628A/648A
PIC16F627A/628A/648A
SSOP
RA2/AN2/VREF
Preliminary
PIC16F627A/628A/648A
Table of Contents
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
11.0
12.0
13.0
14.0
15.0
16.0
17.0
18.0
19.0
General Description...................................................................................................................................................................... 5
PIC16F627A/628A/648A Device Varieties ................................................................................................................................... 7
Architectural Overview ................................................................................................................................................................. 9
Memory Organization ................................................................................................................................................................. 15
I/O Ports ..................................................................................................................................................................................... 31
Timer0 Module ........................................................................................................................................................................... 45
Timer1 Module ........................................................................................................................................................................... 48
Timer2 Module ........................................................................................................................................................................... 52
Capture/Compare/PWM (CCP) Module ..................................................................................................................................... 55
Comparator Module.................................................................................................................................................................... 61
Voltage Reference Module......................................................................................................................................................... 67
Universal Synchronous Asynchronous Receiver Transmitter (USART) Module........................................................................ 69
Data EEPROM Memory ............................................................................................................................................................. 89
Special Features of the CPU...................................................................................................................................................... 93
Instruction Set Summary .......................................................................................................................................................... 111
Development Support............................................................................................................................................................... 125
Electrical Specifications............................................................................................................................................................ 131
DC and AC Characteristics Graphs and Tables....................................................................................................................... 147
Packaging Information.............................................................................................................................................................. 149
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)
The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include literature number) you are using.
Preliminary
DS40044B-page 3
PIC16F627A/628A/648A
NOTES:
DS40044B-page 4
Preliminary
PIC16F627A/628A/648A
1.0
GENERAL DESCRIPTION
TABLE 1-1:
Clock
Memory
1.1
Development Support
PIC16F628A
PIC16F648A
PIC16LF627A
PIC16LF628A
PIC16LF648A
Maximum Frequency
of Operation (MHz)
20
20
20
1024
2048
4096
1024
2048
4096
224
224
256
224
224
256
128
128
256
128
128
256
TMR0, TMR1,
TMR2
TMR0, TMR1,
TMR2
TMR0, TMR1,
TMR2
TMR0, TMR1,
TMR2
TMR0, TMR1,
TMR2
TMR0, TMR1,
TMR2
USART
USART
USART
USART
USART
USART
Yes
Yes
Yes
Yes
Yes
Yes
Timer module(s)
Comparator(s)
Peripherals Capture/Compare/
PWM modules
Serial Communications
Internal Voltage
Reference
Features
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
Yes
18-pin DIP,
SOIC, 20-pin
SSOP,
28-pin QFN
18-pin DIP,
SOIC, 20-pin
SSOP,
28-pin QFN
18-pin DIP,
SOIC, 20-pin
SSOP,
28-pin QFN
18-pin DIP,
SOIC, 20-pin
SSOP,
28-pin QFN
18-pin DIP,
SOIC, 20-pin
SSOP,
28-pin QFN
18-pin DIP,
SOIC, 20-pin
SSOP,
28-pin QFN
All PICmicro 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.
Preliminary
DS40044B-page 5
PIC16F627A/628A/648A
NOTES:
DS40044B-page 6
Preliminary
PIC16F627A/628A/648A
2.0
PIC16F627A/628A/648A
DEVICE VARIETIES
2.1
Flash Devices
2.2
Quick-Turnaround-Production
(QTP) Devices
2.3
Preliminary
DS40044B-page 7
PIC16F627A/628A/648A
NOTES:
DS40044B-page 8
Preliminary
PIC16F627A/628A/648A
3.0
ARCHITECTURAL OVERVIEW
TABLE 3-1:
Device
Flash
Program
RAM
Data
EEPROM
Data
PIC16F627A
1024 x 14
224 x 8
128 x 8
PIC16F628A
2048 x 14
224 x 8
128 x 8
PIC16F648A
4096 x 14
256 x 8
256 x 8
PIC16LF627A
1024 x 14
224 x 8
128 x 8
PIC16LF628A
2048 x 14
224 x 8
128 x 8
PIC16LF648A
4096 x 14
256 x 8
256 x 8
Preliminary
DS40044B-page 9
PIC16F627A/628A/648A
FIGURE 3-1:
BLOCK DIAGRAM
13
Program
Memory
RAM
File
Registers
8-Level Stack
(13-bit)
Program
Bus
14
Data Bus
Program Counter
Flash
PORTA
Addr MUX
Instruction reg
Direct Addr
RA0/AN0
RA1/AN1
RA2/AN2/VREF
RA3/AN3/CMP1
RA4/T0CK1/CMP2
RA5/MCLR/VPP
RA6/OSC2/CLKOUT
RA7/OSC1/CLKIN
Indirect
Addr
FSR reg
Status Reg
8
3
Power-up
Timer
Instruction
Decode &
Control
Timing
Generation
OSC1/CLKIN
OSC2/CLKOUT
Oscillator
Start-up Timer
MUX
RB0/INT
RB1/RX/DT
RB2/TX/CK
RB3/CCP1
RB4/PGM
RB5
RB6/T1OSO/T1CKI/PGC
RB7/T1OSI/PGD
ALU
Power-on
Reset
Watchdog
Timer
Brown-out
Detect
PORTB
W reg
Low-Voltage
Programming
MCLR
Comparator
Timer0
VREF
CCP1
Note:
VDD, VSS
Timer1
Timer2
USART
Data EEPROM
DS40044B-page 10
Preliminary
PIC16F627A/628A/648A
TABLE 3-2:
Name
RA0/AN0
RA1/AN1
RA2/AN2/VREF
RA3/AN3/CMP1
RA4/T0CKI/CMP2
RA5/MCLR/VPP
RA6/OSC2/CLKOUT
RA7/OSC1/CLKIN
Function
Description
RA0
ST
AN0
AN
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
ST
CMOS
OSC1
XTAL
CLKIN
ST
RB0/INT
RB0
TTL
CMOS
INT
ST
RB1/RX/DT
RB1
TTL
CMOS
RX
ST
DT
ST
CMOS
RB2
TTL
CMOS
RB2/TX/CK
RB3/CCP1
O = Output
= Not used
TTL = TTL Input
External interrupt.
Bidirectional I/O port. Can be software
programmed for internal weak pull-up.
USART receive pin
TX
CMOS
CK
ST
CMOS
RB3
TTL
CMOS
ST
CMOS
Capture/Compare/PWM I/O
CCP1
Legend:
Preliminary
P = Power
ST = Schmitt Trigger Input
AN = Analog
DS40044B-page 11
PIC16F627A/628A/648A
TABLE 3-2:
Name
RB4/PGM
Function
Description
RB4
TTL
CMOS
PGM
ST
RB5
RB5
TTL
CMOS
RB6/T1OSO/T1CKI/PGC
RB6
TTL
CMOS
T1OSO
XTAL
T1CKI
ST
PGC
ST
RB7
TTL
CMOS
T1OSI
XTAL
PGD
ST
CMOS
VSS
VSS
Power
VDD
VDD
Power
RB7/T1OSI/PGD
Legend:
O = Output
= Not used
TTL = TTL Input
DS40044B-page 12
Preliminary
P = Power
ST = Schmitt Trigger Input
AN = Analog
PIC16F627A/628A/648A
3.1
Clocking Scheme/Instruction
Cycle
3.2
Instruction Flow/Pipelining
FIGURE 3-2:
CLOCK/INSTRUCTION CYCLE
Q2
Q1
Q3
Q4
Q1
Q2
Q3
Q4
Q1
Q2
Q3
Q4
OSC1
Q1
Q2
Internal
phase
clock
Q3
Q4
PC
PC
PC+1
PC+2
CLKOUT
Fetch INST (PC)
Execute INST (PC-1)
EXAMPLE 3-1:
2. MOVWF PORTB
SUB_1
4. BSF
PORTA, 3
1. MOVLW 55h
3. CALL
Fetch 1
Execute 1
Fetch 2
Execute 2
Fetch 3
Execute 3
Fetch 4
Flush
Fetch SUB_1 Execute SUB_1
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.
Preliminary
DS40044B-page 13
PIC16F627A/628A/648A
NOTES:
DS40044B-page 14
Preliminary
PIC16F627A/628A/648A
4.0
MEMORY ORGANIZATION
4.2
4.1
FIGURE 4-1:
CALL, RETURN
RETFIE, RETLW
13
On-chip Program
Memory
PIC16F648A
Bank0
20-7Fh
20-7Fh
Bank1
A0h-FF
A0h-FF
Bank2
120h-14Fh, 170h-17Fh
120h-17Fh
Bank3
1F0h-1FFh
1F0h-1FFh
Stack Level 8
Interrupt Vector
TABLE 4-1:
Stack Level 1
Stack Level 2
Reset Vector
TABLE 4-2:
000h
0004
0005
PIC16F627A,
PIC16F628A and
PIC16F648A
03FFh
On-chip Program
Memory
PIC16F628A and
PIC16F648A
07FFh
4.2.1
ACCESS TO BANKS OF
REGISTERS
RP1
RP0
Bank0
Bank1
Bank2
Bank3
On-chip Program
Memory
PIC16F648A only
0FFFh
1FFFh
Preliminary
DS40044B-page 15
PIC16F627A/628A/648A
FIGURE 4-2:
Indirect addr.(1)
00h
Indirect addr.(1)
80h
Indirect addr.(1)
100h
Indirect addr.(1)
180h
TMR0
01h
OPTION
81h
TMR0
101h
OPTION
181h
PCL
02h
82h
PCL
102h
PCL
182h
STATUS
03h
STATUS
83h
STATUS
103h
STATUS
183h
FSR
04h
FSR
84h
FSR
104h
FSR
184h
PORTA
05h
TRISA
85h
PORTB
06h
TRISB
86h
PCL
105h
PORTB
106h
185h
TRISB
186h
07h
87h
107h
187h
08h
88h
108h
188h
89h
109h
189h
09h
8Ah
PCLATH
10Ah
PCLATH
18Ah
8Bh
INTCON
10Bh
INTCON
18Bh
PCLATH
0Ah
PCLATH
INTCON
0Bh
INTCON
PIR1
0Ch
PIE1
8Ch
10Ch
18Ch
8Dh
10Dh
18Dh
8Eh
10Eh
18Eh
10Fh
18Fh
0Dh
TMR1L
0Eh
TMR1H
0Fh
8Fh
T1CON
10h
90h
TMR2
11h
T2CON
12h
PCON
91h
PR2
92h
13h
93h
14h
94h
CCPR1L
15h
95h
CCPR1H
16h
96h
CCP1CON
17h
97h
RCSTA
18h
TXSTA
98h
TXREG
19h
99h
RCREG
1Ah
SPBRG
EEDATA
1Bh
EEADR
9Bh
1Ch
EECON1
9Ch
1Dh
EECON2(1)
9Dh
1Eh
CMCON
1Fh
9Ah
9Eh
VRCON
20h
9Fh
A0h
General
Purpose
Register
80 Bytes
General
Purpose
Register
General
Purpose
Register
48 Bytes
11Fh
120h
14Fh
150h
80 Bytes
6Fh
70h
16 Bytes
accesses
70h-7Fh
7Fh
Bank 0
EFh
F0h
accesses
70h-7Fh
1EFh
1F0h
accesses
70h - 7Fh
17Fh
FFh
Bank 2
Bank 1
16Fh
170h
1FFh
Bank 3
DS40044B-page 16
Preliminary
PIC16F627A/628A/648A
FIGURE 4-3:
Indirect addr.(1)
00h
Indirect addr.(1)
80h
Indirect addr.(1)
100h
Indirect addr.(1)
180h
TMR0
01h
OPTION
81h
TMR0
101h
OPTION
181h
PCL
02h
82h
PCL
102h
PCL
182h
STATUS
03h
STATUS
83h
STATUS
103h
STATUS
183h
FSR
04h
FSR
84h
FSR
104h
FSR
184h
PORTA
05h
TRISA
85h
PORTB
06h
TRISB
86h
PCL
105h
PORTB
106h
185h
TRISB
186h
07h
87h
107h
187h
08h
88h
108h
188h
89h
109h
189h
09h
8Ah
PCLATH
10Ah
PCLATH
18Ah
8Bh
INTCON
10Bh
INTCON
18Bh
PCLATH
0Ah
PCLATH
INTCON
0Bh
INTCON
PIR1
0Ch
PIE1
8Ch
10Ch
18Ch
8Dh
10Dh
18Dh
8Eh
10Eh
18Eh
10Fh
18Fh
0Dh
TMR1L
0Eh
TMR1H
0Fh
8Fh
T1CON
10h
90h
TMR2
11h
T2CON
12h
PCON
91h
PR2
92h
13h
93h
14h
94h
CCPR1L
15h
95h
CCPR1H
16h
96h
CCP1CON
17h
97h
RCSTA
18h
TXSTA
98h
TXREG
19h
99h
RCREG
1Ah
SPBRG
EEDATA
1Bh
EEADR
9Bh
1Ch
EECON1
9Ch
1Dh
EECON2(1)
9Dh
1Eh
CMCON
1Fh
9Ah
9Eh
VRCON
20h
9Fh
11Fh
120h
A0h
General
Purpose
Register
80 Bytes
General
Purpose
Register
80 Bytes
General
Purpose
Register
80 Bytes
6Fh
70h
16 Bytes
accesses
70h-7Fh
7Fh
Bank 0
EFh
F0h
accesses
70h-7Fh
1EFh
1F0h
accesses
70h - 7Fh
17Fh
FFh
Bank 2
Bank 1
16Fh
170h
1FFh
Bank 3
Preliminary
DS40044B-page 17
PIC16F627A/628A/648A
4.2.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:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on Details
on
POR
Reset(1) Page
Bank 0
00h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical register)
xxxx xxxx
28
01h
TMR0
xxxx xxxx
45
02h
03h
PCL
STATUS
04h
FSR
05h
PORTA
06h
PORTB
07h
08h
IRP
RA7
RB7
RP1
RP0
RA6
RB6
RA5
RB5
TO
PD
DC
RA4
RB4
RA3
RB3
RA2
RB2
RA1
RB1
RA0
RB0
Unimplemented
Unimplemented
09h
0Ah
PCLATH
0Bh
0Ch
INTCON
PIR1
0Dh
0Eh
TMR1L
Unimplemented
Holding register for the Least Significant Byte of the 16-bit TMR1
Holding register for the Most Significant Byte of the 16-bit TMR1
0Fh
TMR1H
10h
T1CON
11h
12h
TMR2
T2CON
13h
14h
15h
16h
CCPR1L
CCPR1H
17h
CCP1CON
18h
RCSTA
19h
1Ah
TXREG
RCREG
Unimplemented
0000 0000
28
0001 1xxx
22
xxxx xxxx
28
xxxx 0000
xxxx xxxx
31
36
---0 0000
28
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0000 000x
24
EEIF
CMIF
RCIF
TXIF
CCP1IF
TMR2IF
TMR1IF
0000 -000
26
xxxx xxxx
48
xxxx xxxx
48
T1CKPS1
T1CKPS0
T1OSCEN
T1SYNC
TMR1CS
TMR1ON
TOUTPS3
TOUTPS2
TOUTPS1
TOUTPS0
TMR2ON
T2CKPS1
T2CKPS0
Unimplemented
Unimplemented
Capture/Compare/PWM register (LSB)
Capture/Compare/PWM register (MSB)
SPEN
RX9
CCP1X
SREN
CCP1Y
CREN
CCP1M3
ADEN
CCP1M2
FERR
CCP1M1
OERR
CCP1M0
RX9D
--00 0000
48
0000 0000
52
-000 0000
52
xxxx xxxx
xxxx xxxx
55
55
--00 0000
0000 000x
55
69
0000 0000
0000 0000
76
79
1Bh
1Ch
Unimplemented
Unimplemented
1Dh
1Eh
Unimplemented
Unimplemented
0000 0000
61
1Fh
CMCON
C2OUT
C1OUT
C2INV
C1INV
CIS
CM2
CM1
CM0
Legend:
DS40044B-page 18
Preliminary
PIC16F627A/628A/648A
TABLE 4-4:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on Details
POR
on
Reset(1) Page
Bank 1
80h
INDF
81h
OPTION
82h
PCL
83h
STATUS
84h
FSR
Addressing this location uses contents of FSR to address data memory (not a physical
register)
RBPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
xxxx xxxx
PS0
RP1
RP0
TO
PD
DC
28
1111 1111
23
0000 0000
28
0001 1xxx
22
xxxx xxxx
28
85h
TRISA
TRISA7
TRISA6
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
1111 1111
31
86h
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
TRISB3
TRISB2
TRISB1
TRISB0
1111 1111
36
87h
Unimplemented
88h
Unimplemented
89h
Unimplemented
---0 0000
28
8Ah
PCLATH
8Bh
INTCON
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0000 000x
24
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
CCP1IE
TMR2IE
TMR1IE
0000 -000
25
---- 1-0x
27
1111 1111
52
8Dh
8Eh
PCON
8Fh
90h
Unimplemented
Unimplemented
Unimplemented
Timer2 Period Register
93h
94h
Unimplemented
Unimplemented
95h
96h
Unimplemented
Unimplemented
97h
98h
TXSTA
Unimplemented
CSRC
TX9
0000 -010
71
99h
9Ah
SPBRG
EEDATA
0000 0000
xxxx xxxx
71
89
9Bh
9Ch
EEADR
EECON1
xxxx xxxx
90
---- x000
90
9Dh
EECON2
---- ----
90
91h
92h
9Eh
9Fh
PR2
VRCON
Unimplemented
TXEN
OSCF
SYNC
WRERR
BRGH
WREN
POR
TRMT
WR
BOR
TX9D
RD
Unimplemented
VREN
VROE
VRR
VR3
VR2
VR1
VR0
000- 0000
67
Legend: = Unimplemented locations read as 0, u = unchanged, x = unknown, q = value depends on condition, shaded = unimplemented
Note 1: For the Initialization Condition for Registers Tables, refer to Table 14-6 and Table 14-7.
Preliminary
DS40044B-page 19
PIC16F627A/628A/648A
TABLE 4-5:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Reset(1)
Details
on
Page
Bank 2
100h
INDF
101h
102h
TMR0
PCL
103h
STATUS
104h
FSR
Addressing this location uses contents of FSR to address data memory (not a physical register) xxxx xxxx
Timer0 modules Register
xxxx xxxx
Program Counter's (PC) Least Significant Byte
IRP
RP1
RP0
TO
0000 0000
PD
DC
105h
106h
PORTB
107h
108h
109h
10Ah
PCLATH
10Bh
INTCON
Unimplemented
28
45
28
0001 1xxx
22
xxxx xxxx
28
xxxx xxxx
36
Unimplemented
Unimplemented
Unimplemented
---0 0000
28
RB7
RB6
RB5
GIE
PEIE
T0IE
RB4
RB3
RB2
RB1
RB0
0000 000x
24
10Ch
Unimplemented
INTE
RBIE
T0IF
INTF
RBIF
10Dh
Unimplemented
10Eh
Unimplemented
10Fh
110h
Unimplemented
Unimplemented
111h
112h
Unimplemented
Unimplemented
113h
114h
Unimplemented
Unimplemented
115h
116h
Unimplemented
Unimplemented
117h
118h
Unimplemented
Unimplemented
119h
11Ah
Unimplemented
Unimplemented
11Bh
11Ch
Unimplemented
Unimplemented
11Dh
11Eh
Unimplemented
Unimplemented
11Fh
Unimplemented
Legend:
DS40044B-page 20
Preliminary
PIC16F627A/628A/648A
TABLE 4-6:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Reset(1)
Details
on
Page
Bank 3
180h
INDF
Addressing this location uses contents of FSR to address data memory (not a physical register) xxxx xxxx
28
181h
182h
OPTION
PCL
INTEDG
T0CS
T0SE
RBPU
Program Counter's (PC) Least Significant Byte
PSA
1111 1111
23
0000 0000
28
183h
STATUS
IRP
PD
0001 1xxx
22
184h
FSR
xxxx xxxx
28
185h
186h
TRISB
187h
188h
189h
18Ah
PCLATH
18Bh
INTCON
RP1
RP0
TO
PS2
Z
PS1
DC
PS0
C
Unimplemented
1111 1111
36
Unimplemented
Unimplemented
Unimplemented
---0 0000
28
TRISB7
TRISB6
TRISB5
GIE
PEIE
T0IE
TRISB4
TRISB3
TRISB2
TRISB1
TRISB0
0000 000x
24
18Ch
Unimplemented
INTE
RBIE
T0IF
INTF
RBIF
18Dh
Unimplemented
18Eh
Unimplemented
18Fh
190h
Unimplemented
Unimplemented
191h
192h
Unimplemented
Unimplemented
193h
194h
Unimplemented
Unimplemented
195h
196h
Unimplemented
Unimplemented
197h
198h
Unimplemented
Unimplemented
199h
19Ah
Unimplemented
Unimplemented
19Bh
19Ch
Unimplemented
Unimplemented
19Dh
19Eh
Unimplemented
Unimplemented
19Fh
Unimplemented
Legend:
Preliminary
DS40044B-page 21
PIC16F627A/628A/648A
4.2.2.1
Status Register
REGISTER 4-1:
R/W-0
R/W-0
R-1
R-1
R/W-x
R/W-x
R/W-x
IRP
RP1
RP0
TO
PD
DC
bit 7
bit 0
bit 7
bit 6-5
bit 4
bit 3
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
For borrow, the polarity is reversed. A subtraction is executed by adding the twos
complement of the second operand. For rotate (RRF, RLF) instructions, this bit is
loaded with either the high or low order bit of the source register.
Legend:
DS40044B-page 22
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F627A/628A/648A
4.2.2.2
OPTION Register
Note:
REGISTER 4-2:
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
R/W-1
RBPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2-0
TMR0 Rate
1:2
1:4
1:8
1 : 16
1 : 32
1 : 64
1 : 128
1 : 256
WDT Rate
1:1
1:2
1:4
1:8
1 : 16
1 : 32
1 : 64
1 : 128
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS40044B-page 23
PIC16F627A/628A/648A
4.2.2.3
INTCON Register
Note:
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 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
DS40044B-page 24
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F627A/628A/648A
4.2.2.4
PIE1 Register
REGISTER 4-4:
R/W-0
R/W-0
R/W-0
U-0
R/W-0
R/W-0
R/W-0
EEIE
CMIE
RCIE
TXIE
CCP1IE
TMR2IE
TMR1IE
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
Unimplemented: Read as 0
bit 2
bit 1
bit 0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS40044B-page 25
PIC16F627A/628A/648A
4.2.2.5
PIR1 Register
Note:
REGISTER 4-5:
R/W-0
R-0
R-0
U-0
R/W-0
R/W-0
R/W-0
EEIF
CMIF
RCIF
TXIF
CCP1IF
TMR2IF
TMR1IF
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
Unimplemented: Read as 0
bit 2
bit 1
bit 0
DS40044B-page 26
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F627A/628A/648A
4.2.2.6
PCON Register
REGISTER 4-6:
Note:
U-0
U-0
U-0
R/W-1
U-0
R/W-0
R/W-x
OSCF
POR
BOR
bit 7
bit 0
bit 7-4
Unimplemented: Read as 0
bit 3
bit 2
Unimplemented: Read as 0
bit 1
bit 0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS40044B-page 27
PIC16F627A/628A/648A
4.3
FIGURE 4-4:
LOADING OF PC IN
DIFFERENT SITUATIONS
4.4
PCH
PCL
12
PC
8
PCLATH<4:0>
Instruction with
PCL as
Destination
ALU result
PCLATH
PCH
12
11 10
PCL
8
GOTO, CALL
PC
2
PCLATH<4:3>
11
Opcode <10:0>
PCLATH
EXAMPLE 4-1:
4.3.1
COMPUTED GOTO
4.3.2
NEXT
MOVLW
MOVWF
CLRF
INCF
BTFSS
GOTO
Indirect Addressing
0x20
FSR
INDF
FSR
FSR,4
NEXT
;initialize pointer
;to RAM
;clear INDF register
;inc pointer
;all done?
;no clear next
;yes continue
STACK
DS40044B-page 28
Preliminary
PIC16F627A/628A/648A
FIGURE 4-5:
Status
Register
RP1
RP0
bank select
Direct Addressing
6
from opcode
IRP
Indirect Addressing
7
bank select
location select
00
01
10
FSR Register
location select
11
00h
180h
RAM
File
Registers
7Fh
1FFh
Bank 0
Note:
Bank 1
Bank 2
Bank 3
For memory map detail see Figure 4-3, Figure 4-2 and Figure 4-1.
Preliminary
DS40044B-page 29
PIC16F627A/628A/648A
NOTES:
DS40044B-page 30
Preliminary
PIC16F627A/628A/648A
5.0
I/O PORTS
5.1
The RA2 pin will also function as the output for the
voltage reference. When in this mode, the VREF pin is a
very high-impedance output. The user must configure
TRISA<2> bit as an input and use high-impedance
loads.
In one of the Comparator modes defined by the
CMCON register, pins RA3 and RA4 become outputs
of the comparators. The TRISA<4:3> bits must be
cleared to enable outputs to use this function.
EXAMPLE 5-1:
PORTA
MOVLW
MOVWF
0x07
CMCON
BCF
BSF
MOVLW
STATUS, RP1
STATUS, RP0 ;Select Bank1
0x1F
;Value used to initialize
;data direction
TRISA
;Set RA<4:0> as inputs
;TRISA<5> always
;read as 1.
;TRISA<7:6>
;depend on oscillator
;mode
MOVWF
Data
Bus
WR
PORTA
BLOCK DIAGRAM OF
RA0/AN0:RA1/AN1 PINS
Q
CK
VDD
Data Latch
WR
TRISA
CK
RD
TRISA
I/O Pin
TRIS Latch
;Initialize PORTA by
;setting
;output data latches
;Turn comparators off and
;enable pins for I/O
;functions
FIGURE 5-1:
Initializing PORTA
CLRF
Analog
Input Mode
(CMCON Reg.)
VSS
Schmitt Trigger
Input Buffer
EN
RD PORTA
To Comparator
Preliminary
DS40044B-page 31
PIC16F627A/628A/648A
FIGURE 5-2:
Data
Bus
BLOCK DIAGRAM OF
RA2/VREF PIN
WR
PORTA
CK
VDD
Data Latch
D
Q
RA2 Pin
WR
TRISA
CK
Analog
Input Mode
(CMCON Reg.)
TRIS Latch
RD
TRISA
VSS
Schmitt Trigger
Input Buffer
EN
RD PORTA
To Comparator
VROE
VREF
FIGURE 5-3:
Data
Bus
VDD
Q
Comparator Output
WR
PORTA
1
CK
Data Latch
D
Q
RA3 Pin
WR
TRISA
CK
Analog
Input Mode
(CMCON Reg.)
TRIS Latch
RD
TRISA
VSS
Schmitt Trigger
Input Buffer
EN
RD PORTA
To Comparator
DS40044B-page 32
Preliminary
PIC16F627A/628A/648A
FIGURE 5-4:
Data
Bus
Q
Comparator Output
WR
PORTA
1
CK
Q
0
Data Latch
D
Q
RA4 Pin
WR
TRISA
CK
Q
Vss
Vss
TRIS Latch
Schmitt Trigger
Input Buffer
RD TRISA
Q
EN
RD PORTA
FIGURE 5-5:
FIGURE 5-6:
BLOCK DIAGRAM OF
RA6/OSC2/CLKOUT PIN
RA5/MCLR/VPP PIN
From OSC1
OSC
Circuit
VDD
CLKOUT(FOSC/4)
1
CK
Q
(FOSC =
Data
Latch
101, 111) (2)
Schmitt Trigger
Input Buffer
Program
mode
WR
PORTA
VSS
HV Detect
RA5/MCLR/VPP
WR
TRISA
Data
Bus
CK
Q
Q
TRIS Latch
VSS
RD
TRISA
RD
TRISA
FOSC =
011, 100, 110
Schmitt
Trigger
Input Buffer
(1)
VSS
Q
Q
D
EN
RD
PORTA
D
EN
RD PORTA
Note
Preliminary
1:
2:
DS40044B-page 33
PIC16F627A/628A/648A
FIGURE 5-7:
To Clock Circuits
VDD
Data Bus
WR PORTA
Q
RA7/OSC1/CLKIN Pin
CK
Data Latch
D
WR TRISA
CK
VSS
Q
Q
TRIS Latch
RD TRISA
D
Schmitt Trigger
Input Buffer
EN
RD PORTA
Note
DS40044B-page 34
Preliminary
PIC16F627A/628A/648A
TABLE 5-1:
PORTA FUNCTIONS
Name
RA0/AN0
RA1/AN1
RA2/AN2/VREF
RA3/AN3/CMP1
RA4/T0CKI/CMP2
RA5/MCLR/VPP
RA6/OSC2/CLKOUT
Function
Input
Type
Output
Type
RA0
AN0
RA1
AN1
RA2
AN2
VREF
RA3
AN3
CMP1
RA4
T0CKI
CMP2
ST
AN
ST
AN
ST
AN
ST
AN
ST
ST
CMOS
CMOS
CMOS
AN
CMOS
CMOS
OD
OD
RA5
ST
MCLR
ST
VPP
RA6
OSC2
HV
ST
CMOS
XTAL
CLKOUT
RA7/OSC1/CLKIN
Legend:
RA7
OSC1
CLKIN
O = Output
= Not used
TTL = TTL Input
Description
Bidirectional I/O port
Analog comparator input
Bidirectional I/O port
Analog comparator input
Bidirectional I/O port
Analog comparator input
VREF output
Bidirectional I/O port
Analog comparator input
Comparator 1 output
Bidirectional I/O port. Output is open drain type.
External clock input for TMR0 or comparator output
Comparator 2 output
Input port
Master clear. When configured as MCLR, this pin is an
active low Reset to the device. Voltage on MCLR/VPP must
not exceed VDD during normal device operation.
Programming voltage input.
Preliminary
DS40044B-page 35
PIC16F627A/628A/648A
TABLE 5-2:
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
All Other
Resets
PORTA
RA7
RA6
RA5(2)
RA4
RA3
RA2
RA1
RA0
xxxx 0000
qqqu 0000
85h
TRISA
TRISA7
TRISA6
TRISA5 TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
1111 1111
1111 1111
1Fh
CMCON
C2OUT
C1OUT
C2INV
C1INV
CIS
CM2
CM1
CM0
0000 0000
0000 0000
9Fh
VRCON
VREN
VROE
VRR
VR3
VR2
VR1
VR0
000- 0000
000- 0000
Address
05h
Name
5.2
DS40044B-page 36
Preliminary
PIC16F627A/628A/648A
FIGURE 5-8:
BLOCK DIAGRAM OF
RB0/INT PIN
FIGURE 5-9:
BLOCK DIAGRAM OF
RB1/RX/DT PIN
VDD
VDD
RBPU
Weak
P Pull-up
VDD
RBPU
P Weak Pull-up
SPEN
VDD
USART Data Output
Data Bus
WR PORTB
Data Bus
D
Q
RB0/INT
CK
WR TRISB
CK
CK
RB1/
RX/DT
Data Latch
VSS
Data Latch
WR PORTB
WR TRISB
CK
VSS
TRIS Latch
Peripheral OE(1)
TRIS Latch
TTL
Input
Buffer
RD TRISB
TTL
Input
Buffer
RD TRISB
D
EN
RD PORTB
EN
EN
USART Receive Input
RD PORTB
Schmitt
Trigger
INT
Note
Schmitt
Trigger
Preliminary
1:
DS40044B-page 37
PIC16F627A/628A/648A
FIGURE 5-10:
BLOCK DIAGRAM OF
RB2/TX/CK PIN
FIGURE 5-11:
VDD
Weak
P Pull-up
VDD
RBPU
SPEN
CK
RB2/
TX/CK
WR TRISB
CK
CCP1CON
Data Bus
WR PORTB
Data Latch
D
VDD
Weak
P Pull-up
VDD
RBPU
CCP output
1
D
BLOCK DIAGRAM OF
RB3/CCP1 PIN
CK
Data Latch
VSS
WR TRISB
TRIS Latch
CK
VSS
TRIS Latch
Peripheral OE(1)
Peripheral OE(2)
TTL
Input
Buffer
RD TRISB
Q
TTL
Input
Buffer
RD TRISB
EN
RD PORTB
RD PORTB
CCP In
Schmitt
Trigger
1:
D
EN
Note
RB3/
CCP1
DS40044B-page 38
Schmitt
Trigger
Note
Preliminary
1:
PIC16F627A/628A/648A
FIGURE 5-12:
RBPU
P weak pull-up
Data Bus
WR PORTB
CK
VDD
Data Latch
WR TRISB
CK
RB4/PGM
VSS
TRIS Latch
RD TRISB
RD PORTB
PGM input
TTL
input
buffer
Schmitt
Trigger
EN
Q1
Set RBIF
From other
RB<7:4> pins
D
EN
Note:
Q3
The low voltage programming disables the interrupt-on-change and the weak pull-ups on RB4.
Preliminary
DS40044B-page 39
PIC16F627A/628A/648A
FIGURE 5-13:
RBPU
weak VDD
P pull-up
Data Bus
CK
RB5 pin
WR PORTB
Data Latch
VSS
D
CK
WR TRISB
TRIS Latch
TTL
input
buffer
RD TRISB
RD PORTB
EN
Q1
Set RBIF
From other
RB<7:4> pins
EN
DS40044B-page 40
Preliminary
Q3
PIC16F627A/628A/648A
FIGURE 5-14:
RBPU
P weak pull-up
Data Bus
WR PORTB
CK
VDD
Data Latch
WR TRISB
CK
RB6/
T1OSO/
T1CKI
pin
VSS
TRIS Latch
RD TRISB
T1OSCEN
TTL
input
buffer
RD PORTB
TMR1 Clock
From RB7
Schmitt
Trigger
TMR1 oscillator
EN
Q1
Set RBIF
From other
RB<7:4> pins
D
Q3
EN
Preliminary
DS40044B-page 41
PIC16F627A/628A/648A
FIGURE 5-15:
RBPU
P weak pull-up
TMR1 oscillator
To RB6
VDD
Data Bus
WR PORTB
CK
RB7/T1OSI
pin
Data Latch
WR TRISB
CK
VSS
TRIS Latch
RD TRISB
T10SCEN
TTL
input
buffer
RD PORTB
EN
Q1
Set RBIF
From other
RB<7:4> pins
EN
DS40044B-page 42
Preliminary
Q3
PIC16F627A/628A/648A
TABLE 5-3:
PORTB FUNCTIONS
Name
Output
Type
RB0/INT
RB0
TTL
CMOS
RB1/RX/DT
INT
RB1
ST
TTL
CMOS
RB2/TX/CK
RX
DT
RB2
TX
CK
RB3/CCP1
RB3
RB4/PGM
CCP1
RB4
RB5
RB6/T1OSO/T1CKI/
PGC
RB6
T1OSO
T1CKI
PGC
RB7
RB7/T1OSI/PGD
T1OSI
PGD
Legend: O = Output
= Not used
TTL = TTL Input
TABLE 5-4:
External interrupt.
Bidirectional I/O port. Can be software programmed for
internal weak pull-up.
ST
CMOS
USART Transmit Pin
ST
CMOS
Synchronous Clock I/O. Can be software programmed
for internal weak pull-up.
TTL
CMOS
Bidirectional I/O port. Can be software programmed for
internal weak pull-up.
ST
CMOS
Capture/Compare/PWM/I/O
TTL
CMOS
Bidirectional I/O port. Interrupt-on-pin change. Can be
software programmed for internal weak pull-up.
ST
XTAL
Timer1 Oscillator Output
ST
PGM
RB5
Description
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
All Other
Resets
06h, 106h
PORTB
RB7
RB6
RB5
RB4(2)
RB3
RB2
RB1
RB0
xxxx xxxx
uuuu uuuu
86h, 186h
TRISB
TRISB7
TRISB6
1111 1111
81h, 181h
OPTION
RBPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
1111 1111
1111 1111
Preliminary
DS40044B-page 43
PIC16F627A/628A/648A
5.3
5.3.1
EXAMPLE 5-2:
FIGURE 5-16:
READ-MODIFY-WRITE
INSTRUCTIONS ON AN
I/O PORT
5.3.2
PC
MOVWF PORTB
Write to PORTB
PC + 1
MOVF PORTB, W
Read to PORTB
PC + 2
NOP
PC + 3
NOP
Port pin
sampled here
TPD
Execute
MOVWF
PORTB
Note
1:
2:
Execute
MOVF
PORTB, W
Execute
NOP
DS40044B-page 44
Preliminary
PIC16F627A/628A/648A
6.0
TIMER0 MODULE
6.2
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
6.1
6.2.1
EXTERNAL CLOCK
SYNCHRONIZATION
Timer0 Interrupt
Preliminary
DS40044B-page 45
PIC16F627A/628A/648A
6.3
Timer0 Prescaler
FIGURE 6-1:
FOSC/4
T0CKI
PIN
T0SE
T0CS
0
1
TMR0 REG
PSA
WATCHDOG
TIMER
SYNC
2
CYCLES
WDT POSTSCALER/
TMR0 PRESCALER
8
PSA
8-TO-1MUX
PS0 - PS2
WDT
TIME OUT
PSA
Note:
DS40044B-page 46
Preliminary
PIC16F627A/628A/648A
6.3.1
SWITCHING PRESCALER
ASSIGNMENT
EXAMPLE 6-1:
BCF
CHANGING PRESCALER
(TIMER0WDT)
STATUS, RP0
CLRWDT
CLRF
TMR0
BSF
MOVLW
STATUS, RP0
'00101111b
MOVWF
OPTION_REG
CLRWDT
MOVLW
'00101xxxb
MOVWF
OPTION_REG
BCF
STATUS, RP0
TABLE 6-1:
Address
01h, 101h
;Skip if 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
EXAMPLE 6-2:
CHANGING PRESCALER
(WDTTIMER0)
CLRWDT
BSF
MOVLW
STATUS, RP0
b'xxxx0xxx'
MOVWF
BCF
OPTION_REG
STATUS, RP0
TMR0
0Bh, 8Bh,
INTCON
10Bh, 18Bh
81h, 181h
OPTION(2)
85h
TRISA
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
All Other
Resets
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
RBPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
TRISA7 TRISA6 TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 1111 1111 1111 1111
Preliminary
DS40044B-page 47
PIC16F627A/628A/648A
7.0
TIMER1 MODULE
As a timer
As a counter
REGISTER 7-1:
U-0
R/W-0
R/W-0
T1CKPS1 T1CKPS0
R/W-0
T1OSCEN
R/W-0
R/W-0
R/W-0
bit 7
bit 0
bit 7-6
Unimplemented: Read as 0
bit 5-4
bit 3
bit 2
bit 1
bit 0
DS40044B-page 48
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F627A/628A/648A
7.1
7.2.1
7.2
FIGURE 7-1:
Synchronized
TMR1
Clock Input
TMR1L
1
TMR1ON
T1SYNC
T1OSC
RB6/T1OSO/T1CKI
RB7/T1OSI
1
T1OSCEN
Enable
Oscillator(1)
FOSC/4
Internal
Clock
Prescaler
1, 2, 4, 8
Synchronize
det
0
2
Sleep Input
T1CKPS1:T1CKPS0
TMR1CS
Note 1: When the T1OSCEN bit is cleared, the inverter and feedback resistor are turned off. This eliminates power drain.
Preliminary
DS40044B-page 49
PIC16F627A/628A/648A
7.3
EXAMPLE 7-1:
Timer1 Operation in
Asynchronous Counter Mode
7.3.1
7.3.2
DS40044B-page 50
Preliminary
PIC16F627A/628A/648A
7.4
Timer1 Oscillator
7.5
TABLE 7-1:
C1
Timer1 must be configured for either timer or synchronized Counter mode to take advantage of this feature.
If Timer1 is running in Asynchronous Counter mode,
this Reset operation may not work.
Freq
C2
32.768 kHz
15 pF
15 pF
These values are for design guidance only.
Consult AN826 (DS00826) for further information
on Crystal/Capacitor Selection.
7.6
7.7
Timer1 Prescaler
TABLE 7-2:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
all other
Resets
0Bh, 8Bh,
10Bh, 18Bh
INTCON
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0000 000x
0000 000u
0Ch
PIR1
EEIF
CMIF
RCIF
TXIF
CCP1IF
TMR2IF
TMR1IF
0000 -000
0000 -000
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
CCP1IE
TMR2IE
TMR1IE
0000 -000
0000 -000
0Eh
TMR1L
Holding register for the Least Significant Byte of the 16-bit TMR1 register
xxxx xxxx
uuuu uuuu
0Fh
TMR1H
Holding register for the Most Significant Byte of the 16-bit TMR1 register
xxxx xxxx
uuuu uuuu
10h
T1CON
--00 0000
--uu uuuu
Legend:
T1CKPS1
T1CKPS0
T1OSCEN
T1SYNC
TMR1CS
TMR1ON
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by the Timer1 module.
Preliminary
DS40044B-page 51
PIC16F627A/628A/648A
8.0
TIMER2 MODULE
8.1
8.2
TMR2 Output
FIGURE 8-1:
Sets flag
bit TMR2IF
TMR2
output
Reset
TMR2 reg
EQ
Comparator
Prescaler
1:1, 1:4, 1:16
FOSC/4
2
T2CKPS<1:0>
PR2 reg
TOUTPS<3:0>
DS40044B-page 52
Preliminary
PIC16F627A/628A/648A
REGISTER 8-1:
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
TOUTPS0
R/W-0
R/W-0
bit 7
bit 0
bit 7
Unimplemented: Read as 0
bit 6-3
bit 2
bit 1-0
TABLE 8-1:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
Address Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
Value on
all other
POR
Resets
0Bh, 8Bh,
INTCON
10Bh, 18Bh
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0Ch
PIR1
EEIF
CMIF
RCIF
TXIF
CCP1IF
TMR2IF
TMR1IF
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
CCP1IE
TMR2IE
TMR1IE
11h
TMR2
T2CKPS1
12h
T2CON
92h
PR2
Legend:
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by the Timer2 module.
Preliminary
DS40044B-page 53
PIC16F627A/628A/648A
NOTES:
DS40044B-page 54
Preliminary
PIC16F627A/628A/648A
9.0
CAPTURE/COMPARE/PWM
(CCP) MODULE
TABLE 9-1:
CCP Mode
Timer Resource
Capture
Compare
PWM
Timer1
Timer1
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 PICmicro Mid-Range Reference Manual
(DS33023).
REGISTER 9-1:
U-0
R/W-0
R/W-0
R/W-0
CCP1X
CCP1Y
CCP1M3
R/W-0
R/W-0
R/W-0
bit 7
bit 0
bit 7-6
Unimplemented: Read as 0
bit 5-4
bit 3-0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS40044B-page 55
PIC16F627A/628A/648A
9.1
9.1.4
Capture Mode
9.1.1
In Capture mode, the RB3/CCP1 pin should be configured as an input by setting the TRISB<3> bit.
Note:
EXAMPLE 9-1:
CLRF
MOVLW
MOVWF
9.2
FIGURE 9-1:
CAPTURE MODE
OPERATION BLOCK
DIAGRAM
Prescaler
1, 4, 16
CCPR1H
and
edge detect
CCPR1L
Driven High
Driven Low
Remains Unchanged
FIGURE 9-2:
Qs
9.1.3
Compare Mode
TMR1L
CCP1CON<3:0>
9.1.2
SOFTWARE INTERRUPT
DS40044B-page 56
CCP1CON
;Turn CCP module off
NEW_CAPT_PS ;Load the W reg with
; the new prescaler
; mode value and CCP ON
CCP1CON
;Load CCP1CON with this
; value
Capture
Enable
TMR1H
CHANGING BETWEEN
CAPTURE PRESCALERS
RB3/CCP1
Pin
CCP PRESCALER
COMPARE MODE
OPERATION BLOCK
DIAGRAM
Set flag bit CCP1IF
(PIR1<2>)
CCPR1H CCPR1L
Q S Output
Logic
match
RB3/CCP1
R
Pin
TRISB<3>
Output Enable CCP1CON<3:0>
Mode Select
Preliminary
Note:
Comparator
TMR1H
TMR1L
PIC16F627A/628A/648A
9.2.1
9.2.3
9.2.2
9.2.4
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.
Address
TABLE 9-2:
Bit 7 Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
RBIF
Value on
POR
Value on
all other
Resets
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
0Ch
PIR1
EEIF CMIF
RCIF
TXIF
CCP1IF
TMR2IF
8Ch
PIE1
EEIE CMIE
RCIE
TXIE
CCP1IE
TMR2IE
86h, 186h
TRISB
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 TMR1register
10h
T1CON
15h
CCPR1L
16h
CCPR1H
17h
CCP1CON
Legend:
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by Capture and Timer1.
T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 --uu uuuu
CCP1X
CCP1Y
Preliminary
DS40044B-page 57
PIC16F627A/628A/648A
9.3
PWM Mode
FIGURE 9-4:
Period
Duty Cycle
TMR2 = PR2
FIGURE 9-3:
PWM OUTPUT
9.3.1
PWM PERIOD
CCP1CON<5:4>
CCPR1L
CCPR1H (Slave)
Comparator
Q
RB3/CCP1
TMR2
(1)
S
TRISB<3>
Comparator
Clear Timer,
CCP1 pin and
latch D.C.
PR2
Note
1:
TMR2 is cleared
The CCP1 pin is set (exception: if PWM duty
cycle = 0%, the CCP1 pin will not be set)
The PWM duty cycle is latched from CCPR1L into
CCPR1H
Note:
DS40044B-page 58
Preliminary
PIC16F627A/628A/648A
9.3.2
Fosc
log -------------------------------------------------------------
PWM
Fpwm TMR2 Prescaler
Resolution = --------------------------------------------------------------------------- bits
log(2)
Note:
9.3.3
1.
2.
3.
4.
5.
TABLE 9-3:
1.22 kHz 4.88 kHz 19.53 kHz 78.12 kHz 156.3 kHz 208.3 kHz
TABLE 9-4:
Address
16
0xFF
10
4
0xFF
10
1
0xFF
10
1
0x3F
8
1
0x1F
7
1
0x17
6.5
Name
0Bh, 8Bh,
INTCON
10Bh, 18Bh
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
all other
Resets
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0000 000x
0000 000u
0Ch
PIR1
EEIF
CMIF
RCIF
TXIF
CCP1IF
TMR2IF
TMR1IF
0000 -000
0000 -000
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
CCP1IE
TMR2IE
TMR1IE
0000 -000
0000 -000
86h, 186h
TRISB
1111 1111
1111 1111
11h
TMR2
0000 0000
0000 0000
92h
PR2
1111 1111
1111 1111
12h
T2CON
-000 0000
uuuu uuuu
15h
CCPR1L
xxxx xxxx
uuuu uuuu
16h
CCPR1H
17h
CCP1CON
Legend:
x = unknown, u = unchanged, - = unimplemented read as 0. Shaded cells are not used by PWM and Timer2.
CCP1X
CCP1Y
CCP1M3
Preliminary
CCP1M2
CCP1M1
CCP1M0
xxxx xxxx
uuuu uuuu
--00 0000
--00 0000
DS40044B-page 59
PIC16F627A/628A/648A
NOTES:
DS40044B-page 60
Preliminary
PIC16F627A/628A/648A
10.0
COMPARATOR MODULE
REGISTER 10-1:
R-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
R/W-0
C2OUT
C1OUT
C2INV
C1INV
CIS
CM2
CM1
CM0
bit 7
bit 7
bit 0
bit 6
bit 5
bit 4
bit 3
bit 2-0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS40044B-page 61
PIC16F627A/628A/648A
10.1
Comparator Configuration
FIGURE 10-1:
VIN-
RA3/AN3/CMP1
VIN+
RA1/AN1
VIN-
RA2/AN2/VREF
VIN+
C1
RA0/AN0
VIN-
RA3/AN3/CMP1
VIN+
VIN-
VIN+
RA1/AN1
C2
RA2/AN2/VREF
C1
C2
VSS
Four Inputs Multiplexed to Two Comparators
CM2:CM0 = 010
RA0/AN0
VIN+
RA3/AN3/CMP1
RA0/AN0
VIN-
RA1/AN1
VIN-
RA2/AN2/VREF
VIN+
C1
C2
C1VOUT
A
CIS = 0
CIS = 1
RA3/AN3/CMP1 A
RA1/AN1
RA2/AN2/VREF
CIS = 0
CIS = 1
C2VOUT
VINVIN+
C1
C1VOUT
C2
C2VOUT
VINVIN+
From VREF
Module
Two Common Reference Comparators with Outputs
CM2:CM0 = 110
A
D
VIN+
RA1/AN1
VIN-
RA2/AN2/VREF
VIN+
RA3/AN3/CMP1
VIN-
RA3/AN3/CMP1
VIN+
RA1/AN1
VIN-
RA2/AN2/VREF
VIN+
RA0/AN0
VINC1
C2
C1VOUT
C2VOUT
C1
C1VOUT
C2
C2VOUT
RA3/AN3/CMP1 D
VINVIN+
RA0/AN0
C1
RA3/AN3/CMP1 A
CIS = 0
CIS = 1
VINVIN+
C1
C1VOUT
C2
C2VOUT
VSS
RA1/AN1
RA2/AN2/VREF
VIN-
VIN+
C2
DS40044B-page 62
RA1/AN1
VIN-
RA2/AN2/VREF
VIN+
C2VOUT
D = Digital Input.
Preliminary
PIC16F627A/628A/648A
The code example in Example 10-1 depicts the steps
required to configure the Comparator module. RA3 and
RA4 are configured as digital output. RA0 and RA1 are
configured as the V- inputs and RA2 as the V+ input to
both comparators.
EXAMPLE 10-1:
FLAG_REG
CLRF
CLRF
MOVF
ANDLW
IORWF
MOVLW
MOVWF
BSF
MOVLW
MOVWF
BCF
CALL
MOVF
BCF
BSF
BSF
BCF
BSF
BSF
10.2
FIGURE 10-2:
SINGLE COMPARATOR
Vin+
Vin-
Result
INITIALIZING
COMPARATOR MODULE
EQU
0X20
FLAG_REG
PORTA
CMCON, W
0xC0
FLAG_REG,F
0x03
CMCON
STATUS,RP0
0x07
TRISA
Comparator Operation
VINVIN+
Result
10.3.1
10.3.2
10.3
10.4
Comparator Reference
Preliminary
DS40044B-page 63
PIC16F627A/628A/648A
10.5
Comparator Outputs
FIGURE 10-3:
D
Q3
EN
RD CMCON
EN
CL
Q1
DS40044B-page 64
Preliminary
PIC16F627A/628A/648A
10.6
Comparator Interrupts
10.7
10.8
Effects of a Reset
10.9
Preliminary
DS40044B-page 65
PIC16F627A/628A/648A
FIGURE 10-4:
RS < 10 K
RIC
AIN
CPIN
5 pF
VA
VT = 0.6V
ILEAKAGE
500 nA
VSS
Legend
TABLE 10-1:
Address
1Fh
CPIN
VT
ILEAKAGE
RIC
RS
VA
= Input Capacitance
= Threshold Voltage
= Leakage Current At The Pin
= Interconnect Resistance
= Source Impedance
= Analog Voltage
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
CMCON
Value on
POR
Value on
All Other
Resets
C2OUT
C1OUT
C2INV
C1NV
CIS
CM2
CM1
CM0
0Bh, 8Bh,
INTCON
10Bh, 18Bh
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0Ch
EEIF
CMIF
RCIF
TXIF
EEIE
CMIE
RCIE
TXIE
PIR1
8Ch
PIE1
85h
TRISA
Legend:
TRISA2
TRISA1
TRISA0
DS40044B-page 66
Preliminary
PIC16F627A/628A/648A
11.0
VOLTAGE REFERENCE
MODULE
11.1
VR <3:0>
VREF = ---------------------- VDD
24
if VRR = 0:
1
VR <3:0>
VREF = VDD --- + ---------------------- VDD
4
32
The setting time of the Voltage Reference must be
considered when changing the VREF output
(Table 17-3). Example 11-1 demonstrates how Voltage
Reference is configured for an output voltage of 1.25V
with VDD = 5.0V.
REGISTER 11-1:
R/W-0
R/W-0
U-0
R/W-0
R/W-0
R/W-0
R/W-0
VREN
VROE
VRR
VR3
VR2
VR1
VR0
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
Unimplemented: Read as 0
bit 3-0
FIGURE 11-1:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
VREN
16 Stages
8R
8R
VSS
VREF
Note:
VRR
VSS
VR3
(From VRCON<3:0>)
VR0
Preliminary
DS40044B-page 67
PIC16F627A/628A/648A
EXAMPLE 11-1:
MOVLW
MOVWF
BSF
MOVLW
MOVWF
MOVLW
MOVWF
BCF
CALL
11.2
VOLTAGE REFERENCE
CONFIGURATION
0x02
CMCON
STATUS,RP0
0x07
TRISA
0xA6
VRCON
STATUS,RP0
DELAY10
11.4
;4 Inputs Muxed
;to 2 comps.
;go to Bank 1
;RA3-RA0 are
;outputs
;enable VREF
;low range set VR<3:0>=6
;go to Bank 0
;10s delay
11.5
FIGURE 11-2:
Connection Considerations
The
Voltage
Reference
Module
operates
independently of the comparator module. The output of
the reference generator may be connected to the RA2
pin if the TRISA<2> bit is set and the VROE bit,
VRCON<6>, is set. Enabling the Voltage Reference
output onto the RA2 pin with an input signal present will
increase current consumption. Connecting RA2 as a
digital output with VREF enabled will also increase
current consumption.
11.3
Effects of a Reset
R(1)
VREF
Opamp
RA2
Module
VREF Output
Voltage
Reference
Output
Impedance
Note 1: R is dependent upon the Voltage Reference Configuration VRCON<3:0> and VRCON<5>.
TABLE 11-1:
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value On
POR
Value On
All Other
Resets
9Fh
VRCON
VREN
VROE
VRR
VR3
VR2
VR1
VR0
000- 0000
000- 0000
1Fh
CMCON
C2OUT C1OUT
C2INV
C1INV
CIS
CM2
CM1
CM0
0000 0000
0000 0000
85h
TRISA
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
1111 1111
1111 1111
Address
DS40044B-page 68
Preliminary
PIC16F627A/628A/648A
12.0
UNIVERSAL SYNCHRONOUS
ASYNCHRONOUS RECEIVER
TRANSMITTER (USART)
MODULE
REGISTER 12-1:
R/W-0
TX9
R/W-0
TXEN
R/W-0
U-0
R/W-0
R-1
R/W-0
SYNC
BRGH
TRMT
TX9D
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
Unimplemented: Read as 0
bit 2
bit 1
bit 0
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS40044B-page 69
PIC16F627A/628A/648A
REGISTER 12-2:
R/W-0
R/W-0
R/W-0
R/W-0
R-0
R-0
R-x
SPEN
RX9
SREN
CREN
ADEN
FERR
OERR
RX9D
bit 7
bit 0
bit 7
bit 6
bit 5
bit 4
bit 3
bit 2
bit 1
bit 0
DS40044B-page 70
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F627A/628A/648A
12.1
EXAMPLE 12-1:
CALCULATING BAUD
RATE ERROR
Fosc
Desired Baud Rate = ----------------------64 ( x + 1 )
16000000
Calculated Baud Rate = -------------------------- = 9615
64 ( 25 + 1 )
16000000
9600 = -----------------------64 ( x + 1 )
x = 25.042
FOSC = 16 MHz
9615 9600
= ------------------------------ = 0.16%
9600
TABLE 12-1:
SYNC
TABLE 12-2:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on all
other
Resets
98h
TXSTA
CSRC
TX9
TXEN
SYNC
BRGH
TRMT
TX9D
0000 -010
0000 -010
18h
RCSTA
SPEN
RX9
SREN
CREN
ADEN
FERR
OERR
RX9D
0000 000x
0000 000x
99h
SPBRG
0000 0000
0000 0000
Preliminary
DS40044B-page 71
PIC16F627A/628A/648A
TABLE 12-3:
BAUD
RATE (K)
0.3
1.2
2.4
9.6
19.2
76.8
96
300
500
HIGH
LOW
BAUD
RATE (K)
FOSC = 20 MHz
KBAUD
ERROR
NA
NA
NA
NA
19.53
76.92
96.15
294.1
500
5000
19.53
+1.73%
+0.16%
+0.16%
-1.96
0
SPBRG 16 MHz
value
KBAUD
(decimal)
255
64
51
16
9
0
255
NA
NA
NA
NA
19.23
76.92
95.24
307.69
500
4000
15.625
ERROR
+0.16%
+0.16%
-0.79%
+2.56%
0
207
51
41
12
7
0
255
NA
NA
NA
9.766
19.23
75.76
96.15
312.5
500
2500
9.766
SPBRG 4 MHz
value
KBAUD
(decimal)
ERROR
SPBRG
value
(decimal)
+1.73%
+0.16%
-1.36%
+0.16%
+4.17%
0
255
129
32
25
7
4
0
255
ERROR
SPBRG
value
(decimal)
KBAUD
ERROR
0.3
1.2
2.4
9.6
19.2
76.8
96
300
NA
NA
NA
9.622
19.24
77.82
94.20
298.3
+0.23%
+0.23%
+1.32
-1.88
-0.57
185
92
22
18
5
NA
NA
NA
9.6
19.2
79.2
97.48
316.8
0
0
+3.13%
+1.54%
5.60%
131
65
15
12
3
NA
NA
NA
9.615
19.231
75.923
1000
NA
500
NA
NA
NA
HIGH
LOW
1789.8
6.991
0
255
1267
4.950
0
255
100
3.906
0
255
ERROR
SPBRG
value
(decimal)
+1.14%
-2.48%
26
6
BAUD
RATE (K)
SPBRG 1 MHz
value
KBAUD
(decimal)
ERROR
SPBRG 10 MHz
value
KBAUD
(decimal)
KBAUD
ERROR
0.3
1.2
2.4
NA
NA
NA
NA
1.202
2.404
+0.16%
+0.16%
207
103
0.303
1.170
NA
9.6
19.2
76.8
9.622
19.04
74.57
+0.23%
-0.83%
-2.90%
92
46
11
9.615
19.24
83.34
+0.16%
+0.16%
+8.51%
25
12
2
NA
NA
NA
96
99.43
+3.57%
NA
298.3
NA
0.57%
NA
NA
NA
300
500
NA
HIGH
LOW
894.9
3.496
0
255
250
0.9766
0
255
8.192
0.032
DS40044B-page 72
ERROR
+0.16%
+0.16%
+0.16%
+4.17%
Preliminary
103
51
12
9
0
255
PIC16F627A/628A/648A
TABLE 12-4:
BAUD
RATE (K)
0.3
1.2
2.4
9.6
19.2
76.8
96
300
500
HIGH
LOW
BAUD
RATE (K)
0.3
1.2
2.4
9.6
19.2
76.8
96
300
500
HIGH
LOW
BAUD
RATE (K)
0.3
1.2
2.4
9.6
19.2
76.8
96
300
500
HIGH
LOW
FOSC = 20 MHz
KBAUD
ERROR
NA
1.221
2.404
9.469
19.53
78.13
104.2
312.5
NA
312.5
1.221
+1.73%
+0.16%
-1.36%
+1.73%
+1.73%
+8.51%
+4.17%
ERROR
NA
1.203
2.380
9.322
18.64
NA
NA
NA
NA
111.9
0.437
+0.23%
-0.83%
-2.90%
-2.90%
ERROR
0.301
1.190
2.432
9.322
18.64
NA
NA
NA
NA
55.93
0.2185
+0.23%
-0.83%
+1.32%
-2.90%
-2.90%
SPBRG 16 MHz
value
KBAUD
(decimal)
255
129
32
15
3
2
0
0
255
NA
1.202
2.404
9.615
19.23
83.33
NA
NA
NA
250
0.977
92
46
11
5
0
255
0.31
1.2
2.4
9.9
19.8
79.2
NA
NA
NA
79.2
0.3094
SPBRG 1 MHz
value
KBAUD
(decimal)
185
46
22
5
2
0
255
0.300
1.202
2.232
NA
NA
NA
NA
NA
NA
15.63
0.0610
ERROR
+0.16%
+0.16%
+0.16%
+0.16%
+8.51%
ERROR
+3.13%
0
0
+3.13%
+3.13%
+3.13%
ERROR
+0.16%
+0.16%
-6.99%
Preliminary
SPBRG 10 MHz
value
KBAUD
(decimal)
207
103
25
12
2
0
255
NA
1.202
2.404
9.766
19.53
78.13
NA
NA
NA
156.3
0.6104
SPBRG 4 MHz
value
KBAUD
(decimal)
255
65
32
7
3
0
0
255
0.3005
1.202
2.404
NA
NA
NA
NA
NA
NA
62.500
3.906
0
255
0.256
NA
NA
NA
NA
NA
NA
NA
NA
0.512
0.0020
ERROR
SPBRG
value
(decimal)
+0.16%
+0.16%
+1.73%
+1.73V
+1.73%
129
64
15
7
1
0
255
ERROR
SPBRG
value
(decimal)
-0.17%
+1.67%
+1.67%
207
51
25
0
255
ERROR
SPBRG
value
(decimal)
-14.67%
0
255
DS40044B-page 73
PIC16F627A/628A/648A
TABLE 12-5:
BAUD
RATE (K)
9600
19200
38400
57600
115200
250000
625000
1250000
BAUD
RATE (K)
9600
19200
38400
57600
115200
250000
625000
1250000
BAUD
RATE (K)
9600
19200
38400
57600
115200
250000
625000
1250000
FOSC = 20 MHz
KBAUD
ERROR
9.615
19.230
37.878
56.818
113.636
250
625
1250
+0.16%
+0.16%
-1.36%
-1.36%
-1.36%
0
0
0
ERROR
9.520
19.454
37.286
55.930
111.860
NA
NA
NA
-0.83%
+1.32%
-2.90%
-2.90%
-2.90%
ERROR
9725.543
18640.63
37281.25
55921.88
111243.8
223687.5
NA
NA
1.308%
-2.913%
-2.913%
-2.913%
-2.913%
-10.525%
DS40044B-page 74
SPBRG 16 MHz
value
KBAUD
(decimal)
129
64
32
21
10
4
1
0
9.615
19.230
38.461
58.823
111.111
250
NA
NA
9598.485
18632.35
39593.75
52791.67
105583.3
316750
NA
NA
SPBRG 1 MHz
value
KBAUD
(decimal)
22
11
5
3
1
0
8.928
20833.3
31250
62500
NA
NA
NA
NA
ERROR
+0.16%
+0.16%
+0.16%
+2.12%
-3.55%
0
ERROR
0.016%
-2.956%
3.109%
-8.348%
-8.348%
26.700%
ERROR
-6.994%
8.507%
-18.620%
+8.507
Preliminary
SPBRG 10 MHz
value
KBAUD
(decimal)
103
51
25
16
8
3
9.615
18.939
39.062
56.818
125
NA
625
NA
SPBRG 4 MHz
value
KBAUD
(decimal)
32
16
7
5
2
0
9615.385
19230.77
35714.29
62500
125000
250000
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
ERROR
SPBRG
value
(decimal)
+0.16%
-1.36%
+1.7%
-1.36%
+8.51%
64
32
15
10
4
ERROR
SPBRG
value
(decimal)
0.160%
0.160%
-6.994%
8.507%
8.507%
0.000%
25
12
6
3
1
0
ERROR
SPBRG
value
(decimal)
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
PIC16F627A/628A/648A
The data on the RB1/RX/DT pin is sampled three times
by a majority detect circuit to determine if a high or a
low level is present at the RX pin. If bit BRGH
(TXSTA<2>) is clear (i.e., at the low baud rates), the
sampling is done on the seventh, eighth and ninth falling edges of a x16 clock (Figure 12-3). If bit BRGH is
set (i.e., at the high baud rates), the sampling is done
on the 3 clock edges preceding the second rising edge
after the first falling edge of a x4 clock (Figure 12-4 and
Figure 12-5).
FIGURE 12-1:
RX
(RB1/RX/DT pin)
Start bit
bit 0
Baud CLK for all but Start bit
Baud CLK
x16 CLK
1
10
11
12
13
14
15
16
Samples
FIGURE 12-2:
bit 0
Start Bit
bit 1
Baud CLK
First falling edge after RX pin goes low
Second rising edge
x4 CLK
1
Q2, Q4 CLK
Samples
FIGURE 12-3:
Samples
Samples
RX pin
Start Bit
bit 0
Baud CLK for all but Start bit
Baud CLK
Q2, Q4 CLK
Samples
Preliminary
DS40044B-page 75
PIC16F627A/628A/648A
FIGURE 12-4:
RX
(RB1/RX/DT pin)
Start bit
bit 0
Baud CLK for all but Start bit
Baud CLK
x16 CLK
1
10
11
12
13
14
15
16
Samples
12.2
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.2.1
USART ASYNCHRONOUS
TRANSMITTER
DS40044B-page 76
Preliminary
PIC16F627A/628A/648A
FIGURE 12-5:
TXREG register
TXIE
8
MSb
(8)
LSb
0
Pin Buffer
and Control
TSR register
RB2/TX/CK pin
Interrupt
TXEN
SPEN
SPBRG
TX9
TX9D
2.
3.
4.
5.
6.
7.
8.
FIGURE 12-6:
ASYNCHRONOUS TRANSMISSION
Write to TXREG
BRG output
(shift clock)
Word 1
RB2/TX/CK (pin)
Start Bit
Bit 1
Bit 7/8
Stop Bit
WORD 1
TXIF bit
(Transmit buffer
reg. empty flag)
TRMT bit
(Transmit shift
reg. empty flag)
Bit 0
WORD 1
Transmit Shift Reg
Preliminary
DS40044B-page 77
PIC16F627A/628A/648A
FIGURE 12-7:
Write to TXREG
Word 1
BRG output
(shift clock)
RB2/TX/CK (pin)
Start Bit
TXIF bit
(interrupt reg. flag)
TRMT bit
(Transmit shift
reg. empty flag)
Note:
TABLE 12-6:
Address
Name
Word 2
Bit 0
Bit 1
WORD 1
Bit 7/8
Start Bit
Stop Bit
Bit 0
WORD 2
WORD 1
Transmit Shift Reg.
WORD 2
Transmit Shift Reg.
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
all other
Resets
0Ch
PIR1
EEIF
CMIF
RCIF
TXIF
CCP1IF
TMR2IF
TMR1IF
0000 -000
0000 -000
18h
RCSTA
SPEN
RX9
SREN
CREN
ADEN
FERR
OERR
RX9D
0000 000x
0000 000x
19h
EEIE
CMIE
RCIE
TXIE
CCP1IE
TMR2IE
TMR1IE
98h
TXSTA
CSRC
TX9
TXEN
SYNC
BRGH
TRMT
TX9D
99h
8Ch
0000 0000
0000 0000
0000 -000
0000 -000
0000 -010
0000 -010
0000 0000
0000 0000
DS40044B-page 78
Preliminary
PIC16F627A/628A/648A
12.2.2
USART ASYNCHRONOUS
RECEIVER
FIGURE 12-8:
FERR
OERR
CREN
SPBRG
64
or
16
MSb
Stop (8)
RSR register
LSb
0 Start
RB1/RX/DT
Pin Buffer
and Control
Data
Recovery
RX9
8
SPEN
RX9
ADEN
Enable
Load of
RX9
ADEN
RSR<8>
Receive
Buffer
8
RX9D
RCREG register
RX9D
RCREG register
FIFO
8
Interrupt
RCIF
Data Bus
RCIE
Preliminary
DS40044B-page 79
PIC16F627A/628A/648A
FIGURE 12-9:
RB1/RX/DT (PIN)
START
BIT BIT0
BIT1
BIT8 STOP
BIT
START
BIT BIT0
BIT8
STOP
BIT
READ RCV
BUFFER REG
RCREG
WORD 1
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 Buffer) because ADEN = 1 and Bit 8 = 0.
FIGURE 12-10:
RB1/RX/DT (PIN)
RCV SHIFT
REG
RCV BUFFER REG
BIT1
BIT8 STOP
BIT
START
BIT BIT0
READ RCV
BUFFER REG
RCREG
BIT8
STOP
BIT
RCIF
(INTERRUPT FLAG)
1
ADEN = 1
(ADDRESS MATCH
ENABLE)
Note:
This timing diagram shows an address byte followed by an data byte. The data byte is not read into the RCREG
(receive buffer) because ADEN was not updated (still = 1) and Bit 8 = 0.
FIGURE 12-11:
RB1/RX/DT (PIN)
RCV SHIFT
REG
RCV BUFFER REG
READ RCV
BUFFER REG
RCREG
BIT1
BIT8 STOP
BIT
START
BIT BIT0
BIT8
STOP
BIT
WORD 2
RCREG
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 Buffer) because ADEN was updated after an address match, and was cleared to a 0, so the contents
of the Receive Shift Register (RSR) are read into the Receive Buffer regardless of the value of Bit 8.
DS40044B-page 80
Preliminary
PIC16F627A/628A/648A
Follow these steps when setting up an Asynchronous
Reception:
1.
TABLE 12-7:
Address
Name
Bit 6
Bit 5
Bit 4
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
all other
Resets
BRGH
TRMT
TX9D 0000 -010 0000 -010
99h
SPBRG Baud Rate Generator Register
0000 0000 0000 0000
Legend: x = unknown, - = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Reception.
0Ch
18h
1Ah
EEIF
CMIF RCIF
TXIF
PIR1
RCSTA
SPEN
RX9 SREN CREN
RCREG USART Receive data register
Bit 3
ADEN
Preliminary
DS40044B-page 81
PIC16F627A/628A/648A
12.3
12.3.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.
Reception is
(RCSTA<4>).
12.3.1.1
Name
setting
bit
CREN
1.
Address
by
TABLE 12-8:
enabled
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on
all other
Resets
EEIF CMIF
RCIF
TXIF
BRGH
TRMT
TX9D 0000 -010 0000 -010
99h
SPBRG
Baud Rate Generator Register
0000 0000 0000 0000
Legend: x = unknown, - = unimplemented locations read as 0. Shaded cells are not used for Asynchronous Reception.
0Ch
18h
1Ah
8Ch
98h
DS40044B-page 82
Preliminary
PIC16F627A/628A/648A
12.4
12.4.1
2.
3.
4.
5.
6.
7.
8.
Preliminary
DS40044B-page 83
PIC16F627A/628A/648A
TABLE 12-9:
Address
0Ch
18h
19h
8Ch
98h
Name
Bit 7
Bit 6
Bit 5
Bit 4
PIR1
EEIF
CMIF RCIF TXIF
RCSTA SPEN
RX9 SREN CREN
TXREG USART Transmit data register
PIE1
EEIE
CMIE RCIE TXIE
TXSTA CSRC
TX9 TXEN SYNC
Bit 3
ADEN
Bit 2
Bit 1
Bit 0
Value on
POR
-000
000x
0000
-000
-010
Value on all
other Resets
0000
0000
0000
0000
0000
-000
000x
0000
-000
-010
99h
SPBRG Baud Rate Generator Register
0000 0000 0000 0000
Legend: x = unknown, - = unimplemented, read as 0. Shaded cells are not used for Synchronous Master Transmission.
FIGURE 12-12:
SYNCHRONOUS TRANSMISSION
Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4Q1Q2Q3Q4
BIT 0
RB1/RX/DT PIN
BIT 1
BIT 2
BIT 7
WORD 1
BIT 0
BIT 1
WORD 2
BIT 7
RB2/TX/CK PIN
WRITE TO
TXREG REG
WRITE WORD1
TXIF BIT
(INTERRUPT FLAG)
WRITE WORD2
TRMT
TRMT
BIT
1
TXEN BIT
Note:
FIGURE 12-13:
RB1/RX/DT PIN
BIT0
BIT1
BIT2
BIT6
BIT7
RB2/TX/CK PIN
WRITE TO
TXREG REG
TXIF BIT
TRMT BIT
TXEN BIT
DS40044B-page 84
Preliminary
PIC16F627A/628A/648A
12.4.2
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on:
POR
Value on all
other Resets
EEIF
CMIF RCIF TXIF
BRGH
TRMT
TX9D 0000 -010 0000 -010
99h
SPBRG Baud Rate Generator Register
0000 0000 0000 0000
Legend: x = unknown, - = unimplemented read as 0. Shaded cells are not used for Synchronous Master Reception.
0Ch
18h
1Ah
8Ch
Preliminary
DS40044B-page 85
PIC16F627A/628A/648A
FIGURE 12-14:
RB1/RX/DT PIN
BIT0
BIT1
BIT2
BIT3
BIT4
BIT5
BIT6
BIT7
RB2/TX/CK PIN
WRITE TO
BIT SREN
SREN BIT
CREN BIT 0
RCIF BIT
(INTERRUPT)
READ
RXREG
Note:
12.5
Timing diagram demonstrates Sync Master Mode with bit SREN = 1 and bit BRG = 0.
12.5.1
e)
DS40044B-page 86
2.
3.
4.
5.
6.
7.
8.
Preliminary
PIC16F627A/628A/648A
12.5.2
2.
3.
4.
5.
6.
7.
8.
9.
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on all
other Resets
EEIF
CMIF RCIF TXIF
BRGH
TRMT
TX9D 0000 -010 0000 -010
99h
SPBRG Baud Rate Generator Register
0000 0000 0000 0000
Legend: x = unknown, - = unimplemented read as 0. Shaded cells are not used for Synchronous Slave Transmission.
0Ch
18h
19h
8Ch
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR
Value on all
other Resets
EEIF
CMIF RCIF TXIF
BRGH
TRMT
TX9D 0000 -010 0000 -010
99h
SPBRG Baud Rate Generator Register
0000 0000 0000 0000
Legend: x = unknown, - = unimplemented read as 0. Shaded cells are not used for Synchronous Slave Reception.
Preliminary
DS40044B-page 87
PIC16F627A/628A/648A
NOTES:
DS40044B-page 88
Preliminary
PIC16F627A/628A/648A
13.0
EECON1
EECON2 (Not a physically implemented register)
EEDATA
EEADR
REGISTER 13-1:
R/W-x
R/W-x
R/W-x
R/W-x
EEDAT7
EEDAT6
EEDAT5
EEDAT4
EEDAT3
R/W-x
R/W-x
EEDAT2 EEDAT1
R/W-x
EEDAT0
bit 7
bit 7-0
bit 0
EEDATn: Byte value to write to or read from Data EEPROM memory location.
Legend:
REGISTER 13-2:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
x = Bit is unknown
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
R/W-x
EADR7
EADR6
EADR5
EADR4
EADR3
EADR2
EADR1
EADR0
bit 7
bit 0
bit 7
bit 6-0
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
DS40044B-page 89
PIC16F627A/628A/648A
13.1
EEADR
13.2
REGISTER 13-3:
U-0
U-0
U-0
R/W-x
R/W-0
R/S-0
R/S-0
WRERR
WREN
WR
RD
bit 7
bit 0
bit 7-4
Unimplemented: Read as 0
bit 3
bit 2
bit 1
bit 0
DS40044B-page 90
R = Readable bit
W = Writable bit
-n = Value at POR
1 = Bit is set
0 = Bit is cleared
Preliminary
x = Bit is unknown
PIC16F627A/628A/648A
13.3
EXAMPLE 13-1:
BSF
MOVLW
MOVWF
BSF
MOVF
BCF
STATUS, RP0
CONFIG_ADDR
EEADR
EECON1, RD
EEDATA, W
STATUS, RP0
;Bank 1
;
;Address to read
;EE Read
;W = EEDATA
;Bank 0
13.4
Required
Sequence
BSF
BSF
BCF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
WRITE VERIFY
BSF
MOVF
BSF
STATUS, RP0
EECON1, WREN
INTCON, GIE
55h
EECON2
AAh
EECON2
EECON1,WR
13.5
EXAMPLE 13-3:
EXAMPLE 13-2:
;Bank 1
;Enable write
;Disable INTs.
;
;Write 55h
;
;Write AAh
;Set WR bit
;begin write
;Enable INTs.
WRITE VERIFY
;
;Is the value written (in W reg) and
;read (in EEDATA) the same?
;
SUBWF EEDATA, W ;
BTFSS STATUS, Z ;Is difference 0?
GOTO WRITE_ERR ;NO, Write error
:
;YES, Good write
:
;Continue program
13.6
PROTECTION AGAINST
SPURIOUS WRITE
Preliminary
DS40044B-page 91
PIC16F627A/628A/648A
13.7
The data EEPROM is a high endurance, byte addressable array that has been optimized for the storage of
frequently changing information (e.g., program
variables or other data that are updated often).
Frequently changing values will typically be updated
more often than specification D124. If this is not the
case, an array refresh must be performed.
EXAMPLE 13-4:
BANKSEL
CLRF
BCF
BSF
Loop
BSF
MOVLW
MOVWF
MOVLW
MOVWF
BSF
BTFSC
GOTO
Note:
;select Bank1
;start at address 0
;disable interrupts
;enable EE writes
EECON1, RD
0x55
EECON2
0xAA
EECON2
EECON1, WR
EECON1, WR
$ - 1
#IFDEF __16F648A
INCFSZ
#ELSE
INCF
BTFSS
#ENDIF
EEADR, f
EEADR, 7
GOTO
Loop
BCF
BSF
EECON1, WREN
INTCON, GIE
;disable EE writes
;enable interrupts (optional)
13.8
TABLE 13-1:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
9Ah
9Bh
9Ch
9Dh
Legend:
Note
Bit 1
Bit 0
EEDATA
EEPROM data register
EEADR
EEPROM address register
EECON1
WRERR WREN
WR
RD
EECON2(1) EEPROM control register 2
x = unknown, u = unchanged, - = unimplemented read as 0, q = value depends upon condition.
Shaded cells are not used by data EEPROM.
1: EECON2 is not a physical register.
DS40044B-page 92
Preliminary
Value on
Power-on
Reset
Value on all
other
Resets
xxxx xxxx
xxxx xxxx
---- x000
---- ----
uuuu uuuu
uuuu uuuu
---- q000
---- ----
PIC16F627A/628A/648A
14.0
OSC selection
Reset
Power-on Reset (POR)
Power-up Timer (PWRT)
Oscillator Start-Up Timer (OST)
Brown-out Reset (BOR)
Interrupts
Watchdog Timer (WDT)
Sleep
Code protection
ID Locations
In-Circuit Serial Programming (ICSP)
14.1
Configuration Bits
Preliminary
DS40044B-page 93
PIC16F627A/628A/648A
REGISTER 14-1:
CP
CONFIGURATION WORD
CPD
LVP
BOREN
MCLRE
FOSC2
PWRTE
WDTE
F0SC1
bit 13
bit 0
bit 13:
bit 12-9:
Unimplemented: Read as 0
bit 8:
bit 7:
bit 6:
bit 5:
bit 3:
bit 2:
bit 4, 1-0:
Note
F0SC0
1:
2:
3:
4:
Enabling Brown-out Reset does not automatically enable the Power-up Timer (PWRT) the way it did in the PIC16F627/628.
The code protection scheme has changed from the code protection scheme used in the PIC16F627/628. The entire Flash program memory needs to be bulk erased to set the CP bit, turning the code protection off. See 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 Programming Specification
DS41196 for details.
When MCLR is asserted in INTOSC mode, the internal clock oscillator is disabled.
Legend:
R = Readable bit
W = Writable bit
-n = Value at POR
1 = bit is set
0 = bit is cleared
DS40044B-page 94
Preliminary
x = bit is unknown
PIC16F627A/628A/648A
14.2
TABLE 14-1:
Oscillator Configurations
14.2.1
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
Freq
OSC1(C1)
OSC2(C2)
XT
455 kHz
2.0 MHz
4.0 MHz
22 - 100 pF
15 - 68 pF
15 - 68 pF
22 - 100 pF
15 - 68 pF
15 - 68 pF
HS
8.0 MHz
16.0 MHz
10 - 68 pF
10 - 22 pF
10 - 68 pF
10 - 22 pF
CRYSTAL OPERATION
(OR CERAMIC
RESONATOR) (HS, XT OR
LP OSC
CONFIGURATION)
XTAL
RF
Sleep
OSC2
RS(1)
C2
Note
1:
2:
FOSC
PIC16F627A/628A/648A
A series resistor may be required for AT strip cut
crystals.
See Table 14-1 and Table 14-2 for recommended
values of C1 and C2.
Mode
Freq
OSC1(C1)
OSC2(C2)
LP
32 kHz
200 kHz
15 - 30 pF
0 - 15 pF
15 - 30 pF
0 - 15 pF
XT
100 kHz
2 MHz
4 MHz
68 - 150 pF
15 - 30 pF
15 - 30 pF
150 - 200 pF
15 - 30 pF
15 - 30 pF
HS
8 MHz
10 MHz
20 MHz
15 - 30 pF
15 - 30 pF
15 - 30 pF
15 - 30 pF
15 - 30 pF
15 - 30 pF
Note:
14.2.3
OSC1
C1
TABLE 14-2:
FIGURE 14-1:
Mode
Note:
Preliminary
DS40044B-page 95
PIC16F627A/628A/648A
FIGURE 14-2:
EXTERNAL PARALLEL
RESONANT CRYSTAL
OSCILLATOR CIRCUIT
FIGURE 14-4:
+5V
TO OTHER
DEVICES
Clock From
ext. system
10K
4.7K
74AS04
PIC16F627A/628A/648A
10K
14.2.6
C2
EXTERNAL SERIES
RESONANT CRYSTAL
OSCILLATOR CIRCUIT
330 K
74AS04
RC OSCILLATOR
For applications where precise timing is not a requirement, the RC oscillator option is available. The
operation and functionality of the RC oscillator is
dependent upon a number of variables. The RC
oscillator frequency is a function of:
10K
330 K
RA6/OSC2/CLKOUT
RA6
XTAL
FIGURE 14-3:
PIC16F627A/628A/648A
CLKIN
74AS04
C1
RA7/OSC1/CLKIN
74AS04
TO OTHER
DEVICES
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:
RC OSCILLATOR MODE
74AS04
CLKIN
VDD
PIC16F627A/628A/648A
0.1 PF
PIC16F627A/
628A/648A
REXT
RA7/OSC1/
CLKIN
XTAL
Internal
Clock
CEXT
14.2.4
VSS
FOSC/4
14.2.5
EXTERNAL CLOCK IN
DS40044B-page 96
RA6/OSC2/CLKOUT
14.2.7
CLKOUT
Preliminary
PIC16F627A/628A/648A
14.2.8
14.3
Reset
FIGURE 14-6:
MCLR/
VPP Pin
Sleep
WDT
Module
VDD rise
detect
WDT
Time out
Reset
Power-on Reset
VDD
Brown-out
detect 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:
Preliminary
DS40044B-page 97
PIC16F627A/628A/648A
14.4
14.4.1
14.4.3
14.4.4
FIGURE 14-7:
14.4.2
VBOR
TBOR
INTERNAL
RESET
72 ms
VDD
VBOR
INTERNAL
RESET
<72 ms
72 ms
VDD
VBOR
INTERNAL
RESET
72 ms
Note:
DS40044B-page 98
Preliminary
PIC16F627A/628A/648A
14.4.5
14.4.6
Since the time outs occur from the POR pulse, if MCLR
is kept low long enough, the time outs will expire. Then
bringing MCLR high will begin execution immediately
(see Figure 14-9). This is useful for testing purposes or
to synchronize more than one PIC16F627A/628A/
648A device operating in parallel.
TABLE 14-3:
Brown-out Reset
Oscillator Configuration
PWRTEN = 0
PWRTEN = 1
PWRTEN = 0
PWRTEN = 1
XT, HS, LP
72 ms +
1024TOSC
1024TOSC
72 ms +
1024TOSC
1024TOSC
1024TOSC
RC, EC
72 ms
72 ms
INTOSC
72 ms
72 ms
6 s
TABLE 14-4:
POR
BOR
TO
PD
Power-on Reset
Brown-out Reset
WDT Reset
WDT Wake-up
Legend:
Wake-up
from Sleep
Condition
u = unchanged, x = unknown
Preliminary
DS40044B-page 99
PIC16F627A/628A/648A
TABLE 14-5:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR Reset
Value on all
other
Resets(1)
03h, 83h,
103h, 183h
STATUS
IRP
RP1
RPO
TO
PD
DC
0001 1xxx
000q quuu
8Eh
PCON
OSCF
POR
BOR
---- 1-0x
---- u-uq
Legend:
Note
TABLE 14-6:
Status
Register
PCON
Register
Power-on Reset
000h
0001 1xxx
---- 1-0x
000h
000u uuuu
---- 1-uu
000h
0001 0uuu
---- 1-uu
Condition
WDT Reset
WDT Wake-up
Brown-out Reset
Interrupt Wake-up from Sleep
000h
0000 uuuu
---- 1-uu
PC + 1
uuu0 0uuu
---- u-uu
000h
000x xuuu
---- 1-u0
uuu1 0uuu
---- u-uu
PC + 1
(1)
DS40044B-page 100
Preliminary
PIC16F627A/628A/648A
TABLE 14-7:
Register
Address
Power-on
Reset
xxxx xxxx
uuuu uuuu
INDF
00h
TMR0
01h, 101h
xxxx xxxx
uuuu uuuu
uuuu uuuu
PCL
02h, 82h,
102h, 182h
0000 0000
0000 0000
PC + 1(3)
STATUS
03h, 83h,
103h, 183h
0001 1xxx
000q quuu(4)
uuuq 0uuu(4)
FSR
04h, 84h,
104h, 184h
xxxx xxxx
uuuu uuuu
uuuu uuuu
PORTA
05h
xxxx 0000
xxxx 0000
uuuu uuuu
PORTB
06h, 106h
xxxx xxxx
uuuu uuuu
uuuu uuuu
PCLATH
0Ah, 8Ah,
10Ah, 18Ah
---0 0000
---0 0000
---u uuuu
INTCON
0Bh, 8Bh,
10Bh,18Bh
0000 000x
0000 000u
uuuu uqqq(2)
PIR1
0Ch
0000 -000
0000 -000
qqqq -qqq(2)
TMR1L
0Eh
xxxx xxxx
uuuu uuuu
uuuu uuuu
TMR1H
0Fh
xxxx xxxx
uuuu uuuu
uuuu uuuu
T1CON
10h
--00 0000
--uu uuuu(6)
--uu uuuu
TMR2
11h
0000 0000
0000 0000
uuuu uuuu
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
0000 -000
uuuu -uuu
PCON
8Eh
---- 1-0x
---- 1-uq(1,5)
---- u-uu
PR2
92h
1111 1111
1111 1111
uuuu uuuu
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
Legend:
Note 1:
2:
3:
4:
5:
6:
7:
uuuu uuuu
Preliminary
DS40044B-page 101
PIC16F627A/628A/648A
FIGURE 14-8:
VDD
MCLR
INTERNAL POR
Tpwrt
PWRT TIME OUT
Tost
INTERNAL RESET
FIGURE 14-9:
VDD
MCLR
INTERNAL POR
Tpwrt
PWRT TIME OUT
Tost
INTERNAL RESET
FIGURE 14-10:
VDD
MCLR
INTERNAL POR
Tpwrt
PWRT TIME OUT
Tost
INTERNAL RESET
DS40044B-page 102
Preliminary
PIC16F627A/628A/648A
FIGURE 14-11:
EXTERNAL POWER-ON
RESET CIRCUIT (FOR
SLOW VDD POWER-UP)
FIGURE 14-13:
EXTERNAL BROWN-OUT
PROTECTION CIRCUIT 2
VDD
VDD
VDD
VDD
R1
Q1
MCLR
PIC16F627A/628A/648A
R2
R1
40k
MCLR
PIC16F627A/628A/648A
C
Note 1: This Brown-out Circuit is less expensive,
albeit less accurate. Transistor Q1 turns off
when VDD is below a certain level such that:
FIGURE 14-12:
VDD x
R1
R1 + R2
= 0.7 V
R1
0.7 V be dis2: Internal
Reset= should
VddBrown-out
x
R1 + R2
abled when using this circuit.
3: Resistors should be adjusted for the
characteristics of the transistor.
EXTERNAL BROWN-OUT
PROTECTION CIRCUIT 1
VDD
VDD
33k
10k
MCLR
40k
PIC16F627A/628A/648A
Preliminary
DS40044B-page 103
PIC16F627A/628A/648A
14.5
Interrupts
FIGURE 14-14:
INTERRUPT LOGIC
TMR1IF
TMR1IE
TMR2IF
TMR2IE
T0IF
T0IE
INTF
INTE
CCP1IF
CCP1IE
CMIF
CMIE
TXIF
TXIE
RCIF
RCIE
EEIF
EEIE
RBIF
RBIE
DS40044B-page 104
Interrupt to CPU
PEIE
GIE
Preliminary
PIC16F627A/628A/648A
14.5.1
RB0/INT INTERRUPT
14.5.3
14.5.2
PORTB INTERRUPT
14.5.4
COMPARATOR INTERRUPT
for
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
INTF flag
(INTCON<1>)
(1)
(1)
(5)
GIE bit
(INTCON<7>)
INSTRUCTION FLOW
PC
PC
Instruction
Fetched
Inst (PC)
Instruction
Executed
Inst (PC-1)
PC+1
PC+1
Inst (PC+1)
Inst (PC)
Dummy Cycle
0004h
0005h
Inst (0004h)
Inst (0005h)
Dummy Cycle
Inst (0004h)
Preliminary
DS40044B-page 105
PIC16F627A/628A/648A
TABLE 14-8:
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Value on
POR Reset
Value on all
other
Resets(1)
GIE
PEIE
T0IE
INTE
RBIE
T0IF
INTF
RBIF
0000 000x
0000 000u
0Ch
PIR1
EEIF
CMIF
RCIF
TXIF
0000 -000
0000 -000
8Ch
PIE1
EEIE
CMIE
RCIE
TXIE
0000 -000
0000 -000
Note 1: Other (non Power-up) Resets include MCLR Reset, Brown-out Reset and Watchdog Timer Reset during normal
operation.
14.6
EXAMPLE 14-2:
MOVWF W_TEMP
14.7.1
WDT PERIOD
14.7.2
DS40044B-page 106
14.7
WDT PROGRAMMING
CONSIDERATIONS
Preliminary
PIC16F627A/628A/648A
FIGURE 14-16:
M
U
1X
Watchdog
Timer
WDT POSTSCALER/
TMR0 PRESCALER
8
8 to 1 MUX
PSA
PS<2:0>
WDT
Enable Bit
To TMR0
(Figure 6-1)
MUX
PSA
WDT
Time out
Note:
TABLE 14-9:
Value on all
other
Resets
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
2007h
Config.
bits
LVP
BOREN
MCLRE
FOSC2
PWRTE
WDTE
FOSC1
FOSC0
81h, 181h
OPTION
RBPU
INTEDG
T0CS
T0SE
PSA
PS2
PS1
PS0
Legend:
Note:
14.8
Preliminary
DS40044B-page 107
PIC16F627A/628A/648A
14.8.1
The first event will cause a device Reset. The two latter
events are considered a continuation of program
execution. The TO and PD bits in the Status Register
can be used to determine the cause of device Reset.
PD bit, which is set on power-up is cleared when Sleep
is invoked. TO bit is cleared if WDT wake-up occurred.
FIGURE 14-17:
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
Tost(2)
CLKOUT(4)
INT pin
INTF flag
(INTCON<1>)
Interrupt Latency
(Note 2)
GIE bit
(INTCON<7>)
Processor in
Sleep
INSTRUCTION FLOW
PC
Instruction
Fetched
Instruction
Executed
Note
1:
2:
3:
4:
14.9
PC
Inst(PC) = Sleep
Inst(PC - 1)
PC+1
PC+2
Inst(PC + 2)
Sleep
Inst(PC + 1)
PC + 2
Dummy cycle
0004h
0005h
Inst(0004h)
Inst(0005h)
Dummy cycle
Inst(0004h)
Code Protection
PC+2
Inst(PC + 1)
DS40044B-page 108
Preliminary
PIC16F627A/628A/648A
14.11 In-Circuit Serial Programming
FIGURE 14-18:
External
Connector
Signals
TYPICAL IN-CIRCUIT
SERIAL PROGRAMMING
CONNECTION
To Normal
Connections
PIC16F627A/628A/648A
+5V
VDD
0V
VSS
VPP
RA5/MCLR/VPP
CLK
RB6/PGC
Data I/O
RB7/PGD
VDD
To Normal
Connections
Preliminary
DS40044B-page 109
PIC16F627A/628A/648A
NOTES:
DS40044B-page 110
Preliminary
PIC16F627A/628A/648A
15.0
TABLE 15-1:
OPCODE FIELD
DESCRIPTIONS
Field
Description
label
Label name
TOS
Top of Stack
PC
Program Counter
0xhh
where h signifies a hexadecimal digit.
FIGURE 15-1:
WDT
Watchdog Timer/Counter
PD
Power-down bit
dest
[ ]
Options
General
( )
Contents
13
Assigned to
<>
In the set of
italics
b (BIT #)
TO
0
f (FILE #)
d = 0 for destination W
d = 1 for destination f
f = 7-bit file register address
f (FILE #)
8 7
OPCODE
k (literal)
k (literal)
Preliminary
DS40044B-page 111
PIC16F627A/628A/648A
TABLE 15-2:
Mnemonic,
Operands
Description
Cycles
MSb
LSb
Status
Affected
Notes
f, d
f, d
f
f, d
f, d
f, d
f, d
f, d
f, d
f, d
f
f, d
f, d
f, d
f, d
f, d
Add W and f
AND W with f
Clear f
Clear W
Complement f
Decrement f
Decrement f, Skip if 0
Increment f
Increment f, Skip if 0
Inclusive OR W with f
Move f
Move W to f
No Operation
Rotate Left f through Carry
Rotate Right f through Carry
Subtract W from f
Swap nibbles in f
Exclusive OR W with f
1
1
1
1
1
1
1(2)
1
1(2)
1
1
1
1
1
1
1
1
1
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
0111
0101
0001
0001
1001
0011
1011
1010
1111
0100
1000
0000
0000
1101
1100
0010
1110
0110
dfff
dfff
lfff
0000
dfff
dfff
dfff
dfff
dfff
dfff
dfff
lfff
0xx0
dfff
dfff
dfff
dfff
dfff
ffff
ffff
ffff
0011
ffff
ffff
ffff
ffff
ffff
ffff
ffff
ffff
0000
ffff
ffff
ffff
ffff
ffff
1
1
1(2)
1(2)
01
01
01
01
00bb
01bb
10bb
11bb
bfff
bfff
bfff
bfff
ffff
ffff
ffff
ffff
1
1
2
1
2
1
1
2
2
2
1
1
1
11
11
10
00
10
11
11
00
11
00
00
11
11
111x
1001
0kkk
0000
1kkk
1000
00xx
0000
01xx
0000
0000
110x
1010
kkkk
kkkk
kkkk
0110
kkkk
kkkk
kkkk
0000
kkkk
0000
0110
kkkk
kkkk
kkkk
kkkk
kkkk
0100
kkkk
kkkk
kkkk
1001
kkkk
1000
0011
kkkk
kkkk
C,DC,Z
Z
Z
Z
Z
Z
Z
Z
Z
C
C
C,DC,Z
Z
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
f, b
f, b
f, b
f, b
Bit Clear f
Bit Set f
Bit Test f, Skip if Clear
Bit Test f, Skip if Set
1,2
1,2
3
3
1:
2:
3:
k
k
k
k
k
k
k
k
C,DC,Z
Z
TO,PD
Z
TO,PD
C,DC,Z
Z
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.
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.
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.
DS40044B-page 112
Preliminary
PIC16F627A/628A/648A
15.1
Instruction Descriptions
ADDLW
Syntax:
[ label ] ADDLW
Operands:
ANDLW
Syntax:
[ label ] ANDLW
0 k 255
Operands:
0 k 255
Operation:
(W) + k (W)
Operation:
Status Affected:
C, DC, Z
Status Affected:
Encoding:
11
Encoding:
11
Description:
Description:
Words:
Cycles:
Words:
Example
ADDLW
Cycles:
Before Instruction
W = 0x10
After Instruction
W = 0x25
Example
ANDLW
ADDWF
Add W and f
ANDWF
AND W with f
Syntax:
[ label ] ADDWF
Syntax:
[ label ] ANDWF
Operands:
0 f 127
d [0,1]
Operands:
0 f 127
d [0,1]
Operation:
Operation:
Status Affected:
C, DC, Z
Status Affected:
Encoding:
00
Encoding:
00
Description:
Description:
Words:
Words:
Cycles:
Cycles:
Example
ADDWF
Example
ANDWF
111x
kkkk
kkkk
0x15
0111
kkkk
kkkk
0x5F
Before Instruction
W = 0xA3
After Instruction
W = 0x03
f,d
dfff
REG1, 0
ffff
0101
f,d
dfff
ffff
REG1, 1
Before Instruction
W
= 0x17
REG1 = 0xC2
After Instruction
W
= 0x17
REG1 = 0x02
Before Instruction
W
= 0x17
REG1 = 0xC2
After Instruction
W
= 0xD9
REG1 = 0xC2
Z
= 0
C
= 0
DC
= 0
1001
Preliminary
DS40044B-page 113
PIC16F627A/628A/648A
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:
None
Status Affected:
None
Encoding:
01
f,b
00bb
bfff
Description:
Words:
Cycles:
Example
BCF
ffff
Encoding:
Description:
Before Instruction
REG1 = 0xC7
After Instruction
REG1 = 0x47
Bit Set f
Syntax:
[ label ] BSF
Operands:
0 f 127
0b7
Operation:
1 (f<b>)
Status Affected:
None
Encoding:
01
Description:
Words:
Cycles:
Example
BSF
01bb
Words:
bfff
ffff
Cycles:
1(2)
Example
HERE
FALSE
TRUE
f,b
bfff
10bb
REG1, 7
BSF
01
ffff
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
DS40044B-page 114
Preliminary
PIC16F627A/628A/648A
BTFSS
CALL
Call Subroutine
Syntax:
Syntax:
[ label ] CALL k
Operands:
0 f 127
0b<7
Operands:
0 k 2047
Operation:
Operation:
skip if (f<b>) = 1
Status Affected:
None
(PC)+ 1 TOS,
k PC<10:0>,
(PCLATH<4:3>) PC<12:11>
Encoding:
01
Status Affected:
None
Description:
Encoding:
10
Description:
Words:
Cycles:
Example
HERE
Words:
Cycles:
1(2)
Example
HERE
FALSE
TRUE
11bb
BTFSS
GOTO
bfff
ffff
REG1
PROCESS_CODE
Before Instruction
PC = address HERE
After Instruction
if FLAG<1> = 0,
PC = address FALSE
if FLAG<1> = 1,
PC = address TRUE
0kkk
kkkk
CALL
kkkk
THERE
Before Instruction
PC = Address HERE
After Instruction
PC = Address THERE
TOS = Address HERE+1
CLRF
Syntax:
Clear f
[ label ] CLRF
Operands:
0 f 127
Operation:
00h (f)
1Z
Status Affected:
Encoding:
00
Description:
Words:
Cycles:
Example
CLRF
0001
1fff
ffff
REG1
Before Instruction
REG1 = 0x5A
After Instruction
REG1 = 0x00
Z
= 1
Preliminary
DS40044B-page 115
PIC16F627A/628A/648A
CLRW
Clear W
COMF
Complement f
Syntax:
[ label ] CLRW
Syntax:
[ label ] COMF
Operands:
None
Operands:
Operation:
00h (W)
1Z
0 f 127
d [0,1]
Operation:
(f) (dest)
Status Affected:
Status Affected:
Encoding:
00
Encoding:
00
Description:
Description:
Words:
Cycles:
Example
CLRW
Words:
Before Instruction
W = 0x5A
After Instruction
W = 0x00
Z = 1
Cycles:
Example
COMF
CLRWDT
DECF
Syntax:
[ label ] CLRWDT
Operands:
None
Operands:
Operation:
00h WDT
0 WDT prescaler,
1 TO
1 PD
0 f 127
d [0,1]
Operation:
(f) - 1 (dest)
Status Affected:
Status Affected:
TO, PD
Encoding:
Encoding:
00
Description:
0001
0000
0011
1001
f,d
dfff
ffff
REG1, 0
Before Instruction
REG1 = 0x13
After Instruction
REG1 = 0x13
W
= 0xEC
Syntax:
Decrement f
[ label ] DECF f,d
00
0011
dfff
ffff
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:
Words:
Cycles:
Cycles:
Example
DECF
Example
0000
0110
CLRWDT
Before Instruction
WDT counter = ?
After Instruction
WDT counter =
WDT prescaler =
=
TO
=
PD
DS40044B-page 116
0100
0x00
0
1
1
Preliminary
CNT, 1
Before Instruction
CNT = 0x01
Z
= 0
After Instruction
CNT = 0x00
Z
= 1
PIC16F627A/628A/648A
DECFSZ
Decrement f, Skip if 0
GOTO
Unconditional Branch
Syntax:
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operands:
0 k 2047
Operation:
(f) - 1 (dest);
0
Operation:
k PC<10:0>
PCLATH<4:3> PC<12:11>
Status Affected:
None
Status Affected:
None
Encoding:
Encoding:
10
00
Description:
Description:
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
Words:
1011
skip if result =
dfff
ffff
1(2)
Example
HERE
DECFSZ
GOTO
CONTINUE
1kkk
kkkk
kkkk
After Instruction
PC = Address THERE
Cycles:
GOTO k
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
Preliminary
DS40044B-page 117
PIC16F627A/628A/648A
INCF
Increment f
INCFSZ
Increment f, Skip if 0
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operands:
0 f 127
d [0,1]
Operation:
(f) + 1 (dest)
Operation:
Status Affected:
Status Affected:
None
Encoding:
00
Encoding:
00
Description:
Description:
Words:
Cycles:
Example
INCF
Words:
INCF f,d
1010
dfff
ffff
REG1, 1
Before Instruction
REG1 = 0xFF
Z
= 0
After Instruction
REG1 = 0x00
Z
= 1
INCFSZ f,d
1111
Cycles:
1(2)
Example
HERE
dfff
INCFSZ
GOTO
CONTINUE
ffff
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
DS40044B-page 118
Preliminary
PIC16F627A/628A/648A
IORLW
MOVLW
Move Literal to W
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 k 255
Operands:
0 k 255
Operation:
Operation:
k (W)
Status Affected:
Status Affected:
None
Encoding:
11
Encoding:
11
Description:
Description:
Words:
Words:
Cycles:
Cycles:
Example
MOVLW
Example
IORLW
IORLW k
1000
kkkk
kkkk
0x35
MOVLW k
00xx
kkkk
kkkk
0x5A
After Instruction
W = 0x5A
Before Instruction
W = 0x9A
After Instruction
W = 0xBF
Z = 0
IORWF
Inclusive OR W with f
MOVF
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operands:
0 f 127
d [0,1]
Operation:
(f) (dest)
Status Affected:
Encoding:
00
Description:
Words:
Cycles:
Example
MOVF
IORWF
f,d
Operation:
Status Affected:
Encoding:
00
Description:
Words:
Cycles:
Example
IORWF
0100
dfff
REG1, 0
Before Instruction
REG1 = 0x13
W
= 0x91
After Instruction
REG1 = 0x13
W
= 0x93
Z
= 1
ffff
Move f
MOVF f,d
1000
dfff
ffff
REG1, 0
After Instruction
W= value in REG1 register
Z = 1
Preliminary
DS40044B-page 119
PIC16F627A/628A/648A
MOVWF
Move W to f
OPTION
Syntax:
[ label ]
Syntax:
[ label ]
0 f 127
Operands:
None
Operands:
Operation:
(W) (f)
Operation:
(W) OPTION
Status Affected:
None
Status Affected:
None
Encoding:
00
Encoding:
00
Description:
Words:
Cycles:
MOVWF
0000
1fff
Description:
Words:
Cycles:
Example
MOVWF
ffff
REG1
Before Instruction
REG1 = 0xFF
W
= 0x4F
After Instruction
REG1 = 0x4F
W
= 0x4F
OPTION
0000
0110
0010
Example
To maintain upward compatibility with future PICmicro
products, do not use this
instruction.
NOP
No Operation
RETFIE
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
None
Operands:
None
Operation:
No operation
Operation:
Status Affected:
None
TOS PC,
1 GIE
Encoding:
00
Status Affected:
None
Description:
No operation.
Encoding:
00
Words:
Description:
Cycles:
Example
NOP
Words:
Cycles:
Example
RETFIE
NOP
0000
0xx0
0000
RETFIE
0000
0000
1001
After Interrupt
PC = TOS
GIE = 1
DS40044B-page 120
Preliminary
PIC16F627A/628A/648A
RETLW
RLF
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 k 255
Operands:
Operation:
k (W);
TOS PC
0 f 127
d [0,1]
Operation:
Status Affected:
None
Status Affected:
Encoding:
11
Encoding:
00
Description:
Description:
Words:
Cycles:
Example
TABLE
RETLW k
01xx
kkkk
kkkk
Cycles:
Example
RLF
f,d
1101
Words:
RLF
dfff
ffff
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:
00
Description:
Words:
Cycles:
Example
RETURN
RETURN
0000
0000
1000
After Interrupt
PC = TOS
Preliminary
DS40044B-page 121
PIC16F627A/628A/648A
RRF
SUBLW
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operands:
0 k 255
Operation:
k - (W) (W)
Operation:
C, DC, Z
Status Affected:
Status
Affected:
Encoding:
00
Encoding:
11
Description:
Description:
1100
Words:
Cycles:
Example
RRF
RRF f,d
dfff
ffff
REGISTER F
SUBLW k
110x
Words:
Cycles:
Example 1:
SUBLW
kkkk
kkkk
0x02
Before Instruction
W = 1
C = ?
REG1, 0
After Instruction
Before Instruction
REG1 = 1110 0110
C
= 0
After Instruction
REG1 = 1110 0110
W
= 0111 0011
C
= 0
W = 1
C = 1; result is positive
Example 2:
Before Instruction
W = 2
C = ?
After Instruction
W = 0
C = 1; result is zero
SLEEP
Example 3:
Syntax:
[ label ]
SLEEP
Operands:
None
Operation:
00h WDT,
0 WDT prescaler,
1 TO,
0 PD
W =
C =
W =
C =
TO, PD
Encoding:
00
Description:
Words:
Cycles:
Example:
SLEEP
DS40044B-page 122
0110
3
?
After Instruction
Status Affected:
0000
Before Instruction
0xFF
0; result is negative
0011
Preliminary
PIC16F627A/628A/648A
SUBWF
Subtract W from f
SWAPF
Swap Nibbles in f
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 f 127
d [0,1]
Operands:
0 f 127
d [0,1]
Operation:
Operation:
Status
Affected:
C, DC, Z
(f<3:0>) (dest<7:4>),
(f<7:4>) (dest<3:0>)
Status Affected:
None
Encoding:
00
Encoding:
00
Description:
Description:
Words:
Words:
Cycles:
Cycles:
Example 1:
SUBWF
Example
SWAPF
SUBWF f,d
0010
dfff
ffff
REG1, 1
Before Instruction
Example 2:
1
2
1; result is positive
1
0
After Instruction
Example 3:
TRIS
REG1 = 1
W
= 2
C
= ?
[ label ] TRIS
Operands:
5f7
Operation:
Status Affected:
None
Encoding:
00
Description:
Words:
Cycles:
0000
0110
0fff
Example
After Instruction
=
=
=
=
Syntax:
0
2
1; result is zero
DC = 1
Before Instruction
REG1
W
C
Z
REG1, 0
REG1 = 0xA5
W
= 0x5A
REG1 = 2
W
= 2
C
= ?
=
=
=
=
ffff
After Instruction
Before Instruction
REG1
W
C
Z
dfff
REG1 = 0xA5
After Instruction
=
=
=
=
=
1110
Before Instruction
REG1 = 3
W
= 2
C
= ?
REG1
W
C
DC
Z
SWAPF f,d
0xFF
2
0; result is negative
DC = 0
Preliminary
DS40044B-page 123
PIC16F627A/628A/648A
XORLW
XORWF
Exclusive OR W with f
Syntax:
[ label ]
Syntax:
[ label ]
Operands:
0 k 255
Operands:
0 f 127
d [0,1]
Operation:
Status Affected:
Encoding:
00
Description:
Words:
Cycles:
Example
XORWF
XORLW k
Operation:
Status Affected:
Encoding:
11
Description:
1010
Words:
Cycles:
Example:
XORLW
kkkk
0xAF
Before Instruction
W = 0xB5
kkkk
XORWF
0110
f,d
dfff
ffff
REG1, 1
Before Instruction
After Instruction
REG1 = 0xAF
W
= 0xB5
W = 0x1A
After Instruction
REG1 = 0x1A
W
= 0xB5
DS40044B-page 124
Preliminary
PIC16F627A/628A/648A
16.0
DEVELOPMENT SUPPORT
16.1
16.2
MPASM Assembler
Preliminary
DS40044B-page 125
PIC16F627A/628A/648A
16.3
16.6
16.4
16.5
DS40044B-page 126
16.7
The MPLAB SIM software simulator allows code development in a PC hosted environment by simulating the
PICmicro series microcontrollers on an instruction
level. On any given instruction, the data areas can be
examined or modified and stimuli can be applied from
a file, or user defined key press, to any pin. The execution can be performed in Single-Step, Execute Until
Break or Trace mode.
The MPLAB SIM simulator fully supports symbolic
debugging using the MPLAB C17 and MPLAB C18
C Compilers, as well as the MPASM assembler. The
software simulator offers the flexibility to develop and
debug code outside of the laboratory environment,
making it an excellent, economical software
development tool.
16.8
Preliminary
PIC16F627A/628A/648A
16.9
Preliminary
DS40044B-page 127
PIC16F627A/628A/648A
16.14 PICSTART Plus Development
Programmer
DS40044B-page 128
Preliminary
PIC16F627A/628A/648A
16.20 PICDEM 17 Demonstration Board
The PICDEM 17 demonstration board is an evaluation
board that demonstrates the capabilities of several
Microchip microcontrollers, including PIC17C752,
PIC17C756A, PIC17C762 and PIC17C766. A
programmed sample is included. The PRO MATE II
device programmer, or the PICSTART Plus development programmer, can be used to reprogram the
device for user tailored application development. The
PICDEM 17 demonstration board supports program
download and execution from external on-board Flash
memory. A generous prototype area is available for
user hardware expansion.
Preliminary
DS40044B-page 129
PIC16F627A/628A/648A
NOTES:
DS40044B-page 130
Preliminary
PIC16F627A/628A/648A
17.0
ELECTRICAL SPECIFICATIONS
Note:
Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up.
Thus, a series resistor of 50-100 should be used when applying a low level to the MCLR pin rather than
pulling this pin directly to VSS.
Preliminary
DS40044B-page 131
PIC16F627A/628A/648A
PIC16F627A/628A/648A VOLTAGE-FREQUENCY GRAPH, -40C TA +125C
FIGURE 17-1:
6.0
5.5
5.0
VDD
(VOLTS)
4.5
4.0
3.5
3.0
2.5
4
10
20
25
FREQUENCY (MHz)
Note:
The shaded region indicates the permissible combinations of voltage and frequency.
FIGURE 17-2:
6.0
5.5
5.0
4.5
VDD
(VOLTS)
4.0
3.5
3.0
2.5
2.0
0
10
20
25
FREQUENCY (MHz)
Note:
The shaded region indicates the permissible combinations of voltage and frequency.
DS40044B-page 132
Preliminary
PIC16F627A/628A/648A
17.1
PIC16LF627A/628A/648A
(Industrial)
PIC16F627A/628A/648A
(Industrial, Extended)
Param
No.
Sym
VDD
D001
Characteristic/Device
Min
Typ
Max
Units
PIC16LF627A/628A/648A
2.0
5.5
PIC16F627A/628A/648A
Conditions
Supply Voltage
3.0
5.5
D002
VDR
1.5*
D003
VPOR
VSS
D004
SVDD
0.05*
V/ms
D005
VBOR
3.65
3.65
4.0
4.0
4.35
4.4
V
V
Legend: Rows with standard voltage device data only are shaded for improved readability.
* These parameters are characterized but not tested.
Data in Typ column is at 5.0 V, 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.
Preliminary
DS40044B-page 133
PIC16F627A/628A/648A
17.2
Param
No.
LF and F Device
Characteristics
Min
Typ
Max
Conditions
Units
VDD
Note
LF
2.0
5.5
LF/F
3.0
5.5
0.1
0.80
2.0
0.1
0.85
3.0
0.2
2.7
5.0
2.0
2.0
3.4
3.0
17.0
5.0
32
TBD
4.5
33
TBD
5.0
15
TBD
2.0
27
TBD
3.0
49
TBD
5.0
34
TBD
2.0
50
TBD
3.0
80
TBD
5.0
1.2
2.0
2.0
1.3
2.2
3.0
1.8
2.9
5.0
12
15
2.0
21
25
3.0
38
48
5.0
130
190
2.0
220
340
3.0
370
520
5.0
270
350
2.0
430
600
3.0
780
995
5.0
2.6
2.9
mA
4.5
3.3
mA
5.0
LF
D020
LF/F
LF
D021
D022
LF/F
LF/F
LF
D023
LF/F
LF
D024
LF/F
LF
D025
LF/F
WDT Current
BOR Current
Comparator Current
VREF Current
T1OSC Current
LF
D010
LF/F
LF
D011
LF/F
LF
D012
D013
LF/F
LF/F
FOSC = 32 kHz
LP Oscillator Mode
FOSC = 1 MHz
XT Oscillator Mode
FOSC = 4 MHz
XT Oscillator Mode
FOSC = 20 MHz
HS Oscillator Mode
Note 1: 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.
DS40044B-page 134
Preliminary
PIC16F627A/628A/648A
17.3
Param
No.
Device Characteristics
Min
Typ
Max
Conditions
Units
VDD
Note
3.0
5.5
0.1
TBD
3.0
0.2
TBD
5.0
TBD
3.0
WDT Current
D022E
D023E
D024E
D025E
TBD
5.0
32
TBD
4.5
33
TBD
5.0
27
TBD
3.0
49
TBD
5.0
50
TBD
3.0
83
TBD
5.0
1.3
TBD
3.0
1.8
TBD
5.0
BOR Current
Comparator Current
VREF Current
T1OSC Current
D011E
D012E
D013E
21
TBD
3.0
38
TBD
5.0
220
TBD
3.0
370
TBD
5.0
430
TBD
3.0
780
TBD
5.0
2.6
TBD
mA
4.5
TBD
mA
5.0
FOSC = 32 kHz
LP Oscillator Mode
FOSC = 1 MHz
XT Oscillator Mode
FOSC = 4 MHz
XT Oscillator Mode
FOSC = 20 MHz
HS Oscillator Mode
Note 1: 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.
Preliminary
DS40044B-page 135
PIC16F627A/628A/648A
17.4
DC CHARACTERISTICS
Param.
No.
Sym
VIL
Characteristic/Device
D031
D032
D033
VIH
(4)
I/O ports
with TTL buffer
D041
D042
D043
D043A
VOL
VOH
VSS
VSS
VSS
VSS
0.8
0.15 VDD
0.2 VDD
0.2 VDD
V
V
V
V
VSS
VSS
0.3 VDD
0.8
V
V
2.0 V
.25 VDD + 0.8 V
0.8 VDD
0.8 VDD
0.7 VDD
0.9 VDD
VDD
VDD
VDD
VDD
VDD
VDD
V
V
V
V
V
V
50
200
400
1.0
0.5
1.0
5.0
A
A
A
A
0.6
0.6
V
V
VDD-0.7
VDD-0.7
V
V
8.5*
(Note1)
D090
Conditions
D080
Unit
D060
D061
D063
Max
D040
D070
Typ
D030
Min
D150
VOD
D100*
COSC2
OSC2 pin
15
pF
Cio
50
pF
D101*
Note
DS40044B-page 136
Preliminary
PIC16F627A/628A/648A
TABLE 17-1:
DC Characteristics
Parameter
Sym
No.
Characteristic
Min
Typ
Max
D120
D120A
D121
100K
10K
VMIN
1M
100K
5.5
D122
D123
100
8*
D124
TREF
1M
10M
D130
D130A
D131
EP
EP
VPR
10K
1000
VMIN
100K
10K
5.5
D132
D132A
VIE
VDD for Block erase
VPEW VDD for write
4.5
VMIN
5.5
5.5
D133
D133A
D134
TIE
Block Erase cycle time
TPEW Write cycle time
TRETP Characteristic Retention
100
4
2
8*
4*
Units
Conditions
Preliminary
DS40044B-page 137
PIC16F627A/628A/648A
TABLE 17-2:
COMPARATOR SPECIFICATIONS
Operating Conditions: 2.0V < VDD <5.5V, -40C < TA < +125C, unless otherwise stated.
Param
No.
Characteristics
Sym
Min
Typ
Max
Units
D300
VIOFF
5.0
10
mV
D301
VICM
VDD - 1.5*
D302
CMRR
55*
db
D303
Response Time(1)
TRESP
300
400*
ns
400
600*
ns
400
600*
ns
300
10*
D304
TMC2OV
Comments
TABLE 17-3:
Spec
No.
Characteristics
Sym
Min
Typ
Max
Units
Comments
D310
Resolution
VRES
VDD/24
VDD/32
LSb
LSb
D311
Absolute Accuracy
VRAA
1/4(2)*
1/2(2)*
LSb
LSb
D312
VRUR
2k*
TSET
10*
D313
Settling Time
(1)
DS40044B-page 138
Preliminary
PIC16F627A/628A/648A
17.5
The timing parameter symbols have been created with one of the following formats:
1. TppS2ppS
2. TppS
T
F
Frequency
Lowercase subscripts (pp) and their meanings:
pp
ck
CLKOUT
io
I/O port
mc
MCLR
Uppercase letters and their meanings:
S
F
Fall
H
High
I
Invalid (Hi-impedance)
L
Low
FIGURE 17-3:
Time
osc
t0
OSC1
T0CKI
P
R
V
Z
Period
Rise
Valid
Hi-Impedance
LOAD CONDITIONS
LOAD CONDITION 2
LOAD CONDITION 1
VDD/2
RL
CL
PIN
CL
PIN
VSS
VSS
RL = 464
CL = 50 pF for all pins except OSC2
15 pF for OSC2 output
Preliminary
DS40044B-page 139
PIC16F627A/628A/648A
17.6
FIGURE 17-4:
Q1
Q3
Q2
Q4
Q1
OSC1
1
2
CLKOUT
TABLE 17-4:
Parameter
No.
Characteristic
External CLKIN Frequency(1)
Oscillator Frequency(1)
Tosc
Oscillator Period(1)
2
3
4
*
Tcy
TosL,
TosH
RC
Min
Typ
Max
DC
DC
DC
0.1
1
250
50
5
250
250
50
5
200
100*
4
37
250
27
TCY
20
200
4
4
20
200
10,000
1,000
DC
4 MHz
Units
Conditions
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance only
and are not tested.
Note:
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 operation 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.
DS40044B-page 140
Preliminary
PIC16F627A/628A/648A
TABLE 17-5:
Parameter
No.
Sym
F10
FIOSC
IOSC
F13
F14
Characteristic
Min
Max
Units
MHz
1
2
%
%
6
4
3
TBD
TBD
TBD
s
s
s
start-up time
FIGURE 17-5:
Typ
Conditions
Q4
Q2
Q3
OSC1
11
10
22
CLKOUT
23
13
19
14
12
18
16
I/O PIN
(INPUT)
15
17
I/O PIN
(OUTPUT)
NEW VALUE
OLD VALUE
20, 21
Preliminary
DS40044B-page 141
PIC16F627A/628A/648A
TABLE 17-6:
Parameter
No.
10
Characteristic
10A
11
11A
12
TckR
TckF
14
TckL2ioV
15
12A
13
13A
Min
Typ
Max
Units
PIC16F62X
75
200*
ns
PIC16LF62X
400*
ns
PIC16F62X
75
200*
ns
PIC16LF62X
400*
ns
PIC16F62X
35
100*
ns
PIC16LF62X
200*
ns
PIC16F62X
35
100*
ns
200*
ns
20*
ns
PIC16LF62X
Tosc+200 ns*
ns
PIC16F62X
ns
16
TckH2ioI
17
18
TosH2ioI
PIC16F62X
PIC16LF62X
ns
50
150*
ns
300*
ns
100*
200*
ns
FIGURE 17-6:
VDD
MCLR
30
Internal
POR
33
PWRT
Time out
32
OST
Time out
Internal
RESET
Watchdog
Timer
RESET
34
31
34
I/O Pins
DS40044B-page 142
Preliminary
PIC16F627A/628A/648A
FIGURE 17-7:
VBOR
VDD
35
TABLE 17-7:
Parameter
No.
Sym
30
TmcL
31
Characteristic
Min
Typ
Max
Units
Conditions
2000
TBD
TBD
TBD
ns
ms
Twdt
7*
TBD
18
TBD
33*
TBD
ms
ms
32
Tost
1024TOSC
33
Tpwrt
28*
TBD
72
TBD
132*
TBD
ms
ms
34
TIOZ
2.0*
35
TBOR
100*
FIGURE 17-8:
RA4/T0CKI
41
40
42
RB6/T1OSO/T1CKI
46
45
47
48
TMR0 OR
TMR1
Preliminary
DS40044B-page 143
PIC16F627A/628A/648A
TABLE 17-8:
Param
No.
Sym
40
Tt0H
41
42
45
46
47
48
*
Min
Typ
Max Units
Conditions
ns
With Prescaler
10*
ns
Tt0L T0CKI Low Pulse Width
No Prescaler 0.5TCY + 20*
ns
With Prescaler
10*
ns
Tt0P T0CKI Period
Greater of:
ns
N = prescale
TCY + 40*
value (2, 4, ...,
N
256)
Tt1H T1CKI High
Synchronous, No Prescaler
0.5TCY + 20*
ns
Time
Synchronous, PIC16F62X
15*
ns
with Prescaler PIC16LF62X
25*
ns
Asynchronous PIC16F62X
30*
ns
PIC16LF62X
50*
ns
Tt1L T1CKI Low
Synchronous, No Prescaler
0.5TCY + 20*
ns
Time
Synchronous, PIC16F62X
15*
ns
with Prescaler PIC16LF62X
25*
ns
Asynchronous PIC16F62X
30*
ns
PIC16LF62X
50*
ns
Tt1P T1CKI input
Synchronous PIC16F62X
Greater of:
ns
N = prescale
period
TCY + 40*
value (1, 2, 4, 8)
N
PIC16LF62X
Greater of:
TCY + 40*
N
Asynchronous PIC16F62X
60*
ns
PIC16LF62X
100*
ns
Ft1 Timer1 oscillator input frequency range
32.7(1)
kHz
(oscillator enabled by setting bit T1OSCEN)
TCKEZt Delay from external clock edge to timer
2Tosc
7Tosc
mr1 increment
These parameters are characterized but not tested.
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
DS40044B-page 144
54
Preliminary
PIC16F627A/628A/648A
TABLE 17-9:
CAPTURE/COMPARE/PWM REQUIREMENTS
Param
Sym
No.
50
Characteristic
TccL CCP
input low time
Min
No Prescaler
51
TccH CCP
input high time
ns
10*
ns
PIC16LF62X
20*
ns
0.5TCY + 20*
ns
PIC16F62X
10*
ns
PIC16LF62X
20*
ns
3TCY + 40*
N
ns
PIC16F62X
10
25*
ns
PIC16LF62X
25
45*
ns
No Prescaler
With Prescaler
52
53
54
0.5TCY + 20*
PIC16F62X
With Prescaler
PIC16F62X
10
25*
ns
PIC16LF62X
25
45*
ns
Conditions
N = prescale
value (1,4 or 16)
Data in Typ column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only
and are not tested.
FIGURE 17-10:
RA4/T0CKI
41
40
42
TMR0
Characteristic
40
41
42
Min
No Prescaler
ns
With Prescaler
10*
ns
No Prescaler
ns
With Prescaler
10*
ns
TCY + 40*
N
ns
Conditions
N = prescale value
(1, 2, 4, ..., 256)
Data in Typ column is at 5.0V, 25C unless otherwise stated. These parameters are for design guidance only and are not
tested.
Preliminary
DS40044B-page 145
PIC16F627A/628A/648A
NOTES:
DS40044B-page 146
Preliminary
PIC16F627A/628A/648A
18.0
Preliminary
DS40044B-page 147
PIC16F627A/628A/648A
NOTES:
DS40044B-page 148
Preliminary
PIC16F627A/628A/648A
19.0
PACKAGING INFORMATION
19.1
XXXXXXXXXXXXXX
XXXXXXXXXXXXXX
EXAMPLE
PIC16F627A-I/P
YYWWNNN
18-LEAD SOIC (.300")
XXXXXXXXXXXX
XXXXXXXXXXXX
XXXXXXXXXXXX
YYWWNNN
EXAMPLE
PIC16F628A
-E/SO
0210017
20-LEAD SSOP
EXAMPLE
XXXXXXXXXXX
XXXXXXXXXXX
YYWWNNN
PIC16F648A
-I/SS
0210017
28-LEAD QFN
EXAMPLE
XXXXXXXX
XXXXXXXX
YYWWNNN
16F628A
-I/ML
0210017
Legend: XX...X
YY
WW
NNN
Note:
0210017
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 number of available characters for customer specific
information.
Standard PICmicro device marking consists of Microchip part number, year code, week code, and traceability code.
For PICmicro device marking beyond this, certain price adders apply. Please check with your Microchip Sales Office.
For QTP devices, any special marking adders are included in QTP price.
Preliminary
DS40044B-page 149
PIC16F627A/628A/648A
18-Lead Plastic Dual In-line (P) 300 mil (PDIP)
E1
2
n
A2
A
L
c
A1
B1
B
eB
Units
Dimension Limits
n
p
MIN
INCHES*
NOM
18
.100
.155
.130
MAX
MILLIMETERS
NOM
18
2.54
3.56
3.94
2.92
3.30
0.38
7.62
7.94
6.10
6.35
22.61
22.80
3.18
3.30
0.20
0.29
1.14
1.46
0.36
0.46
7.87
9.40
5
10
5
10
MIN
Number of Pins
Pitch
Top to Seating Plane
A
.140
.170
Molded Package Thickness
A2
.115
.145
Base to Seating Plane
A1
.015
Shoulder to Shoulder Width
E
.300
.313
.325
Molded Package Width
E1
.240
.250
.260
Overall Length
D
.890
.898
.905
Tip to Seating Plane
L
.125
.130
.135
c
Lead Thickness
.008
.012
.015
Upper Lead Width
B1
.045
.058
.070
Lower Lead Width
B
.014
.018
.022
Overall Row Spacing
eB
.310
.370
.430
DS40044B-page 150
Preliminary
MAX
4.32
3.68
8.26
6.60
22.99
3.43
0.38
1.78
0.56
10.92
15
15
PIC16F627A/628A/648A
18-Lead Plastic Small Outline (SO) Wide, 300 mil (SOIC)
E
p
E1
2
B
45
c
A2
Units
Dimension Limits
n
p
Number of Pins
Pitch
Overall Height
Molded Package Thickness
Standoff
Overall Width
Molded Package Width
Overall Length
Chamfer Distance
Foot Length
Foot Angle
Lead Thickness
Lead Width
Mold Draft Angle Top
Mold Draft Angle Bottom
A
A2
A1
E
E1
D
h
L
c
B
MIN
.093
.088
.004
.394
.291
.446
.010
.016
0
.009
.014
0
0
A1
INCHES*
NOM
18
.050
.099
.091
.008
.407
.295
.454
.020
.033
4
.011
.017
12
12
MAX
.104
.094
.012
.420
.299
.462
.029
.050
8
.012
.020
15
15
MILLIMETERS
NOM
18
1.27
2.36
2.50
2.24
2.31
0.10
0.20
10.01
10.34
7.39
7.49
11.33
11.53
0.25
0.50
0.41
0.84
0
4
0.23
0.27
0.36
0.42
0
12
0
12
MIN
MAX
2.64
2.39
0.30
10.67
7.59
11.73
0.74
1.27
8
0.30
0.51
15
15
* Controlling Parameter
Significant Characteristic
Notes:
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010 (0.254mm) per side.
JEDEC Equivalent: MS-013
Drawing No. C04-051
Preliminary
DS40044B-page 151
PIC16F627A/628A/648A
20-Lead Plastic Shrink Small Outline (SS) 209 mil, 5.30 mm (SSOP)
E
E1
p
2
1
A2
A1
Units
Dimension Limits
n
p
Number of Pins
Pitch
Overall Height
Molded Package Thickness
Standoff
Overall Width
Molded Package Width
Overall Length
Foot Length
Lead Thickness
Foot Angle
Lead Width
Mold Draft Angle Top
Mold Draft Angle Bottom
A
A2
A1
E
E1
D
L
c
MIN
.068
.064
.002
.299
.201
.278
.022
.004
0
.010
0
0
INCHES*
NOM
20
.026
.073
.068
.006
.309
.207
.284
.030
.007
4
.013
5
5
MAX
.078
.072
.010
.322
.212
.289
.037
.010
8
.015
10
10
MILLIMETERS
NOM
20
0.65
1.73
1.85
1.63
1.73
0.05
0.15
7.59
7.85
5.11
5.25
7.06
7.20
0.56
0.75
0.10
0.18
0.00
101.60
0.25
0.32
0
5
0
5
MIN
MAX
1.98
1.83
0.25
8.18
5.38
7.34
0.94
0.25
203.20
0.38
10
10
* Controlling Parameter
Significant Characteristic
Notes:
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed
.010 (0.254mm) per side.
JEDEC Equivalent: MO-150
Drawing No. C04-072
DS40044B-page 152
Preliminary
PIC16F627A/628A/648A
28-Lead Plastic Quad Flat No Lead Package (ML) 6x6 mm Body (QFN)
EXPOSED
METAL
PADS
E
E1
Q
D1
D2
p
2
1
n
R
E2
CH x 45
L
TOP VIEW
BOTTOM VIEW
A2
A1
A3
Units
Dimension Limits
Number of Pins
INCHES
MIN
MILLIMETERS*
NOM
MIN
MAX
MAX
NOM
28
28
Pitch
Overall Height
.033
.039
0.85
1.00
A2
.026
.031
0.65
0.80
Standoff
A1
.0004
.002
0.01
0.05
Base Thickness
A3
.008 REF.
0.20 REF.
6.00 BSC
.000
.236 BSC
E1
.226 BSC
E2
Overall Width
Overall Length
0.65 BSC
.026 BSC
.140
.146
0.00
5.75 BSC
.152
3.55
.236 BSC
3.70
3.85
6.00 BSC
.226 BSC
5.75 BSC
D1
D2
.140
.146
.152
3.55
3.70
Lead Width
.009
.011
.014
0.23
0.28
0.35
Lead Length
.020
.024
.030
0.50
0.60
0.75
3.85
.005
.007
.010
0.13
0.17
0.23
.012
.016
.026
0.30
0.40
0.65
CH
.009
.017
.024
0.24
0.42
0.60
Chamfer
Mold Draft Angle Top
12
12
*Controlling Parameter
Notes:
Dimensions D and E1 do not include mold flash or protrusions. Mold flash or protrusions shall not exceed .010 (0.254mm) per side.
JEDEC equivalent: M0-220
Drawing No. C04-114
Preliminary
DS40044B-page 153
PIC16F627A/628A/648A
NOTES:
DS40044B-page 154
Preliminary
PIC16F627A/628A/648A
APPENDIX A:
DATA SHEET
REVISION HISTORY
APPENDIX B:
DEVICE
DIFFERENCES
Revision A
This is a new data sheet.
TABLE B-1:
Revision B
Revised 28-Pin QFN Pin Diagram
Revised Figure 5-4 Block Diagram
Revised Register 7-1 TMR1ON
Revised Example 13-4 Data EEPROM Refresh
Routine
Revised Instruction Set SUBWF, Example 1
Revised DC Characteristics 17-2 and 17-3
Revised Tables 17-4 and 17-6
Corrected Table and Figure numbering in Section 17.0
DEVICE DIFFERENCES
Memory
Device
Flash
Program
RAM
Data
EEPROM
Data
PIC16F627A
1024 x 14
224 x 8
128 x 8
PIC16F628A
2048 x 14
224 x 8
128 x 8
PIC16F648A
4096 x 14
256 x 8
256 x 8
Preliminary
DS40044B-page 155
PIC16F627A/628A/648A
APPENDIX C:
DEVICE MIGRATIONS
3.
4.
5.
6.
7.
PIC16F627/628 to a PIC16F627A/628A
ER mode is now RC mode.
Code Protection for the Program Memory has
changed from Code Protect sections of memory
to Code Protect of the whole memory. The
Configuration bits CP0 and CP1 in the
PIC16F627/628 do not exist in the PIC16F627A/
628A. They have been replaced with one
Configuration bit<13> CP.
Brown-out Detect (BOD) terminology has
changed to Brown-out Reset (BOR) to better
represent the function of the Brown-out circuitry.
Enabling Brown-out Reset (BOR) does not
automatically enable the Power-up Timer
(PWRT) the way it did in the PIC16F627/628.
INTRC is now called INTOSC.
Timer1 Oscillator is now designed for
32.768 kHz operation. In the PIC16F627/628
the Timer1 Oscillator was designed to run up to
200 kHz.
The Dual Speed Oscillator mode only works in
the INTOSC Oscillator mode. In the PIC16F627/
628 the Dual Speed Oscillator mode worked in
both the INTRC and ER Oscillator modes.
DS40044B-page 156
APPENDIX D:
MIGRATING FROM
OTHER PICmicro
DEVICES
PIC16C62X/CE62X to PIC16F627A/628A/
648A Migration
See
Microchip
web
(www.microchip.com).
D.2
Preliminary
for
availability
PIC16C622A to PIC16F627A/628A/648A
Migration
See
Microchip
web
(www.microchip.com).
Note:
site
site
for
availability
PIC16F627A/628A/648A
APPENDIX E:
DEVELOPMENT
TOOL VERSION
REQUIREMENTS
TBD
MPLAB
SIMULATOR:
TBD
MPLAB
ICE 3000:
MATE
PICSTART
TM
MPASM
MPLAB
Note:
TBD
II:
TBD
Plus:
TBD
Assembler:
TBD
Preliminary
DS40044B-page 157
PIC16F627A/628A/648A
NOTES:
DS40044B-page 158
Preliminary
PIC16F627A/628A/648A
ON-LINE SUPPORT
Microchip provides on-line support on the Microchip
World Wide Web site.
The web site is used by Microchip as a means to make
files and information easily available to customers. To
view the site, the user must have access to the Internet
and a web browser, such as Netscape or Microsoft
Internet Explorer. Files are also available for FTP
download from our FTP site.
Preliminary
DS40044B-page 159
PIC16F627A/628A/648A
READER RESPONSE
It is our intention to provide you with the best documentation possible to ensure successful use of your Microchip product. 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) 792-4150.
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: (_______) _________ - _________
Application (optional):
Would you like a reply?
Device: PIC16F627A/628A/648A
N
Literature Number: DS40044B
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?
DS40044B-page 160
Preliminary
PIC16F627A/628A/648A
INDEX
A
A/D
Special Event Trigger (CCP)....................................... 57
Absolute Maximum Ratings .............................................. 131
ADDLW Instruction ........................................................... 113
ADDWF Instruction ........................................................... 113
ANDLW Instruction ........................................................... 113
ANDWF Instruction ........................................................... 113
Architectural Overview .......................................................... 9
Assembler
MPASM Assembler ................................................... 125
B
Baud Rate Error .................................................................. 71
Baud Rate Formula ............................................................. 71
BCF Instruction ................................................................. 114
Block Diagrams
Comparator
I/O Operating Modes .......................................... 62
Modified Comparator Output .............................. 64
I/O Ports
RB0/INT Pin ........................................................ 37
RB1/RX/DT Pin ................................................... 37
RB2/TX/CK Pin ................................................... 38
RB3/CCP1 Pin .................................................... 38
RB4/PGM Pin ..................................................... 39
RB5 Pin............................................................... 40
RB6/T1OSO/T1CKI Pin ...................................... 41
RB7/T1OSI Pin ................................................... 42
RC Oscillator Mode..................................................... 96
USART Receive.......................................................... 79
USART Transmit ......................................................... 77
BRGH bit ............................................................................. 71
Brown-Out Detect (BOD) .................................................... 98
BSF Instruction ................................................................. 114
BTFSC Instruction............................................................. 114
BTFSS Instruction ............................................................. 115
C
C Compilers
MPLAB C17 .............................................................. 126
MPLAB C18 .............................................................. 126
MPLAB C30 .............................................................. 126
CALL Instruction ............................................................... 115
Capture (CCP Module) ....................................................... 56
Block Diagram............................................................. 56
CCP Pin Configuration................................................ 56
CCPR1H:CCPR1L Registers...................................... 56
Changing Between Capture Prescalers...................... 56
Prescaler..................................................................... 56
Software Interrupt ....................................................... 56
Timer1 Mode Selection ............................................... 56
Capture/Compare/PWM (CCP)........................................... 55
Capture Mode. See Capture
CCP1 .......................................................................... 55
CCPR1H Register............................................... 55
CCPR1L Register ............................................... 55
CCP2 .......................................................................... 55
Compare Mode. See Compare
PWM Mode. See PWM
Timer Resources......................................................... 55
CCP1CON Register
CCP1M3:CCP1M0 Bits ............................................... 55
CCP1X:CCP1Y Bits.................................................... 55
CCP2CON Register
CCP2M3:CCP2M0 Bits .............................................. 55
CCP2X:CCP2Y Bits.................................................... 55
Clocking Scheme/Instruction Cycle .................................... 13
CLRF Instruction............................................................... 115
CLRW Instruction.............................................................. 116
CLRWDT Instruction......................................................... 116
Code Examples
Data EEPROM Refresh Routine ................................ 92
Code Protection ................................................................ 108
COMF Instruction.............................................................. 116
Comparator
Block Diagrams
I/O Operating Modes .......................................... 62
Modified Comparator Output .............................. 64
Comparator Module.................................................... 61
Configuration .............................................................. 62
Interrupts .................................................................... 65
Operation.................................................................... 63
Reference ................................................................... 63
Compare (CCP Module) ..................................................... 56
Block Diagram ............................................................ 56
CCP Pin Configuration ............................................... 57
CCPR1H:CCPR1L Registers ..................................... 56
Software Interrupt ....................................................... 57
Special Event Trigger ................................................. 57
Timer1 Mode Selection............................................... 57
Configuration Bits ............................................................... 93
Crystal Operation................................................................ 95
D
Data EEPROM Memory...................................................... 89
EECON1 Register ...................................................... 89
EECON2 Register ...................................................... 89
Operation During Code Protection ............................. 92
Reading ...................................................................... 91
Spurious Write Protection ........................................... 91
Using .......................................................................... 92
Write Verify ................................................................. 91
Writing to .................................................................... 91
Data Memory Organization................................................. 15
DECF Instruction .............................................................. 116
DECFSZ Instruction.......................................................... 117
Demonstration Boards
PICDEM 1................................................................. 128
PICDEM 17............................................................... 129
PICDEM 18R ............................................................ 129
PICDEM 2 Plus......................................................... 128
PICDEM 3................................................................. 128
PICDEM 4................................................................. 128
PICDEM LIN ............................................................. 129
PICDEM USB ........................................................... 129
PICDEM.net Internet/Ethernet .................................. 128
Development Support ....................................................... 125
Development Tool Version Requirements ........................ 157
Device Differences............................................................ 155
Device Migrations ............................................................. 156
Dual-speed Oscillator Modes.............................................. 97
Preliminary
DS40044B-page 161
PIC16F627A/628A/648A
E
EECON1 register ................................................................ 90
EECON2 register ................................................................ 90
Errata .................................................................................... 3
Evaluation and Programming Tools .................................. 129
External Crystal Oscillator Circuit........................................ 95
G
General-Purpose Register File............................................ 15
GOTO Instruction .............................................................. 117
I
I/O Ports .............................................................................. 31
Bi-Directional............................................................... 44
Block Diagrams
RB0/INT Pin ........................................................ 37
RB1/RX/DT Pin ................................................... 37
RB2/TX/CK Pin ................................................... 38
RB3/CCP1 Pin .................................................... 38
RB4/PGM Pin...................................................... 39
RB5 Pin............................................................... 40
RB6/T1OSO/T1CKI Pin ...................................... 41
RB7/T1OSI Pin ................................................... 42
PORTA ........................................................................ 31
PORTB........................................................................ 36
Programming Considerations ..................................... 44
Successive Operations ............................................... 44
TRISA ......................................................................... 31
TRISB ......................................................................... 36
ID Locations ...................................................................... 108
INCF Instruction ................................................................ 118
INCFSZ Instruction............................................................ 118
In-Circuit Serial Programming ........................................... 109
Indirect Addressing, INDF and FSR Registers.................... 28
Instruction Flow/Pipelining .................................................. 13
Instruction Set
ADDLW ..................................................................... 113
ADDWF ..................................................................... 113
ANDLW ..................................................................... 113
ANDWF ..................................................................... 113
BCF ........................................................................... 114
BSF ........................................................................... 114
BTFSC ...................................................................... 114
BTFSS ...................................................................... 115
CALL ......................................................................... 115
CLRF......................................................................... 115
CLRW........................................................................ 116
CLRWDT................................................................... 116
COMF ....................................................................... 116
DECF ........................................................................ 116
DECFSZ.................................................................... 117
GOTO........................................................................ 117
INCF.......................................................................... 118
INCFSZ ..................................................................... 118
IORLW....................................................................... 119
IORWF ...................................................................... 119
MOVF........................................................................ 119
MOVLW..................................................................... 119
MOVWF .................................................................... 120
NOP .......................................................................... 120
OPTION .................................................................... 120
RETFIE ..................................................................... 120
RETLW...................................................................... 121
RETURN ................................................................... 121
RLF ........................................................................... 121
DS40044B-page 162
M
Memory Organization
Data EEPROM Memory.................................. 89, 91, 92
Migrating from other PICmicro Devices ............................ 156
MOVF Instruction.............................................................. 119
MOVLW Instruction........................................................... 119
MOVWF Instruction .......................................................... 120
MPLAB ASM30 Assembler, Linker, Librarian ................... 126
MPLAB ICD 2 In-Circuit Debugger ................................... 127
MPLAB ICE 2000 High-Performance Universal In-Circuit Emulator................................................................................. 127
MPLAB ICE 4000 High-Performance Universal In-Circuit Emulator................................................................................. 127
MPLAB Integrated Development Environment Software.. 125
MPLAB PM3 Device Programmer .................................... 127
MPLINK Object Linker/MPLIB Object Librarian ................ 126
N
NOP Instruction ................................................................ 120
O
OPTION Instruction .......................................................... 120
OPTION Register................................................................ 23
Oscillator Configurations..................................................... 95
Oscillator Start-up Timer (OST) .......................................... 98
P
Package Marking Information ........................................... 149
Packaging Information ...................................................... 149
PCL and PCLATH............................................................... 28
Stack ........................................................................... 28
PCON Register ................................................................... 27
PICkit 1 Flash Starter Kit .................................................. 129
PICSTART Plus Development Programmer..................... 128
PIE1 Register...................................................................... 25
Pin Functions
RC6/TX/CK ........................................................... 6986
RC7/RX/DT........................................................... 6986
PIR1 Register ..................................................................... 26
Port RB Interrupt............................................................... 105
PORTA ............................................................................... 31
PORTB ............................................................................... 36
Preliminary
PIC16F627A/628A/648A
Power Control/Status Register (PCON) .............................. 99
Power-Down Mode (SLEEP) ............................................ 107
Power-On Reset (POR) ...................................................... 98
Power-up Timer (PWRT) .................................................... 98
PR2 Register................................................................. 52, 58
PRO MATE II Universal Device Programmer ................... 127
Program Memory Organization ........................................... 15
PWM (CCP Module) ........................................................... 58
Block Diagram............................................................. 58
Simplified PWM .................................................. 58
CCPR1H:CCPR1L Registers...................................... 58
Duty Cycle................................................................... 59
Example Frequencies/Resolutions ............................. 59
Period.......................................................................... 58
Set-Up for PWM Operation ......................................... 59
TMR2 to PR2 Match ................................................... 58
Q
Q-Clock ............................................................................... 59
Quick-Turnaround-Production (QTP) Devices ...................... 7
R
RC Oscillator ....................................................................... 96
RC Oscillator Mode
Block Diagram............................................................. 96
Registers
Maps
PIC16F627A ................................................. 16, 17
PIC16F628A ................................................. 16, 17
Reset................................................................................... 97
RETFIE Instruction............................................................ 120
RETLW Instruction ............................................................ 121
RETURN Instruction ......................................................... 121
Revision History ................................................................ 155
RLF Instruction.................................................................. 121
RRF Instruction ................................................................. 122
S
Serial Communication Interface (SCI) Module, See USART
Serialized Quick-Turnaround-Production (SQTP) Devices ... 7
SLEEP Instruction ............................................................. 122
Software Simulator (MPLAB SIM)..................................... 126
Software Simulator (MPLAB SIM30)................................. 126
Special Event Trigger. See Compare
Special Features of the CPU .............................................. 93
Special Function Registers ................................................. 18
Status Register ................................................................... 22
SUBLW Instruction............................................................ 122
SUBWF Instruction ........................................................... 123
SWAPF Instruction............................................................ 123
T
T1CKPS0 bit ....................................................................... 48
T1CKPS1 bit ....................................................................... 48
T1OSCEN bit ...................................................................... 48
T1SYNC bit ......................................................................... 48
T2CKPS0 bit ....................................................................... 53
T2CKPS1 bit ....................................................................... 53
Timer0
Block Diagrams
Timer0/WDT ....................................................... 46
External Clock Input.................................................... 45
Interrupt....................................................................... 45
Prescaler..................................................................... 46
Switching Prescaler Assignment................................. 47
Timer0 Module............................................................ 45
Timer1
Asynchronous Counter Mode ..................................... 50
Capacitor Selection .................................................... 51
External Clock Input ................................................... 49
External Clock Input Timing........................................ 50
Oscillator..................................................................... 51
Prescaler .............................................................. 49, 51
Resetting Timer1 ........................................................ 51
Resetting Timer1 Registers ........................................ 51
Special Event Trigger (CCP) ...................................... 57
Synchronized Counter Mode ...................................... 49
Timer Mode................................................................. 49
TMR1H ....................................................................... 50
TMR1L........................................................................ 50
Timer2
Block Diagram ............................................................ 52
Postscaler ................................................................... 52
PR2 register................................................................ 52
Prescaler .............................................................. 52, 59
Timer2 Module............................................................ 52
TMR2 output ............................................................... 52
TMR2 to PR2 Match Interrupt..................................... 58
Timing Diagrams
Timer0....................................................................... 143
Timer1....................................................................... 143
USART
Asynchronous Receiver...................................... 80
USART Asynchronous Master Transmission ............. 77
USART Asynchronous Reception .............................. 80
USART RX Pin Sampling ..................................... 75, 76
USART Synchronous Reception ................................ 86
USART Synchronous Transmission ........................... 84
Timing Diagrams and Specifications ................................ 140
TMR0 Interrupt.................................................................. 105
TMR1CS bit ........................................................................ 48
TMR1ON bit........................................................................ 48
TMR2ON bit........................................................................ 53
TOUTPS0 bit ...................................................................... 53
TOUTPS1 bit ...................................................................... 53
TOUTPS2 bit ...................................................................... 53
TOUTPS3 bit ...................................................................... 53
TRIS Instruction ................................................................ 123
TRISA ................................................................................. 31
TRISB ................................................................................. 36
U
Universal Synchronous Asynchronous Receiver Transmitter
(USART) ............................................................................. 69
Asynchronous Receiver
Setting Up Reception.......................................... 82
Asynchronous Receiver Mode
Address Detect ................................................... 82
Block Diagram .................................................... 82
USART
Asynchronous Mode................................................... 76
Asynchronous Receiver.............................................. 79
Asynchronous Reception............................................ 81
Asynchronous Transmission....................................... 77
Asynchronous Transmitter.......................................... 76
Baud Rate Generator (BRG) ...................................... 71
Block Diagrams
Transmit.............................................................. 77
USART Receive ................................................. 79
BRGH bit .................................................................... 71
Preliminary
DS40044B-page 163
PIC16F627A/628A/648A
Sampling ......................................................... 72, 73, 74
Synchronous Master Mode ......................................... 83
Synchronous Master Reception .................................. 85
Synchronous Master Transmission............................. 83
Synchronous Slave Mode ........................................... 86
Synchronous Slave Reception .................................... 87
Synchronous Slave Transmit ...................................... 86
V
Voltage Reference
Configuration............................................................... 67
Voltage Reference Module.......................................... 67
W
Watchdog Timer (WDT) .................................................... 106
WWW, On-Line Support........................................................ 3
X
XORLW Instruction ........................................................... 124
XORWF Instruction ........................................................... 124
DS40044B-page 164
Preliminary
PIC16F627A/628A/648A
PRODUCT IDENTIFICATION SYSTEM
To order or obtain information, e.g., on pricing or delivery, refer to the factory or the listed sales office.
PART NO.
-X
/XX
XXX
Device
Temperature
Range
Package
Pattern
Examples:
a)
b)
Device
Temperature Range
I
E
=
=
-40C to
-40C to
Package
P
SO
SS
ML
=
=
=
=
PDIP
SOIC (Gull Wing, 300 mil body)
SSOP (209 mil)
QFN (28 Lead)
Pattern
+85C
+125C
* JW Devices are UV erasable and can be programmed to any device configuration. JW Devices meet the electrical requirement of
each oscillator type.
Please specify which device, revision of silicon and Data Sheet (include Literature #) you are using.
New Customer Notification System
Register on our web site (www.microchip.com/cn) to receive the most current information on our products.
Preliminary
DS40044B-page 165
China - Beijing
Korea
Corporate Office
Unit 706B
Wan Tai Bei Hai Bldg.
No. 6 Chaoyangmen Bei Str.
Beijing, 100027, China
Tel: 86-10-85282100
Fax: 86-10-85282104
China - Chengdu
Boston
China - Fuzhou
Atlanta
Chicago
333 Pierce Road, Suite 180
Itasca, IL 60143
Tel: 630-285-0071
Fax: 630-285-0075
Dallas
4570 Westgrove Drive, Suite 160
Addison, TX 75001
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Tri-Atria Office Building
32255 Northwestern Highway, Suite 190
Farmington Hills, MI 48334
Tel: 248-538-2250
Fax: 248-538-2260
Kokomo
2767 S. Albright Road
Kokomo, IN 46902
Tel: 765-864-8360
Fax: 765-864-8387
Los Angeles
18201 Von Karman, Suite 1090
Irvine, CA 92612
Tel: 949-263-1888
Fax: 949-263-1338
San Jose
1300 Terra Bella Avenue
Mountain View, CA 94043
Tel: 650-215-1444
Fax: 650-961-0286
Toronto
6285 Northam Drive, Suite 108
Mississauga, Ontario L4V 1X5, Canada
Tel: 905-673-0699
Fax: 905-673-6509
ASIA/PACIFIC
Australia
Suite 22, 41 Rawson Street
Epping 2121, NSW
Australia
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
Singapore
Taiwan
Kaohsiung Branch
30F - 1 No. 8
Min Chuan 2nd Road
Kaohsiung 806, Taiwan
Tel: 886-7-536-4818
Fax: 886-7-536-4803
Taiwan
Taiwan Branch
11F-3, No. 207
Tung Hua North Road
Taipei, 105, Taiwan
Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
EUROPE
China - Shanghai
Austria
Durisolstrasse 2
A-4600 Wels
Austria
Tel: 43-7242-2244-399
Fax: 43-7242-2244-393
Denmark
China - Shenzhen
China - Shunde
Room 401, Hongjian Building, No. 2
Fengxiangnan Road, Ronggui Town, Shunde
District, Foshan City, Guangdong 528303, China
Tel: 86-757-28395507 Fax: 86-757-28395571
China - Qingdao
Rm. B505A, Fullhope Plaza,
No. 12 Hong Kong Central Rd.
Qingdao 266071, China
Tel: 86-532-5027355 Fax: 86-532-5027205
India
Divyasree Chambers
1 Floor, Wing A (A3/A4)
No. 11, OShaugnessey Road
Bangalore, 560 025, India
Tel: 91-80-2290061 Fax: 91-80-2290062
Japan
Benex S-1 6F
3-18-20, Shinyokohama
Kohoku-Ku, Yokohama-shi
Kanagawa, 222-0033, Japan
Tel: 81-45-471- 6166 Fax: 81-45-471-6122
France
Parc dActivite du Moulin de Massy
43 Rue du Saule Trapu
Batiment A - ler Etage
91300 Massy, France
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Germany
Steinheilstrasse 10
D-85737 Ismaning, Germany
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Italy
Via Quasimodo, 12
20025 Legnano (MI)
Milan, Italy
Tel: 39-0331-742611
Fax: 39-0331-466781
Netherlands
P. A. De Biesbosch 14
NL-5152 SC Drunen, Netherlands
Tel: 31-416-690399
Fax: 31-416-690340
United Kingdom
505 Eskdale Road
Winnersh Triangle
Wokingham
Berkshire, England RG41 5TU
Tel: 44-118-921-5869
Fax: 44-118-921-5820
01/26/04
DS40044B-page 166
Preliminary