Escolar Documentos
Profissional Documentos
Cultura Documentos
been phenomenally successful in the market for many reasons, the most significant
ones are mentioned below. PIC micros have grown in steadily in popularity over
the last decade, ever since their inception into the market in the early 1990s. PIC
micros have grown to become the most widely used microcontrollers in the 8- bit
microcontroller segment. The PIC16F877 is 40 pin IC. There are six ports in this
Among these ports PORT B, PORT C and PORT D contains 8-pins, where PORTA
Each pins in the ports can be used as either input or output pins. Before
using the port pins as input or output, directions should be given in TRIS register.
For example setting all the bits in TRIS D register indicates all the pins in PORT D
Clearing all the bits in TRIS D register indicates all the pins in PORT D are
The main factors that account for the popularity of PIC micros include the
following:
Speed: When operated at its maximum clock rate, a PIC executes most
instructions.
on Reset and Brown out protection which ensures that the chip operates only
when the supply voltage is within specification. A watchdog timer resets the
PIC if the chip ever malfunctions and deviates from its normal operations.
Flexibility in clock sources: The PIC micros can be run with four different
types of clock sources which help in cost cutting and power saving.
High current capabilities of ports: The ports pins on PIC micros can
source and sink up to 25mA, which make them all the more versatile and
economic.
Serial programming via two pins: PIC micros can be programmed serially
with two pins, which bring down the complexity and the cost of PIC
programmers, drastically.
On chip EEPROM: The on chip EEPROM helps retain critical data even if
the power is down. There by reducing the cost of and external EEPROM
Harvard Architecture
Apart from these features are reasons of non technical nature like the
as Bank 0, Bank 1, Bank 2 and Bank 3 from 00h-07h, 80h-FFh, 100h-17Fh and
memory and Data EEPROM of 8K, 368 and 256 Bytes respectively.
REGISTER FILE
The term register file in PIC terminology used to denote the locations than an
instruction can access via an address. The register file consists of two components,
they are
RAM. Data can be written to each 8-bit location, updated and retrieved any number
of times. All control registers are coming under the general purpose register file.
SPECIAL PURPOSE REGISTER FILE
The special purpose register file contains input and output ports as well as the
control registers used to establish each bit of port as either an input or output. It
contains registers that provide the data input and data output to the variety of
resources on the chip, such as the timers, the serial ports and the analog–to–digital
converter. It has registers that contain control bits for selecting the mode of
Every instruction that can employ the direct addressing mode can, as an
alternative employ the indirect addressing mode. In this alternative mode, the full
8-bit register file address is first written into FSR, a special purpose register that
serves as an address pointer to any address throughout the entire register file. A
subsequent direct access of INDF will actually access the register file using the
register
PIR1 Peripheral interrupt 0CH Yes
control
RCSTA Receive status and 18H Yes
control register
TXREG Transmit register 19H Yes
RCREG Receive register 1AH Yes
OPTION_REG Optional register 81H Yes
TRISA I/O register 85H Yes
TRISB I/O register 86H Yes
TRISC I/O register 87H Yes
TRISD I/O register 88H Yes
TRISE I/O register 89H Yes
TXSTA Transmit status and 98H Yes
control register
SPBRG Baud rate generator 99H Yes
STATUS REGISTER
Flags are one bit registers provided to store results of certain program
instructions, other instructions can test the condition of the flags and make decisions
based on the flag states. In order to address the flags conveniently flags are
The PIC16F877 has three flags such as Zero(Z), Digit Carry(DC) and
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
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
One of the methods to determine the condition that exists in internal and
external circuits is to respond to the hardware signals, called interrupts which force
External interrupts respectively. Any interrupts can cause or transfer the PIC16f877
1. Interrupt on Change
2. External interrupt
All the External interrupts are generated when the port pin is considered as
input pin.
INTERRUPT ON CHANGE
These external interrupts can be generated only on the PORT B, when it acts
as a input port. If any of the change in the port pins from PB4 – PB7 then the
Change.
EXTERNAL INTERRUPT
This external interrupt can be generated only at the PORT B-0 (PB0) , by
using the pull-ups resistors we can generate the interrupt during when the port pin
send and receive data bytes serially. The P16F77 micro controller has serial data
communication circuits that transmits and receive the data. By configuring the
by configuring the TXSTA (Transmit Status and Control Register) and RCSTA
(Receive Status and Control Register) we can transmit and receive the data serially.
The any date in TXREG (Transmit Register) transmit the data and the data which is
in RCREG (Receive Register) is the receive data. The following figure shows the
RX9D: 9th bit of Received Data (can be parity bit, but must be calculated by user
Firmware)
MAX 232
Many microcontrollers have asynchronous serial ports, but their inputs and
outputs use 5v logic rather than RS-232 port requires converting to and from RS-
232 level, with TTL logic, a logic low output must be no higher than 0.4v and a
logic low input must be no higher than 0.8V. A logic high output must be at least
2.4V while a logic-high input must be at least 2V using these levels, an interface
The original MAX-232 includes two drivers that convert TTL inputs to RS-
232 outputs, and two receivers that accept RS-232 inputs and translate them to
asynchronous receiver/ transmitter) that handles most of the details of sending and
In PCS the operating system and programming languages include support for
programming serial links without having to understand every detail of the UART’s
architecture. To open a link, the applications selects a data rate and other settings
ISOLATED LINKS
RS-232’s large noise margin help to make the interface reliable and immune
to data errors caused by external noise coupling into the wires. If a links
environment is electrically noisy, isolation can keep noise from coupling between
use optical and magnetic coupling to transfer power and data, while filtering out the
The isolation may isolate the ground, the datalink, or both. Ground isolation
makes a circuit immune to power surges and noise in the earth ground shared by
nearby circuit. In long links, ground isolation also makes the link immune to
differences in ground potential from end to end. Isolation the data link keeps noise
from coupling between the link and the circuits it connects to.
transistor. The current through the photodiode causes it to emit energy in the