Unit 1 Introduction
Unit 1 Introduction
Systems
Unit One
An embedded system is a computer system that is designed to perform a specific
task or set of tasks.
It is a combination of hardware and software that is integrated into a larger
system or product.
Unlike general-purpose computers, which are designed to run a wide range of
applications, embedded systems are typically designed to perform a single
function or a limited set of functions.(User Interface)
(display, keypad etc.)
Embedded Computer
Conditioning
Conversion
Signal
Input
Output
Drive
Data Output
Variables Software Variables
Hardware
2. Compilers: Compilers are software tools that convert high-level programming code
into machine code that can be executed by the embedded system's processor.
The assembler, first converts source code to object code and then to the
language that the machine can understand(Machine Code).
Its main function is to take object files generated by the compiler and combine
5. Debuggers: Debuggers are software tools that allow developers to identify and
fix bugs in software code.
They typically include features such as code editors, debugging tools, and project
management tools. Examples of popular IDEs for embedded systems include Micro C,
Eclipse, Visual Studio, and Code Composer Studio.
1. Power Supply
A power supply is a crucial component of the embedded system design. It is an electrical device
mainly used to power up the electrical load. Normally, a 5V power supply is required for the
system, however, it can also range from 1.8 to 3.3V. You can pick either one based on your
requirements and application. To work the embedded system properly, a smooth and efficient
power supply is needed. Both wall adopter and battery can be used as a power supply.
2. Microcontroller
An embedded system is either a microcontroller-based or microprocessor based system.
They give a system computing power and are called integrated circuits. The embedded
hardware performance is mainly dependent on the processor which is normally called the brain
of the embedded system. Pick from a range of processors including 8-bit, 16-bit, and 32-bit
processors. They are different in terms of processing speed. For example, a 32-bit processor
comes with more processing speed and can manipulate 32-bits at a time while an 8-
bit processor comes with less processing speed and can manipulate 8-bits at a time.
For simple applications, an 8-bit processor would suffice while for complex and advanced
3. ROM/RAM Memory
Memory is essential to store important information in the embedded computer
system. Memory is integrated into a microcontroller or microprocessor. There
are two types of memories including ROM (read-only-memory) and RAM
(random access memory). The former is called the code memory that stores the
program code and is non-volatile which means it stays stored in the system
when the power supply is removed. While latter is called the data memory and
is a volatile memory which means it is used for temporally storing the
information and is removed from the system when the power supply is turned
off.
4. Timers / Counters
Sometimes you need to create a delay before a specific function. Timers are
5. Communication Ports
Communication ports are used in embedded systems to establish communication
with other embedded systems. There are several communication ports including
USB, UART, I2C, SPI, and RS-485.
For simple applications, communications ports are utilized from the microcontroller,
and for complex and advanced applications these ports are externally installed
inside the embedded systems.
6. Output and Input
Input is required to interact with the embedded system. A sensor can be used to
provide input to the system. The microcontroller pins used in the system can be
configured as an input or output port. In the microcontroller, there are a fixed
number of input and output ports that you can utilize as per your requirement.
7. Electrical component and Circuit
A PCB (printed circuit board), Resistors, Capacitors, Diodes, Integrated Circuits,
Characteristics of Embedded System
4. Integration with hardware: Embedded systems are often tightly integrated with
hardware components, such as sensors, actuators, and communication interfaces.
6. Low cost: Embedded systems are often designed for mass production, which requires
low-cost components and manufacturing processes.
Application Areas
(1) Consumer electronics: Camcorders, cameras, etc.
(2) Household appliances: Television, DVD players, washing machine, fridge, microwave
oven, etc.
(3) Home automation and security systems: Air conditioners, sprinklers, intruder
detection alarms, closed circuit television cameras, fi re alarms, etc.
(4) Automotive industry: Anti-lock breaking systems (ABS), engine control, ignition systems,
automatic navigation systems, etc.
(5) Telecom: Cellular telephones, telephone switches, handset multimedia applications, etc.
(6) Computer peripherals: Printers, scanners, fax machines, etc.
(7) Computer networking systems: Network routers, switches, hubs, firewalls, etc.
(8) Healthcare: Different kinds of scanners, EEG, ECG machines etc.
(9) Measurement & Instrumentation: Digital multimeters, logic analysers PLC systems,
etc.
(10) Banking & Retail: Automatic teller machines (ATM) and currency counters, point of
PURPOSE OF EMBEDDED SYSTEM
(1) Data collection/Storage/Representation (2) Data
communication
PURPOSE OF EMBEDDED SYSTEM
(3) Data (signal) processing (4)
Monitoring(Knowing)
PURPOSE OF EMBEDDED SYSTEM
(5) Control (6) Application specific user
interfaces
A computer can be simplified down to the essential elements shown.
Data
Memory
The Central
Outside Input/
Processing
World Output
Unit (CPU)
Program
Memory
2. Registers: A register is just a collection of flip-flops. A flip-flop can only store one bit
so to handle 32 bits at a time we would need 32 flip-flops and would refer to this as a
32-bit register.
4. Instruction Decoder: The instruction decoder is the part of the microprocessor that
is able to actually carry out an instruction.
low cost,
physically small,
input/output intensive, and capable of easy interfacing,
limited memory capability for program and data,
instruction set leading to compact code, with limited arithmetic capability,
ability to operate in a real-time environment.
• ability to operate in hostile environment, e.g. high or low temperature, tolerant to electromagnetic
interference,
• low power, with features adapted to battery power.
Embedded
Computer is
Microcontroller
Or
Components
of Embedded
System
1. CPU
ALU( Arithmetic Logical Unit): is used to perform arithmetic and logical
operations.
Registers
These elements of the microprocessor are programmable for data storage and
manipulations
Accumulator: This has 8 bit capacity and performs arithmetic or logic operation and
stores results and data
• In addition there are 6 general purpose 8 bit registers that can be used by a
programmer for a variety of purposes.
1. Program counter (PC): is used to keep track of the address of the instruction in memory that has to be
executed next.
It points to the address of the next instruction in the memory
sometimes it becomes necessary to save the contents of certain registers because the registers
may be required to be used for some other operations in subsequent steps.
After completing these operations the saved contents are transferred back to the registers using POP
operations
A set of memory locations are kept for this purpose which are known as stacks
The last memory location occupied portion of the stack is called as ‘stack top’ and the SP holds the address
37
of the ‘stack top’
38
39
3. Status Register/Flags Register: The status
register, also known as the flags register, contains
individual flags or bits that reflect the status of the
processor or the outcome of arithmetic and logical
operations.
These flags can indicate conditions such as carry,
overflow, zero, negative, and others, which are used
for program control, conditional branching, and error
handling.
Further there are flip flops which act as status flags or status registers.
Each of these hold 1 bit flag that indicates certain conditions which arises
during arithmetic and logic operations. The status flags are:
i. Carry (CS) flag: This flag is set to ‘1’ whenever there is carry from addition
operation or borrow from a subtraction operation
ii. Zero (Z) flag: It is set to ‘1’ if the result of arithmetic or logic operation is
zero otherwise it is set to ’0’.
iii. Sign (S) flag: This is set to ‘1’ if most significant bit is one otherwise is ‘0’.
iv. Parity (P) flag: If no. of ‘1’s is even then this is set to ‘1’ if the no. of 1’s is
odd this is set to ‘0’
v. Auxiliary carry (AC) flag: Whenever a carry is generated from 3rd bit to 4th
bit during arithmetic operation AC flag is set to ‘1’
Example: 10011101
+ 11011001
= 101110110
There are 5 no. of 1’s hence P is set to 0
The result is non zero hence the Z is set to 0
There is a carry in the lost carry form hence CS is set to 1
The sign bit is ‘0’ hence S is set to 0 41
4. Instruction Register (IR):
The instruction register is a register that holds the current
instruction being executed by the processor. It is responsible
for temporarily storing the fetched instruction before it is
decoded and executed.
5. Memory Address Register (MAR) and Memory Data
Register (MDR):
These registers are used in the memory subsystem. The memory
address register holds the memory address being accessed,
while the memory data register temporarily stores the data
being read from or written to memory.
6. Control Registers:
Control registers are used to configure and control various
aspects of the processor or system. They can include
registers that control memory management, interrupt handling,
cache settings, and system mode configuration.
7. Timer/Counter Registers:
2. Memory
Depending upon the type used we can classify memories into two groups:
Program memory and
Data memory.
• Data memory is where the temporary data used in a program are stored
and this memory is usually volatile, i.e. data is lost after the removal of
power.
Memory Types
This type of memory was invented in the 80s in the laboratories of INTEL and was
represented as the successor to the UV EPROM. Since the content of this memory can
be written and cleared practically an unlimited number of times, microcontrollers
with Flash ROM are ideal for learning, experimentation and small-scale production. Because
of its great popularity, most microcontrollers are manufactured in flash technology today.
Once the power supply is off the contents of RAM is cleared. It is used for temporary
storing data and intermediate results created and used during the operation of
the microcontroller.
The contents of EEPROM may be changed during operation (similar to RAM), but
remains permanently saved even after the loss of power (similar to ROM).
Accordingly, EEPROM is often used to store values, created during operation, which must be
3. Interrupts
This is the command where MPU suspends the execution of
current program and jumps to a subroutine at a predetermined
location.
There are two types of interrupts;
1. Non maskable interrupt
2. Software interrupt
Non maskable interrupt forces the MPU to interrupt signal
unconditionally. For example in emergency situations such as
power failure.
In software interrupt, the interrupt inputs are disabled by the
software. This is commonly used by I/O devices for data
communication. For example, while using a key board, after
pressing one key, the processor stays in the loop until another
47
4. BUS : a set of wires connecting the CPU with Memory. (8,16,24,32 bit …)
Data Bus : contains wires as wide as the memory content we want to read/write.
Address Bus : contains as many lines as the amount of memory we wish to address
Address bus: These are communication lines used to carry memory address and I/O
device address. Based on address line capacity, eg n-bit address line n = 8,16,…
It can provide up to 2 n
no. Of memory locations.
These are unidirectional lines i.e. the information flow is from µp to memory
locations.
Data Bus: The information, instructions, data and address are communicated with
outside world by transferring data in both directions.
Address multiplexing: Thus a part of address and data are transmitted over a set of
shared lines. This is known as The ‘A-D’ bus transmits data/address at different
moments.
At one particular moment it transmits either data or address, which is termed as time sharing
mode or multiplexing technique
Control bus: the generation of various signals and receiving of signals for
coordination and control of different operations pertaining to external devices is
the responsibility of the control bus. This can be categorized into i) Memory and I/O
49
lines and ii) CPU and bus control lines. Read, Write, Enable, Chip select
5. Input/output Unit (PORT) : block to interface the system with the outside world
The CPU treats the input/output ports just like any memory.
They can be Input port, Output port, Bidirectional port
6. Serial Communication: A protocol where one bit is transferred at a
time.
Used for communication between two devices on longer distances it is not
possible to use parallel connection. There are different types of serial
communication which are selected based on
• How many devices the microcontroller has to exchange data with?
• How fast the data exchange has to be?
• What is the distance between devices?
• Is it necessary to send and receive data simultaneously?
BAUD RATE
The term baud rate is used to denote the number of bits transferred per
second [bps].
It is usually required by the protocol that each byte is transferred along with
Serial Communication: A protocol where one bit is transferred at a time.
I2C (INTER INTEGRATED CIRCUIT) : Inter-integrated circuit is a system for
serial data exchange between the microcontrollers and specialized
integrated circuits of a new generation.
It is used when the distance between them is short (receiver and
transmitter are usually on the same printed board).
Connection is established via two conductors. One is used for
data transfer, the other is used for synchronization (clock
signal)
SPI (SERIAL PERIPHERAL INTERFACE BUS):
A serial peripheral interface (SPI) bus is a system for serial communication which uses
up to four conductors, commonly three.
One conductor is used for data receiving, one for data sending,
one for synchronization and one alternatively for selecting a device to
communicate with.
is a full duplex connection, which means that data is sent and received
simultaneously.
The maximum baud rate is higher than that in the I2C communication system.
UART (UNIVERSAL ASYNCHRONOUS RECEIVER/TRANSMITTER):
This sort of communication is asynchronous, which means
that a special line for transferring clock signal is not
used.
This feature is crucial. Since only one communication line
is used, both receiver and transmitter operate at the
same predefined rate in order to maintain necessary
synchronization
It has the low speed.
7. Oscillator: Every pulse generated by the oscillator enable
harmonic and synchronous operation of all circuits within the
microcontroller. (XT, HS, RC)
It defines the clock cycle of the embedded system.
• LP low power crystals 32 kHz–200 kHz.
• XT crystal/ceramic resonator 100 kHz–4 MHz.
• HS high speed crystal/ceramic resonator 4 MHz–20 MHz.
• RC resistor/capacitor.
8. POWER SUPPLY CIRCUIT
There are two things worth attention concerning the microcontroller power supply circuit:
Brown out is a potentially dangerous condition which occurs at the moment the
microcontroller is being turned off or when the power supply voltage drops to a
minimum due to electric noise. As the microcontroller consists of several circuits
with different operating voltage levels, this state can cause its out-of-control
performance. In order to prevent it, the microcontroller usually has a built-in circuit
for brown out reset which resets the whole electronics as soon as the
microcontroller incurs a state of emergency.
Reset pin is usually marked as MCLR (Master Clear Reset). It is used for external
reset of the
microcontroller by applying a logic zero (0) or one (1) to it, which depends on the type
of the microcontroller. In case the brown out circuit is not built in, a simple external
circuit for brown out reset can be connected to the MCLR pin.
9. Timer: If it is necessary to measure time between two events, it is sufficient to
count up pulses generated by this oscillator. This is exactly what the timer does.
It is a counter which we can use to measure time, period and define protocol.
10. Watch Dog Timer : a counter where our program needs to write a zero in every
time it executes correctly. In case that program gets “stuck” , a zero will not be written
in and the counter alone will reset the microcontroller upon achieving its maximum
value.
11. Analog to Digital Converter: This part is responsible for converting
analog signal to digital form and pass it along to the CPU.
Based on The internal Architecture,
1.Von-Neuman Architecture
2.Harvard Architecture
VON-NEUMAN ARCHITECTURE
same time.
Data Data
Memory Memory
Data
Address
Central Address
Input/ Central
Processing Input/
Unit (CPU) Output Processing
Data Output
Unit (CPU) Data
Address
Program
Memory Program
Memory
Data
A computer “executes” instructions in its Arithmetic Logic Unit (ALU), running through a series of
instructions called a program. An ALU can only do a few things, but it can do them very fast. A typical 8-
bit ALU can do the list shown below. A is the “Accumulator”, a digital register where the computations
actually occur, and M is a location in memory. The ALU in turn forms part of the Central Processing Unit
(CPU).
Increment A A = A plus 1
Decrement A A=A-1
Add A to M A = A plus M
Subtract M from A A=A-M
AND A with M A = A.M
OR A with M A=A+M
Exclusive OR A with M A = A+ M
Shift A left A = 2A
Shift A right A = A/2
Rotate A left
Rotate A right
Complement A A = NOT A
Clear A A=0
How Instruction Sets are Made: the “CISC” Machine
Any CPU has a set of instructions that it recognizes and responds to ; all programs are
built up in one way or another from this instruction set. We want computers to execute code as fast as
possible, but how to achieve this aim is not always an obvious matter.
One approach is to build sophisticated CPUs with exotic instruction sets, with an instruction ready for
every foreseeable operation. This leads to the CISC, the Complex Instruction Set Computer. A CISC has
many instructions, and considerable sophistication. Yet the complexity of the design needed to achieve this
tends to lead to slow operation. One characteristic of the CISC approach is that instructions have
different levels of complexity. Simple ones can be expressed in a short instruction code, say one byte of
data, and execute quickly. Complex ones may need several bytes of code to define them, and take a long
time to execute.
Another approach is to keep the CPU very simple, and have a limited instruction set. This leads to the
RISC approach – the Reduced Instruction Set Computer. The instruction set, and hence overall design, is
kept simple. This leads to fast operation. One characteristic of the RISC approach is that each instruction is
contained within a single binary word. That word must hold all information necessary, including the
instruction code itself, as well as any address or data information also needed. A further characteristic, an
outcome of the simplicity of the approach, is that every instruction normally takes the same amount of
time to execute.
The CPU fetches one instruction from the memory at a time and
executes it in series to produce the final result.
The necessary steps that a CPU carries out to fetch an instruction and
necessary data from memory and execute it, constitutes an instruction
cycle which consists of two parts, viz. fetch cycle and execute cycle
67
In fetch cycle the CPU fetches opcode from memory
During execute cycle, CPU gets data from memory to perform the specific
operation which is specified in the instruction
The time required to fetch opcode is fixed while the execution of the instruction
varies on the type of the instruction.
Hence the total time required execute an instruction cycle is
IC = FC + EC
68
The first byte of an instruction is its opcode. The instruction may be more than one
byte long.
The other bytes are operands and address
In the beginning of the fetch cycle, the content of the Program counter (PC) which is
the address of the memory location where opcode is available is sent to memory.
The memory places the opcode on the data bus so as to transfer it to the CPU.
The entire operation of fetching an opcode takes three clock cycles
69
Execute operation
The opcode fetched from the memory goes to the data register/ data buffer then to
instruction register, IR.
If the instruction has data and address which are in the memory, then the CPU has to
perform some READ operation to get the desired data.
In WRITE cycle data is sent from the CPU to the memory or an I/O device. 70
Machine cycle
The instruction cycle consists of opcode fetch followed by an execute cycle.
The execute cycle itself consists of none or more fetch cycle like READ / WRITE
operation.
All these operations are performed in different time slots known as machine
cycles
An opcode is fetched in first machine cycle
Additional machine cycles are needed to read data from or to write data
to memory or I/O devices
71
Architec
tures
8086
Micro-