Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 71

MEIE

Lecture 1

Introduction to microcontrollers

Presenter: Doc Namoshe Date: 08/10/2020


Lecturer, MEIE Venue: BIUST Auditorium
Table of contents
 History of electronic devices
 Concept of µC and µP
 Deference between µC and µP
 Harvard and Von- Neumann
architecture
 Risc and Cisc machine
1939 Computers In 1947
used

1960 logic gates


1971 microcontroller
Vacuum tube computers (1939)
Transistor (1947)
Transistor vs Vacuum Tubes
Transistor is a semiconductor device which is used as an electronic
switch and as a signal amplifier. It is a semiconductor device that
revolutionized the electronic industry. It replaced vacuum diode that
was used in most appliances before the invention of transistor.

• The disadvantages of vacuum diodes:


• bulky (large in size)
• High power consumption because works on thermionic emission
• Glass tubes are fragile
• Higher operating voltage requirement
• Shorter life span

• Advantages of transistors
Usually lower cost and smaller than tubes, especially in small-signal circuits.
• Lower power consumption, less waste heat
• Can operate on lower-voltage supplies.
• Long life span
1960 birth of logic gates
History of microcontroller
If we will go back to history the 8051 microcontroller was first invented
in the year 1980 by the microprocessor giant Intel and gradually it
has been accepted worldwide and with the every coming days the
importance of the 8051 microcontroller is escalating. When it was
invented by the Intel, it was developed by means of NMOS technology
(N-type metal-oxide-semiconductor or Negative Channel MOS), but as
NMOS technology but it was not very effective.

In order to increase the effectiveness and the productivity the Intel has
remodeled it by implementing the technology of CMOS (Complementary
Metal Oxide Semiconductor) technology and a new edition came into
existence with a letter ‘C’ in the title name so that it can meet the
demand and can perform up to the mark. The new edition of the 8051
micro controller has two buses and out of which one for the program
and other for data so that it can perform well.
Microprocessor and Microcontroller development history
Summary History
Functions of µC / µP

 digital devices

 can perform arithmetic (add, subtraction,


addition, division)and logical operations
(and/or/nor/xor)

 can perform instructions given by users (set of


instruction is called a program - µC/ µP can
perform different operations)
µP µC
ALU
ALU
REGISTERS
FEW REGISTERS (STORE DATA)
CONTROL UNIT
CONTROL UNIT(GENERATE DIFF CONTROL
SIGAL, E.G WRITE SIGNAL, CHIP SELECT SIGNAL ) INTERNAL MEMORY
RAM – used to store data
ROM – used to store program/ instructions

TO use µP you must interface devices


inbuilt timers- used for delay
externally such as memory, timers, interrupts, generation/counting external events
ports, serial communication

WATCH DOG timers- protect the microcontroller

SERIAL COMMUNICATION-used to transmit or


receive serially

INTERRUPTS
PORTS -connect or interface I/o devices directly
µP µC
• PC can perform several tasks • Microcontroller is typically
simultaneously (e.g. type in dedicated to the same task
homework while playing music)
• Central Processing Unit
Store
programs

peripherals
Determines processing speed
µP based system
µP based system

• The central processing unit (CPU) consists


of six main components:
• control unit (CU)
• arithmetic logic unit (ALU)
• registers
• cache
• buses
• Clock
• All the components work together to allow
processing and system control.
Control unit (CU)

• The CU provides several functions:

• it fetches, decodes and executes


instructions
• it issues control signals that control
hardware components within the CPU
• it transfers data and instructions
around the system
Arithmetic logic
unit (ALU)

• The ALU has two main


functions:
• it performs arithmetic and
logical operations
(decisions).
• it acts as a gateway
between primary
storage and secondary
storage - data transferred
between them passes
through the ALU.
• The ALU performs
arithmetic and logical
operations.
Registers

Registers are small amounts of high-speed memory contained within the


CPU. They are used by the processor to store small amounts of data that
are needed during processing, such as:

• the address of the next instruction to be executed


• the current instruction being decoded
• the results of calculations

Different processors have different numbers of registers for different


purposes. Most have some, or all, of the following:

• program counter (PC)


• memory address register (MAR)
• memory data register (MDR)
• current instruction register (CIR)
• accumulator (ACC)
The fetch-decode-execute cycle

The fetch-decode-execute cycle is a key feature of the von Neumann architecture and
consists of seven stages:

