0% found this document useful (0 votes)
9 views39 pages

CPE - 416 (1st Lecture)

The document provides an overview of PIC microcontrollers, specifically the PIC16F84, detailing its features, architecture, and differences from microprocessors. It explains the components of microcontrollers, including memory, CPU, buses, and peripheral interfaces, as well as the importance of assembly language programming. Additionally, it discusses the applications and advantages of using PIC microcontrollers in various electronic projects and industries.

Uploaded by

yinka8380
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views39 pages

CPE - 416 (1st Lecture)

The document provides an overview of PIC microcontrollers, specifically the PIC16F84, detailing its features, architecture, and differences from microprocessors. It explains the components of microcontrollers, including memory, CPU, buses, and peripheral interfaces, as well as the importance of assembly language programming. Additionally, it discusses the applications and advantages of using PIC microcontrollers in various electronic projects and industries.

Uploaded by

yinka8380
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

INTRODUCTION

TO
PIC MICROCONTROLLERS PIC16F84

The term PIC stands for


“Peripheral Interface Controller”
BY ENGR. I.A. DAUDA

CPE416 Assembly Language Programming, Feb, 2025


INTRODUCTION
Peripheral Interface Controller was originally designed by General Instruments in
the late 1970s, GI introduces PIC 1650 and 1655-RISC with 30 instructions.

IPC was sold to microchip

Features: low cost, self-contained, 8-bit, Harvard structure, pipelined, RISC, single
accumulator with fixed reset and interrupt vectors

Various companies

§ Intel-8051

§ Atmel-AVR

§ Zilong-Z8

§ Motorola

§ Microchip technology – PIC

§ etc
INTRODUCTION
Pic microcontroller assembly language programing: Like we need language to
communicate with each other. Language is a set of symbols by which we convey our
message to others. Similarly, we communicate with microcontrollers with a
language called assembly. An assembler is used to understand our instruction or
you can say our symbols which we provide to microcontroller Assembly language
program is basically a set of instructions stored in computer memory. Computer can
only understand 1’s and 0’s. Assembly language instructions are for humans only.
Computer do not understand them. So we need to converter these assembly
language instructions to binary form which is understandable for computers.
Assembly language commands are converted into one’s and zero’s by compiler.
INTRO Contd…..
 A data file used for storing compiled program is called an “executive file”, i.e.
“HEX data file”. The name comes from the hexadecimal presentation of a data
file and has a suffix of “hex” as well, for example “probe.hex”. After has been
generated, the data file is loaded into the microcontroller using a programmer.
Assembly language codes can be written in any editor.
INTRO Contd…..

PIC microcontrollers; low-cost computers-in-a-chip; allows electronics designers and


hobbyists add intelligence and functions that mimic big computers for almost any
electronic product or projects.

Circumstances that we find ourselves in today in the field of microcontrollers had their
beginnings in the development of technology of integrated circuits. This development has
made it possible to store hundreds of thousands of transistors into one chip. That was a
prerequisite for production of microprocessors , and the first computers were made by
adding external peripherals such as memory, input-output lines, timers and other. Further
increasing of the volume of the package resulted in creation of integrated circuits. These
integrated circuits contained both processor and peripherals. That is how the first chip
containing a microcomputer, or what would later be known as a microcontroller came
a b o u t .
Microcontrollers versus Microprocessors

Microcontroller differs from a microprocessor in many ways. First and the most important is its
functionality. In order for a microprocessor to be used, other components such as memory, or
components for receiving and sending data must be added to it. In short that means that
microprocessor is the very heart of the computer. On the other hand, microcontroller is
designed to be all of that in one. No other external components are needed for its application
because all necessary peripherals are already built into it. Thus, we save the time and space
n e e d e d t o c o n s t r u c t d e v i c e s .
Microprocessor vs. Microcontroller
Microprocessor Microcontroller
• CPU is stand-alone, RAM, • CPU, RAM, ROM, I/O and timer
ROM, I/O, timer are separate are all on a single chip
• designer can decide on the • fixed amount of on-chip ROM,
amount of ROM, RAM and RAM, I/O ports
I/O ports.
• for applications in which cost,
• expensive power and space are critical
• versatility
• single-purpose (control-oriented)
• general-purpose
• Low processing power
• High processing power
• Low power consumption
• High power consumption
• Instruction sets focus on • Bit-level operations
processing-intensive • Instruction sets focus on control
operations and bit-level operations
• Typically 32/64 – bit • Typically 8/16 bit
• Typically deep pipeline (5-20 • Typically single-cycle/two-stage
stages) pipeline
7
Core components of Microcontroller.

