You are on page 1of 45

Hawassa University, Institute of Technology School of Electrical and

Computer Engineering

Embedded Systems (ECEg-5702)

Lecture 2: Embedded Microcontrollers

By Demisew T. 06/30/2021 1
Outline of the Lecture

Structure of a Basic Computer Systems

CPU families used in Microcontrollers

Basic I/O Devices and Technologies

Interrupts and Memories

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 2
Structure of a Basic Computer Systems

• Some important terminology


• One of the most important features of a computer is how much memory it has.
• Terms used to describe amounts of memory are
• Bit
• Nibble (4bit)
• Byte (8bit)
• Word (2bytes)
• Kilobyte (210 bytes = 1,024 bytes)
• Megabyte (220 bytes = 1,048,576)
• Gigabyte (230 bytes, just over one billion bytes)
• Terabyte (240 bytes, just over one trillion bytes)
• Petabyte (250 bytes, just over one quadrillion bytes) Two types of memory
• Exabyte (260 bytes, just over one quintillion bytes) used in
• Zettabyte (270 bytes, just over one Sextillion bytes) microcomputers are
• Yottabyte (280 bytes, just over one Septillion bytes) RAM and ROM

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 3
Structure of a Basic Computer Systems

• Internal organization of computers

• The internal working of every • In every computer there are


computer can be broken down into three types of buses: address
three parts: CPU (central processing bus, data bus, and control bus.
unit), memory, and I/O
(input/output) devices.

• The address bus and data


bus determine the
capability of a given CPU.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 4
Structure of a Basic Computer Systems

• More about the data bus


• Data buses are bidirectional, since the CPU must use them either to receive or to
send data.
• The processing power of a computer is related to the size of its buses
• A n 8-bit bus can send out 1 byte a time, but a 16-bit bus can send out 2 bytes at a
time, which is twice as fast.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 5
Structure of a Basic Computer Systems

• More about the address bus


• The number of address buses for a CPU determines the number of locations with
which it can communicate.
• The number of locations is always equal to 2x, where x is the number of address
lines, regardless of the size of the data bus.
• Each location can have a maximum of 1 byte of data. This is due to the fact that all
general-purpose microprocessor CPUs are what is called byte addressable.
• The address bus is a unidirectional bus, which means that the CPU uses the
address bus only to send out addresses

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 6
Structure of a Basic Computer Systems

• CPU and its relation to RAM and ROM


• For the CPU to process information, the data must be stored in RAM or ROM.
The function of ROM in computers is to provide information that is fixed and
permanent.
• RAM is used to store information that is not permanent and can change with time

• the CPU gets the information to be processed, first from RAM (or ROM). Only if
it is not there does the CPU seek it from a mass storage device such as a disk, and
then it transfers the information to RAM.
• RAM and ROM are sometimes referred to as primary memory and disks are called
secondary memory.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 7
Structure of a Basic Computer Systems

• Inside CPUs
• A program stored in memory provides instructions to the CPU to perform an
action.
• It is the function of the CPU to fetch these instructions from memory and execute
them. To perform these actions all CPUs are equipped with resources such as the
following:
• Registers-store information temporarily

• ALU-for performing arithmetic and logic functions

• Program counter-used to point to the address of the next instruction to be executed

• Instruction decoder -used to interpret the instruction fetched into the CPU

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 8
Structure of a Basic Computer Systems

• Internal working of computers


• Assume that an imaginary CPU has registers called A, B, C, and D. It has an 8-
bit data bus and a 16-bit address bus.
• The action to be performed by the CPU is to put hexadecimal value 21H into
register A, and then add to register A values 42H and 12H.
• Assume that the code for the CPU to move a value to register A is 1011 0000
(B0H) and the code for adding a value to register A is 0000 0100 (04H) in some
imaginary instruction format.
• The necessary steps and code to perform them are as follows.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 9
Structure of a Basic Computer Systems

• Internal working of computers


• If the program to perform the actions listed above is stored in memory locations
starting at 1400H, the following would represent the contents for each memory
address location:

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 10
Structure of a Basic Computer Systems

• Inside the embedded system:


