Lecture Notes on ETI 4211 Microprocessors and Embedded Systems
Sept-Dec 2024 Semester
Samuel Ndegwa
1
Prerequisites
ETI 3206 Digital Electronics II
Purpose of the Course
The purpose of this course is to design and program embedded systems and implement them in
low-level hardware using standard C and assembly language.
Expected Learning Outcomes
By the end of this course, the learner should be able to;
1. Describe processor architectures
2. Design embedded systems
3. Software design basics, software engineering principles
4. Ability to build an Arm-based embedded system and program to satisfy given
user specifications
Course Content
Introduction to computing platforms: microprocessors, micro-controllers, single board
computers, smart cards, desk tops, super computers.
Internal organization of a computer: CPU, memory, peripherals, flags, ALU, Registers, data
buses, I/O interfaces. Microprocessor systems development tools and monitors, assemblers, link
loaders, editors, debugging facilities.
Programming for microprocessors: assembler concept, mnemonics, symbolic addresses,
literal and pseudo operations, simple instructions and addressing modes, data storage location,
counter error flags and messages.
Introduction to Embedded Systems Design: Software Design Basics;The Arm Cortex-M4
Processor Architecture; Interrupts and Low Power Features; General Purpose I/O; Analog
Interfacing; Timer Peripherals; Serial Communication. Hardware: CPU, EEPROM, EPROM,
RAM, peripheral interfaces and devices, Software language requirements, development
environments.
Real time systems: Scheduling and priority management. Development of embedded
applications for micro-controllers, single board computers, smart cards and mobile phones.
Introduction to Programmable Logic Controllers (PLCs), and their application in SCADA
systems. Peripheral interfacing methods and standards. Analog-digital conversion methods and
interfacing.
Laboratory/Practical Exercises
i). Introduction to Lab and PIC Programming
2
ii). Introduction to Embedded Systems Peripherals
iii). Hardware/Software Design
Course Assessment
Cats 10%
Assignments 5%
Labs 15%
Exam 70%
Total 100%
Reference Materials
Core Text book
1. Russell, D. (2010). Introduction to embedded systems: using ANSI C and the Arduino
development environment.
Reference Text books
1. Wolf, W. (2008). Computers as Components: Principles of Embedded Computing
System Design (2nd Ed). Morgan Kaufmann
2. Liu, D. (2008). Embedded DSP processor design: application specific instruction set
processors (2nd Ed). Morgan Kaufmann.
3
MICROPROCESSORS & MICROCOMPUTERS
Introduction
Figure 1: Microprocessor Chip
A microprocessor is an electronic device, which can perform basic arithmetic/logical functions
such as and, or, add, subtract upon given input signals. The word 'micro' is used to indicate the
physical size of the components involved.
Microprocessor is a VLSI (Very Large Scale Integration) device that contains thousands of gates
in a single chip. It constitutes the heart of a microcomputer and it fetches microinstructions from
memory, decodes the instructions into a series of actions, and carries out these actions in a
sequence of steps.
All microprocessors contain microprograms, which impart basic logic given by their instruction
set for which they are called “Microprogrammed devices”.
The microprocessor is usually enclosed in one IC package called a 'Microprocessor chip'.
The microprocessor and associated support chips make up the “Central Processor or Central
Processing Unit (CPU)” which is also called the ”Micro Processing Unit” (MPU). The CPU is
the nerve center of any digital computer, since it coordinates and, controls the activities of all the
peripheral units and performs all the calculations.
Microcomputers are defined as the first small desktop computers that were based upon an 8-bit
microprocessor with up to 64Kbytes of memory, and input/output (I/O) ports for connecting
peripheral units.
Microcomputers are also termed as “Personal Computers”.
Figure 2: Block diagram of a microcomputer
4
Microprocessor Terminologies
Integrated circuits
An electronic circuit fabricated out of a solid block of semiconductor material. This design of circuit,
often called a solid state circuit, allows for very complex circuits to be constructed in a small
volume. An integrated circuit is also called a‘chip’.
Microprocessor-based system
A microprocessor based system consists of data input, storage, processing and output devices, under the
control of a CPU.
Microcontroller
This is a complete microprocessor-based control system built onto a single chip. It is small and
convenient but doesn’t do anything that could not be done with a microprocessor and a few additional
components.
Applications of Microprocessors (Microcomputers)
While comparing microprocessors it is better to consider the application at hand. Generally, there
are three main types of microprocessor depending on their use:
A General-Purpose microprocessor is capable of executing various instructions and can be
instructed as to what specific sequence of operations it must perform. It has myriad (variation)
of applications as personal computer in education, business, and home.
Embedded or Dedicated microprocessors are special purpose microprocessors, the sequence
of micro-operations is fixed and the computer performs the same specific task over and over
again.
These used to control 'smart machines' such as microwave ovens, food blenders,
washing machines, and driers.
These are also termed as 'Microcontrollers'. One of the fastest growing
applications of microcontrollers is in the automotive industry.
Peripheral Control microprocessors are attached to main microprocessors. So they are also
referred as 'Attach/Slave microprocessors or Coprocessors'.
These are used in many computer systems for video graphics, data
communication, sound synthesis, floating-point math, and direct memory accesses
(DMA).
Their main objective is to offload the main microprocessor, thus saving time and
improving speeds. As a result, the main processor is able to concentrate on higher-level
tasks resulting in improved system performance.
The concept of 'Distributed Computing or Processing' is evolving, and future microcomputers
systems will be designed with separate processors for each I/O device in the system. Distributed
5
processing is the organization of processing in such a way that a number of machines
(microprocessors) can cooperate in exchanging data over a network. Local processing is carried
out locally and the exchanged data affects the system as a whole.
Computer Architecture
Computer Architecture refers to the internal design of a computer with its CPU, which includes: Arithmetic and
logic unit, Control unit, Registers, Memory for data and instructions, Input/output interface and External storage
functions.
Von-Neumann architecture: The same memory and bus are used to store both Data and
Instructions
Figure 3: Von-Neumann computer architecture
The main drawback: CPU is unable to access program memory and data memory simultaneously. This case
is called the "bottleneck" that affects system performance.
The bottleneck:
If a Von-Neumann machine wants to perform an instruction (already fetched from the memory)
on some data in memory, it has to move the data across the bus into the CPU.
When the computation is done, it needs to move outputs ofthe computation to memory across
the same bus; this operation will be completed if the bus is not used by another operation to fetch
another instruction or data from the shared memory; otherwise the outputs of the computation
has to wait.
Harvard architecture: The Harvard architecture stores machine instructions and data in separate
memory units using different buses.
6
Figure 4: Harvard computer architecture
The main advantage: Computers designed with the Harvard architecture are able to run a program and
access data independently, and thereforesimultaneously. Harvard architecture is more complicated but
separatepipelines remove the bottleneck that Von-Neumann creates.
Modified Harvard Architecture: The majority of modern computers have no physical
separation between the memory spaces used by both data and instructions, therefore could be
described technically as Von-Neumann.
Figure 5: Modified Harvard computer architecture
But as they have two separate address spaces, different buses and special instructions that keep data
from being mistaken for code, thisarchitecture is called "Modified Harvard Architecture". Ex. some
initialdata values or constants can be accessed by the running program directly from instruction memory
without taking up space in data memory.
Classification of Computer Systems
A computer sequentially performs one operation at a time. The time required to perform
operations is called the 'Processing Speed' of the computer.
Computers are classified according to their processing speed. It depends not only on the hardware
characteristics of the system but also on the efficiency of its software components.
Some hardware characteristics of importance in achieving high processing speed are as follows:
Word Length/Size: is the number of bits treated by the computer as a unit. It can be 4-, 8-, 16-,
7
32-bits and so on e.g. a 16-bit word will be able to hold numbers in the range from -215 through
+215-1.
The number of different types of instructions is directly related to the word length/size. So it can
be concluded that larger the word length, the greater the processing speed.
Data Path Size: depends on the width of the internal CPU buses. Wider data paths speed up
CPU operations, since more information is transmitted in a single transfer.
Other important hardware functions are the logic family, overlapping of CPU instructions,
memory bandwidth, I/O bandwidth etc.
Fundamental Steps of a Microprocessor Cycle
Execution of an instruction starts from the program counter (PC), which contains the address of
the instruction and ends with the placement of the result in the appropriate location.
The sequence of steps during execution of instructions is:
i. Fetch Instruction: Every instruction cycle begins with an op-code fetch bus cycle i.e., a
memory read of the op-code.
ii. Determine Operand: The operand is required to execute the instructions.
iii. Execute Instruction: Control signal from the control unit activates the operation, so the
instructions are executed.
iv. Store the Result: The memory stores the result in the specified location, and the
execution/microprocessor cycle ends.
After completing one instruction, the CPU moves on to the next one. This fetch and execute
process is repeated until all of the instructions in a specific program have been executed.
The CPU’s lifeblood, its heartbeat is the system clock, which synchronizes all activities within
the computer. Each step in the microprocessor cycle takes at least one tick of the system clock
called a 'Clock Cycle or T Cycle' e.g., one T cycle for 8088 5MHz is 200 nanoseconds.
We measure the speed of an instruction by the number of clock cycles required to execute it. A
clock cycle is the microprocessor's smallest unit of time measurement.
The Intel 8088/86 Microprocessor Family
The width of the data bus in bits is usually used to categorize the microprocessors. On this basis
of word length, they are categorized into:
i.8-bit microprocessor.
ii.16-bit microprocessor.
iii.32-bit microprocessor and so on.
The width of data bus determines how much data the microprocessor can read or write in one
memory or I/O cycle.
The term 16-bit means that it’s ALU, its internal registers, and most of its instructions are
designed to work with 16-bits (also called 'word').
Some microprocessors have an internal data bus wider than the external one, e.g. in the Intel
8088 the widths of the external and internal data buses are 8- and 16-bits respectively, for which
8
it is also referred to as “8/16- bit microprocessor”.
8088/8086 CPU Architecture: -
The term architecture in relation to microprocessor refers to the internal design and organization
of the device.
Every microprocessor does two basic things over and over again- fetching instructions and then
executing them. The older microprocessors could only do one thing at a time, if it is busy
fetching an instruction it could not execute one.
The entire process of reading memory, incrementing the IP, and decoding the instruction is
known as the 'Fetch and Execute principle' of the stored program computer.
A stored program computer works mainly on instructions held in store (ROM/RAM); and these
can be altered. One way of increasing the processing speed of a microprocessor is to clock at a
higher frequency. Another way is to employ the 'Pipelining Technique'.
A computer performs sequentially one operation at a time i.e., CPU performs all the tasks
involved in processing an instruction such as fetching, decoding, determining operands, and
executing instructions serially on a one-at-a-time basis. It is termed as 'Serial or Sequential
Fetch/Execute Cycle'.
On the other hand, 8088/8086 incorporates 'Overlap Fetch/Execute Cycle', which is also known
as 'Pipelining Technique'. This technique is based on the overlapping of the execution of several
instructions simultaneously. Each instruction is executed as a number of cycles that must be
performed in sequentially. Thus we enable several instructions to be done by the execution of
different cycles on different instructions concurrently.
9
Figure 1: 8088/8086 CPU Architecture
Fig 5 shows that a model of 8088/86 CPU, which consists of two separate processors, called the
Bus Interface Unit (BIU) and the Execution Unit (EU). Since these two units are entirely
independent of each other, the 8088 can do two things at the same time. Together they form a
two-stage pipeline. Each unit performs certain tasks associated with the instruction processing
simultaneously and this allows the 8088/86 to achieve a higher execution rate.
Bus Interface Unit (BIU): fetches instructions, calculates addresses, fetches operands
and writes results in memory as requested by the EU.
However, if no such requests are outstanding and the bus is free, the BIU proceeds to fill any
vacancies created in the Instruction Queue (IQ).
Execution Unit (EU): receives program instructions and data from the BIU, executes
these instructions, and stores the result in the general registers.
When the EU completes the execution of an instruction, it passes to the BIU any results (destined
for memory or I/O) and proceeds to the next instruction.
First-in-First-Out (FIFO) buffer called an 'Instruction Queue or Pre-fetch Queue' (IQ). FIFO is
10
the processing of items in a list such that the earliest arrival is processed first and the latest
arrival is processed last.
The main advantage of the Pipelining is that the EU can execute instructions almost
continually instead of having to wait for the BIU to fetch a new instruction.
Another subtle advantage to the Pipelined Architecture is that as the next several instructions
are in the IQ, and the BIU can access memory at a 'leisurely' pace. This means that slow-memory
parts such as printers can be used without affecting overall system performance.
There are three conditions that will cause the EU to enter in a 'wait' mode.
i.Firstly, when an instruction requires access to a memory location not in the queue.
ii.The second condition occurs when the instruction to be executed is a “Branch/Jump”
instruction. In this case control is to be transferred to a new (non-sequential) address.
iii.The last condition occurs during execution of instructions that are slow to execute. This can
cause the BIU to suspend fetching instructions.
11