Sei sulla pagina 1di 20

What is a Microprocessor?

Computer's Central Processing Unit (CPU) built on a single Integrated Circuit (IC) is called
a microprocessor.

A digital computer with one microprocessor which acts as a CPU is called microcomputer.

It is a programmable, multipurpose, clock -driven, register-based electronic device that reads


binary instructions from a storage device called memory, accepts binary data as input and
processes data according to those instructions and provides results as output.

The microprocessor contains millions of tiny components like transistors, registers, and
diodes that work together.

Block Diagram of a Microcomputer

A microprocessor consists of an ALU, control unit and register array. Where ALU performs
arithmetic and logical operations on the data received from an input device or memory.
Control unit controls the instructions and flow of data within the computer. And, register
array consists of registers identified by letters like B, C, D, E, H, L, and accumulator.

The popular input devices are keyboard and floppy disk and the output devices are printer, LED/LCD
displays, CRT monitor, etc.

Introduction to PIC
Microchip Corporation manufactured a series of microcontroller chips named as “peripheral
interface controller” or simply called as PIC (also called programmable interface controller).
Microchip Corporation also provides a trademark for the name PIC . The term “PIC” is normally used
to describe the micro controllers developed by Microchip Corporation. Before we discuss more
about PIC, you need to know the basics about microprocessors and microcontrollers.
A microprocessor is a programmable multipurpose-multitasking logic chip that fabricated by LSI, VLSI
or other higher manufacturing techniques. The first microprocessor developed by the INTEL
corporation in 1971 (INTEL-4004), which was only a 4 bit microprocessor .A microprocessor can
accept input data’s in  binary forms, read binary instructions, perform data processing and provide
desired output. In a modern computer system, the microprocessor is usually referred to as CPU
(central processing unit). A microprocessor is basically classified by its word length (word length
represented by the number of bits, that is, 4bit, 8bit, 16bit, 32bit, 64bits are normally used for micro
processors). The basic block diagram of a microprocessor and a microprocessor based computer
system is given below.

Microprocessor-Block-Diagram

Arithmetic and Logic Unit (ALU)

ALU is one of the basic units of a microprocessor. All the computing functions are
maintained in this unit. As the name shows, the ALU can perform all the arithmetic
operations (+,-,*,/,%,etc) and all logical operations (AND, OR, NOT, XOR, etc).

Control Unit (CU)


The CPU’s control unit coordinates and times the CPU’s functions, and it uses the program counter
to locate and retrieve the next instruction from memory.

Another purpose of control unit is, controlling the data flow between microprocessor and peripheral
devices/peripheral chips.

Registers

Registers are the important section of microprocessor chip. Registers are primarily used to
store the data temporarily during the execution/runtime of the program. A microprocessor
contains several kinds of registers that can be classified according to the instructions provided
to the processor. These instructions are called instruction sets. The registers are basically 8bit,
16bit or 32 bit according to the type. Registers can easily accessible to the user by using
various commands (instructions). Some registers are used to store address of memory
locations that can be easily accessed by the microprocessor.

Memory

Memory are used to store the information (data&instructios) as in the binary form. According to this
binary information’s, a microprocessor perform its operation during the execution period. A
microprocessor can read the information from memory and perform the corresponding operations
in its ALU. The result of each operation stored in a memory or given to any output unit associated
with the system. The data stored in the memory can be used further. But some memories used in a
computer system are temporary memories or instantaneously fed to the any peripheral units. These
type data can’t be store in computer memory for later use. The memory unit of a microprocessor
computer system consist of two types of memories. They are Read Only Memory (simply called as
ROM) and Random Access Memory (simply called as RAM).

 Read Only Memory (ROM)

Read-only memory is one of the computer memories. ROM memory is used to store items
that the computer needs to execute when it is first turned on. For example, the ROM memory
on a PC contains a basic set of instructions, called the basic input-output system (BIOS). The
PC uses BIOS to start up the operating system. BIOS is stored on computer chips in a way
that causes the information to remain even when power is turned off.ROM is a non-volatile
memory. The program stored in ROM can only read.

 Random Access Memory  (RAM)