8
Memory unit
Memory is part of the microcontroller whose
f u n c t i o n i s t o s t o r e d a t a .
The easiest way to explain it is to describe it as one
big closet with lots of drawers. If
suppose we marked the drawers in such a way
that they can not be confused, any of their
contents will then be easily accessible. It is enough
to know the designation of the drawer and
so its contents will be known to us for sure.
Memory components are exactly like that.

For a certain input we get the contents of a certain


a ddresse d memory location a nd that 's a ll.
Central Processing Unit

CPU Its memory locations are called registers.


Registers are therefore memory locations whose role is to
help with performing various mathematical operations or
any other operations with data wherever data can be found.
Look at the current situation. We have two independent
entities (memory and CPU) which are interconnected, and
thus any exchange of data is hindered, as well as its
functionality. If, for example, we wish to add the contents of
two memory locations and return the result again back to
memory, we would need a connection between memory and
CPU. Simply stated, we must have some "way" through
which data goes from one block to another.
BUS
Bus also known as communication high-way.

That "way" is called "bus". Physically, it represents a


group of 8, 16, or more wires. There are two types of
buses: address and data bus. The first one consists of as
many lines as the amount of memory we wish to address,
and the other one is as wide as data, in our case 8
bits or the connection line. First one serves to transmit
address from CPU memory, and the second to connect all
blocks inside the microcontroller.
There are three types of Buses

 Address Bus:- it is a group of I/O devices or microprocessor.


conducting wires which carries • Control Bus:- it is a group of
address only. Address bus is conducting wires, which is used
unidirectional because data flow to generate timing and control
in one direction from uP to signals to control all the
memory and from uP to IO associated peripherals,
devices. microprocessor uses control bus
 Data Bus:- It is a group of to process data, that is what to do
conducting wires which carries with the selected memory
data only. Data bus is location. Some control signals
bidirectional, that is, data flow in are: Memory read, memory
both directions, from uP to write, I/O read, I/O write,
memory or I/O devices and from Opcode fetch
memory to
Bus organization system of 8085 Microprocessor
INPUT AND OUTPUT UNIT

v Those locations we've just added are called

"ports". There are several types of ports : input,


output or bidirectional ports. When working with
ports, first of all it is necessary to choose which
port we need to work with, and then to send data
to, or take it from the port.

v When working with it the port acts like a memory

location. Something is simply being written into or


read from it, and it could be noticed on the pins of
the microcontroller.
WATCHDOG

Watchdog is a key function of the microcontroller


during its run-time. Suppose that as a result of some
interference (which often does occur in
industry) our microcontroller stops executing the program, or
worse, it starts working incorrectly when this happens with a
computer, we simply reset it and it will keep working.
However, there is no reset button we can push on the
microcontroller and thus solve our problem. To overcome
this obstacle, we need to introduce one more block called
watchdog. This block is in fact another free-run counter
where our program needs to write a zero in every time it
executes correctly.
Watchdog Application
A watchdog device is a device used to protect a system from specific software or hardware
failures that may cause the system to stop responding. The application is first registered
with the watchdog device. Once the watchdog is running on your system, the application
must periodically send information to the watchdog device. If the device does not receive
the signal within the set period of time it would execute the proper keystrokes to reboot
the machine or restart the application. Watchdog are also available for internet websites. In
this instances, the watchdog may be set to monitor your on website by attempting to access
it from several different city or country locations at regular intervals.You could then view
an online report of the connectivity or have the watchdog system e-mail you should it
become inaccessible
Types of Watchdog
There are two types of watchdogs, non-windowed and windowed. Both types causes
a reset if servicing the counter is late.
ANALOG TO DIGITAL CONVERTER

As the peripheral signals usually are substantially


different from the ones that microcontroller
can understand (zero and one), they have to be
converted into a pattern which can be
comprehended by a microcontroller. This task is
performed by a block for analog to digital
conversion or by an ADC. This block is responsible
for converting an information about some
analog value to a binary number and follow it
through to a CPU block so that CPU block can
further process it.
Analog to Digital Converter CONT.

v Finally, the microcontroller is now completed, and all

we need to do now is to assemble it into an


electronic component where it will access inner
blocks through the outside pins. The picture below
shows what a microcontroller looks like inside.

v Thin lines which lead from the center towards the

