English
Language : 

PIC16F8X_13 Datasheet, PDF (23/128 Pages) Microchip Technology – 18-pin Flash/EEPROM 8-Bit Microcontrollers
5.2 PORTB and TRISB Registers
PORTB is an 8-bit wide bi-directional port. The
corresponding data direction register is TRISB. A '1' on
any bit in the TRISB register puts the corresponding
output driver in a hi-impedance mode. A '0' on any bit
in the TRISB register puts the contents of the output
latch on the selected pin(s).
Each of the PORTB pins have a weak internal pull-up.
A single control bit can turn on all the pull-ups. This is
done by clearing the RBPU (OPTION_REG<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 a Power-on Reset.
Four of PORTB’s pins, RB7:RB4, have an interrupt on
change feature. Only pins configured as inputs can
cause this interrupt to occur (i.e., any RB7:RB4 pin
configured as an output is excluded from the interrupt
on change comparison). The pins value in input mode
are compared with the old value latched on the last
read of PORTB. The “mismatch” outputs of the pins are
OR’ed together to generate the RB port
change interrupt.
FIGURE 5-3: BLOCK DIAGRAM OF PINS
RB7:RB4
RBPU(1)
Data bus
WR Port
WR TRIS
Data Latch
DQ
CK
TRIS Latch
DQ
CK
VDD
P
weak
pull-up
I/O
pin(2)
TTL
Input
Buffer
Set RBIF
RD TRIS
RD Port
Latch
QD
EN
From other
RB7:RB4 pins
QD
EN
RD Port
Note 1: TRISB = '1' enables weak pull-up
(if RBPU = '0' in the OPTION_REG register).
2: I/O pins have diode protection to VDD and VSS.
PIC16F8X
This interrupt can wake the device from SLEEP. The
user, in the interrupt service routine, can clear the
interrupt in the following manner:
a) Read (or write) PORTB. This will end the mis-
match condition.
b) Clear flag bit RBIF.
A mismatch condition will continue to set the RBIF bit.
Reading PORTB will end the mismatch condition, and
allow the RBIF bit to be cleared.
This interrupt on mismatch feature, together with
software configurable pull-ups on these four pins allow
easy interface to a key pad and make it possible for
wake-up on key-depression (see AN552 in the
Embedded Control Handbook).
Note 1: For a change on the I/O pin to be
recognized, the pulse width must be at
least TCY (4/fOSC) wide.
The interrupt on change feature is recommended for
wake-up on key depression operation and operations
where PORTB is only used for the interrupt on change
feature. Polling of PORTB is not recommended while
using the interrupt on change feature.
FIGURE 5-4:
RBPU(1)
Data bus
WR Port
WR TRIS
BLOCK DIAGRAM OF PINS
RB3:RB0
VDD
Data Latch
DQ
CK
P
weak
pull-up
I/O
pin(2)
TRIS Latch
DQ
CK
TTL
Input
Buffer
RD TRIS
RD Port
QD
EN
RB0/INT
Schmitt Trigger
Buffer
RD Port
Note 1: TRISB = '1' enables weak pull-up
(if RBPU = '0' in the OPTION_REG register).
2: I/O pins have diode protection to VDD and VSS.
 1996-2013 Microchip Technology Inc.
DS30430D-page 23