1. The memory address held in the program counter (PC) is copied into the memory
address register (MAR).
2. The address in the program counter is incremented (increased) by one. The
program counter now holds the address of the next instruction to be fetched.
3. The processor sends a signal along the address bus to the memory address held in
the MAR.
4. The instruction or data held in that memory address is sent along the data bus to
the memory data register (MDR).
5. The instruction or data held in the MDR is copied into the current instruction
register (CIR).
6. The instruction or data held in the CIR is decoded and then executed. Results of
processing are stored in the accumulator (ACC).
7. The cycle returns to step one.
The fetch-decode-execute cycle
Processor Signal sent
Memory adds copied MAR

Instruction sent via


To
MDR
The fetch-decode-execute cycle
Cache

Cache is a small amount of high-speed


random access memory (RAM) built
directly within the processor. It is used
to temporarily hold data and instructions
that the processor is likely to reuse. This
allows for faster processing, as the
processor does not have to wait for
the data and instructions to be
fetched from the RAM.
Clock

• The CPU contains a clock which, along with the CU, is used to
coordinate all of the computer's components. The clock
sends out a regular electrical pulse which synchronizes (keeps
in time) all the components.

• The frequency of the pulses is known as clock speed. Clock


speed is measured in hertz (Hz). The greater the speed, the
more instructions can be performed in any given moment of
time.

• In the 1980s, processors commonly ran at a rate of between 3


megahertz (MHz) and 5 MHz, which is 3 million to 5 million
pulses or cycles per second. Today, processors commonly run
at a rate of between 3 gigahertz (GHz) and 5 GHz, which is 3
billion to 5 billion pulses or cycles per second.
Buses
A bus is a high-speed internal
connection. Buses are used to
send control signals and data
between the processor and other
components.

Three types of bus are used.

Address bus - carries memory


addresses from the processor to
other components such as
primary storage and
input/output devices. The
address bus is unidirectional.

Data bus - carries the data


between the processor and other
components. The data bus is
bidirectional.

Control bus - carries control


signals from the processor to
other components. The control
bus also carries the clock's pulses.
The control bus is unidirectional.
µP vs µC based system
 µP based systems are • µC based systems are
 more flexible because were  less flexible
interfacing all devices
o everything is available
externally, such as memory,
internally
serial communication, timers,
o one can not upgrade the
o it depends upon our
memory requirement for
application
example
o the choice of size of
memory also depends on
application
o the choice of devices is
application based
Von- Neumann architecture

The von Neumann architecture, which is also known as the von Neumann model and Princeton
architecture, is a computer architecture based on the 1945 description by the mathematician and
physicist John von Neumann. This describes a design architecture for an electronic digital
computer with parts consisting of a Central Processing Unit (CPU) containing an Arithmetic
Logic Unit (ALU) and Processor Registers; a Control Unit containing an instruction register
and program counter; a memory to store both data and instructions; external mass storage;
and input and output mechanisms.
The meaning has evolved to be any stored-program computer in which an instruction fetch and a
data operation cannot occur at the same time because they share a common bus. This is
referred to as the von Neumann bottleneck and often limits the performance of the system.
Von- Neumann architecture
summary
Von Neumann architecture is the design upon which many general purpose computers are based. The key
elements of von Neumann architecture are:

• data and instructions are both stored as binary digits


• data and instructions are both stored in primary storage
• instructions are fetched from memory one at a time and in order (serially)
• the processor decodes and executes an instruction, before cycling around to fetch the next instruction
• the cycle continues until no more instructions are available

A processor based on von Neumann architecture has five special registers which it uses for processing:

• the program counter (PC) holds the memory address of the next instruction to be fetched from primary
storage
• the memory address register (MAR) holds the address of the current instruction that is to be fetched from
memory, or the address in memory to which data is to be transferred
• the memory data register (MDR) holds the contents found at the address held in the MAR, or data which
is to be transferred to primary storage
• the current instruction register (CIR) holds the instruction that is currently being decoded and executed
• the accumulator (ACC) is a special purpose register and is used by the arithmetic logic unit (ALU) to hold
the data being processed and the results of calculations
https://www.bbc.co.uk/bitesize/guides/zhppfcw/revision/3
Harvard architecture

In early computer systems, machine instructions


were stored on punch cards and data could be
stored on another media such as magnetic tape.
This kept the instructions and data entirely separate
from one another, known as the Harvard
architecture.
In modern computer systems this can be achieved
by using a central processing unit with two
separate memory units, one to store machine
instructions and another to store data, which
are connected by different buses.
Harvard architecture
Factors affecting CPU performance