• CPU: the main criteria for choosing specific processor is: Can
it provide the processing power needed to perform the tasks
within the system?
• While processor performance is essential and forms the first gating criterion,
there are others such as cost — this should be system cost and not just the cost
of the processor in isolation, power consumption, software tools and
component availability and so on.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 11
Structure of a Basic Computer Systems

• Inside the embedded system:


• Memory: is an important part of any embedded system design and
is heavily influenced by the software design, and in turn may
dictate how the software is designed, written and developed.
Memory essentially performs two functions within an embedded
system:
• It provides storage for the software that it will run
• It provides storage for data such as program variables and intermediate results, status
information and any other data that might be created throughout the operation
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 12
Structure of a Basic Computer Systems

• Inside the embedded system:


• Peripherals: are used to communicate with the outside
world. The main types of peripherals that are used
include:
• Binary outputs: They can be used individually or grouped together to create parallel
ports where a group of bits can be input or output simultaneously.
• Serial outputs: These are interfaces that send or receive data using one or two pins in
a serial mode. They are less complex to connect but are more complicated to program.
• Analogue values: While processors operate in the digital domain, the natural world
does not and tends to orientate to analogue values.
• Displays: Displays are becoming important and can vary from simple. LEDs and
seven segment displays to small alpha-numeric LCD panels.
• Time derived outputs: Timers and counters are probably the most commonly used
functions within an embedded system.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 13
Structure of a Basic Computer Systems

• Inside the embedded system:


• Software: The software components within an embedded
system often encompasses the technology that adds value
to the system and defines what it does and how well it
does it. The software can consist of several different
components:
• Initialization and configuration
• Operating system or run-time environment
• The applications software itself
• Error handling
• Debug and maintenance support.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 14
Structure of a Basic Computer Systems

• Inside the embedded system:


• Algorithms: are the key constituents of the software that
makes an embedded system behave in the way that it does.
They can range from mathematical processing through to
models of the external environment which are used to
interpret information from external sensors and thus
generate control signals..

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 15
Structure of a Basic Computer Systems

• Types of Embedded systems:

 We can divide all embedded systems into four categories:

Microcontroller

Expanded Microcontroller

Microprocessor based

Board based

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 16
Structure of a Basic Computer Systems

• Types of Embedded systems:


Microcontroller: can be considered as self-contained systems with a
processor, memory and peripherals so that in many cases all that is
needed to use them within an embedded system is to add software.
Microcontrollers are usually available in several forms:
• Devices for prototyping or low volume production runs (uses flash
memory for program downloading)
• Devices for low to medium volume production runs (uses OTP ROM
for program downloading)
• Devices for high volume production runs (uses Masked ROM for
program)

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 17
Structure of a Basic Computer Systems

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 18
Structure of a Basic Computer Systems

•Types of Embedded systems:


Expanded microcontroller: The choice of memory
sizes and partitioning is usually a major
consideration.
• Some applications require more memory or peripherals than are available on a
standard part.
• Most microcontroller families have parts that support external expansion and
have an external memory and/or I/O bus which can allow the designer to put
almost any configuration together.
• Many of the higher performance microcontrollers are adopting this approach.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 19
Structure of a Basic Computer Systems

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 20
Structure of a Basic Computer Systems

•Types of Embedded systems:


Microprocessor based: Microprocessor-based
embedded systems originally took existing general-
purpose processors such as the MC6800 and 8080
devices and constructed systems around them using
external peripherals and memory.
• These systems offer more performance than is usually available from a
traditional microcontroller.
• There has been the development of integrated microprocessors where the
processor is combined with peripherals such as parallel and serial ports, DMA
controllers and interface logic to create devices that are more suitable for
embedded systems by reducing the hardware design task and costs.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 21
Structure of a Basic Computer Systems

•Types of Embedded systems:


Board based: So far, the types of embedded systems
that we have considered have assumed that the
hardware needs to be designed, built and debugged.
• An alternative is to use hardware that has already been
built and tested.
• The main advantage is the reduced work load and the
availability of ported software that can simply be utilized
with very little effort.
• The disadvantages are higher cost and in some cases
restrictions in the functionality that is available.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 22
CPU families used in Microcontrollers

• Processor Architectures: we have several