sides of the microcontroller represent wires


connecting inner blocks with the pins on the housing
of the microcontroller so called bonding lines. Chart
on the following page represents the center section
of a microcontroller.
For a real application, a microcontroller alone is not enough. Beside a
microcontroller, we need a program that would be executed, and a
few more elements which make up a interface logic towards the
elements of regulation.
Microcontroller PIC16F84

CPE439 Assembly Language Programming


Introduction
v PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. The
PIC is a tiny but complete computer. It has a CPU (central processing unit),
program memory (PROM), working memory (RAM), and two input-output ports
Program memory (FLASH)- for storing a written program. Since memory made
in FLASH technology can be programmed and cleared more than once, it makes
this microcontroller suitable for device development.
v EEPROM - data memory that needs to be saved when there is no supply.
It is usually used for storing important data that must not be lost if power supply
suddenly stops
v RAM - data memory used by a program during its execution.
In RAM are stored all inter-results or temporary data during run-time.
PORTA and PORTB are physical connections between the microcontroller and
the outside world. Port A has five, and port B eight pins.
Introduction CONT.
FREE-RUN TIMER is an 8-bit register inside a microcontroller that works
independently of the program. On every fourth clock of the oscillator it increments
its value until it reaches the maximum (255), and then it starts counting over again
from zero. As we know the exact timing between each two increments of the timer
contents, timer can be used for measuring time which is very useful with some
devices.
CENTRAL PROCESSING UNIT has a role of connective element between other
blocks in the microcontroller. It coordinates the work of other blocks and executes
the user program.
PIC16F84 Microcontroller Outline
CISC, RISC

 CISC stands for Complex Instruction Set Computer while RISC stands for Reduced

Instruction Set Computer. It has already been said that PIC16F84 has a RISC
architecture, however, Since PIC16F84 is a RISC microcontroller, that means that it has a
reduced set of instructions, more precisely 35 instructions.

 RISC - relatively limited number of instructions smaller number of types of computer


instructions so that it can operate at a higher speed.

. (ex. Intel's and Motorola's microcontrollers have over hundred instructions) All of these
instructions are executed in one cycle except for jump and branch instructions.
CISC CISC Architecture

 A complex instruction set


computer is a computer where
single instructions can
perform numerous low-level
operations like a load from
memory, an arithmetic
operation, and a memory store
or are accomplished by multi-
step processes or addressing It is a CPU design plan based on single
modes in single instructions, commands, which are skilled in executing
as its name proposes multi-step operations.
“Complex Instruction Set ”.
RISC
RISC Architecture
 A reduced instruction set computer is a
computer that only uses simple
commands that can be divided into
several instructions that achieve low-
level operation within a single CLK
cycle, as its name proposes “Reduced
Instruction Set”.
 In this machine, the instruction sets are
modest and simple, which help in comprising
more complex commands. Each instruction is It is a CPU design plan based on simple
of a similar length; these are wound together orders and acts fast.
to get compound tasks done in a single
operation. Most commands are completed in
one machine cycle.
RISC CISC
RISC processors have simple instructions CSIC processor has complex instructions that
taking about one clock cycle. The average take up multiple clocks for execution. The
clock cycle per instruction (CPI) is 1.5 average clock cycle per instruction (CPI) is in
the range of 2 and 15.
Performance is optimized with more focus on Performance is optimized with more focus on
software hardware.
It has no memory unit and uses separate It has a memory unit to implement complex
hardware to implement instructions instructions.
It has a hard-wired unit of programming It has a microprogramming unit.
The instruction set is reduced i.e. it has only The instruction set has a variety of different
a few instructions in the instruction set. Many instructions that can be used for complex
of these instructions are very primitive operations
The instruction set has a variety of different CISC has many different addressing modes and
instructions that can be used for complex can thus be used to represent higher-level
operations programming language statements more
efficiently.
Complex addressing modes are synthesized CISC already supports complex addressing
using the software modes
RISC CISC
Multiple register sets are present Only has a single register set
. The complexity of RISC lies with the The complexity lies in the microprogram
compiler that executes the program
Execution time is very less Execution time is very high
It does not require external memory for It requires external memory for calculations
calculations
The most common RISC microprocessors are Examples of CISC processors are the
Alpha, ARC, ARM, AVR, MIPS, PA-RISC, PIC, System/360, VAX, PDP-11, Motorola 68000
Power Architecture, and SPARC. family, AMD, and Intel x86 CPUs
RISC architecture is used in high-end CISC architecture is used in low-end
applications such as video processing, applications such as security systems, home
telecommunications and image processing automation, etc
The decoding of instructions is simple. The decoding of instructions is complex
Applications
 PIC16F84 perfectly fits many uses, from automotive industries and controlling home