Random access memory is the other type of internal memory .RAM also called main memory
because it is the primary memory that the CPU uses when processing information. The
electronic circuits used to construct this main internal RAM can be classified as dynamic
RAM (DRAM), synchronized dynamic RAM (SDRAM), or static RAM (SRAM).This memory is
used to store user programs and data’s temporarily. RAM is a volatile memory.

System Bus

A bus is the set of hardware lines or circuit lines which help the communication between the
processor and other input/output units. A system bus is a flat cable with numerous parallel
wires. Each wire can carry one bit, so the bus can transmit many bits along the cable at the
same time. For example, a 16-bit bus, with 16 parallel wires, allows the simultaneous
transmission of 16 bits (2 bytes) of information from one component to another. The system
bus basically classified into three groups .

1)   Controlbus
2)   Databus
3)    Address bus.

1) Control bus

A control bus is a bi-directional bus which is used to transfer the control signals (read, write,
interrupt) and timing signals(clock pulses) between microprocessor and other peripheral
components.

2) Data Bus

Data bus is also a bi-directional bus that used to transmit data bi-directionally between the
microprocessor and peripherals devices.

3) Address Bus

Address bus is a unidirectional bus which is used to send the address of a peripheral from
microprocessor to the peripheral device.

 Advantages of a Microprocessor

a)    high speed

b)  high accuracy and reliability


c)   data movement between memory locations
d)   used to perform multitask operations
e)    only require limited current and low voltages

 Disadvantages of a Microprocessor

a)  Highly sensitive to thermal and electric variations


b)    Do not have internal memory(RAM&ROM),input/output ports inside the microprocessor
c)   No timers, interrupts inside the microprocessor
d)   Make a system expensive
e)   Need proper interfacing components for functioning

 Applications

a)    Widely used in modern computer systems


b)    Used in robotics
c)    Used in telecommunication fields
d)    Used in space systems
What is a Microcontroller?

A microcontroller is a single chip microcomputer made through VLSI fabrication. A microcontroller


also called an embedded controller because the microcontroller and its support circuits are often
built into, or embedded in, the devices they control. A microcontroller is available in different word
lengths like microprocessors (4bit,8bit,16bit,32bit,64bit and 128-bit microcontrollers are available
today).

1) A microcontroller basically contains one or more following components:

 Central processing unit(CPU)


 Random Access Memory)(RAM)
 Read Only Memory(ROM)
 Input/output ports
 Timers and Counters
 Interrupt Controls
 Analog to digital converters
 Digital  analog converters
 Serial interfacing ports
 Oscillatory circuits

2) A microcontroller internally consists of all features required for a computing system and
functions as a computer without adding any external digital parts in it.

3) Most of the pins in the microcontroller chip can be made programmable by the user.

4) A microcontroller has many bit handling instructions that can be easily understood by the
programmer.

5) A microcontroller is capable of handling Boolean functions.

6) Higher speed and performance.

7) On-chip ROM structure in a microcontroller provides better firmware security.

8 ) Easy to design with low cost and small size.

Microcontroller structure

The basic structure and block diagram of a microcontroller is


 CPU

CPU is the brain of a microcontroller. CPU is responsible for fetching the instruction,
decodes it, then finally executed. CPU connects every part of a microcontroller into a single
system. The primary function of CPU is fetching and decoding instructions. The instruction
fetched from program memory must be decoded by the CPU.

 Memory

The function of memory in a microcontroller is the same as a microprocessor. It is used to


store data and program. A microcontroller usually has a certain amount of RAM and ROM
(EEPROM, EPROM, etc) or flash memories for storing program source codes.

 Parallel input/output ports

Parallel input/output ports are mainly used to drive/interface various devices such as LCD’S,
LED’S, printers, memories, etc to a microcontroller.

 Serial ports