options for CPU architectures such as:
• CISC Vs RISC
• Harvard Vs Princeton
• Microcoded Vs Hardwired Processors

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 23
CPU families used in Microcontrollers

• CISC Vs RISC:
• Until the early 1980s, all CPUs, whether single-chip or whole-board,
followed the CISC (complex instruction set computer) design philosophy.

• CISC refers to CPUs with hundreds of instructions designed for


every possible situation.
• Drawbacks of CISC- consumes millions of transistors, makes the
design very complicated, time-consuming, and expensive.
• In the early 1980s, a new CPU design philosophy called RISC
(reduced instruction set computer) was developed.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 24
CPU families used in Microcontrollers

• CISC Vs RISC:
• RISC Streamline the instructions by simplifying and reducing them
from many to few and use all the transistors that are saved to
enhance the power of the CPU
• the first working single-chip RISC microprocessor was implemented
by a group of researchers at the University of California at Berkeley
in 1980.
• Since the late 1980s, many companies designing new CPUs (either
single-chip or whole-board) have used the RISC philosophy.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 25
CPU families used in Microcontrollers

• Harvard Vs Princeton:
• Princeton computer architecture or John Von Neumann
architecture had common memory for storing the control
program as well as variables and other data structures.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 26
CPU families used in Microcontrollers

• Harvard Vs Princeton:
• Harvard’s response was a design that used separate memory
banks for program storage, the processor stack, and variable
RAM.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 27
CPU families used in Microcontrollers

• Microcoded Vs Hardwired Processors: are two


types of processor implementations once specific
architecture is chosen.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 28
Embedded Microcontroller Modules

• Generally, any embedded microcontrollers have the


following modules in side.
• Register Set.
• Bus structure
• Memory
• Timing base or system
• Ports Systems
• Analog to digital Converters
• Communication Systems
• Interrupt systems

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 29
Embedded Microcontroller Modules

• Register Set:
• Is the interface between the user and the different subsystems aboard the
Microcontroller. They are often called Special Function Registers (SFRs).
• Each register consists of a collection of flip-flops that can either be set to a logic
one or logic zero. Each flip-flop can be viewed as a software configurable switch.
• The function of each register and each register bit are carefully defined in the
specific microcontroller’s documentation.
• To configure a specific subsystem the system designer will determine the
appropriate setting for each bit within the register.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 30
Embedded Microcontroller Modules
• Register Set:

• The flip-flops are categorized by subsystem as shown in Figure


2-11.
• Usually all registers associated with a given subsystem are
grouped together.
• All bits within a register are programmed simultaneously by
setting the name of the register (as defined in the compiler
definitions) to the desired bit pattern.
• For example, to set a register called SCIBaudRate to the
binary value 1010 1110 the following command may be used:

SCIBaudRate = 0xAE; //0x means hexadecimal.


Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 31
Embedded Microcontroller Modules

• BUS Structure:
• Different subsystems within a microcontroller are
connected with several different buses.
• Most microcontrollers are equipped with
• an address bus,
• a data bus, and
• a control bus.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 32
Embedded Microcontroller Modules

• Memory:
• The span of addressable memory usually contains several
different types of memory including
• Static Random Access Memory (SRAM),

• byte-addressable Electrically Erasable Programmable Read Only Memory


(EEPROM), and
• bulk programmable Flash EEPROM.

• It should be emphasized that these memory components are


contained within the confines of the microcontroller chip.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 33
Embedded Microcontroller Modules

• Memory:
• To keep a track of the memory
locations in use and the type of
memory present within the system, a
visual tool called a memory map is
employed.
• The memory map provides the size in
bytes of each memory component and
its start and stop address within the
memory system.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 34
Embedded Microcontroller Modules

• Time base:
• The speed at which a microcontroller sequences through its actions is
controlled by an external time base.
• The time base may be provided by an external quartz crystal, a
programmable oscillator, a ceramic resonator, or an internal time base.
• Some microcontrollers are designed to operate at a set specific frequency
such as 8 MHz while others have been flexibly designed to operate at a
wide range of frequencies.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 35
Embedded Microcontroller Modules

• Time base:
• Most microcontrollers are equipped with a
multichannel timing system. The channels within the
timing system may be configured to
• Measure parameters of input signals such as period and duty cycle.

