Study of Pic16F877A Microcontroller: Equipments Required
Study of Pic16F877A Microcontroller: Equipments Required
EQUIPMENTS REQUIRED:
1. PIC16F877A DEVELOPMENT BOARD
2. SERIAL CABLE (RS232)
3. 5 V ADAPTER
4. CONNECTING WIRES
EMBEDDED SYSTEMS
An embedded system is a special-purpose computer system designed to perform one or a few
dedicated functions, often with real-time computing constraints. It is usually embedded as part
of a complete device including hardware and mechanical parts. In contrast, a general purpose
computer, such as a personal computer, can do many different tasks depending on
programming. Embedded systems control many of the common devices in use today
i. Cost
Micro controllers with the supplementary circuit components are much cheaper than a
computer with an analog and digital I/O.
iv. Reliability
Since the architecture is much simpler than a computer it is less likely to fail.
v. Speed
All the components on the microcontroller are located on a single piece of silicon. Hence, the
applications run much faster than it does on a computer.
HARDWARE DETAILS:
PIC 16F877 is a 40-pin 8-Bit CMOS FLASH Microcontroller from Microchip. The core
architecture is high-performance RISC CPU with only 35 single word1 instructions. Since it
follows the RISC architecture, all single cycle instructions take only one instruction cycle except
for program branches which take two cycles. 16F877 comes with 3 operating speeds with 4, 8,
or 20 MHz clock input. Since each instruction cycle takes four operating clock cycles, each
instruction takes 0.2 μs when 20MHz oscillator is used.
It has two types of internal memories: program memory and data memory. Program memory is
provided by 8K words (or 8K*14 bits) of FLASH Memory, and data memory has two sources.
One type of data memory is a 368-byte RAM (random access memory) and the other is 256-
byte EEPROM (Electrically erasable programmable ROM).
The core feature includes interrupt capability up to 14 sources, power saving SLEEP mode, and
single 5V In-Circuit Serial Programming (ICSP) capability. The sink/source current, which
indicates a driving power from I/O port, is high with 25mA. Power consumption is less than 2mA
in 5V operating condition.
There are three package types are available: DIP, PLCC, and QFP. This book assumes that we all use the
DIP because of its best fit to breadboard or proto-board.
BLOCK DIAGRAM:
The internal schematic of PIC16F877 is illustrated in the following block diagram. In the block
diagram, we first see built-in function modules in boxes such as PORTA, PORTB for inputs and
outputs, a 10-bit Analog-to-Digital (AD) module, 3 timer modules (Timer 0, Timer 1, and Timer
EEPROM, etc.
Block Diagram of PIC16F877A
We also see the modules are connected via internal data bus of 8-bit width. This is the reason
why 16F877 is called an 8-bit microcontroller. Since the program memory (FLASH) is organized
with 14-bit word, it's content is accessed (or fetched) via 14-bit program bus by the instruction
register. Instruction registers are not in the file (RAM) area so is not accessible by program.
Another internal register, program counter (PC) accesses the program memory location
("addressing") via 13 bit information. With 13 bits, the addressing range goes to 2 13 =23 *210 =8K
word.
RAM file registers for data are connected via 8-bit data bus. The W register is a user accessible
register. As you see in the block diagram, W directly accesses the ALU and the 8-bit data bus.
As we can see, there should be W involved to move data between modules and inside the file
RAM, except via indirect addressing mode. This means that writing to the output ports is done
via the W register. The details of the indirect addressing are discussed in the PIC instruction.
PROGRAM MEMORY:
The PIC16F877 has a 13-bit program counter (PC) capable of addressing an 8K word of
program memory pace, and accessing a location above the physically implemented address will
cause a wrap-around. The reset vector is at address 0000 and the interrupt vector is at address
00043. Details of this will be discussed throughout the book as related subjects pop up.
Let's examine the file register map briefly. As mentioned above, the fourth register (address
03h, 83h, 103h, and 183h) at each bank is assigned to STATUS register (see the Register file
map).
The STATUS register tells you about the status arithmetic and logical status. It also has very
important function of selecting a bank.
The detail of the STATUS register is shown below. Here, we highlight only bits of 6, 5, 2, and 0
of the register. Note that the bit number of the byte of the register starts from 0 ending at 7. As
we see, bits 5 and 6 of the register, as we indicate them as STATUS<6:5>, are RP1 and RP0
bits which select banks. In other words, for example, if you access a register in bank 3, you
have to set the two bits as 11, or STATUS<6:5>=11b4. In this selection, we change each bit of
a register. In such case, we may better use bit-oriented instruction (Details on instruction come
later). STATUS<2> is for Z flag to see if an operation results in zero or not.
Result:
Thus PIC16F877A Microcontroller was studied.