Serial ports provide various serial interfaces between a microcontroller and other peripherals
like parallel ports.

 Timers/counters
This is the one of the useful function of a microcontroller. A microcontroller may have more
than one timer and counters. The timers and counters provide all timing and counting
functions inside the microcontroller. The major operations of this section are performed clock
functions, modulations, pulse generations, frequency measuring, making oscillations, etc.
This also can be used for counting external pulses.

 Analog to Digital Converter (ADC)

ADC converters are used for converting the analog signal to digital form. The input signal in
this converter should be in analog form (e.g. sensor output) and the output from this unit is in
digital form. The digital output can be used for various digital applications (e.g. measurement
devices).

 Digital to Analog Converter (DAC)

DAC perform reversal operation of ADC conversion.DAC converts the digital signal into
analog format. It usually used for controlling analog devices like DC motors, various drives,
etc.

 Interrupt control

The interrupt control used for providing interrupt (delay) for a working program. The
interrupt may be external (activated by using interrupt pin) or internal (by using interrupt
instruction during programming).

 Special functioning block

Some microcontrollers used only for some special applications (e.g. space systems and
robotics) these controllers containing additional ports to perform such special operations.
This considered as special functioning block.

Comparison between Microprocessor and Microcontroller

The main comparison between microprocessor and microcontroller shown in fig (1.2)
Comparison of Microprocessor and Microcontroller

Source Of Image

Microprocessors                                                                                          Microcontrollers

1 It is only a general purpose computer It is a microcomputer itself


CPU

2 Memory, I/O ports, timers, interrupts All are integrated inside the microcontroller chip
are not available inside the chip

3 This must have many additional digital Can function as a microcomputer without any
components to perform its operation additional components.

4 Systems become bulkier and expensive. Make the system simple, economic and compact

5 Not capable for handling Boolean Handling Boolean functions


functions
6 Higher accessing time required Low accessing time

7 Very few pins are programmable Most of the pins are programmable

8 Very few number of bit handling Many bit handling instructions


instructions

9 Widely Used in modern PC  and laptops widely in small control systems

E.g. INTEL 8086,INTEL Pentium series INTEL8051,89960,PIC16F877

Advantages of Microcontrollers

The main advantages of microcontrollers are given.

a)      Microcontrollers act as a microcomputer without any digital parts.

b)     As the higher integration inside microcontroller reduces cost and size of the system.

c)      Usage of a microcontroller is simple, easy to troubleshoot and system maintaining.

d)     Most of the pins are programmable by the user for performing different functions.

e)      Easily interface additional RAM, ROM,I/O ports.

f)       Low time required for performing operations.

Disadvantages of Microcontrollers

a)      Microcontrollers have got more complex architecture than that of microprocessors.

b)     Only perform a limited number of executions simultaneously.

c)      Mostly used in micro-equipments.

d)     Cannot interface high power devices directly.

Applications

You can find microcontrollers in all kinds of electronic devices these days. Any device that
measures, stores, controls, calculates, or displays information must have a microcontroller
chip inside. The largest single use for microcontrollers is in the automobile industry
(microcontrollers widely used for controlling engines and power controls in automobiles).
You can also find microcontrollers inside keyboards, mouse, modems, printers, and other
peripherals. In test equipment, microcontrollers make it easy to add features such as the
ability to store measurements, to create and store user routines, and to display messages and
waveforms. Consumer products that use microcontrollers include digital camcorders, optical
players, LCD/LED display units, etc. And these are just a few examples.

Some basic applications of a microcontroller are given below.

a)      Used in biomedical instruments.

b)     Widely used in communication systems.

c)      Used as a peripheral controller in PC.

d)     Used in robotics.

e)      Used in automobile fields.

Introduction to Peripheral Interface Controllers (PIC)

Peripheral Interface Controllers (PIC) is one of the advanced microcontrollers developed by