• Even though today's processors are


tremendously fast, their performance can
be affected by several factors, such as:

• clock speed
• cache size
• number of cores
Clock speed
• Clock speed is the number of pulses the central processing unit’s
(CPU) clock generates per second. It is measured in hertz (Hz).
• The faster the clock speed, the faster the computer is able to run
fetch-decode-execute cycles. This means that it can process more
instructions in the same amount of time.

• CPU clocks can sometimes be sped up by the user. This process is
known as overclocking. When the number of pulses per second is
increased, more fetch-decode-execute cycles can be performed and
more instructions can be processed in a given time. This increases
performance, but also requires more power, which results in a
greater need for heat dissipation and can strain the life of the
battery. Overclocking causes the CPU to work harder and produce
more heat, which can lead to long-term damage to the hardware.
Cache

• Cache is a small amount of high-speed random


access memory (RAM) built directly within the
processor. It is used to temporarily hold data
and instructions that the processor is likely to
reuse. This allows for faster processing as the
processor does not have to wait for the data and
instructions to be fetched from RAM.
• The larger the cache size, the less time a processor
has to wait for instructions to be fetched. This
improves performance.
Number of
cores
A processing unit within a CPU is
core
known as a core. Each core is
capable of fetching, decoding and
executing its own instructions.

A CPU with more cores can process


more instructions in a given time.
However, sometimes one core will
have to wait for the output from
another before carrying out the
next phase of the instruction,
which can cause a delay.

Multiple cores increase the processor


cost. Many modern CPUs are dual-
core (two) or quad-core (four)
processors. This provides vastly
superior processing power.
What is a microcontroller

A Microcontroller is a VLSI (Very Large Scale Integration)


Integrated Circuit (IC) that contains electronic computing unit
and logic unit (combinedly known as CPU), Memory (Program
Memory and Data Memory), I/O Ports (Input / Output Ports)
and few other components integrated on a single chip that is
programmable to do/ carry out a specific task
Or
Simply Microcontrollers are a just a mini- computers
Basics of Microcontrollers
• Basically, a Microcontroller consists of the following components.

• Central Processing Unit (CPU)


• Program Memory (ROM – Read Only Memory)
• Data Memory (RAM – Random Access Memory)
• Timers and Counters
• I/O Ports (I/O – Input/Output)
• Serial Communication Interface
• Clock Circuit (Oscillator Circuit)
• Interrupt Mechanism

• Most modern Microcontrollers might contain even more


peripherals like SPI (Serial Peripheral Interface), I2C (Inter
Integrated Circuit), ADC (Analog to Digital Converter), DAC (Digital
to Analog Converter), CAN (Controlled Area Network), USB
(Universal Serial Bus), and many more.
µP µC
Microprocessor Microcontroller
Applications General computing(i.e. Appliances, specialized
laptops, tablets) devices
Speed Very fast (GHz) Relatively slow (no speed is
needed for running microwave)
External parts It need many parts (Its It has most things built into
useless on its on) it so only a few parts are
Main job is to process need (memory, way to
data/ math communicate with external
world)
Cost High (very complex to make) Low
Medium to high Very low
Vendors Intel, ARM, AND Atmel, ST,TI, microchip
Microcontrollers??
Sometimes, a Microcontroller is also called as a
Computer-on-a-Chip or a Single-Chip-Computer.
Since the Microcontroller and its supporting circuitry
are often embedded in the device it controls, a
Microcontroller is also called as an Embedded
Controller.

Microcontrollers are omnipresent. If a device or an


application involves measuring, storing, calculating,
controlling or displaying information, then device
contains a Microcontroller in it. Let us see some of
the areas where microcontrollers are used.
Application of Microcontrollers
The biggest user of Microcontrollers is probably the
Automobiles Industry. Almost every car that comes out of
the assembly factory contains at least one Microcontroller
for the purpose of engine control. You can find many more
Microcontrollers for controlling additional systems.

Consumer Electronics is another area which is loaded with


Microcontrollers. Microcontrollers are a part of Digital Cameras, Video
Camcorders, CD and DVD Players, Washing Machines, Ovens, etc.

Microcontrollers are also used in test and measurement equipment


like Multimeters, Oscilloscopes, Function Generators, etc. You can
also find microcontrollers near your desktop computer like Printers,
Routers, Modems, Keyboards, etc.
Microcontrollers in automobile
Where do you find them??

