PIC16F627
PIC16F627
PIC16F627
Data Sheet
FLASH-Based
8-Bit CMOS Microcontroller
• 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 knowl-
edge, 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.
PIC16F62X
RA4/TOCKI/CMP2 3 16 RA7/OSC1/CLKIN
RA5/MCLR/VPP 4 15 RA6/OSC2/CLKOUT
VSS 5 14 VDD
RB0/INT 6 13 RB7/T1OSI/PGD
RB1/RX/DT 7 12 RB6/T1OSO/T1CKI/PGC
RB2/TX/CK 8 11 RB5
RB3/CCP1 9 10 RB4/PGM
SSOP
RA2/AN2/VREF •1 20 RA1/AN1
RA3/AN3/CMP1 2 19 RA0/AN0
PIC16F62X
RA4/TOCKI/CMP2 3 18 RA7/OSC1/CLKIN
RA5/MCLR/VPP 4 17 RA6/OSC2/CLKOUT
VSS 5 16 VDD
VSS 6 15 VDD
RB0/INT 7 14 RB7/T1OSI/PGD
RB1/RX/DT 8 13 RB6/T1OSO/T1CKI/PGC
RB2/TX/CK 9 12 RB5
RB3/CCP1 10 11 RB4/PGM
Device Differences
Process
Voltage
Device Oscillator Technology
Range
(Microns)
PIC16F627 3.0 - 5.5 (Note 1) 0.7
PIC16F628 3.0 - 5.5 (Note 1) 0.7
PIC16LF627 2.0 - 5.5 (Note 1) 0.7
PIC16LF628 2.0 - 5.5 (Note 1) 0.7
Note 1: If you change from this device to another device, please verify oscillator characteristics in your
application.
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision
of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
• Microchip’s Worldwide Web site; http://www.microchip.com
• Your local Microchip sales office (see last page)
• The Microchip Corporate Literature Center; U.S. FAX: (480) 792-7277
When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include liter-
ature number) you are using.
13 Data Bus 8
FLASH Program Counter
Program
Memory RAM
8-Level Stack File
(13-bit) Registers
Program 14
Bus RAM Addr (1) 9 PORTA
3 MUX PORTB
Power-up
Timer RB0/INT
RB1/RX/DT
Instruction Oscillator
Decode & Start-up Timer RB2/TX/CK
ALU RB3/CCP1
Control
Power-on RB4/PGM
Reset 8
RB5
Timing Watchdog RB6/T1OSO/T1CKI/PGC
Generation Timer W reg
RB7/T1OSI/PGD
OSC1/CLKIN Brown-out
OSC2/CLKOUT Detect
Low-voltage
Programming
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
Q1
Q2 Internal
phase
Q3 clock
Q4
PC PC PC+1 PC+2
CLKOUT
Fetch INST (PC)
Execute INST (PC-1) Fetch INST (PC+1)
Execute INST (PC) Fetch INST (PC+2)
Execute INST (PC+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.
On-chip Program
Memory
PIC16F628 only
07FFh
1FFFh
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 PCL 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 105h 185h
PORTB 06h TRISB 86h PORTB 106h TRISB 186h
07h 87h 107h 187h
08h 88h 108h 188h
09h 89h 109h 189h
PCLATH 0Ah PCLATH 8Ah PCLATH 10Ah PCLATH 18Ah
INTCON 0Bh INTCON 8Bh INTCON 10Bh INTCON 18Bh
PIR1 0Ch PIE1 8Ch 10Ch 18Ch
0Dh 8Dh 10Dh 18Dh
TMR1L 0Eh PCON 8Eh 10Eh 18Eh
TMR1H 0Fh 8Fh 10Fh 18Fh
T1CON 10h 90h
TMR2 11h 91h
T2CON 12h PR2 92h
13h 93h
14h 94h
CCPR1L 15h 95h
CCPR1H 16h 96h
CCP1CON 17h 97h
RCSTA 18h TXSTA 98h
TXREG 19h SPBRG 99h
RCREG 1Ah EEDATA 9Ah
1Bh EEADR 9Bh
1Ch EECON1 9Ch
1Dh EECON2(1) 9Dh
1Eh 9Eh
CMCON 1Fh VRCON 9Fh 11Fh
20h General 120h
A0h Purpose
General General Register
Purpose Purpose 48 Bytes 14Fh
Register Register
150h
80 Bytes
80 Bytes
bit 7 IRP: Register Bank Select bit (used for indirect addressing)
1 = Bank 2, 3 (100h - 1FFh)
0 = Bank 0, 1 (00h - FFh)
bit 6-5 RP1:RP0: Register Bank Select bits (used for direct addressing)
00 = Bank 0 (00h - 7Fh)
01 = Bank 1 (80h - FFh)
10 = Bank 2 (100h - 17Fh)
11 = Bank 3 (180h - 1FFh)
bit 4 TO: Timeout bit
1 = After power-up, CLRWDT instruction, or SLEEP instruction
0 = A WDT timeout occurred
bit 3 PD: Power-down bit
1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
bit 2 Z: Zero bit
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero
bit 1 DC: Digit carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) (for borrow the polarity
is reversed)
1 = A carry-out from the 4th low order bit of the result occurred
0 = No carry-out from the 4th low order bit of the result
bit 0 C: Carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions)
1 = A carry-out from the Most Significant bit of the result occurred
0 = No carry-out from the Most Significant bit of the result occurred
Note 1: For borrow the polarity is reversed. A subtraction is executed by adding the two’s
complement of the second operand. For rotate (RRF, RLF) instructions, this bit is
loaded with either the high or low order bit of the source register.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
PCH PCL
3.4 Indirect Addressing, INDF and
12 8 7 0
FSR Registers
Instruction with
PC PCL as The INDF register is not a physical register. Addressing
Destination
PCLATH<4:0> 8 the INDF register will cause indirect addressing.
5 ALU result
Indirect addressing is possible by using the INDF
register. Any instruction using the INDF register actu-
PCLATH
ally accesses data pointed to by the file select register
(FSR). Reading INDF itself indirectly will produce 00h.
PCH PCL
Writing to the INDF register indirectly results in a no-
12 11 10 8 7 0
operation (although STATUS bits may be affected). An
PC GOTO, CALL
effective 9-bit address is obtained by concatenating the
2
PCLATH<4:3> 11 8-bit FSR register and the IRP bit (STATUS<7>), as
Opcode <10:0>
shown in Figure 3-4.
PCLATH A simple program to clear RAM location 20h-2Fh using
indirect addressing is shown in Example 3-1.
3.3.2 STACK
The PIC16F62X family has an 8-level deep x 13-bit
wide hardware stack (Figure 3-1 and Figure 3-2). The
stack space is not part of either program or data space
and the stack pointer is not readable or writable. The
PC is PUSHed onto the stack when a CALL instruction
is executed or an interrupt causes a branch. The stack
is POPed in the event of a RETURN, RETLW or a
RETFIE instruction execution. PCLATH is not affected
by a PUSH or POP operation.
RAM
File
Registers
7Fh 1FFh
Bank 0 Bank 1 Bank 2 Bank 3
D Q D Q
I/O Pin RA2 Pin
WR WR
TRISA TRISA
CK Q CK Q
VSS
TRIS Latch VSS TRIS Latch Analog
Input Mode
Analog
Input Mode RD
TRISA Schmitt Trigger
RD Schmitt Trigger Input Buffer
TRISA Input Buffer
Q D
Q D
EN
EN
RD PORTA
RD PORTA
To Comparator
To Comparator VROE
VREF
D Q
RA3 Pin
WR
TRISA
CK Q
VSS
TRIS Latch
Analog
Input Mode
RD
TRISA Schmitt Trigger
Input Buffer
Q D
EN
RD PORTA
To Comparator
Schmitt Trigger
Input Buffer
RD TRISA
Q D
EN
RD PORTA
CLKOUT(FOSC/4)
1
MCLRE
MCLR
circuit D Q 0
WR
MCLR Filter PORTA
CK Q
Program Schmitt Trigger (FOSC = VSS
(2) Data Latch
mode Input Buffer 101, 111)
HV Detect
RA5/MCLR/VPP
D Q
WR
Data TRISA
CK Q
Bus
VSS TRIS Latch
RD
TRISA Schmitt
Trigger
Input Buffer
FOSC =
RD (1)
100, 110
TRISA VSS
Q D
Q D
EN
EN RD PORTA
RD
PORTA Note 1: INTRC with RA6 = I/O or ER with RA6 = I/O.
2: INTRC with RA6 = CLKOUT or ER with RA6 = CLK-
OUT.
To OSC2 Oscillator
Circuit
Data Bus
D Q
RA7/OSC1/CLKIN Pin
WR PORTA
CK Q
Data Latch
D VSS
Q
WR TRISA
CK Q
TRIS Latch
RD TRISA
Q D
Schmitt Trigger
Input Buffer
EN
RD PORTA
5.2 PORTB and TRISB Registers This interrupt on mismatch feature, together with
software configurable pull-ups on these four pins allow
PORTB is an 8-bit wide bi-directional port. The easy interface to a key pad and make it possible for
corresponding data direction register is TRISB. A '1' in wake-up on key-depression. (See AN552)
the TRISB register puts the corresponding output driver
in a Hi-impedance mode. A '0' in the TRISB register Note: If a change on the I/O pin should occur
puts the contents of the output latch on the selected when a read operation is being executed
pin(s). (start of the Q2 cycle), then the RBIF inter-
rupt flag may not get set.
PORTB is multiplexed with the external interrupt,
USART, CCP module and the TMR1 clock input/output. The interrupt-on-change feature is recommended for
The standard port functions and the alternate port wake-up on key depression operation and operations
functions are shown in Table 5-3. Alternate port where PORTB is only used for the interrupt-on-change
functions override TRIS setting when enabled. feature. Polling of PORTB is not recommended while
using the interrupt-on-change feature.
Reading PORTB register reads the status of the pins,
whereas writing to it will write to the port latch. All write
operations are read-modify-write operations. So a write
to a port implies that the port pins are first read, then
this value is modified and written to the port data latch.
Each of the PORTB pins has a weak internal pull-up
(≈200 µA typical). A single control bit can turn on all the
pull-ups. This is done by clearing the RBPU
(OPTION<7>) bit. The weak pull-up is automatically
turned off when the port pin is configured as an output.
The pull-ups are disabled on Power-on Reset.
Four of PORTB’s pins, RB<7:4>, have an interrupt-on-
change feature. Only pins configured as inputs can
cause this interrupt to occur (i.e., any RB<7:4> pin con-
figured as an output is excluded from the interrupt-on-
change comparison). The input pins (of RB7:RB4) are
compared with the old value latched on the last read of
PORTB. The “mismatch” outputs of RB7:RB4 are
OR’ed together to generate the RBIF interrupt (flag
latched in INTCON<0>).
This interrupt can wake the device from SLEEP. The
user, in the interrupt service routine, can clear the
interrupt in the following manner:
a) Any read or write of PORTB. This will end the
mismatch condition.
b) Clear flag bit RBIF.
A mismatch condition will continue to set flag bit RBIF.
Reading PORTB will end the mismatch condition and
allow flag bit RBIF to be cleared.
Data Bus D
Data Bus Q 1 RB1/
D Q
RX/DT
RB0/INT WR PORTB
WR PORTB CK Q
CK Q
Data Latch VSS
Data Latch VSS
D Q
D Q WR TRISB
CK Q
WR TRISB
CK Q TRIS Latch
Peripheral OE(2)
TRIS Latch
TTL
RD TRISB Input
TTL Buffer
RD TRISB
Input Q D
Buffer
Q D EN
RD PORTB
EN
EN
WR PORTB WR PORTB
CK Q CK Q
D Q D Q
WR TRISB WR TRISB
CK Q CK Q
TTL TTL
RD TRISB Input RD TRISB Input
Buffer Buffer
Q D Q D
EN EN
RD PORTB RD PORTB
Note 1: Port/Peripheral select signal selects between port Note 1: Port/Peripheral select signal selects between port
data and peripheral output. data and peripheral output.
2: Peripheral OE (output enable) is only active if 2: Peripheral OE (output enable) is only active if
peripheral select is active. peripheral select is active.
Data Bus
D Q VDD
WR PORTB
CK Q
Data Latch
RB4/PGM
D Q
WR TRISB
CK Q
VSS
TRIS Latch
RD TRISB
LVP
RD PORTB
PGM input
TTL
Schmitt
input
Trigger
buffer
Q D
EN Q1
Set RBIF
From other Q D
RB<7:4> pins
Q3
EN
Note 1: The low voltage programming disables the interrupt-on-change and the weak pull-ups on RB4.
Data Bus
D Q
RB5 pin
WR PORTB
CK Q
Data Latch
VSS
D Q
WR TRISB
CK Q
TRIS Latch
TTL
input
buffer
RD TRISB
Q D
RD PORTB
EN Q1
Set RBIF
From other Q D
RB<7:4> pins
Q3
EN
VDD
RBPU
P weak pull-up
Data Bus
D Q
VDD
WR PORTB
CK Q
Data Latch
RB6/
D Q T1OSO/
T1CKI
WR TRISB pin
CK Q
VSS
TRIS Latch
RD TRISB
T1OSCEN
TTL
input
buffer
RD PORTB
TMR1 Clock
Schmitt
From RB7 Trigger
Q D
EN
Set RBIF
From other Q D
RB<7:4> pins
Q3
EN
VDD
Data Bus
D Q
WR PORTB RB7/T1OSI
CK Q
pin
Data Latch
D Q VSS
WR TRISB
CK Q
TRIS Latch
RD TRISB
T10SCEN
TTL
RD PORTB input
buffer
Schmitt
Trigger
Q D
EN
Set RBIF
From other Q D
RB<7:4> pins
EN
81h, 181h OPTION RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0 1111 1111 1111 1111
Legend: u = unchanged, x = unknown
Note 1: Shaded bits are not used by PORTB.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
PC PC PC + 1 PC + 2 PC + 3
Instruction MOWF PORTB MOWF PORTB, W NOP NOP
fetched Write to PORTB Read to PORTB
Port pin
sampled here
TPD
Execute Execute Execute
MOVWF MOVWF NOP
PORTB PORTB
Note 1: This example shows write to PORTB followed by a read from PORTB.
2: Data setup time = (0.25 TCY - TPD) where TCY = instruction cycle and TPD = propagation delay of Q1 cycle to output valid.
Therefore, at higher clock frequencies, a write followed by a read may be problematic.
0 8
1
T0CKI SYNC
Pin 1 2 TMR0 reg
Cycles
0
T0SE
T0CS
Set Flag Bit T0IF
PSA on Overflow
WDT Postscaler/
0 TMR0 Prescaler
Watchdog 1 8
Timer
WDT
Timeout
Note 1: T0SE, T0CS, PSA, .PS0-PS2 are bits in the Option Register.
81h, 181h OPTION(2) RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0 1111 1111 1111 1111
85h TRISA TRISA7 TRISA6 TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 1111 1111 1111 1111
Legend: — = Unimplemented locations, read as ‘0’, u = unchanged, x = unknown
Note 1: Shaded bits are not used by TMR0 module.
2: Option is referred by OPTION_REG in MPLAB.
Counter mode is selected by setting bit TMR1CS. In When the prescaler is 1:1, the external clock input is
this mode the timer increments on every rising edge of the same as the prescaler output. The synchronization
clock input on pin RB7/T1OSI when bit T1OSCEN is of T1CKI with the internal phase clocks is accom-
set or pin RB6/T1OSO/T1CKI when bit T1OSCEN is plished by sampling the prescaler output on the Q2 and
cleared. Q4 cycles of the internal phase clocks. Therefore, it is
necessary for T1CKI to be high for at least 2Tosc (and
If T1SYNC is cleared, then the external clock input is a small RC delay of 20 ns) and low for at least 2Tosc
synchronized with internal phase clocks. The synchro- (and a small RC delay of 20 ns). Refer to the appropri-
nization is done after the prescaler stage. The ate electrical specifications, parameters 45, 46, and 47.
prescaler stage is an asynchronous ripple-counter.
When a prescaler other than 1:1 is used, the external
In this configuration, during SLEEP mode, Timer1 will clock input is divided by the asynchronous ripple-
not increment even if the external clock is present, counter type prescaler so that the prescaler output is
since the synchronization circuit is shut off. The symmetrical. In order for the external clock to meet the
prescaler however will continue to increment. sampling requirement, the ripple-counter must be
taken into account. Therefore, it is necessary for T1CKI
to have a period of at least 4Tosc (and a small RC delay
of 40 ns) divided by the prescaler value. The only
requirement on T1CKI high and low time is that they do
not violate the minimum pulse width requirements of 10
ns). Refer to the appropriate electrical specifications,
parameters 40, 42, 45, 46, and 47.
Note 1: When the T1OSCEN bit is cleared, the inverter and feedback resistor are turned off. This eliminates power drain.
Postscaler 2
Comparator
1:1 to 1:16 EQ
T2CKPS<1:0>
4 PR2 reg
TOUTPS<3:0>
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
8Ch PIE1 EEIE CMIE RCIE TXIE — CCP1IE TMR2IE TMR1IE 0000 -000 0000 -000
12h T2CON — TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
92h PR2 Timer2 Period Register 1111 1111 1111 1111
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by the Timer2 module.
When C2INV = 1:
1 = C2 VIN+ < C2 VIN-
0 = C2 VIN+ > C2 VIN-
bit 6 C1OUT: Comparator 1 Output
When C1INV = 0:
1 = C1 VIN+ > C1 VIN-
0 = C1 VIN+ < C1 VIN-
When C1INV = 1:
1 = C1 VIN+ < C1 VIN-
0 = C1 VIN+ > C1 VIN-
bit 5 C2INV: Comparator 2 Output Inversion
1 = C2 Output inverted
0 = C2 Output not inverted
bit 4 C1INV: Comparator 1 Output Inversion
1 = C1 Output inverted
0 = C1 Output not inverted
bit 3 CIS: Comparator Input Switch
When CM2:CM0: = 001
Then:
1 = C1 VIN- connects to RA3
0 = C1 VIN- connects to RA0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
D VIN-
RA1/AN1 A VIN- RA1/AN1
Off (Read as '0') D VIN+ C2 Off (Read as '0')
RA2/AN2 A VIN+ C2 RA2/AN2
VSS
Four Inputs Multiplexed to Two Comparators
Two Independent Comparators CM2:CM0 = 010
CM2:CM0 = 100
RA0/AN0 A
A VIN- CIS = 0 VIN-
RA0/AN0
C1 C1VOUT RA3/AN3/CMP1 A CIS = 1
C1 C1VOUT
A VIN+ VIN+
RA3/AN3/CMP1
RA1/AN1 A
CIS = 0 VIN-
RA1/AN1 A VIN- RA2/AN2 A CIS = 1 C2VOUT
VIN+ C2
C2 C2VOUT
RA2/AN2 A VIN+
From VREF
Module
Two Common Reference Comparators Two Common Reference Comparators with Outputs
CM2:CM0 = 011 CM2:CM0 = 110
A VIN-
A VIN- RA0/AN0
RA0/AN0 C1VOUT
D VIN+ C1
D VIN+ C1 C1VOUT RA3/AN3/CMP1
RA3/AN3/CMP1
RA1/AN1 A VIN-
RA1/AN1 A VIN-
C2VOUT A VIN+ C2 C2VOUT
RA2/AN2 A VIN+ C2 RA2/AN2/CMP2
CnINV
EN
RD CMCON
EN Q1
CL
From other Comparator
RESET
VT = 0.6V RIC
RS < 10K
AIN
CPIN ILEAKAGE
VA VT = 0.6V ±500 nA
5 pF
VSS
Legend CPIN = Input Capacitance
VT = Threshold Voltage
ILEAKAGE = Leakage Current At The Pin
RIC = Interconnect Resistance
RS = Source Impedance
VA = Analog Voltage
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
VREN
8R R R R R
8R Vrr
VSS VSS
Vr3
Vref 16-1 Analog Mux (From VRCON<3:0>)
Vr0
Op Amp
R(1) RA2
VREF +
Module VREF Output
Voltage
Reference
Output
Impedance
Note 1: R is dependent upon the Voltage Reference Configuration VRCON<3:0> and VRCON<5>.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
REGISTER 12-1: TXSTA: TRANSMIT STATUS AND CONTROL REGISTER (ADDRESS: 98h)
R/W-0 R/W-0 R/W-0 R/W-0 U-0 R/W-0 R-1 R/W-0
CSRC TX9 TXEN SYNC — BRGH TRMT TX9D
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
BAUD FOSC = 3.579545 MHz SPBRG 1 MHz SPBRG 32.768 MHz SPBRG
RATE value value value
(K) KBAUD ERROR (decimal) KBAUD ERROR (decimal) KBAUD ERROR (decimal)
0.3 NA — — NA — — 0.303 +1.14% 26
1.2 NA — — 1.202 +0.16% 207 1.170 -2.48% 6
2.4 NA — — 2.404 +0.16% 103 NA — —
9.6 9.622 +0.23% 92 9.615 +0.16% 25 NA — —
19.2 19.04 -0.83% 46 19.24 +0.16% 12 NA — —
76.8 74.57 -2.90% 11 83.34 +8.51% 2 NA — —
96 99.43 +3.57% 8 NA — — NA — —
300 298.3 0.57% 2 NA — — NA — —
500 NA — — NA — — — —
HIGH 894.9 — 0 250 — 0 8.192 — 0
LOW 3.496 — 255 0.9766 — 255 0.032 — 255
BAUD FOSC = 3.579545 MHz SPBRG 1 MHz SPBRG 32.768 MHz SPBRG
RATE value value value
(K) KBAUD ERROR (decimal) KBAUD ERROR (decimal) KBAUD ERROR (decimal)
0.3 0.301 +0.23% 185 0.300 +0.16% 51 0.256 -14.67% 1
1.2 1.190 -0.83% 46 1.202 +0.16% 12 NA — —
2.4 2.432 +1.32% 22 2.232 -6.99% 6 NA — —
9.6 9.322 -2.90% 5 NA — — NA — —
19.2 18.64 -2.90% 2 NA — — NA — —
76.8 NA — — NA — — NA — —
96 NA — — NA — — NA — —
300 NA — — NA — — NA — —
500 NA — — NA — — NA — —
HIGH 55.93 — 0 15.63 — 0 0.512 — 0
LOW 0.2185 — 255 0.0610 — 255 0.0020 — 255
BAUD FOSC = 3.579 MHz SPBRG 1 MHz SPBRG 32.768 MHz SPBRG
RATE value value value
(K) KBAUD ERROR (decimal) KBAUD ERROR (decimal) KBAUD ERROR (decimal)
9600 9725.543 1.308% 22 8.928 -6.994% 6 NA NA NA
19200 18640.63 -2.913% 11 20833.3 8.507% 2 NA NA NA
38400 37281.25 -2.913% 5 31250 -18.620% 1 NA NA NA
57600 55921.88 -2.913% 3 62500 +8.507 0 NA NA NA
115200 111243.8 -2.913% 1 NA — — NA NA NA
250000 223687.5 -10.525% 0 NA — — NA NA NA
625000 NA — — NA — — NA NA NA
1250000 NA — — NA — — NA NA NA
x16 CLK
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3
Samples
baud clk
First falling edge after RX pin goes low
Second rising edge
x4 clk
1 2 3 4 1 2 3 4 1 2
Q2, Q4 clk
Q2, Q4 CLK
Samples
x16 CLK
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3
Samples
12.2 USART Asynchronous Mode software. It will RESET only when new data is loaded
into the TXREG register. While flag bit TXIF indicated
In this mode, the USART uses standard non-return to the status of the TXREG register, another bit TRMT
zero (NRZ) format (one START bit, eight or nine data (TXSTA<1>) shows the status of the TSR register.
bits and one STOP bit). The most common data format STATUS bit TRMT is a read only bit which is set when
is 8 bits. A dedicated 8-bit baud rate generator is used the TSR register is empty. No interrupt logic is tied to
to derive baud rate frequencies from the oscillator. The this bit, so the user has to poll this bit in order to
USART transmits and receives the LSb first. The determine if the TSR register is empty.
USART’s transmitter and receiver are functionally
independent but use the same data format and baud Note 1: The TSR register is not mapped in data
rate. The baud rate generator produces a clock either memory so it is not available to the user.
x16 or x64 of the bit shift rate, depending on bit BRGH 2: Flag bit TXIF is set when enable bit TXEN
(TXSTA<2>). Parity is not supported by the hardware, is set.
but can be implemented in software (and stored as the
Transmission is enabled by setting enable bit TXEN
ninth data bit). Asynchronous mode is stopped during
(TXSTA<5>). The actual transmission will not occur
SLEEP.
until the TXREG register has been loaded with data
Asynchronous mode is selected by clearing bit SYNC and the baud rate generator (BRG) has produced a
(TXSTA<4>). shift clock (Figure 12-5). The transmission can also be
The USART Asynchronous module consists of the started by first loading the TXREG register and then
following important elements: setting enable bit TXEN. Normally when transmission
is first started, the TSR register is empty, so a transfer
• Baud Rate Generator
to the TXREG register will result in an immediate
• Sampling Circuit transfer to TSR resulting in an empty TXREG. A back-
• Asynchronous Transmitter to-back transfer is thus possible (Figure 12-7). Clearing
• Asynchronous Receiver enable bit TXEN during a transmission will cause the
transmission to be aborted and will RESET the
12.2.1 USART ASYNCHRONOUS transmitter. As a result the RB2/TX/CK pin will revert to
TRANSMITTER hi-impedance.
The USART transmitter block diagram is shown in In order to select 9-bit transmission, transmit bit TX9
Figure 12-5. The heart of the transmitter is the transmit (TXSTA<6>) should be set and the ninth bit should be
(serial) shift register (TSR). The shift register obtains its written to TX9D (TXSTA<0>). The ninth bit must be
data from the read/write transmit buffer, TXREG. The written before writing the 8-bit data to the TXREG
TXREG register is loaded with data in software. The register. This is because a data write to the TXREG
TSR register is not loaded until the STOP bit has been register can result in an immediate transfer of the data
transmitted from the previous load. As soon as the to the TSR register (if the TSR is empty). In such a
STOP bit is transmitted, the TSR is loaded with new case, an incorrect ninth data bit may be loaded in the
data from the TXREG register (if available). Once the TSR register.
TXREG register transfers the data to the TSR register
(occurs in one TCY), the TXREG register is empty and
flag bit TXIF (PIR1<4>) is set. This interrupt can be
enabled/disabled by setting/clearing enable bit TXIE
( PIE1<4>). Flag bit TXIF will be set regardless of the
state of enable bit TXIE and cannot be cleared in
Write to TXREG
Word 1
BRG output
(shift clock)
RB2/TX/CK (pin)
START Bit Bit 0 Bit 1 Bit 7/8 STOP Bit
WORD 1
TXIF bit
(Transmit buffer
reg. empty flag)
Write to TXREG
WORD 1 WORD 2
BRG output
(shift clock)
RB2/TX/CK (pin)
START Bit Bit 0 Bit 1 Bit 7/8 STOP Bit START Bit Bit 0
TXIF bit
(interrupt reg. flag) WORD 1 WORD 2
RB1/RX/DT
Pin Buffer Data
and Control Recovery RX9
SPEN
RX9 Enable
ADEN Load of
RX9 Receive
Buffer
ADEN
RSR<8> 8
Interrupt RCIF
Data Bus
RCIE
RCIF
(INTERRUPT FLAG)
'1' '1'
ADEN = 1
(ADDRESS MATCH
ENABLE)
Note 1: 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.
RCIF
(INTERRUPT FLAG)
'1' '1'
ADEN = 1
(ADDRESS MATCH
ENABLE)
Note 1: 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.
RCIF
(INTERRUPT FLAG)
ADEN
(ADDRESS MATCH
ENABLE)
Note 1: 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.
Q1Q2 Q3Q4 Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2 Q3Q4 Q3Q4 Q1Q2 Q3Q4 Q1Q2 Q3Q4 Q1Q2 Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4
TRMTTRMT
Bit
'1' '1'
TXEN Bit
Note 1: Sync Master mode; SPBRG = ‘0’. Continuous transmission of two 8-bit words.
RB2/TX/CK pin
Write to
TXREG reg
TXIF bit
TRMT bit
TXEN bit
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' '0'
RCIF BIT
(INTERRUPT)
READ
RXREG
Note 1: Timing diagram demonstrates Sync Master mode with bit SREN = ‘1’ and bit BRG = ‘0’.
12.5 USART Synchronous Slave Mode Steps to follow when setting up a Synchronous Slave
Transmission:
Synchronous Slave mode differs from the Master mode
in the fact that the shift clock is supplied externally at 1. Enable the synchronous slave serial port by
the RB2/TX/CK pin (instead of being supplied internally setting bits SYNC and SPEN and clearing bit
in Master mode). This allows the device to transfer or CSRC.
receive data while in SLEEP mode. Slave mode is 2. Clear bits CREN and SREN.
entered by clearing bit CSRC (TXSTA<7>). 3. If interrupts are desired, then set enable bit
TXIE.
12.5.1 USART SYNCHRONOUS SLAVE 4. If 9-bit transmission is desired, then set bit TX9.
TRANSMIT 5. Enable the transmission by setting enable bit
The operation of the Synchronous Master and Slave TXEN.
modes are identical except in the case of the SLEEP 6. If 9-bit transmission is selected, the ninth bit
mode. should be loaded in bit TX9D.
If two words are written to the TXREG and then the 7. Start transmission by loading data to the TXREG
SLEEP instruction is executed, the following will occur: register.
a) The first word will immediately transfer to the
TSR register and transmit.
b) The second word will remain in TXREG register.
c) Flag bit TXIF will not be set.
d) When the first word has been shifted out of TSR,
the TXREG register will transfer the second
word to the TSR and flag bit TXIF will now be
set.
e) If enable bit TXIE is set, the interrupt will wake
the chip from SLEEP and if the global interrupt
is enabled, the program will branch to the
interrupt vector (0004h).
EEDATA holds the 8-bit data for read/write, and Additional information on the Data EEPROM is
EEADR holds the address of the EEPROM location available in the PICmicro™ Mid-Range Reference
being accessed. PIC16F62X devices have 128 bytes of Manual, (DS33023).
data EEPROM with an address range from 0h to 7Fh.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
13.1 EEADR The WREN bit, when set, will allow a write operation.
On power-up, the WREN bit is clear. The WRERR bit is
The EEADR register can address up to a maximum of set when a write operation is interrupted by a MCLR
256 bytes of data EEPROM. Only the first 128 bytes of Reset or a WDT Timeout Reset during normal
data EEPROM are implemented and only seven of the operation. In these situations, following RESET, the
eight bits in the register (EEADR<6:0>) are required. user can check the WRERR bit and rewrite the
The upper bit is address decoded. This means that this location. The data and address will be unchanged in
bit should always be '0' to ensure that the address is in the EEDATA and EEADR registers.
the 128 byte memory space. Interrupt flag bit EEIF in the PIR1 register is set when
write is complete. This bit must be cleared in software.
13.2 EECON1 AND EECON2
EECON2 is not a physical register. Reading EECON2
REGISTERS
will read all '0's. The EECON2 register is used
EECON1 is the control register with five low order bits exclusively in the Data EEPROM write sequence.
physically implemented. The upper-three bits are non-
existent and read as '0's.
Control bits RD and WR initiate read and write,
respectively. These bits cannot be cleared, only set, in
software. They are cleared in hardware at completion
of the read or write operation. The inability to clear the
WR bit in software prevents the accidental, premature
termination of a write operation.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ’1’ = Bit is set ’0’ = Bit is cleared x = Bit is unknown
MOVLW 55h ;
write to the data EEPROM memory. To protect against
Required
1. OSC selection
2. RESET
3. Power-on Reset (POR)
4. Power-up Timer (PWRT)
5. Oscillator Start-Up Timer (OST)
6. Brown-out Reset (BOD)
7. Interrupts
8. Watchdog Timer (WDT)
9. SLEEP
10. Code protection
11. ID Locations
12. In-circuit Serial Programming
The PIC16F62X has a Watchdog Timer which is
controlled by configuration bits. It runs off its own RC
oscillator for added reliability. There are two timers that
offer necessary delays on power-up. One is the
Oscillator Start-up Timer (OST), intended to keep the
chip in RESET until the crystal oscillator is stable. The
other is the Power-up Timer (PWRT), which provides a
fixed delay of 72 ms (nominal) on power-up only,
designed to keep the part in RESET while the power
supply stabilizes. There is also circuitry to RESET the
device if a Brown-out occurs, which provides at least a
72 ms RESET. With these three functions on-chip,
most applications need no external RESET circuitry.
The SLEEP mode is designed to offer a very low
current Power-down mode. The user can wake-up from
SLEEP through external RESET, Watchdog Timer
wake-up or through an interrupt. Several oscillator
options are also made available to allow the part to fit
the application. The ER oscillator option saves system
cost while the LP crystal option saves power. A set of
configuration bits are used to select various options.
CP1 CP0 CP1 CP0 — CPD LVP BODEN MCLRE FOSC2 PWRTE WDTE F0SC1 F0SC0
bit 13 bit 0
Legend
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR 1 = bit is set 0 = bit is cleared x = bit is unknown
Resistance Frequency
14.2.4 EXTERNAL CLOCK IN 0 10.4 MHz
For applications, where a clock is already available 1K 10 MHz
elsewhere, users may directly drive the PIC16F62X
10K 7.4 MHz
provided that this external clock source meets the
AC/DC timing requirements listed in Section 17.4. 20K 5.3 MHz
Figure 14-4 shows how an external clock circuit should 47K 3 MHz
be configured. 100K 1.6 MHz
220K 800 kHz
FIGURE 14-4: EXTERNAL CLOCK INPUT
470K 300 kHz
OPERATION (EC, HS, XT
OR LP OSC 1M 200 kHz
CONFIGURATION) The ER Oscillator mode has two options that control
the unused OSC2 pin. The first allows it to be used as
Clock From
OSC1/RA7 a general purpose I/O port. The other configures the
ext. system
PIC16F62X
pin as an output providing the FOSC signal (internal
clock divided by 4) for test or external synchronization
RA6 OSC2/RA6
purposes.
OST/PWRT
OST
Chip_Reset
10-bit Ripple-counter
R Q
OSC1/
CLKIN
Pin
PWRT
On-chip(1)
OSC 10-bit Ripple-counter
Enable OST
Note 1: This is a separate oscillator from the INTRC/ER oscillator.
The POR circuit does not produce an internal RESET 14.5.4 BROWN-OUT DETECT (BOD)
when VDD declines. RESET
When the device starts normal operation (exits the
The PIC16F62X members have on-chip BOD circuitry.
RESET condition), device operating parameters (volt-
A configuration bit, BODEN, can disable (if clear/
age, frequency, temperature, etc.) must be met to
programmed) or enable (if set) the BOD Reset circuitry.
ensure operation. If these conditions are not met, the
If VDD falls below VBOD for longer than TBOD, the
device must be held in RESET until the operating
brown-out situation will RESET the chip. A RESET is
conditions are met.
not guaranteed to occur if VDD falls below VBOD for
For additional information, refer to Application Note shorter than TBOD. VBOD and TBOD are defined in
AN607, “Power-up Trouble Shooting”. Table 17-1 and Table 17-6, respectively.
14.5.2 POWER-UP TIMER (PWRT) On any RESET (Power-on, Brown-out, Watchdog, etc.)
the chip will remain in RESET until VDD rises above
The PWRT provides a fixed 72 ms (nominal) timeout VBOD. The Power-up Timer will now be invoked and will
on power-up only, from POR or Brown-out Detect keep the chip in RESET an additional 72 ms.
Reset. The PWRT operates on an internal RC oscilla-
If VDD drops below VBOD while the Power-up Timer is
tor. The chip is kept in RESET as long as PWRT is
running, the chip will go back into a Brown-out Detect
active. The PWRT delay allows the VDD to rise to an
Reset and the Power-up Timer will be re-initialized.
acceptable level. A configuration bit, PWRTE can
Once VDD rises above VBOD, the Power-Up Timer will
disable (if set) or enable (if cleared or programmed) the
execute a 72 ms RESET. The Power-up Timer should
PWRT. The PWRT should always be enabled when
always be enabled when Brown-out Detect is enabled.
Brown-out Detect Reset is enabled.
Figure 14-7 shows typical Brown-out situations.
VDD
VBOD
INTERNAL <72 MS
RESET 72 MS
VDD
VBOD
INTERNAL
72 MS
RESET
XT, HS, LP 72 ms + 1024 TOSC 1024 TOSC 72 ms + 1024 TOSC 1024 TOSC
ER, INTRC, EC 72 ms — 72 ms —
0 X 1 1 Power-on Reset
MCLR Reset during normal operation 000h 000u uuuu ---- 1-uu
VDD
MCLR
INTERNAL POR
Tpwrt
OST TIMEOUT
INTERNAL RESET
FIGURE 14-9: TIMEOUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 2
VDD
MCLR
INTERNAL POR
Tpwrt
OST TIMEOUT
INTERNAL RESET
VDD
MCLR
INTERNAL POR
Tpwrt
OST TIMEOUT
INTERNAL RESET
Q1
D MCLR
R
R2 40k
R1 PIC16F62X
MCLR
PIC16F62X
C
Note 1: This Brown-out Circuit is less expensive, albeit
less accurate. Transistor Q1 turns off when VDD is
Note 1: External Power-on Reset circuit is required below a certain level such that:
only if VDD power-up slope is too slow. The R1
VDD x = 0.7V
diode D helps discharge the capacitor R1 + R2
quickly when VDD powers down. 2: Internal Brown-out R1Detect Reset should be
2: R < 40 kΩ is recommended to make sure disabled
Vdd when
x using this circuit.
= 0.7 V
that voltage drop across R does not violate 3: Resistors shouldR1 be+adjusted
R2 for the
characteristics of the transistor.
the device’s electrical specification.
3: R1 = 100Ω to 1 kΩ will limit any current
flowing into MCLR from external capacitor
C in the event of MCLR/VPP pin breakdown
due to Electrostatic Discharge (ESD) or
Electrical Overstress (EOS).
10k MCLR
40k PIC16F62X
0
M WDT POSTSCALER/
U TMR0 PRESCALER
Watchdog
Timer 1X
8
8 to 1 MUX PS<2:0>
PSA 3
WDT
Enable Bit
To TMR0
(Figure 6-1)
0 1 PSA
MUX
WDT
Timeout
Note 1: T0SE, T0CS, PSA, PS0-PS2 are bits in the OPTION register.
2007h Config. LVP BODEN MCLRE FOSC2 PWRTE WDTE FOSC1 FOSC0 uuuu uuuu uuuu uuuu
bits
81h OPTION RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0 1111 1111 1111 1111
_
Legend: = Unimplemented location, read as “0”, + = Reserved for future use
Note 1: Shaded cells are not used by the Watchdog Timer.
14.9 Power-Down Mode (SLEEP) For lowest current consumption in this mode, all I/O
pins should be either at VDD, or VSS, with no external
The Power-down mode is entered by executing a circuitry drawing current from the I/O pin and the com-
SLEEP instruction. parators, and VREF should be disabled. I/O pins that
If enabled, the Watchdog Timer will be cleared but are hi-impedance inputs should be pulled high or low
keeps running, the PD bit in the STATUS register is externally to avoid switching currents caused by float-
cleared, the TO bit is set, and the oscillator driver is ing inputs. The T0CKI input should also be at VDD or
turned off. The I/O ports maintain the status they had, VSS for lowest current consumption. The contribution
before SLEEP was executed (driving high, low, or hi- from on-chip pull-ups on PORTB should be considered.
impedance). The MCLR pin must be at a logic high level (VIHMC).
Note: It should be noted that a RESET generated
by a WDT timeout does not drive MCLR
pin low.
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
CLKOUT(4) Tost(2)
INT pin
INTF flag
(INTCON<1>) Interrupt Latency
(Note 2)
GIE bit
(INTCON<7>) Processor in
SLEEP
INSTRUCTION FLOW
PC PC PC+1 PC+2 PC+2 PC + 2 0004h 0005h
Instruction Inst(PC + 1) Inst(PC + 2) Inst(0004h) Inst(0005h)
Fetched Inst(PC) = SLEEP
Instruction SLEEP Inst(PC + 1) Dummy cycle Dummy cycle
Executed Inst(PC - 1) Inst(0004h)
To Normal
Connections
External
Connector PIC16F62X
Signals
+5V VDD
0V VSS
VPP RA5/MCLR/VPP
CLK RB6/PGC
VDD
To Normal
Connections
Description: If bit 'b' in register 'f' is '1' then the Encoding: 10 0kkk kkkk kkkk
next instruction is skipped. Description: Call Subroutine. First, return
If bit 'b' is '1', then the next address (PC+1) is pushed onto
instruction fetched during the the stack. The eleven bit
current instruction execution, is immediate address is loaded
discarded and a NOP is executed into PC bits <10:0>. The upper
instead, making this a two-cycle bits of the PC are loaded from
instruction. PCLATH. CALL is a two-cycle
Words: 1 instruction.
Words: 1 Cycles: 1
Cycles: 2
Words: 1
Example CALL TABLE;W contains table
;offset value Cycles: 1
• ;W now has table Example RLF REG1, 0
value
• Before Instruction
TABLE
• REG1 = 1110 0110
ADDWF PC ;W = offset C = 0
RETLW k1 ;Begin table After Instruction
RETLW k2 ; REG1 = 1110 0110
• W = 1100 1100
• C = 1
•
RETLW kn ; End of table
Before Instruction
W = 0x07
After Instruction
W = value of k8
PIC16C5X
PIC16C6X
PIC16C7X
PIC16C8X
PIC17C4X
PIC16F62X
PIC16C43X
PIC16C7X5
PIC16F8XX
PIC12FXXX
PIC16C7XX
PIC16C9XX
PIC17C7XX
PIC18CXX2
PIC18FXXX
PIC12CXXX
PIC16CXXX
MPLAB Integrated
TABLE 16-1:
Development Environment
DS40300C-page 126
Device#
Software Tools
MPLAB C30 C Compiler
MPLAB ASM30
Assembler/Linker/Librarian
PRO MATE II
Universal Device Programmer **
Preliminary
Programmers Debugger Emulators
†
DEVELOPMENT TOOLS FROM MICROCHIP
PICDEM 17 Demonstration
Board
* Contact the Microchip web site at www.microchip.com for information on how to use the MPLAB ICD In-Circuit Debugger (DV164001) with PIC16C62, 63, 64, 65, 72, 73, 74, 76, 77.
** Contact Microchip Technology Inc. for availability date.
†
Development tool is available on select devices.
Note: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latchup. 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
6.0
5.5
5.0
4.5
VDD
(VOLTS)
4.0
3.5
3.0
2.5
0 4 10 20 25
FREQUENCY (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
FIGURE 17-2: PIC16F62X VOLTAGE-FREQUENCY GRAPH, -40°C ≤ TA < 0°C, +70°C < TA ≤ 85°C
6.0
5.5
5.0
4.5
VDD
(VOLTS)
4.0
3.5
3.0
2.5
2.0
0 4 10 20 25
FREQUENCY (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
5.5
5.0
4.5
VDD
(VOLTS)
4.0
3.5
3.0
2.5
2.0
0 4 10 20 25
FREQUENCY (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
5.5
5.0
4.5
VDD
(VOLTS)
4.0
3.5
3.0
2.5
2.0
0 4 10 20 25
FREQUENCY (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
Param
Sym Characteristic/Device Min Typ† Max Units Conditions
No.
VDD Supply Voltage
D001 PIC16LF62X 2.0 — 5.5 V
D001 PIC16F62X 3.0 — 5.5 V
D002 VDR RAM Data Retention — 1.5 — V Device in SLEEP mode*
Voltage(1)
D003 VPOR VDD Start Voltage — VSS — V See section on Power-on Reset
to ensure Power-on Reset for details
D004 SVDD VDD Rise Rate 0.05 — — V/ms See section on Power-on Reset
to ensure Power-on Reset for details*
D005 VBOD Brown-out Detect Voltage 3.65 4.0 4.35 V BODEN configuration bit is set
3.65 — 4.4 V BODEN configuration bit is set,
Extended
IDD Supply Current(2), (5)
D010 PIC16LF62X — 0.30 0.6 mA Fosc = 4.0 MHz, VDD = 2.0(5)
— 1.10 2.0 mA FOSC = 4.0 MHz, VDD = 5.5*
D013 — 4.0 7.0 mA Fosc = 20.0 MHz, VDD = 5.5
— 3.80 6.0 mA Fosc = 20.0 MHz, VDD = 4.5*
— — 2.0 mA FOSC = 10.0 MHz, VDD = 3.0(6)
— 20 30 µA FOSC = 32 kHz, VDD = 2.0
D010 PIC16F62X — 0.60 0.7 mA Fosc = 4.0 MHz, VDD = 3.0
— 1.10 2.0 mA Fosc = 4.0 MHz, VDD = 5.5*
D013 — 4.0 7.0 mA FOSC = 20.0 MHz, VDD = 5.5
— 3.80 6.0 mA FOSC = 20.0 MHz, VDD = 4.5*
— — 2.0 mA FOSC = 10.0 MHz, VDD = 3.0*(6)
D014 20 30 µA FOSC = 32 kHz, VDD = 3.0*
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.0V, 25°C, 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.
2: The supply current is mainly a function of the operating voltage and frequency. Other factors such as I/O pin loading and
switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current con-
sumption.
The test conditions for all IDD measurements in active Operation mode are:
OSC1 = external square wave, from rail to rail; all I/O pins tri-stated, pulled to VDD,
MCLR = VDD; WDT enabled/disabled as specified.
3: The power-down current in SLEEP mode does not depend on the oscillator type. Power-down current is measured with
the part in SLEEP mode, with all I/O pins in hi-impedance state and tied to VDD or VSS.
4: The ∆ current is the additional current consumed when this peripheral is enabled. This current should be added to the
base IDD or IPD measurement.
5: For RC osc configuration, current through REXT is not included. The current through the resistor can be estimated by the
formula Ir = VDD/2REXT (mA) with REXT in kΩ.
6: Commercial temperature only.
Param
Sym Characteristic/Device Min Typ† Max Units Conditions
No.
Param.
Sym Characteristic/Device Min Typ† Max Unit Conditions
No.
VIL Input Low Voltage
I/O ports
D030 with TTL buffer VSS — 0.8 V VDD = 4.5V to 5.5V
0.15 VDD V otherwise
D031 with Schmitt Trigger input VSS 0.2 VDD V
D032 MCLR, RA4/T0CKI,OSC1 VSS — 0.2 VDD V (Note1)
(in ER mode)
D033 OSC1 (in XT and HS) VSS — 0.3 VDD V
OSC1 (in LP) VSS — 0.6 VDD - 1.0 V
VIH Input High Voltage
I/O ports
D040 with TTL buffer 2.0V — VDD V VDD = 4.5V to 5.5V
.25 VDD + 0.8V VDD V otherwise
D041 with Schmitt Trigger input 0.8 VDD — VDD V
D042 MCLR RA4/T0CKI 0.8 VDD — VDD V
D043 OSC1 (XT, HS and LP) 0.7 VDD — VDD V
D043A OSC1 (in ER mode) 0.9 VDD V (Note1)
D070 IPURB PORTB weak pull-up 50 200 400 µA VDD = 5.0V, VPIN = VSS
current
IIL Input Leakage Current(2), (3)
I/O ports (Except PORTA) ±1.0 µA VSS ≤ VPIN ≤ VDD, pin at hi-impedance
D060 PORTA — — ±0.5 µA VSS ≤ VPIN ≤ VDD, pin at hi-impedance
D061 RA4/T0CKI — — ±1.0 µA VSS ≤ VPIN ≤ VDD
D063 OSC1, MCLR — — ±5.0 µA VSS ≤ VPIN ≤ VDD, XT, HS and LP osc
configuration
VOL Output Low Voltage
D080 I/O ports — — 0.6 V IOL=8.5 mA, VDD=4.5V, -40° to +85°C
— — 0.6 V IOL=7.0 mA, VDD=4.5V, +125°C
D083 OSC2/CLKOUT (ER only) — — 0.6 V IOL=1.6 mA, VDD=4.5V, -40° to +85°C
— — 0.6 V IOL=1.2 mA, VDD=4.5V, +125°C
VOH Output High Voltage(3)
D090 I/O ports (Except RA4) VDD - 0.7 — — V IOH=-3.0 mA, VDD=4.5V, -40° to +85°C
VDD - 0.7 — — V IOH=-2.5 mA, VDD=4.5V, +125°C
D092 OSC2/CLKOUT (ER only) VDD - 0.7 — — V IOH=-1.3 mA, VDD=4.5V, -40° to +85°C
VDD - 0.7 — — V IOH=-1.0 mA, VDD=4.5V, +125°C
D150 VOD Open-Drain High Voltage — 8.5 V RA4 pin PIC16F62X, PIC16LF62X*
Capacitive Loading Specs on Output Pins
D100* COSC2 OSC2 pin — 15 pF In XT, HS and LP modes when external
clock used to drive OSC1.
D101* Cio All I/O pins/OSC2 (in ER mode) — 50 pF
* These parameters are characterized but not tested.
† Data in “Typ” column is at 5.0V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
Note 1: In ER oscillator configuration, the OSC1 pin is a Schmitt Trigger input. It is not recommended that the PIC16F62X be driven with exter-
nal clock in ER mode.
2: The leakage current on the MCLR pin is strongly dependent on applied voltage level. The specified levels represent normal operating
conditions. Higher leakage current may be measured at different input voltages.
3: Negative current is defined as coming out of the pin.
Param
Characteristics Sym Min Typ Max Units Comments
No.
Spec
Characteristics Sym Min Typ Max Units Comments
No.
D310 Resolution VRES VDD/24 — VDD/32 LSb
D311 Absolute Accuracy VRaa — — 1/4 LSb Low Range (VRR = 1)
— — 1/2 LSb High Range (VRR = 0)
D312* Unit Resistor Value (R) VRur — 2k — Ω
310* Settling Time(1) Tset — — 10 µs
* These parameters are characterized but not tested.
Note 1: Settling time measured while VRR = 1 and VR<3:0> transitions from 0000 to 1111.
VDD/2
RL
CL CL
PIN PIN
VSS VSS
RL = 464Ω
CL = 50 pF for all pins except OSC2
15 pF for OSC2 output
Parameter
Sym Characteristic Min Typ† Max Units Conditions
No.
Data EEPROM Memory
D120 ED Endurance 1M* 10M — E/W 25°C at 5V
D121 VDRW VDD for read/write VMIN — 5.5 V VMIN = Minimum operating
voltage
D122 TDEW Erase/Write cycle time — 4 8* ms
Program FLASH Memory
D130 EP Endurance 1000* 10000 — E/W
D131 VPR VDD for read Vmin — 5.5 V VMIN = Minimum operating
voltage
D132 VPEW VDD for erase/write 4.5 — 5.5 V
D133 TPEW Erase/Write cycle time — 4 8* ms
* These parameters are characterized but not tested.
† Data in “Typ” column is at 5.0V, 25°C unless otherwise stated. These parameters are for design guidance only
and are not tested.
Q4 Q1 Q2 Q3 Q4 Q1
OSC1
1 3 3
4 4
2
CLKOUT
OSC1
11
10
22
CLKOUT 23
13 12
19 18
14 16
I/O PIN
(INPUT)
17 15
20, 21
VDD
MCLR
30
Internal
POR
33
PWRT
Timeout 32
OSC
Timeout
Internal
RESET
Watchdog
Timer
RESET
31
34 34
I/O Pins
VDD VBOD
35
TABLE 17-6: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER AND POWER-UP
TIMER REQUIREMENTS
Param
Sym Characteristic Min Typ† Max Units Conditions
No.
30 TmcL MCLR Pulse Width (low) 2000 — — ns VDD = 5V, -40°C to +85°C
TBD TBD TBD ms Extended temperature
31 Twdt Watchdog Timer Timeout Period 7 18 33 ms VDD = 5V, -40°C to +85°C
(No Prescaler) TBD TBD TBD ms Extended temperature
32 Tost Oscillation Start-up Timer Period — 1024TOSC — — TOSC = OSC1 period
33* Tpwrt Power-up Timer Period 28 72 132 ms VDD = 5V, -40°C to +85°C
TBD TBD TBD ms Extended temperature
RA4/T0CKI
40 41
42
RB6/T1OSO/T1CKI
45 46
47 48
TMR0 OR
TMR1
RB3/CCP1
(CAPTURE MODE)
50 51
52
RB3/CCP1
53 54
RA4/T0CKI
40 41
42
TMR0
5.5V
IDD (mA)
5.0V
3
4.5V
2 4.0V
0
4 6 8 10 12 14 16 18 20
FOSC (MHz)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
5.5V
4
IDD (mA)
5.0V
3
4.5V
4.0V
2
0
4 6 8 10 12 14 16 18 20
FOSC (MHz)
1.0
0.8
5.5V
IDD (mA)
0.6 5.0V
4.5V
4.0V
0.4
3.5V
3.0V
2.5V
0.2
2.0V
0.0
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
F OSC (MHz)
1.0
0.8
5.5V
IDD (mA)
0.6 5.0V
4.5V
4.0V
0.4
3.5V
3.0V
2.5V
0.2
2.0V
0.0
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
F O SC (M H z)
80
70
5.5V
60
5.0V
4.5V
50
Ipd (uA)
4.0V
40
3.5V
30
3.0V
20
2.5V
10
0
30.000 40.000 50.000 60.000 70.000 80.000 90.000 100.000
F OSC (kHz)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
100.00
80.00 5.5V
5.0V
IDD (uA)
60.00
4.5V
4.0V
40.00 3.5V
3.0V
20.00 2.5V
0.00
30.000 40.000 50.000 60.000 70.000 80.000 90.000 100.000
F OSC (kHz)
3.50
R = 50 k Ω
3.00
2.50
Frequency (MHz)
2.00
R = 100 k Ω
1.50
1.00
R = 200 k Ω
0.50
R = 500 k Ω
R = 1 M Ω
0.00
2.0 2.5 3.0 3.5 4.0 4.5 5.0
V D D (V o lts)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
125 C
85 C
25 C
4.0
3.9
-40 C
FOSC (MHz)
3.8
3.7
3.6
3.5
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 18-9: TYPICAL INTERNAL RC FOSC VS VDD OVER TEMPERATURE (-40 TO 125°C)
INTERNAL 37 kHz OSCILLATOR
Typical: statistical mean @ 25°C
Typical Internal RC F OSC vs V DD over Maximum: mean + 3σ PIC16LF628
(-40°C to 125°C)
Temperature (-40 to 125 C) Minimum: mean – 3σ (-40°C to 125°C)
Internal 37kHz Oscillator
60.000
50.000
125 C
85 C
40.000
25 C
FOSC (KHz)
30.000 -40 C
20.000
10.000
0.000
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
V DD (V)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
Max (125C)
3.0
IPD (uA)
2.0
1.0
Max (85C)
Typ (25C)
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
0.110
0.100
Max
∆IBOR (mA)
0.090 Max
Typ Reset (25C)
0.070
Indeterminate
Device in Reset Device in Sleep
0.060
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
80
70
60
∆ITMR1OSC (uA)
50
Max
40
Typ (25C)
30
20
10
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
FIGURE 18-13: ∆lWDT VS VDD SLEEP MODE, WATCH DOG TIMER ENABLED
Typical: statistical mean @ 25°C
Maximum: mean + 3σ (-40°C to 125°C)
∆IWDT vs VDD Minimum: mean – 3σ (-40°C to 125°C)
Sleep mode, watch dog timer enabled
13.0
12.0
11.0
10.0
Max (125C)
9.0
8.0
∆IWDT (uA)
7.0
Typ (25C)
6.0
5.0
4.0
3.0
2.0
1.0
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
120.0
100.0
Typ (25C)
60.0
40.0
20.0
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
80.0
70.0
Max (125C)
60.0
Typ (25C)
∆IVREF (uA)
50.0
40.0
30.0
20.0
10.0
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
FIGURE 18-16: MINIMUM, TYPICAL and MAXIMUM WDT PERIOD VS VDD (-40°C to +125°C)
Typical: statistical mean @ 25°C
PIC16LF228
Minimum, Typical and Maximum Maximum: mean + 3σ (-40°C to 125°C)
WDT Period vs V DD (-40C to +125C) Minimum: mean – 3σ (-40°C to 125°C)
45
40
35
30
Max 125C
WDT Period (mS)
25 Max 85C
20
Typ 25C
15
Min -40C
10
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
V DD (V)
40
35
30
WDT Period (mS)
125 C
25
85 C
20
25 C
15
-40 C
10
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
4.5
4.0
3.0
Typ (25C)
VOH (V)
2.5
2.0
1.5
Min (125C)
1.0
0.5
0.0
0.0 5.0 10.0 15.0 20.0 25.0
IOH (-mA)
2.5
2.0
VOH (V)
1.5
1.0
0.5
Note: The graphs and tables provided in this section are for design guidance and are not tested.
0.60
0.50
Typ (25C)
VOL (V)
0.40
Min (-40C)
0.30
0.20
0.10
0.00
0.0 5.0 10.0 15.0 20.0 25.0
IOL (mA)
Max (125C)
1.20
1.00
0.80
Typ (25C)
VOL (V)
0.60
Min (-40C)
0.40
0.20
0.00
0.0 5.0 10.0 15.0 20.0 25.0
IOL (mA)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
Min (125C)
Vin (V)
1.0
0.5
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
4.0
3.0
Vin (V)
2.0
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
35.000
30.000
125 C
25.000
IDD (µA)
85
25 C
20.000
-40 C
15.000
10.000
2.5 3.0 3.5 4.0 4.5 5.0 5.5
V DD (Volts)
35.000
30.000
25.000
IDD (µA)
125 C
20.000 85 C
25 C
-40C
15.000
10.000
2.5 3.0 3.5 4.0 4.5 5.0 5.5
V DD (Volts)
Note: The graphs and tables provided in this section are for design guidance and are not tested.
1.20
1.10
1.00
0.90
IDD (mA)
0.70
0.60
0.50
0.40
2.5 3.0 3.5 4.0 4.5 5.0 5.5
V DD (Volts)
1.200
1.100
1.000
0.900
IDD (mA)
125 C 85 C 25 C -40C
0.800
0.700
0.600
0.500
0.400
2.5 3.0 3.5 4.0 4.5 5.0 5.5
V DD (Volts)
XXXXXXXXXXXXXXXXX PIC16F628/P
XXXXXXXXXXXXXXXXX
YYWWNNN 9917017
YYWWNNN 9910017
XXXXXXXXXX PIC16F628/SO
XXXXXXXXXX
YYWWNNN 9910017
Note: In the event the full Microchip part number cannot be marked on one line, it will be carried
over to the next line thus limiting the number of available characters for customer specific
information.
* Standard OTP marking consists of Microchip part number, year code, week code, facility code, mask rev#, and
assembly code. For OTP 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.
E1
n 1 α
E A2
c L
A1
B1
β
B p
eB
E
p
E1
2
B n 1
h
α
45°
c
A A2
φ
β L A1
E1
p
B 2
n 1
c
A A2
L A1
β
C I
CALL Instruction ............................................................... 111 I/O Ports ............................................................................. 29
Capture (CCP Module) ....................................................... 62 I/O Programming Considerations ....................................... 42
Block Diagram............................................................. 62 ID Locations...................................................................... 105
CCP Pin Configuration................................................ 62 INCF Instruction................................................................ 114
CCPR1H:CCPR1L Registers...................................... 62 INCFSZ Instruction ........................................................... 114
Changing Between Capture Prescalers...................... 62 In-Circuit Serial Programming........................................... 106
Software Interrupt ....................................................... 62 Indirect Addressing, INDF and FSR Registers ................... 25
Timer1 Mode Selection ............................................... 62 Instruction Flow/Pipelining .................................................. 11
Capture/Compare/PWM (CCP)........................................... 61 Instruction Set
Capture Mode. See Capture ADDLW ..................................................................... 109
CCP1 .......................................................................... 61 ADDWF .................................................................... 109
CCPR1H Register............................................... 61 ANDLW ..................................................................... 109
CCPR1L Register ............................................... 61 ANDWF .................................................................... 109
CCP2 .......................................................................... 61 BCF .......................................................................... 110
Compare Mode. See Compare BSF........................................................................... 110
PWM Mode. See PWM BTFSC...................................................................... 110
Timer Resources......................................................... 61 BTFSS ...................................................................... 111
CCP1CON Register CALL......................................................................... 111
CCP1M3:CCP1M0 Bits............................................... 61 CLRF ........................................................................ 111
CCP1X:CCP1Y Bits .................................................... 61 CLRW ....................................................................... 112
CCP2CON Register CLRWDT .................................................................. 112
CCP2M3:CCP2M0 Bits............................................... 61 COMF ....................................................................... 112
CCP2X:CCP2Y Bits .................................................... 61 DECF........................................................................ 112
Clocking Scheme/Instruction Cycle .................................... 11 DECFSZ ................................................................... 113
CLRF Instruction ............................................................... 111 GOTO ....................................................................... 113
CLRW Instruction .............................................................. 112 INCF ......................................................................... 114
CLRWDT Instruction ......................................................... 112 INCFSZ..................................................................... 114
Code Protection ................................................................ 105 IORLW ...................................................................... 115
COMF Instruction .............................................................. 112 IORWF...................................................................... 115
Comparator Configuration................................................... 54 MOVF ....................................................................... 115
U
Universal Synchronous Asynchronous Receiver Transmitter
(USART) ............................................................................. 67
Asynchronous Receiver
Setting Up Reception .......................................... 80
Timing Diagram .................................................. 78
Asynchronous Receiver Mode
Block Diagram .................................................... 80
Section ................................................................ 80
USART
Asynchronous Mode ................................................... 74
Asynchronous Receiver .............................................. 77
From: Name
Company
Address
City / State / ZIP / Country
Telephone: (_______) _________ - _________ FAX: (______) _________ - _________
Application (optional):
Would you like a reply? Y N
Questions:
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?
Package P = PDIP
SO = SOIC (Gull Wing, 300 mil body)
SS = SSOP (209 mil)
* 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.
12/05/02