microchip technologies. These microcontrollers are widely used in modern electronics
applications.  A PIC controller integrates all type of advanced interfacing ports and memory
modules. These controllers are more advanced than normal microcontroller like INTEL 8051.
The first PIC chip was announced in 1975 (PIC1650). As like normal microcontroller, the  
PIC   chip also combines a  microprocessor unit called CPU and is integrated with various
types of memory modules (RAM, ROM, EEPROM ,etc), I/O ports, timers/counters,
communication ports, etc.

PIC Chip
Image From
All PIC microcontroller family uses Harvard architecture. This architecture has the program
and data accessed from separate memories so the device has a program memory bus and a
data memory bus (more than 8 lines in a normal bus). This improves the bandwidth (data
throughput) over traditional von Neumann architecture where program and data are fetched
from the same memory (accesses over the same bus). Separating program and data memory
further allows instructions to be sized differently than the 8-bit wide data word.
Basic structure of a modern Peripheral interface controller chip is show in the picture below.

PIC Structure

Source of the image

CPU

The function of CPU in PIC is same as a normal microcontroller CPU. A PIC CPU consists
of several sub units such as instruction decoder, ALU, accumulator, control unit, etc. The
CPU in PIC normally supports Reduced Instruction Set Computer (RISC) architecture
(Reduced Instruction Set Computer (RISC), a type of microprocessor that focuses on rapid
and efficient processing of a relatively small set of instructions. RISC design is based on the
premise that most of the instructions a computer decodes and executes are simple. As a result,
RISC architecture limits the number of instructions that are built into the microcontroller but
optimizes each so it can be carried out very rapidly (usually within a single clock cycle.) .
These RISC structure gives the following advantages.
•     The RISC structure only has 35 simple instructions as compared to others
•    The execution time is same for most of the instructions (except very few numbers).
•    The execution time required is very less (5 million instructions/second (approximately).

Memory

The memory in a PIC chip used to store the data and programs temporary or permanently. As
like normal microcontrollers, the PIC chip also has certain amount of RAM, ROM,
EEPROM, other flash memory, etc.
ROM memory is used for permanent storage. The ROM memory also called as n program
memory. A PI chip has certain amount of ROM memory.
EEPROM memory is another category of ROM memory. The contents in the EEPROM
changes during run time and at that time it acts like a RAM memory. But the difference is  
after the power goes off   , the data remains in this ROM chip. This is the one of the special
advantages of EEPROM. In the PIC chip   the function of EPROM is to store the values
created during the runtime.
RAM memory is the one of the complex memory module in a PIC chip. This memory
associated with various type of registers (special function registers and general purpose
registers) and memory BANK modules (BANK 0, BANK 1, etc.). Once the power goes off,
the contents in the RAM will be cleared. As like normal microcontrollers, the RAM memory
is used to store temporary data and provide immediate results.

Flash memory

This is a special type of memory where READ, WRITE, and ERASE operations can be done
many times. This type of memory was invented by INTEL corporation in 1980. A PIC Chip
normally contains a certain amount of flash memory.

Registers

Information is stored in a CPU memory location called a register. Registers can be thought of
as the CPU’s tiny scratchpad, temporarily storing instructions or data. Registers basically
classified into the following.

1) General Purpose Register (GPR)


A general purpose register (or processor register) is a small storage area available on a CPU
whose contents can be accessed more quickly than other storage that available on PIC. A
general purpose register can store both data addresses simultaneously.

2) Special Function registers (SFR)


These are also a part of RAM memory locations. As compared to GPR, their purpose is
predetermined during the manufacturing time and cannot be changed by the user. It is only
for special dedicated functions.
Interrupts

Interrupt is the temporary delay in a running program. These delays stop the current
execution for a particular interval. This interval/delay is usually called as interrupt. When an
interrupt request arrives into a current execution program, then it stops its regular execution.
Interrupt can be performed by externally (hardware interrupt) or internally (by using
software).

Bus

BUS is the communication or data transmission/reception path in a microcontroller unit. In a


normal microcontroller chip, two types of  buses are normally available.