appliances to industrial instruments, remote sensors, electrical door locks and safety
devices. It is also ideal for smart cards as well as for battery supplied devices because
of its low consumption. EEPROM memory makes it easier to apply microcontrollers to
devices where permanent storage of various parameters is needed (codes for
transmitters, motor speed, receiver frequencies, etc.).

 Low cost, low consumption, easy handling and flexibility make PIC16F84 applicable

even in areas where microcontrollers had not previously been considered (example:
timer functions, interface replacement in larger systems, coprocessor applications, etc.).
Clock / instruction cycle
 Clock is microcontroller's main starter, and is
obtained from an external component called
an "oscillator". Clock from the oscillator
enters a microcontroller via OSC1 pin where
internal circuit of a microcontroller divides
the clock into four even clocks Q1, Q2, Q3,
and Q4 which do not overlap. These four
clocks make up one instruction cycle (also
called machine cycle) during which one
instruction is executed.
Pin description

 PIC16F84 has a total of 18 pins. It is


most frequently found in a DIP18
type of case but can also
be found in SMD case which is
smaller from a DIP. DIP is an
abbreviation for Dual In Package.
 SMD is an abbreviation for Surface
Mount Devices suggesting that holes
for pins to go through when
mounting, aren't necessary in
soldering this type of a component
Pins on PIC16F84 microcontroller have the following
meaning:

Pin no.1 RA2 Second pin on port A. Has no additional function


Pin no.2 RA3 Third pin on port A. Has no additional function.
Pin no.3 RA4 Fourth pin on port A. TOCK1 which functions as a timer is also found on this pin
Pin no.4 MCLR Reset input and Vpp programming voltage of a microcontroller
Pin no.5 Vss Ground of power supply.
Pin no.6 RB0 Zero pin on port B. Interrupt input is an additional function.
Pin no.7 RB1 First pin on port B. No additional function.
Pin no.8 RB2 Second pin on port B. No additional function.
Pin no.9 RB3 Third pin on port B. No additional function.
Pin no.10 RB4 Fourth pin on port B. No additional function.
Pin no.11 RB5 Fifth pin on port B. No additional function.
Pin no.12 RB6 Sixth pin on port B. 'Clock' line in program mode.
Pin no.13 RB7 Seventh pin on port B. 'Data' line in program mode.
Pin no.14 Vdd Positive power supply pole.
Pin no.15 OSC2 Pin assigned for connecting with an oscillator
Pin no.16 OSC1 Pin assigned for connecting with an oscillator
Pin no.17 RA2 Second pin on port A. No additional function
Pin no.18 RA1 First pin on port A. No additional function.
Reset
Reset is used for putting the microcontroller into a
'known' condition. Whenever microcontroller behave
rather inaccurately under certain undesirable
conditions. In order to continue its proper
functioning it has to be reset, meaning all registers
would be placed in a starting position. Reset is not
only used when microcontroller doesn't behave the
way we want it to, but can also be used when trying
out a device as an interrupt in program execution,
or to get a microcontroller ready when reading in a
program.
Microcontroller PIC16F84 knows several sources of resets:

a)Reset during power on, POR (Power-On Reset)


b) Reset during regular work by bringing logical zero to MCLR microcontroller's pin.
c) Reset during SLEEP regime
d) Reset at watchdog timer (WDT) overflow
e) Reset during at WDT overflow during SLEEP work regime.

The most important reset sources are a) and b). The first one occurs each time a power supply is
brought to the microcontroller and serves to bring all registers to a starting position initial state. The
second one is a product of purposeful bringing in of a logical zero to MCLR pin during normal
operation of the microcontroller. This second one is often used in program development. During a
reset, RAM memory locations are not being reset. They are unknown during a power up and are not
changed at any reset. Unlike these, SFR registers are reset to a starting position initial
state. One of the most important effects of a reset is setting a program counter (PC) to zero(0000h) ,
which enables the program to start executing from the first written instruction.
Assignment (individaul)
Briefly discuss on the following terms:
v Merit and demerit of RISC and CISC
v RISC and CISC as well as area of their applications
v Microcontrollers versus Microprocessors and area of their applications
.

You might also like