Microcontrollers are hidden in tons of appliances, gadgets and


other electronics devices
Parts of Microcontroller
CPU
• CPU is regarded as the brain of the microcontroller which takes instructions in the
form of programming and helps to execute them.

• It behaves like a bridge that communicates with different components and activities
happening inside the single chip.
• Customized programming option available in microcontroller makes it more reliable and
user friendly.
• CPU is incorporated with on board registers which are divided into two types data
registers and addressing registers.
• Data registers also known accumulators are used for logic and shifting instructions.
• Addressing registers are used for holding the addresses for memory data accessing.
The stack pointer is referred as a address register which directs to the memory used for
hardware stack. Hardware stack is used for interrupt calls and returns and for
subroutine calls and returns.
• Hardware stack pointer design is not compulsory, some CPU comes with a single link
register, which behaves like a deep stack on the CPU and helps in fast subroutine calls
and returns.
• A microcontroller CPU is capable of executing series of instructions some of which are
data manipulation instructions, some are logic instruction and some are shifting
instructions.
I/O

• Different I/O ports are incorporated in the


microcontroller.
• They are used to connect the external
devices such as printers, LCD,LED,
external memories to the microcontroller.
• There are several serial ports available in
the microcontroller which are used to
connect peripherals serially with the
microcontroller.
Memory

• Like microprocessor, microcontroller comes


with memory spaces such as RAM and ROM
which help in storing the program source code.
• These memory spaces are very small as
compared to desktop computers.
• Once you generate a program and upload in
the microcontroller, it stores in the certain
memory location of microcontroller.
• These memory locations are already set by the
manufacturer.
Timers and Counters

• Timers and Counters are very handy in


achieving different tasks including pulse
generation, frequency generation,
measuring, clock function and modulation.
• Timer and counters functions are
synchronized with microcontroller clock,
used for measuring time intervals between
two events and can count up to 255 count
for 8 bit microcontroller and 65535 for 16
bit microcontroller.
ADC and DAC

• ADC is an analog to digital converter which


converts the analog signal to digital form such
as converting analog signal of sensor into
digital form.
• Similarly, DAC is a digital to analog converter
which converts the digital signal into analog
form which can be used to control motor.
Microcontroller Types
Classification based on Bits

• Microcontrollers come in 8 bit, 16 bit, 32 bit and 64 bit. Some most


advanced microcontrollers have bits more than 64 which can execute
functions in the embedded systems.

• 8 bit microcontroller is capable of executing smaller arithmetic and


logic instructions. Most common 8 bit microcontrollers are atmel
8031 and 8051.

• In contrast to 8 bit microcontroller, 16 bit microcontroller executes


program with higher precision and accuracy. Most common 16 bit
microcontroller is 8096.

• 32 bit microcontroller is applied into automatic control systems and


robotics where high durability and reliability is required. Office
machines and some power and communication systems use 32 bit
controller to execute different instructions.
Classification based on Memory

• Based on memory, microcontrollers are divided into two


types i.e. external memory microcontrollers and embedded
memory microcontrollers.
• When embedded system needs both microcontroller and
external functioning block that is not incorporated in
microcontroller, then microcontroller is called external
memory microcontroller. 8031 is a great example of external
memory microcontroller.
• When all functioning blocks are incorporated in a single chip
that is connected with embedded system, then microcontroller
is called embedded memory microcontrollers. 8051 is a great
example of embedded memory microcontrollers.
RISC and CISC
• There are two main types of processor:
• Reduced instruction set computer (RISC)
• Complex instruction set computer (CISC)

• RISC processors can process a limited number of relatively simple instructions
by breaking each one down into even simpler instructions that can be carried
out quickly. Processing simpler instructions requires less circuitry, which
consumes less power, so less heat is generated. This makes them ideal for use
in smartphones. RISC processors may be used in an embedded system where it
is not necessary to process complex instructions and where the instructions are
relatively simple and repetitive. They use less power so do not have a need for
dedicated cooling systems.

• CISC processors are physically larger and can process more complex
instructions. They can understand and carry out complex tasks with only a few
instructions. Processing complex instructions requires more complex circuitry
which needs more power and therefore more heat is generated. Most modern
computers use CISC processors.
For more information contact:

Dr. Molaletsa Namoshe


Faculty of Engineering
Department of Mechanical Energy and
Industrial Engineering

Tel: (+267) 4931662


E-mail: namoshem@biust.ac.bw

You might also like