1)  Data bus

Data bus is used for memory addressing. The function of data bus is interfacing all the
circuitry components inside the PIC chip.

2)Addressbus
Address bus mostly used for memory addressing. The function of address bus is to transmit
the address from the CPU to memory locations.

USART or UART

These ports are used for the transmission (TX) and reception (RX) of data. These
transmissions possible with help of various digital data transceiver modules like RF, IR,
Bluetooth, etc. This is the one of the simplest way to communicate the PIC chip with other
devices.

Oscillators

Oscillator unit basically an oscillation/clock generating circuit which is used for providing
proper clock pulses to the PIC chip. This clock pulses also helps the timing and counting
applications . A PIC chip normally use various types of clock generators. According to the
application and the type of PIC used, the oscillators and its frequencies may vary. RC
(Resistor-Capacitor), LC (Inductor-Capacitor), RLC (Resistor-Inductor-capacitor), crystal
oscillators, etc are the normal oscillators used with A PIC chip.

STACK

The entire PIC chip has an area for storing the return addresses. This area or unit called Stack
is used in some Peripheral interface controllers. The hardware stack is not accessible by
software. But  for most of the controllers, it can be easily accessible.

Input/output ports

These ports are used for the interfacing various input/output devices and memories.
According to the type of PIC, the number of ports may change.
Advanced functioning blocks

These sections include various advanced features of a PIC chip. According to the type of PIC,
these features may change. Various advanced features in a peripheral interface controller are
power up timer, oscillator start up timer, power on reset, watch dog timer, brown out reset, in
circuit debugger, low voltage programming, voltage comparator, CCP modules etc.

Limitations of PIC Architecture

•    Peripheral Interface Controller has only one accumulator.


•    Small instruction set.
•    Register banking switch required to access RAM of other devices.
•    Operations and registers are not orthogonal.
•    Program memory is not accessible.

Advantages of PIC Controlled System

•    Reliability
The PIC controlled system often resides machines that are expected to run continuously for
many years without any error and in some cases recover by themselves if an error
occurs(with help of supporting firmware).

•   Performance
Many of the PIC based embedded system use a simple pipelined RISC processor for
computation and most of them provide on-chip SRAM for data storage to improve the
performance.

•   Power consumption


A PIC controlled system operates with minimal power consumption without sacrificing
performance. Power consumption can be reduced by independently and dynamically
controlling multiple power platforms.

•   Memory
Most of the PIC based systems are memory expandable and will help in easily adding more
and more memory according to the usage and type of application. In small applications the
inbuilt memory can be used.

Register Memory Organization in PIC 16F877

General Purpose Registers (GPR)

GPR is a small amount of storage that can be accessible more quickly than any other
memory. These register files can be accessed either directly, or indirectly, through the File
Select Register (FSR). The General Purpose Register (GPR) memory map (PIC16F877A) is
shown in the figure below.
Special Function Registers (SFR)

The special function registers are also memory registers which is used for special dedicated
functions. These registers perform various dedicated functions inside the PIC chip. Each
special function inside this PIC chip is controlled by using these registers. These registers are
used by the CPU and peripheral modules for controlling the desired operation of the device.
These registers are normally implemented as in the form of static RAM memory. A list of
these registers is given in the tables below. The Special Function Registers can be classified
into two sets: core (CPU) and peripheral. Those registers associated with the core functions
are described in detail in this section. The figures below shows SFR memory map of
PIC16F877.
Memory Organization of PIC16F877

The memory of a PIC 16F877 chip is divided into 3 sections. They are

1. Program memory
2. Data memory and
3. Data EEPROM

1. Program memory

Program memory contains the programs that are written by the user. The program
counter (PC) executes these stored commands one by one. Usually PIC16F877
devices have a 13 bit wide program counter that is capable of addressing 8K×14 bit
program memory space. This memory is primarily used for storing the programs that
are written (burned) to be used by the PIC. These devices also have 8K*14 bits of
flash memory that can be electrically erasable /reprogrammed. Each time we write a
new program to the controller, we must delete the old one at that time. The figure
below shows the program memory map and stack.
Program counters (PC) is used to keep the track of the program execution by holding the
address of the current instruction. The counter is automatically incremented to the next
instruction during the current instruction execution.