• Generate precision output pulses or repetitive signals.

• Count incoming pulses present in an input signal.

• Generate PWM signals.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 36
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 37
Embedded Microcontroller Modules

• PORT SYSTEMS:
• Microcontrollers are equipped with a series of ports to provide access to the world
beyond the microcontroller.
• These ports are organized as eight-bit input/output ports.

• Usually a port register is equipped with an accompanying data direction register,


which is used to set the direction (input or output) for a given port pin.
• Many digital I/O ports have alternate functions such as ADC, Serial
Communication and network interfacing.
• some microcontroller ports are equipped with time multiplexed capability. This
simply means that the function of a given port alternates at a prescribed interval.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 38
Embedded Microcontroller Modules

• Analog-to-Digital Converters:
• Many microcontrollers are equipped with analog-to-digital conversion
(ADC) subsystems.
• This subsystem converts continuously varying analog signals from the
outside world into a binary representation suitable for use by the
microcontroller.
• These converters commonly have 8–10-bit resolution.
• Therefore, a continuous signal is converted to a series of digital snapshots of
the analog signal.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 39
Embedded Microcontroller Modules

• COMMUNICATION SYSTEMS:
• When we consider communication between two systems, the taxonomy
consists of parallel and serial communications.
• Simply put, a parallel communication method utilizes multiple channels,
bus wires, to send and receive multiple streams of data simultaneously,
compared to a serial communication method where only a single stream of
data is sent and received at a time.
• Typically, parallel communication techniques are used for short distance
communication within and outside of a microcontroller.
• For a long distance communication, a serial communication technique is
used to send and receive data.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 40
Embedded Microcontroller Modules

• COMMUNICATION SYSTEMS:
A) Serial Communications: There are two different types of serial
communications available: synchronous communication and asynchronous
communication.
• The asynchronous communication method uses a start and stop bit protocol to
synchronize a transmitter and receiver.
• The start and stop synchronization bits are embedded in each transmitted signal
byte.
• The advantage of the asynchronous communication is that it is inexpensive, but
the disadvantage is that the data transmission rates are typically slower than a
synchronous serial communication system due to its overhead (start and stop
bits).
• Asynchronous serial communication subsystems are referred to as the UART
(universal asynchronous receiver transmitter) or the SCI (serial communications
interface).
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 41
Embedded Microcontroller Modules

• COMMUNICATION SYSTEMS:
B) Terminology:
i. Simplex mode: In this mode, the serial communication is accomplished by
transmitting data in one direction at a time.
ii. Duplex mode: In this serial communication mode, data can be transmitted
and received from both ends of the communication link at the same time.
iii.BAUD rate: The rate of bits sent or received. It describes the number of bits
communicated per second.
iv.ASCII code: is used in communication to encode alphabets, numbers,
punctuation, and control characters using a seven-bit representation. ASCII
is a subset of the international Unicode standard.
v. Bit time: The time required to transmit or receive a single bit.
vi.Serial line code: A specific encoding mechanism used to transmit and receive
information.
Hawassa University, Institute of Technology School of Electrical and
Computer Engineering 06/30/2021 42
Embedded Microcontroller Modules

• Interrupt System:

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 43
Embedded Microcontroller Speed

• In general, you should use the lowest acceptable speed for a


given application.
• This is because that the power consumption of a
microcontroller is directly proportional to its operational
speed.
• Since many microcontroller applications are battery powered,
conserving power and hence extending battery life is essential.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 44
Choosing a Microcontroller for a Specific Design

• The following are some of the considerations for choosing an appropriate


microcontroller for a specific application:
• Number of ports: Enough ports and external pins to support application?
• Required subsystems: Equipped with the proper subsystems for a specific
application?
• Memory size and type: Memory large enough to support application
algorithm?
• Clock speed: Does the processor operate at a sufficient speed to complete the
algorithm in the required time?
• Power dissipation: Is a low power dissipation processor required for a specific
application?
• Special feature set: Fuzzy logic? Signal processing features? etc.

Hawassa University, Institute of Technology School of Electrical and


Computer Engineering 06/30/2021 45

You might also like