[
Menu
]>[
Guide to use the PIC
]>[
628 Hardware
]
I/O ports of PIC16F628
The function of the port must be set according to the purpose.
On this page, I will explain function setting registers of each port.
Pin number
Function
Setting registers
1
RA2
CM2-0 bits of
CMCON register
are set as "111". ( Default is "000" )
AN2
CM2-0 bits of
CMCON register
are set according to need. ( Default is "000" )
V
REF
VRON bit of
VRCON register
is set as "1". ( Default is "0" )
2
RA3
CM2-0 bits of
CMCON register
are set as "111". ( Default is "000" )
AN3
CM2-0 bits of
CMCON register
are set according to need. ( Default is "000" )
CMP1
CM2-0 bits of
CMCON register
are set as "110". ( Default is "000" )
3
RA4
CM2-0 bits of
CMCON register
are set as "111". ( Default is "000" )
T0CS bit of
OPTION_REG register
is set as "0". ( Default is "1" )
T0CKI
Default
CMP2
CM2-0 bits of
CMCON register
are set as "111". ( Default is "000" )
T0CS bit of
OPTION_REG register
is set as "0". ( Default is "1" )
4
RA5
MCLRE bit of
Configuration Word
is set as "0".
MCLR
MCLRE bit of
Configuration Word
is set as "1".
Vpp
MCLRE bit of
Configuration Word
is set as "1".
LVP bit of
Configuration Word
is set as "0".
6
RB0
When an interruption function is used, RBIE bit of
INTCON register
is set as "1".
( Default is "0" )
INT
INTE bit of
INTCON register
is set as "1". ( Default is "0" )
INTEDG bit of
OPTION_REG register
is set according to need. ( Default is "1" )
7
RB1
Default
RX
SPEN bit of
RCSTA register
is set as "1". ( Default is "0" )
DT
SPEN bit of
RCSTA register
is set as "1". ( Default is "0" )
SYNC bit of
TXSTA register
is set as "1". ( Default is "0" )
8
RB2
Default
TX
SPEN bit of
RCSTA register
is set as "1". ( Default is "0" )
CK
SPEN bit of
RCSTA register
is set as "1". ( Default is "0" )
SYNC bit of
TXSTA register
is set as "1". ( Default is "0" )
9
RB3
Default
CCP1
CCP1M3-0 bits of
CCP1CON register
are set according to need. ( Default is "0000" )
10
RB4
Default
PGM
LVP bit of
Configuration Word
is set as "1".
11
RB5
Single function
12
RB6
Default
T1OSO
T1OSCEN bit of
T1CON register
is set as "1". ( Default is "0" )
T1CKI
TRM1CS bit of
T1CON register
is set as "1". ( Default is "0" )
PGC
Programming mode
13
RB7
Default
T1OSI
T1OSCEN bit of
T1CON register
is set as "1". ( Default is "0" )
PGD
Programming mode
15
RA6
FOSC2-0 bits of
Configuration Word
are set as "011", "100" or "110".
OSC2
FOSC2-0 bits of
Configuration Word
are set as "000", "001" or "010".
CLKOUT
FOSC2-0 bits of
Configuration Word
are set as "101" or "111".
16
RA7
FOSC2-0 bits of
Configuration Word
are set as "100" or "101".
OSC1
FOSC2-0 bits of
Configuration Word
are set as "000", "001" or "010".
CLKIN
FOSC2-0 bits of
Configuration Word
are set as "011", "110" or "111".
17
RA0
CM2-0 bits of
CMCON register
are set as "111". ( Default is "000" )
AN0
CM2-0 bits of
CMCON register
are set according to need. ( Default is "000" )
18
RA1
CM2-0 bits of
CMCON register
are set as "111". ( Default is "000" )
AN1
CM2-0 bits of
CMCON register
are set according to need. ( Default is "000" )