Specifications

Chapter 2 - Microcontroller PIC16F84
Previous page Table of contents Chapter overview Next page
2.4 Ports
Port refers to a group of pins on a microcontroller which can be accessed simultaneously, or on
which we can set the desired combination of zeros and ones, or read from them an existing status.
Physically, port is a register inside a microcontroller which is connected by wires to the pins of a
microcontroller. Ports represent physical connection of Central Processing Unit with an outside
world. Microcontroller uses them in order to monitor or control other components or devices. Due
to functionality, some pins have twofold roles like PA4/TOCKI for instance, which is simultaneously
the fourth bit of port A and an external input for free-run counter. Selection of one of these two
pin functions is done in one of the configurational registers. An illustration of this is the fifth bit
T0CS in OPTION register. By selecting one of the functions the other one is disabled.
All port pins can be defined as input or output, according to the needs of a device that's being
developed. In order to define a pin as input or output pin, the right combination of zeros and ones
must be written in TRIS register. If at the appropriate place in TRIS register a logical "1" is
written, then that pin is an input pin, and if the opposite is true, it's an output pin. Every port has
its proper TRIS register. Thus, port A has TRISA at address 85h, and port B has TRISB at address
86h.
PORTB
PORTB has 8 pins joined to it. The appropriate register for direction of data is TRISB at address
86h. Setting a bit in TRISB register defines the corresponding port pin as an input pin, and
resetting a bit in TRISB register defines the corresponding port pin as the output pin. Each pin on
PORTB has a weak internal pull-up resistor (resistor which defines a line to logic one) which can be
activated by resetting the seventh bit RBPU in OPTION register. These 'pull-up' resistors are
automatically being turned off when port pin is configured as an output. When a microcontroller is
started, pull-up's are disabled.
Four pins PORTB, RB7:RB4 can cause an interrupt which occurs when their status changes from
http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_05Poglavlje.htm (1 of 2) [4/2/2003 16:17:47]