The PIC16F87XA family has an 8-level deep x 13-bit wide hardware stack. The stack space
is not a part of either program or data space and the stack pointers are not readable or
writable. In the PIC microcontrollers, this is a special block of RAM memory used only for
this purpose.

Each time the main program execution starts at address 0000 – Reset Vector. The address
0004 is “reserved” for the “interrupt service routine” (ISR).

2. PIC16F87XA Data Memory Organization

The data memory of PIC16F877 is separated into multiple banks which contain the general
purpose registers (GPR) and special function registers (SPR). According to the type of the
microcontroller, these banks may vary. The PIC16F877 chip only has four banks (BANK 0,
BANK 1, BANK 2, and BANK4). Each bank holds 128 bytes of addressable memory.
Data Memory Organization

IMAGE TAKEN FROM

The banked arrangement is necessary because there are only 7 bits are available in the
instruction word for the addressing of a register, which gives only 128 addresses. The
selection of the banks are determined by control bits RP1, RP0 in the STATUS registers
Together the RP1, RP0 and the specified 7 bits effectively form a 9 bit address. The first 32
locations of Banks 1 and 2, and the first 16 locations of Banks2 and 3 are reserved for the
mapping of the Special Function Registers (SFR’s).

BANK RP0 RP1

0 0 0

1 1 0

2 0 1

3 1 1

A bit of RP1 & RP0 of the STATUS register selects the bank access.
3. Data EEPROM and FLASH

The data EEPROM and Flash program memory is readable and writable during normal
operation (over the full VDD range). This memory is not directly mapped in the register file
space. Instead, it is indirectly addressed through the Special Function Registers. There are six
SFRs used to read and write this memory:

• EECON1

• EECON2

• EEDATA

• EEDATH

• EEADR

• EEADRH

The EEPROM data memory allows single-byte read and writes. The Flash program memory
allows single-word reads and four-word block writes. Program memory write operations
automatically perform an erase-before write on blocks of four words. A byte write in data
EEPROM memory automatically erases the location and writes the new data (erase-before-
write). The write time is controlled by an on-chip timer. The write/erase voltages are
generated by an on-chip charge pump, rated to operate over the voltage range of the device
for byte or word operations.

To know about the Register Memory Organization, and more of PIC 16F877 click on the link
below.

Loading a Program to a Microcontroller

A program is written using an IDE and is then assembled (if assembly language) or compiled
(if high level language). The machine code generated after compilation and assembly is
encoded in what is known as a binary file. A HEX file is the ASCII representation of binary
files. Some microcontrollers use BIN files instead of HEX files.  The HEX or BIN file is read
and interpreted by a programmer software. The decoded machine code is then burned to the
microcontroller flash memory.

Programmer hardware is needed to load the program into the microcontroller's flash memory.
The hardware may use different ways to program the device. When computers were older,
programs are loaded to the microcontroller via the parallel port. The size of parallel ports is a
disadvantage to modern computers and thus have been removed completely. Nowadays,
microcontrollers are programmed via USB using In-Circuit Serial Programmers (ICSP). For
PICs, the ICSP hardware is known as PicKit. For AVRs, it's Atmel-ICE. You can also create
your own ICSP circuit.
Bootloading is another method of programming a microcontroller. A bootloader is a program
loaded to a microcontroller that can change the program on the flash memory. With it, a
standalone hardware programmer will not be needed to update the program of the
microcontroller -- a personal computer can send the program via serial (USB).

The Arduino has a bootloader which accepts the program sent by the user through USB. PICs
and AVRs can also use bootloaders. The ICSP is still needed for loading the bootloader the
first time

Potrebbero piacerti anche