SlideShare a Scribd company logo
Eng.HamdyAhmedEl-asawy
Eng.Hamdy Ahmed Hamdy El-asawy
IntroductionTo EmbeddedSystems
Content
1. What is An Embedded System
2. Embedded System Design
3. Embedded Design Goals
4. Embedded Design Characteristics
5. Embedded System Application
6. Microcontrollers
7. What is a Development Board
8. Central processing unit (CPU)
9. CPU Architecture(MemoryAccessing)
10. CPU Architecture(Numberof instructions)
11. MemoryTypes
12. Interrupts
13. Power
14. Embedded System Constrains
Eng.Hamdy Ahmed Hamdy El-asawy
What is an Embedded
System
Eng.Hamdy Ahmed Hamdy El-asawy
What is An Embedded System
An embedded system is one that has computer hardware with
software embedded in it as one of its components.
An embedded system is a dedicated system which performs the
desired function upon power up, repeatedly.
Eng.Hamdy Ahmed Hamdy El-asawy
Or we can say that it is “A combination of computer hardware and software, and
perhaps additional mechanical or other parts, designed to perform a dedicated
function. In some cases, embedded systems are part of a larger system or product,
as is the case of an antilock braking system in a car
Eng.Hamdy Ahmed Hamdy El-asawy
What is An Embedded System
Software Hardware
Embedded System
Eng.Hamdy Ahmed Hamdy El-asawy
1.0 What is An Embedded System
For A Dedicated purpose .
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Vs General Purpose system
Eng.Hamdy Ahmed Hamdy El-asawy
General Purpose Systems
• A General Purpose Systems is A Computer System ( Hardware + Software ) That Perform Many
Applications which can be changed by the user.
• Can be ProgramedBy User
• Hardware And Software Modifications
can be done ByThe User
Like :
Personal Computers
Servers
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded Systems General Purpose Systems
Not programmable by user. programmable by user.
Specific Applications that are known at
design time
Computing Lots of Applications
Harder to Develop Easier to Develop
A Part of a Bigger System ( Embedded ) Standalone System or integrated with other
Systems
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded Systems Application
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Application
PC cannot be considered as an embedded system because :
It uses a General-Purpose Processor.
The system is built independently from the software runs on it.
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded Systems Application
• Automotive
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded Systems Application
• V2V Communication
Eng.Hamdy Ahmed Hamdy El-asawy
Communications
Eng.Hamdy Ahmed Hamdy El-asawy
Robotics
Eng.Hamdy Ahmed Hamdy El-asawy
Image Processing
Eng.Hamdy Ahmed Hamdy El-asawy
Biomedical Application
Eng.Hamdy Ahmed Hamdy El-asawy
Biomedical applications
Eng.Hamdy Ahmed Hamdy El-asawy
Military
Eng.Hamdy Ahmed Hamdy El-asawy
SOC ( System on Chip)
Eng.Hamdy Ahmed Hamdy El-asawy
SOB ( System on Board)
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded Systems Design
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Design
• Embedded Systems Consist of Hardware and software combined togetherfor a dedicated purpose
• The Key in Design is to Determine Which Function Block should be Performed in Hardware and
Which should be in software
Eng.Hamdy Ahmed Hamdy El-asawy
• Hardware characteristics
Advantage:
» Betterperformance in high speed real time application
Disadvantage:
» Longer development cycle.
» Customized for specific application, not updatable
(unchangeable).
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Design
• Software characteristic
Advantage:
»Highly Configurable
»Shorter development cycles
»Easier in Versions updates
»Cheaper
Disadvantage:
» Constrains with processor speed which may satisfy
real time applications and may not
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Design
Embedded System Design Steps Requirement Analysis
System Architecture
Specifications
Hardware Design
Hardware
Testing
Hardware
Implementation
Software Design
Software Testing
Software
Implementation
System integration
Operation &
Maintenance
System Validation
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded Design Goals
• Performance
• Functionality and user interface.
• Manufacturing cost.
• Power consumption.
• Safety.
• Other requirements. (physical size ….. etc. )
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Design
• Any Embedded System
• Built for Certain Application
• The System Should Fulfill The Requirements of the Application
• Characteristics
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Design characteristics
1- Dependability:
• MakesUsers to Safely relay on The system
• Systems Like :
• Airplanes
• Nuclear Power Plants
• Automotive break system
• System should be Dependable because it have a direct impact on the Environment
As if any thing goes wrong it would cause some series injury to it’s user or maybe death
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Design characteristics
System is considered to be dependable if
System is Reliable
System is Available
System is Maintainable
System is Safe
System is Secure
Interactive System
Eng.Hamdy Ahmed Hamdy El-asawy
•Reliability
The abilityofa machine, or system to consistentlyperform its intended
or required functionor mission, on demand and withoutdegradation
or failure.
Eng.Hamdy Ahmed Hamdy El-asawy
Maintainability
The ability to modify the system after its initial release and enhance its performance
likeexecution time, code and memory size. likeAntilock ,Barking systems, Autopilot.
• Readability
• Changeability
• Stability
• Testability
Eng.Hamdy Ahmed Hamdy El-asawy
• Availability
Probability of system working at time t.
• Safety
Cause no Harm even if in the case of failure .
Eng.Hamdy Ahmed Hamdy El-asawy
sometimes it shouldn't be 24/7
• Security
The Data of The User is Secure
• Interactive System
It is easily understandable, Operated and Handled by auser and provide ease of task.
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded System Design characteristics
2- Efficiency:-
• Energy Efficiency
• Code Size Efficiency
• Cost Efficiency
• Time Efficiency
• If you consider a Real Time Application is onein which must beable to act at a speedcorresponding with the
occurrenceof an actual process
• MUST COMPLETE CERTAIN RESULTSIN A CERTAIN TIME WITH OUT DELAY
• If you are using an embedded system with a limited power source such as a Battery Efficiency in energy is A
require.
Eng.Hamdy Ahmed Hamdy El-asawy
Energy Efficiency• For Processors Energy Efficiencycanbe estimated based on the number of instructionper joule
𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 α 𝑊𝑜𝑟𝑘 𝑗𝑜𝑢𝑙𝑒
• The More ApplicationSpecificthe Components and the code are
The More Energy Efficientthe system is.
Eng.Hamdy Ahmed Hamdy El-asawy
Efficiency
• Code size : Must Occupy as small space as possible
• Physical Appearance
• Small Size
• Portableif Desired
• Cost :
• Minimal Numbersof Component
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded Systems Characteristic
3- Real TimeConstrains
•If real Time Constrainsare notmet :
• Low Quality
• Serious consequences
• Lackof Dependency
Eng.Hamdy Ahmed Hamdy El-asawy
Software Hardware
Embedded System
Eng.Hamdy Ahmed Hamdy El-asawy
What is An Embedded System
For A Dedicated purpose .
System Bus
Hardware
Eng.Hamdy Ahmed Hamdy El-asawy
POWER
CCT
External
Hardware
Internal
Memory
CPU
Interrupt
Circuit
Timer
Watch
Dog
Serial
Communication
GPIO ADC
SystemBus
System Bus
What is a uc
Eng.Hamdy Ahmed Hamdy El-asawy
Microcontrollers
• It is a micro-computer. As any computer it has internal CPU,
RAM, IOs interface.
• A microcontroller is a single chip, self-contained
computer(SOC), which incorporates all the basic components of
a personal computer on a much smaller scale.
• It is used for control purposes, and for data analysis.
Eng.Hamdy Ahmed Hamdy El-asawy
• Microcontrollers don’t work alone in the circuit it must interfaces with other on chip
devices like Sensors, Switches, Leds , LCD, Keypad and DC Motor.
Microcontrollers
Eng.Hamdy Ahmed Hamdy El-asawy
System Bus
POWER
CCT
External
Hardware
Internal
Memory
CPU
Interrupt
Circuit
Timer
Watch
Dog
Serial
Communication
GPIO ADC
SystemBus
System Bus
What is a Development Board
Eng.Hamdy Ahmed Hamdy El-asawy
What is A Development Board
• A printed circuit board designed to facilitatework
with a particular microcontroller.
Typical components include:
•power circuit
•programming interface
•basic input; usually buttons and LEDs
•I/O pins
Eng.Hamdy Ahmed Hamdy El-asawy
uc Basic Peripherals
Eng.Hamdy Ahmed Hamdy El-asawy
Microcontrollers
• A microcontroller has seven main components:
Central processing unit (CPU)
internal Memory
Input and Output
Timer
Interrupt circuitry
Buses
Eng.Hamdy Ahmed Hamdy El-asawy
Microcontrollers
• A microcontroller has seven main components:
1- Central processing unit (CPU)
Eng.Hamdy Ahmed Hamdy El-asawy
Central processing unit (CPU)
• CPU Dose AllThe Computing :
• Arithmetic , control , logic , data , IO operations
• Instruction Cycle:
• Fetches
• Decodes
• ExecutesProgram Instruction
Eng.Hamdy Ahmed Hamdy El-asawy
Cpu Architecture
Eng.Hamdy Ahmed Hamdy El-asawy
Cpu Architecture
•There aretwo basic types of architecture:
1. Number of Instructions Based Architecture
2. CPU BUS Architecture
Eng.Hamdy Ahmed Hamdy El-asawy
Memory Accessing(BUS) CPU Architecture
• Memory AccessingCPU Architecture :
Harvard and Von Neumann.
• Microcontrollers most often use a Harvard or a
modified Harvard-based architecture.
• The microcontroller is often part of a larger
system.
Eng.Hamdy Ahmed Hamdy El-asawy
VonNeumann
• Von Neumann architecture has a single, common memory space where both program instructions and data
are stored. There are Common buss between both instructions and data memory.
Eng.Hamdy Ahmed Hamdy El-asawy
VonNeumann
• Each time the CPU fetches a program instruction it may have to perform one or more
read/write operations to data memory space.
• It must wait until these subsequent operations are complete before it can fetch and
decode the next program instruction. The advantage to this architecture lies in its
simplicity and economy.
Eng.Hamdy Ahmed Hamdy El-asawy
Harvard
•Harvard architecture computers have separate memory areas for program
instructionsand data.
•There are two or more internal data buses which allowsimultaneousaccess to
both instructionsand data.
Eng.Hamdy Ahmed Hamdy El-asawy
Harvard
• The CPU fetches instructions on the program memory bus. If the fetched instruction
requires an operation on data memory, the CPU can fetch the nextprogram instruction
whileit uses the data bus for its data operation. This speeds up execution time at the
cost of more hardware complexity.
Eng.Hamdy Ahmed Hamdy El-asawy
CPU Architecture(Numberof instructions):
There are two basic types of architecture:
Reduced Instruction Set Computing(RISC).
Complex Instruction Set Computing(CISC).
Microcontrollers most oftenuse a RISC Architecture
Eng.Hamdy Ahmed Hamdy El-asawy
Eng.Hamdy Ahmed Hamdy El-asawy
RISC CISC
CPU design that recognizes only a limited number of
instructions, Simple in design.
CPU design that recognizes a large number of instructions,
Complex in design.
Simple instructions. Complex and Large no. of instructions.
Instructions are executed quickly. Large execution time for each instruction.
Only the load and store instructions operate directly onto
memory.
Instructions can operate directly on memory.
RISC aims to optimize execution of instructions by limiting the
capabilities of a single instruction and having consistent
instructions’ execution time (Instruction Pipelining)
CISC is an old concepts that dates back when memory access
was slow.
CPU Architecture(Numberof instructions):
Eng.Hamdy Ahmed Hamdy El-asawy
RISC CISC
thus gaining speed from execution point of view but code size
will be large for a dedicated function. But it will increase the
number of memory access.
CISC aimed to integrate several functionalities in one
instruction, in order to limit the program size. and thus limit
memory access in order to gain some speed.
So It's harder to write powerful optimized compilers, since
large number of instructions needed.
It's easier to write powerful optimized compilers, since fewer
instructions exist.
Combine a large number of general registers for arithmetic
operations to avoid storing variables on a stack in memory.
Small number of general purpose registers.
Example: ARM, AVR, PIC,POWER-PC and SPARC. Example: Intel X86, AMD and Motorola 68000.
CPU Architecture(Numberof instructions):
Eng.Hamdy Ahmed Hamdy El-asawy
Cpu Structure
Eng.Hamdy Ahmed Hamdy El-asawy
Central processing unit (CPU)
•CPU Mainly consistof :
Arithmetic Logic Unit(ALU).
Control Unit.
Registers.
Bus
Eng.Hamdy Ahmed Hamdy El-asawy
Central processing unit (CPU)
• Arithmetic Logic Unit :-
One part of the CPU is responsible for performing calculationsand executing instructions.Thispart is
calledthe arithmetic logic unit, or ALU.
Eng.Hamdy Ahmed Hamdy El-asawy
Logic instructioninclude
AND
OR
Not
XOR
Arithmetic instructioninclude:-
Addition
Subtraction
ShiftingOperation
Central processing unit (CPU)
• Control Unit:-
Controls The Internal Flow to Fetch , Decode and execute an instruction
Eng.Hamdy Ahmed Hamdy El-asawy
1-Program Counter:-
is a register in a computer processor that containsthe address (location)
of the instructionthat willbe executednext to the current instruction.
Note That in SomeArch, the PC points to the currentinstruction being executed
Central processing unit (CPU)
• Control Unit:-
Controls The Internal Flow to Fetch , Decode and execute an instruction
Eng.Hamdy Ahmed Hamdy El-asawy
2-Instruction Register:-
Register which contains theinstruction after getting it from program memory (Fetch stage).
Central processing unit (CPU)
• Control Unit:-
Controls The Internal Flow to Fetch , Decode and execute an instruction
Eng.Hamdy Ahmed Hamdy El-asawy
3-Instruction Decoder:-
Converts instructionstored or Fetched in aprogram memory into codes whichthe ALUcan
understand and generate the control signalsof this instruction
The instruction set Differs From Microcontroller Family to another and it express the ability of the
Microcontroller circuit
Eng.Hamdy Ahmed Hamdy
El-asawy
AVR CPU Core
 Common CPU for all AVR parts
 Ex. add $r1, $r2, $r3
1. Read instruction from program memory
2. Load instr. into instr. Register
3. Get source register numbers from instruction
4. Fetch source data from register file
5. Pass sources to ALU, add
6. Pass result to register file
Central processing unit (CPU)
• Registers
are used by the CPU to temporarily store vital data which are volatile.(most of them )
Registers are classified into
General Purpose
Stores Current programor data being processed
Special Function
Control Registers
States Registers
• Many of the microcontroller registers arememory-mapped, associated with a memory location, and can beused like
any othermemory location if not the register is then port mappedand require special assembly instruction to handle
it .
• The number and names of registers varies drastically among microcontrollers.Howevertherearecertain registers
which are commonto most microcontrollers
Eng.Hamdy Ahmed Hamdy El-asawy
• Register File
A number of registers grouped together
AVR CPU contains 32 GP registers R0 -R31.
Eng.Hamdy Ahmed Hamdy El-asawy
SFR (Specialfunction registers)
1- The stack pointer
The stack pointer contains the address of the next location on the stack.
The address in the stack pointer is decremented when data is pushed on the stack
and incremented when data is popped from the stack.
• The Stack is implemented as growing from higher memory locations to lower memory
locations. This implies that a Stack PUSH command decreases the Stack Pointer and a
Stack POP command increases the Stack Pointer(and may be vice versa for some
processors).
Eng.Hamdy Ahmed Hamdy El-asawy
•The Stack is mainly used for storing temporary data, for storing local
variables and for storingreturn addresses after interrupts and
subroutine calls.
•A stack is a LIFO(lastin, first out) mechanism the last thing store on the
stack is the first thing tobe retrieved from the stack.
Eng.Hamdy Ahmed Hamdy El-asawy
• Initial Stack Pointer value equals the last address of the internalSRAM and the Stack
Pointer must be set to point above start of the SRAM
• Stack Pointer have to be initialized to point to the last memory location in SRAM
(i.e. first empty location in the stack).
AVR Stack
Eng.Hamdy Ahmed Hamdy El-asawy
Stack Example
Eng.Hamdy Ahmed Hamdy El-asawy
SFR (Specialfunction registers)
2- IndexRegister
• The index register is used to specify an address when certain addressing modes are used. It is also known as
the pointer register.The Microchip devices use the name FSR (file select register).
• Also called Base Register.
Eng.Hamdy Ahmed Hamdy El-asawy
Used in indirect addressing modes,
as the accessed address = index register + offset mentioned in code.
Eng.Hamdy Ahmed Hamdy El-asawy
SFR (Special function registers)
3 - The program counter
• Perhaps the single most important CPU registeris the program counter(PC). The PC holds the address of the
next instruction in program memory space.
• It contains the address of the next instruction the CPU will process. As each instruction is fetched and
processed by the ALU, the CPU increments the PC and thereby steps through the program stored in the
program memory space.
Eng.Hamdy Ahmed Hamdy El-asawy
4- Instruction Register(IR)
Register which contains the instruction after getting it from program memory (Fetch stage).
5- Processor Status Word/Register(PSW)
• The Status Register contains information about the result of the most recently executed arithmetic instruction. This
information can be used for altering programflow in order to perform conditional operations.
• Status Register is updated after ALU operations.
SFR (Special function registers)
Eng.Hamdy Ahmed Hamdy El-asawy
SREG - AVRStatus Register
• Bit 7 – I: Global Interrupt Enable
The Global Interrupt Enable bit must be set for the interrupts to be enabled. The individual interrupt enable control is
thenperformedin separate control registers.
If the Global Interrupt Enable Register is cleared,none of the interrupts areenabled independent of the individual
interrupt enable settings.
The I-bit is cleared by hardware after an interrupt has occurred,and is set by the RETI instruction to enable subsequent
interrupts. The I-bit can also beset and cleared in software with the SEI and CLI instructions, as describedin the
instruction set reference.
Eng.Hamdy Ahmed Hamdy El-asawy
SREG - AVRStatus Register
• Bit 4–S: Sign Flag
indicates theresult sign ofarithmetic Data.
Bit 3–V :Overflow flag
indicates an overflowoccurs in an arithmetic operation.
• Bit 2–N: Negativeflag
indicates a negativeresult in an arithmetic or logic operation.(ALU)
• Bit 1–Z :Zero flag
indicates a zero result in an arithmetic or logic operation.
• Bit 0–C: Carryflag
indicates a carry in an arithmetic or logic operation.
Eng.Hamdy Ahmed Hamdy El-asawy
Instruction Pipelining:
Continuous and parallel streaming of instruction to the CPU.
A method of achieving higher execution speed at same clock speed.
Eng.Hamdy Ahmed Hamdy El-asawy
Co processors
• A Processor that supplements the function of the primary processor.
• Ex:
FPU
Graphics processor
Digital Signalprocessor
Encryption processor
Eng.Hamdy Ahmed Hamdy El-asawy
System Bus
• DataBus
The set of lines carrying data and instructions to or fromthe CPU is called the databus.
The number of lines in the data bus determines the maximum datawidththe CPU can handle in a single transaction
an 8-bit data bus can transfer atmost one byte (or two nibbles) in a single transaction, and a 16-bit transaction would
require two data bus transactions.
Eng.Hamdy Ahmed Hamdy El-asawy
System Bus
• Address Bus
The CPUinteracts with only one memory register or peripheral device at a time.
Each register, either in memory or aperipheral device, is uniquely identified with
an identifier called address.
The set of lines transporting this address information form the addressbus..
Eng.Hamdy Ahmed Hamdy El-asawy
System Bus
• ControlBus
The controlbusgroups all the lines carryingthe signalsthat regulate the system activity.
Control signals include those used to indicate whether the CPU is performing a read or write access.
For Example : Memory chip READ/WRITE (R/W)lines and Chip Select (CS)lines
Eng.Hamdy Ahmed Hamdy El-asawy
Microcontrollers
• A microcontroller has seven main components:
1- Central processing unit (CPU)
2- Memory Unit ( RAM , ROM )
Eng.Hamdy Ahmed Hamdy El-asawy
MemoryUnits
• Memory is a part of a microcontroller used for data and program storage
There are Two Basic Types of Memory
RAM
ROM
Eng.Hamdy Ahmed Hamdy El-asawy
ROM
• ROM, read only memory, is non-volatile memory used for program information and permanent data.
• The microcontroller uses ROM memory space to store program instructions it will execute when it is started
or reset.
• Program instructions must be saved in non-volatile memory so that they are not affectedby loss of power.
Eng.Hamdy Ahmed Hamdy El-asawy
ROM Types
• Mask ROM (MROM)is a type of read-only memory (ROM)whose contents are programmed by the
integrated circuit manufacturer (rather than by the user).
• It is common practice to use rewritable non-volatile memory – such as UV-EPROM or EEPROM – for the
development phase of a project, and to switch to mask ROM when the code has been finalized.
Eng.Hamdy Ahmed Hamdy El-asawy
MROM
• The main advantage of mask ROM is its cost. Per bit, mask ROM is more compact than any other kind of
semiconductor memory. Since the cost of an integrated circuit strongly depends on its size, mask ROM is
significantly cheaper than any other kind of semiconductor memory.
Design errors are costly: if an error in the data or code is found, the mask ROM is useless and must be
replaced in order to change the code or data.
Eng.Hamdy Ahmed Hamdy El-asawy
One Time Programed Memory (OTP) (PROM)
• Can be programed one time only
• A typical PROM comes with all bits reading as "1". Burning a fuse bit during programming causes the bit
to read as "0". The memory can be programmed just once after manufacturing by "blowing" the fuses,
which is an irreversible process.
Eng.Hamdy Ahmed Hamdy El-asawy
UV EPROM
• It enables data to be erased under strong ultraviolet light.
• Aftera fewminutes it is possible to download a new program.
Eng.Hamdy Ahmed Hamdy El-asawy
EEPROM(Electrically ErasableProgrammableROM)
• Can be erased by electricity
• The content of This memory can be changed Like ( RAM ) but it can hold the data inside it even if in
the case of no power
Eng.Hamdy Ahmed Hamdy El-asawy
RAM(Random Access Memory)
• Volatile Memory
• Faster Than Rom
• Used to Store Temporary Programs
• Also called Read/Write Memory, The term random access refers to the ability to access any memory cell
directly.
Eng.Hamdy Ahmed Hamdy El-asawy
DRAM( Dynamic Random AccessMemory )
• The capacitor arrays will hold their charge only for a short period before it
begins to diminish , Meaning that it always have to be refreshed to keep it’s
content
Eng.Hamdy Ahmed Hamdy El-asawy
SRAM( StaticRandom AccessMemory )
• Doesn’t Need To Refresh it Self The Data instead will wait to be overwritten.
• Consist of a 4~ 6 Transistors for
each memory Cell
More Expensive and Higher Performance than DRAM
Eng.Hamdy Ahmed Hamdy El-asawy
Non-Volatile RAM (NVRAM)
• A Volatile Ram connected
to an Emergency battery.
Eng.Hamdy Ahmed Hamdy El-asawy
FLASH Memory ( Hybrid Memory – Mix between Ram & ROM )
• Flash Memory is just like EEPROM the only Difference is in it’s erase cycle as flash is erased sector by
sector ( Multiple Bytes )
• But EEPROM is erased Byte by Byte
Eng.Hamdy Ahmed Hamdy El-asawy
RAM is Divided into
• Mapped General Purpose Registers
• Mapped IO Registers
• SRAM (Contains the Program Data)
• Note thatin Some Arch Ram Contains The Code
To be executed to but ithas to be copied from flash
After each reset.
Eng.Hamdy Ahmed Hamdy El-asawy
Cpu Cache
Cache memory, also called CPU memory, is random access memory
(RAM) that a computer microprocessor can access more quickly than it
can access regular RAM.
This memory is typically integrated directly with the CPU chip or placed
on a separate chip that has a separate bus interconnect with the CPU.
Eng.Hamdy Ahmed Hamdy El-asawy
Eng.Hamdy Ahmed Hamdy El-asawy
Register File:
A (usually) relatively small memory embedded on the CPU. It is used as a scratchpad for
temporary storage of values the CPU is working with you could call it the CPU’s short
term memory.
Data Memory:
For longer term storage, generic CPUs usually employ an external memory which is
much larger than the register file. Data that is stored there may be short-lived, but may
also be valid for as long as the CPU is running
Instruction Memory:
Likethe data memory, the instruction memory is usually a relatively large external
memory (at least with general CPUs)
Eng.Hamdy Ahmed Hamdy El-asawy
Memory Management unit MMU
• Translates Address From CPU Memory ( Virtual Memory ) to Physical Address on Memory
• Provides Memory Protection Function
• Typically the MMU is tightly coupled to the processor core .
Eng.Hamdy Ahmed Hamdy El-asawy
Memory Controller
• The memory controller would handle the physical signaling involved in communicating to external
memory.
• Typically Memory controller is a peripheral on the uc internal bus.
Eng.Hamdy Ahmed Hamdy El-asawy
Direct Memory AccessDMA
• A Co Processorthat Allows Data transfers without the interference of the processor
• It can movedata betweenDifferent Memories or A Memory and an IO Device.
• DMA Speed is limited by the speed of the slowest devicein the transferee.
• Ex:-
In a typical DMA transfer, some event (such as an incoming data-available signal from a UART)
notifiesaseparatedevicecalledtheDMAcontrollerthatdataneedsto be transferredto memory.
TheDMAcontrollerthenassertsaDMArequestsignalto theCPU, askingitspermissionto usethebus.
TheCPU completesitscurrentbus activity,stopsdrivingthebus, andreturnsaDMAacknowledgesignaltotheDMA
controller.
TheDMAcontrollerthenreadsandwritesoneor more memory bytes,drivingtheaddress,data,andcontrolsignalsasif it were
itselftheCPU. (The CPU's address,data,andcontroloutputsaretristatedwhiletheDMA controllerhascontrolof thebus.)
Whenthetransferis complete,theDMAcontrollerstops drivingthebus andde assertstheDMArequestsignal.
TheCPU canthenremoveitsDMAacknowledgesignalandresumecontrolof thebus.
Eng.Hamdy Ahmed Hamdy El-asawy
Microcontrollers
• A microcontroller has seven main components:
Central processing unit (CPU)
ROM
RAM
Input and Output
Timer
Interrupt circuitry
Eng.Hamdy Ahmed Hamdy El-asawy
IO Devices
• Microcontrollers cannot be used without a hardware to interface with I ex:
• Send an information to an lcd
• Receive an analogsignal
• Send a digitalsignal
• IO Modules do the work of exchanging information with the processors and external Hardware.
• All signals passed to the Cpu should be Digital Signals but IO Devices can deal with digital – not digital
signal.
• Ex: if an analog signal is passed to uc a certain IO module called ADC translates the Analog signal
to a digital code which the cpu can handle with.
• Some IO Devices is small enough to be integrated in the same chip with the uc ( ADC , RTC ..ETC)
and some cannot be integrateddue to size or differentinterface system ( LCD , Keypad , Speakers.. ETC)
Eng.Hamdy Ahmed Hamdy El-asawy
How To Access IOMemory Space
• There are 2 Common Ways to Access An IO Space
1. Port Mapped IO
• IO’s Have Their Own Mapping ( Address ) And Require special Assembly instruction to interface with them ( as in , out inst in AVR )
• Isn't common in Embedded System ( But Still used )
2. Memory Mapped IO
1. Io’s Share Memory Mapping ( Memory segmentsand IO’s are in the Same Mapping ) using this way will make it easier to interface
IO as we interface Memory ( Load , Store inst in AVR ).
2. Commonly used in Embedded Sysetms.
Eng.Hamdy Ahmed Hamdy El-asawy
How to Deal WithIO
• There Are Commonly two ways to Deal With IO :
• By Polling :
• Write the Program to Continuously check IO for a Certain Event.
• Less CPU Utilization
• Have A Lot of Disadvantages
• Don't Require extra Resources ( Interrupt pin)
• Assigning them to an interrupt
• The Program wont check the IO , when a certain event reaches the IO , the IO signals The Cpu That
the event has occurred and then the Cpu handles it.
Eng.Hamdy Ahmed Hamdy El-asawy
Interrupts
• Interrupts allow the microcontroller to interact with its environment.
• An interrupt is a signal sent to the microcontroller which causes it to stop its current execution and
perform another action. The chip stops executing your main program and executessome other code.
Interrupts can be edge triggered (rising or falling) or level triggered.
Eng.Hamdy Ahmed Hamdy El-asawy
Interrupt handler
• Code executed by an interrupt is not generally considered part of the main application. Since this
code handles the cases where an interrupt occurs, it is called an interrupt handler or an interrupt
service routine.
Eng.Hamdy Ahmed Hamdy El-asawy
SynchronousandAsynchronousInterrupt Acknowledgement
• Most interrupt acknowledgement is synchronous, the instruction currently being executed is completed
before the interrupt is acknowledged.
• when the processor acknowledges an interrupt asynchronously it halts execution of the currentinstruction
and immediately services theinterrupt.
• The only asynchronously acknowledged interrupt is RESET. Since RESET erases the stateof the machine, it is
a moot point whether the CPU actually halts execution of the current instruction or not.
Eng.Hamdy Ahmed Hamdy El-asawy
NestedInterrupts
• To minimize the possibility of an interrupt handler being itself interrupted, the microcontroller will
usually disable interrupts while executing an interrupt handler.
• if we Enable it again then we have enabled interrupt nesting
Eng.Hamdy Ahmed Hamdy El-asawy
Power
• Most microcontrollers support 4.5 to 5.5 Volt operation. There are also many low voltage parts which
are designed to work at 3 volts or less.
Brownout
• Microcontrollers have an on-board circuit which provides brownout protection. A brownout occurs
when the operating voltage falls below the defined brownout voltage. When a brownout occurs the
device is reset and waits for the operating voltage to rise above the brownout voltage.
Eng.Hamdy Ahmed Hamdy El-asawy
Halt/Idle
• Individual microcontrollers have specific modes which stop the execution of the program without affecting
the power to themicrocontroller. In thesemodes less power is required and power consumption is reduced.
Halt mode stops all activities and can be terminated by a reset or an interrupt. Idle mode
Eng.Hamdy Ahmed Hamdy El-asawy
Watch dog Timer
Most embedded systems need to be self-reliant. It's not usually possible to wait for someone
to reboot them if the software hangs.
A watchdog timer is a piece of hardware that can be used to automatically detect software
anomalies and reset the processor if any occur. Generally speaking, a watchdog timer is based
on a counter that counts down from some initial value to zero.
Eng.Hamdy Ahmed Hamdy El-asawy
Software
Eng.Hamdy Ahmed Hamdy El-asawy
Software
Eng.Hamdy Ahmed Hamdy El-asawy
DEVICE DRIVER
OS
Middleware
Application
Eng.Hamdy Ahmed Hamdy El-asawy
DEVICE DRIVER
Low Level Device Driver
High Level Device Driver
Hardware Dependent
OS Dependent
Eng.Hamdy Ahmed Hamdy El-asawy
Operating Systems
Os is a Software That manages the Hardware Resources.
Two Kinds of Operating Systems Could Be Used With Embedded sys:
GPOS ( the Throughput is the AIM )
RTOS ( Meeting Tasks Deadline is the AIM)
Eng.Hamdy Ahmed Hamdy El-asawy
Middleware
middleware is an abstraction layer generally used on embedded devices with two or
more applications in order to provide flexibility, security, portability, connectivity,
and intercommunication between applications.
Eng.Hamdy Ahmed Hamdy El-asawy
Application
This is a Software Layer that provides User interface (UI)
Uses the OS and Device Drivers
Embedded SystemsConstrains
• Number of Pins ( I/o)
• Memory Size
• Execution Time (speed )
• Sampling Rate
• BuadRate
• Cost
• Performance ( Depend Clock Frequency , Power , Used memory size )
• Time To Market ( Depending on The Market window )
Eng.Hamdy Ahmed Hamdy El-asawy
Embedded systems Life Cycle
Eng.Hamdy Ahmed Hamdy El-asawy
•ThankYou
References
Eng.Hamdy Ahmed Hamdy El-asawy
Any Questions ??
• Hamdy.elasawy@gmail.com
• 01004750613
• https://www.linkedin.com/in/hamdyelasawy
• www.Facebook.com/Hamdy.elasawy
Eng.Hamdy Ahmed Hamdy El-asawy

More Related Content

PPT
Introduction to embedded systems
PPT
WDM - Windows Driver Model overview
PDF
Introduction to Embedded Systems
PDF
Embedded systems introduction
PDF
Module-1 Embedded computing.pdf
PDF
ERTS_Unit 1_PPT.pdf
PDF
Introduction to Embedded Systems
DOCX
edited doc
Introduction to embedded systems
WDM - Windows Driver Model overview
Introduction to Embedded Systems
Embedded systems introduction
Module-1 Embedded computing.pdf
ERTS_Unit 1_PPT.pdf
Introduction to Embedded Systems
edited doc

Similar to introduction to Embedded Systems (20)

PPTX
EMBEDDED AND REAL TIME SYSTEMS Unit-1_6703.pptx
PPT
Introduction to embedded systems powerpoint
PPTX
UNIT 1.pptx
PPTX
ERTS_IV_ECE.pptx
PPTX
Introduction to embedded System.pptx
PPTX
Embedded systems
PPTX
Introduction to Embedded Systems
PDF
es1-150721100817-lva1-app6891.pdf
PPTX
E-m--be-dde-d -sy-s-te---m_Day_1_ES.pptx
PPTX
introduction to embedded system presentation
PPT
39245175 intro-es-ii
PPTX
Embedded systems
PDF
Introduction to embedded computing and arm processors
PPTX
Basic Introduction to Embedded System.pptx
PPTX
1. An Introduction to Embed Systems_DRKG.pptx
PPTX
13. Module-3-Embedded systems.pptx
PPTX
Introduction to Embedded system with its definition and applications
PDF
Unit-I Basic Embedded System Notes
PDF
ES-Basics.pdf
PPTX
EMBEDDED AND REAL TIME SYSTEMS Unit-1_6703.pptx
Introduction to embedded systems powerpoint
UNIT 1.pptx
ERTS_IV_ECE.pptx
Introduction to embedded System.pptx
Embedded systems
Introduction to Embedded Systems
es1-150721100817-lva1-app6891.pdf
E-m--be-dde-d -sy-s-te---m_Day_1_ES.pptx
introduction to embedded system presentation
39245175 intro-es-ii
Embedded systems
Introduction to embedded computing and arm processors
Basic Introduction to Embedded System.pptx
1. An Introduction to Embed Systems_DRKG.pptx
13. Module-3-Embedded systems.pptx
Introduction to Embedded system with its definition and applications
Unit-I Basic Embedded System Notes
ES-Basics.pdf
Ad

Recently uploaded (20)

DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
web development for engineering and engineering
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT
Project quality management in manufacturing
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Construction Project Organization Group 2.pptx
PPTX
Welding lecture in detail for understanding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
web development for engineering and engineering
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Embodied AI: Ushering in the Next Era of Intelligent Systems
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Project quality management in manufacturing
Foundation to blockchain - A guide to Blockchain Tech
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
UNIT 4 Total Quality Management .pptx
bas. eng. economics group 4 presentation 1.pptx
Internet of Things (IOT) - A guide to understanding
Construction Project Organization Group 2.pptx
Welding lecture in detail for understanding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Ad

introduction to Embedded Systems

  • 1. Eng.HamdyAhmedEl-asawy Eng.Hamdy Ahmed Hamdy El-asawy IntroductionTo EmbeddedSystems
  • 2. Content 1. What is An Embedded System 2. Embedded System Design 3. Embedded Design Goals 4. Embedded Design Characteristics 5. Embedded System Application 6. Microcontrollers 7. What is a Development Board 8. Central processing unit (CPU) 9. CPU Architecture(MemoryAccessing) 10. CPU Architecture(Numberof instructions) 11. MemoryTypes 12. Interrupts 13. Power 14. Embedded System Constrains Eng.Hamdy Ahmed Hamdy El-asawy
  • 3. What is an Embedded System Eng.Hamdy Ahmed Hamdy El-asawy
  • 4. What is An Embedded System An embedded system is one that has computer hardware with software embedded in it as one of its components. An embedded system is a dedicated system which performs the desired function upon power up, repeatedly. Eng.Hamdy Ahmed Hamdy El-asawy
  • 5. Or we can say that it is “A combination of computer hardware and software, and perhaps additional mechanical or other parts, designed to perform a dedicated function. In some cases, embedded systems are part of a larger system or product, as is the case of an antilock braking system in a car Eng.Hamdy Ahmed Hamdy El-asawy What is An Embedded System
  • 6. Software Hardware Embedded System Eng.Hamdy Ahmed Hamdy El-asawy 1.0 What is An Embedded System For A Dedicated purpose .
  • 8. Embedded System Vs General Purpose system Eng.Hamdy Ahmed Hamdy El-asawy
  • 9. General Purpose Systems • A General Purpose Systems is A Computer System ( Hardware + Software ) That Perform Many Applications which can be changed by the user. • Can be ProgramedBy User • Hardware And Software Modifications can be done ByThe User Like : Personal Computers Servers Eng.Hamdy Ahmed Hamdy El-asawy
  • 10. Embedded Systems General Purpose Systems Not programmable by user. programmable by user. Specific Applications that are known at design time Computing Lots of Applications Harder to Develop Easier to Develop A Part of a Bigger System ( Embedded ) Standalone System or integrated with other Systems Eng.Hamdy Ahmed Hamdy El-asawy
  • 12. Embedded System Application PC cannot be considered as an embedded system because : It uses a General-Purpose Processor. The system is built independently from the software runs on it. Eng.Hamdy Ahmed Hamdy El-asawy
  • 13. Embedded Systems Application • Automotive Eng.Hamdy Ahmed Hamdy El-asawy
  • 14. Embedded Systems Application • V2V Communication Eng.Hamdy Ahmed Hamdy El-asawy
  • 21. SOC ( System on Chip) Eng.Hamdy Ahmed Hamdy El-asawy
  • 22. SOB ( System on Board) Eng.Hamdy Ahmed Hamdy El-asawy
  • 23. Embedded Systems Design Eng.Hamdy Ahmed Hamdy El-asawy
  • 24. Embedded System Design • Embedded Systems Consist of Hardware and software combined togetherfor a dedicated purpose • The Key in Design is to Determine Which Function Block should be Performed in Hardware and Which should be in software Eng.Hamdy Ahmed Hamdy El-asawy
  • 25. • Hardware characteristics Advantage: » Betterperformance in high speed real time application Disadvantage: » Longer development cycle. » Customized for specific application, not updatable (unchangeable). Eng.Hamdy Ahmed Hamdy El-asawy Embedded System Design
  • 26. • Software characteristic Advantage: »Highly Configurable »Shorter development cycles »Easier in Versions updates »Cheaper Disadvantage: » Constrains with processor speed which may satisfy real time applications and may not Eng.Hamdy Ahmed Hamdy El-asawy Embedded System Design
  • 27. Embedded System Design Steps Requirement Analysis System Architecture Specifications Hardware Design Hardware Testing Hardware Implementation Software Design Software Testing Software Implementation System integration Operation & Maintenance System Validation Eng.Hamdy Ahmed Hamdy El-asawy
  • 28. Embedded Design Goals • Performance • Functionality and user interface. • Manufacturing cost. • Power consumption. • Safety. • Other requirements. (physical size ….. etc. ) Eng.Hamdy Ahmed Hamdy El-asawy
  • 29. Embedded System Design • Any Embedded System • Built for Certain Application • The System Should Fulfill The Requirements of the Application • Characteristics Eng.Hamdy Ahmed Hamdy El-asawy
  • 30. Embedded System Design characteristics 1- Dependability: • MakesUsers to Safely relay on The system • Systems Like : • Airplanes • Nuclear Power Plants • Automotive break system • System should be Dependable because it have a direct impact on the Environment As if any thing goes wrong it would cause some series injury to it’s user or maybe death Eng.Hamdy Ahmed Hamdy El-asawy
  • 31. Embedded System Design characteristics System is considered to be dependable if System is Reliable System is Available System is Maintainable System is Safe System is Secure Interactive System Eng.Hamdy Ahmed Hamdy El-asawy
  • 32. •Reliability The abilityofa machine, or system to consistentlyperform its intended or required functionor mission, on demand and withoutdegradation or failure. Eng.Hamdy Ahmed Hamdy El-asawy
  • 33. Maintainability The ability to modify the system after its initial release and enhance its performance likeexecution time, code and memory size. likeAntilock ,Barking systems, Autopilot. • Readability • Changeability • Stability • Testability Eng.Hamdy Ahmed Hamdy El-asawy
  • 34. • Availability Probability of system working at time t. • Safety Cause no Harm even if in the case of failure . Eng.Hamdy Ahmed Hamdy El-asawy sometimes it shouldn't be 24/7
  • 35. • Security The Data of The User is Secure • Interactive System It is easily understandable, Operated and Handled by auser and provide ease of task. Eng.Hamdy Ahmed Hamdy El-asawy
  • 36. Embedded System Design characteristics 2- Efficiency:- • Energy Efficiency • Code Size Efficiency • Cost Efficiency • Time Efficiency • If you consider a Real Time Application is onein which must beable to act at a speedcorresponding with the occurrenceof an actual process • MUST COMPLETE CERTAIN RESULTSIN A CERTAIN TIME WITH OUT DELAY • If you are using an embedded system with a limited power source such as a Battery Efficiency in energy is A require. Eng.Hamdy Ahmed Hamdy El-asawy
  • 37. Energy Efficiency• For Processors Energy Efficiencycanbe estimated based on the number of instructionper joule 𝑁𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑖𝑛𝑠𝑡𝑟𝑢𝑐𝑡𝑖𝑜𝑛𝑠 α 𝑊𝑜𝑟𝑘 𝑗𝑜𝑢𝑙𝑒 • The More ApplicationSpecificthe Components and the code are The More Energy Efficientthe system is. Eng.Hamdy Ahmed Hamdy El-asawy
  • 38. Efficiency • Code size : Must Occupy as small space as possible • Physical Appearance • Small Size • Portableif Desired • Cost : • Minimal Numbersof Component Eng.Hamdy Ahmed Hamdy El-asawy
  • 39. Embedded Systems Characteristic 3- Real TimeConstrains •If real Time Constrainsare notmet : • Low Quality • Serious consequences • Lackof Dependency Eng.Hamdy Ahmed Hamdy El-asawy
  • 40. Software Hardware Embedded System Eng.Hamdy Ahmed Hamdy El-asawy What is An Embedded System For A Dedicated purpose .
  • 41. System Bus Hardware Eng.Hamdy Ahmed Hamdy El-asawy POWER CCT External Hardware Internal Memory CPU Interrupt Circuit Timer Watch Dog Serial Communication GPIO ADC SystemBus System Bus
  • 42. What is a uc Eng.Hamdy Ahmed Hamdy El-asawy
  • 43. Microcontrollers • It is a micro-computer. As any computer it has internal CPU, RAM, IOs interface. • A microcontroller is a single chip, self-contained computer(SOC), which incorporates all the basic components of a personal computer on a much smaller scale. • It is used for control purposes, and for data analysis. Eng.Hamdy Ahmed Hamdy El-asawy
  • 44. • Microcontrollers don’t work alone in the circuit it must interfaces with other on chip devices like Sensors, Switches, Leds , LCD, Keypad and DC Motor. Microcontrollers Eng.Hamdy Ahmed Hamdy El-asawy System Bus POWER CCT External Hardware Internal Memory CPU Interrupt Circuit Timer Watch Dog Serial Communication GPIO ADC SystemBus System Bus
  • 45. What is a Development Board Eng.Hamdy Ahmed Hamdy El-asawy
  • 46. What is A Development Board • A printed circuit board designed to facilitatework with a particular microcontroller. Typical components include: •power circuit •programming interface •basic input; usually buttons and LEDs •I/O pins Eng.Hamdy Ahmed Hamdy El-asawy
  • 47. uc Basic Peripherals Eng.Hamdy Ahmed Hamdy El-asawy
  • 48. Microcontrollers • A microcontroller has seven main components: Central processing unit (CPU) internal Memory Input and Output Timer Interrupt circuitry Buses Eng.Hamdy Ahmed Hamdy El-asawy
  • 49. Microcontrollers • A microcontroller has seven main components: 1- Central processing unit (CPU) Eng.Hamdy Ahmed Hamdy El-asawy
  • 50. Central processing unit (CPU) • CPU Dose AllThe Computing : • Arithmetic , control , logic , data , IO operations • Instruction Cycle: • Fetches • Decodes • ExecutesProgram Instruction Eng.Hamdy Ahmed Hamdy El-asawy
  • 52. Cpu Architecture •There aretwo basic types of architecture: 1. Number of Instructions Based Architecture 2. CPU BUS Architecture Eng.Hamdy Ahmed Hamdy El-asawy
  • 53. Memory Accessing(BUS) CPU Architecture • Memory AccessingCPU Architecture : Harvard and Von Neumann. • Microcontrollers most often use a Harvard or a modified Harvard-based architecture. • The microcontroller is often part of a larger system. Eng.Hamdy Ahmed Hamdy El-asawy
  • 54. VonNeumann • Von Neumann architecture has a single, common memory space where both program instructions and data are stored. There are Common buss between both instructions and data memory. Eng.Hamdy Ahmed Hamdy El-asawy
  • 55. VonNeumann • Each time the CPU fetches a program instruction it may have to perform one or more read/write operations to data memory space. • It must wait until these subsequent operations are complete before it can fetch and decode the next program instruction. The advantage to this architecture lies in its simplicity and economy. Eng.Hamdy Ahmed Hamdy El-asawy
  • 56. Harvard •Harvard architecture computers have separate memory areas for program instructionsand data. •There are two or more internal data buses which allowsimultaneousaccess to both instructionsand data. Eng.Hamdy Ahmed Hamdy El-asawy
  • 57. Harvard • The CPU fetches instructions on the program memory bus. If the fetched instruction requires an operation on data memory, the CPU can fetch the nextprogram instruction whileit uses the data bus for its data operation. This speeds up execution time at the cost of more hardware complexity. Eng.Hamdy Ahmed Hamdy El-asawy
  • 58. CPU Architecture(Numberof instructions): There are two basic types of architecture: Reduced Instruction Set Computing(RISC). Complex Instruction Set Computing(CISC). Microcontrollers most oftenuse a RISC Architecture Eng.Hamdy Ahmed Hamdy El-asawy
  • 60. RISC CISC CPU design that recognizes only a limited number of instructions, Simple in design. CPU design that recognizes a large number of instructions, Complex in design. Simple instructions. Complex and Large no. of instructions. Instructions are executed quickly. Large execution time for each instruction. Only the load and store instructions operate directly onto memory. Instructions can operate directly on memory. RISC aims to optimize execution of instructions by limiting the capabilities of a single instruction and having consistent instructions’ execution time (Instruction Pipelining) CISC is an old concepts that dates back when memory access was slow. CPU Architecture(Numberof instructions): Eng.Hamdy Ahmed Hamdy El-asawy
  • 61. RISC CISC thus gaining speed from execution point of view but code size will be large for a dedicated function. But it will increase the number of memory access. CISC aimed to integrate several functionalities in one instruction, in order to limit the program size. and thus limit memory access in order to gain some speed. So It's harder to write powerful optimized compilers, since large number of instructions needed. It's easier to write powerful optimized compilers, since fewer instructions exist. Combine a large number of general registers for arithmetic operations to avoid storing variables on a stack in memory. Small number of general purpose registers. Example: ARM, AVR, PIC,POWER-PC and SPARC. Example: Intel X86, AMD and Motorola 68000. CPU Architecture(Numberof instructions): Eng.Hamdy Ahmed Hamdy El-asawy
  • 63. Central processing unit (CPU) •CPU Mainly consistof : Arithmetic Logic Unit(ALU). Control Unit. Registers. Bus Eng.Hamdy Ahmed Hamdy El-asawy
  • 64. Central processing unit (CPU) • Arithmetic Logic Unit :- One part of the CPU is responsible for performing calculationsand executing instructions.Thispart is calledthe arithmetic logic unit, or ALU. Eng.Hamdy Ahmed Hamdy El-asawy Logic instructioninclude AND OR Not XOR Arithmetic instructioninclude:- Addition Subtraction ShiftingOperation
  • 65. Central processing unit (CPU) • Control Unit:- Controls The Internal Flow to Fetch , Decode and execute an instruction Eng.Hamdy Ahmed Hamdy El-asawy 1-Program Counter:- is a register in a computer processor that containsthe address (location) of the instructionthat willbe executednext to the current instruction. Note That in SomeArch, the PC points to the currentinstruction being executed
  • 66. Central processing unit (CPU) • Control Unit:- Controls The Internal Flow to Fetch , Decode and execute an instruction Eng.Hamdy Ahmed Hamdy El-asawy 2-Instruction Register:- Register which contains theinstruction after getting it from program memory (Fetch stage).
  • 67. Central processing unit (CPU) • Control Unit:- Controls The Internal Flow to Fetch , Decode and execute an instruction Eng.Hamdy Ahmed Hamdy El-asawy 3-Instruction Decoder:- Converts instructionstored or Fetched in aprogram memory into codes whichthe ALUcan understand and generate the control signalsof this instruction The instruction set Differs From Microcontroller Family to another and it express the ability of the Microcontroller circuit
  • 68. Eng.Hamdy Ahmed Hamdy El-asawy AVR CPU Core  Common CPU for all AVR parts  Ex. add $r1, $r2, $r3 1. Read instruction from program memory 2. Load instr. into instr. Register 3. Get source register numbers from instruction 4. Fetch source data from register file 5. Pass sources to ALU, add 6. Pass result to register file
  • 69. Central processing unit (CPU) • Registers are used by the CPU to temporarily store vital data which are volatile.(most of them ) Registers are classified into General Purpose Stores Current programor data being processed Special Function Control Registers States Registers • Many of the microcontroller registers arememory-mapped, associated with a memory location, and can beused like any othermemory location if not the register is then port mappedand require special assembly instruction to handle it . • The number and names of registers varies drastically among microcontrollers.Howevertherearecertain registers which are commonto most microcontrollers Eng.Hamdy Ahmed Hamdy El-asawy
  • 70. • Register File A number of registers grouped together AVR CPU contains 32 GP registers R0 -R31. Eng.Hamdy Ahmed Hamdy El-asawy
  • 71. SFR (Specialfunction registers) 1- The stack pointer The stack pointer contains the address of the next location on the stack. The address in the stack pointer is decremented when data is pushed on the stack and incremented when data is popped from the stack. • The Stack is implemented as growing from higher memory locations to lower memory locations. This implies that a Stack PUSH command decreases the Stack Pointer and a Stack POP command increases the Stack Pointer(and may be vice versa for some processors). Eng.Hamdy Ahmed Hamdy El-asawy
  • 72. •The Stack is mainly used for storing temporary data, for storing local variables and for storingreturn addresses after interrupts and subroutine calls. •A stack is a LIFO(lastin, first out) mechanism the last thing store on the stack is the first thing tobe retrieved from the stack. Eng.Hamdy Ahmed Hamdy El-asawy
  • 73. • Initial Stack Pointer value equals the last address of the internalSRAM and the Stack Pointer must be set to point above start of the SRAM • Stack Pointer have to be initialized to point to the last memory location in SRAM (i.e. first empty location in the stack). AVR Stack Eng.Hamdy Ahmed Hamdy El-asawy
  • 75. SFR (Specialfunction registers) 2- IndexRegister • The index register is used to specify an address when certain addressing modes are used. It is also known as the pointer register.The Microchip devices use the name FSR (file select register). • Also called Base Register. Eng.Hamdy Ahmed Hamdy El-asawy Used in indirect addressing modes, as the accessed address = index register + offset mentioned in code.
  • 77. SFR (Special function registers) 3 - The program counter • Perhaps the single most important CPU registeris the program counter(PC). The PC holds the address of the next instruction in program memory space. • It contains the address of the next instruction the CPU will process. As each instruction is fetched and processed by the ALU, the CPU increments the PC and thereby steps through the program stored in the program memory space. Eng.Hamdy Ahmed Hamdy El-asawy 4- Instruction Register(IR) Register which contains the instruction after getting it from program memory (Fetch stage).
  • 78. 5- Processor Status Word/Register(PSW) • The Status Register contains information about the result of the most recently executed arithmetic instruction. This information can be used for altering programflow in order to perform conditional operations. • Status Register is updated after ALU operations. SFR (Special function registers) Eng.Hamdy Ahmed Hamdy El-asawy
  • 79. SREG - AVRStatus Register • Bit 7 – I: Global Interrupt Enable The Global Interrupt Enable bit must be set for the interrupts to be enabled. The individual interrupt enable control is thenperformedin separate control registers. If the Global Interrupt Enable Register is cleared,none of the interrupts areenabled independent of the individual interrupt enable settings. The I-bit is cleared by hardware after an interrupt has occurred,and is set by the RETI instruction to enable subsequent interrupts. The I-bit can also beset and cleared in software with the SEI and CLI instructions, as describedin the instruction set reference. Eng.Hamdy Ahmed Hamdy El-asawy
  • 80. SREG - AVRStatus Register • Bit 4–S: Sign Flag indicates theresult sign ofarithmetic Data. Bit 3–V :Overflow flag indicates an overflowoccurs in an arithmetic operation. • Bit 2–N: Negativeflag indicates a negativeresult in an arithmetic or logic operation.(ALU) • Bit 1–Z :Zero flag indicates a zero result in an arithmetic or logic operation. • Bit 0–C: Carryflag indicates a carry in an arithmetic or logic operation. Eng.Hamdy Ahmed Hamdy El-asawy
  • 81. Instruction Pipelining: Continuous and parallel streaming of instruction to the CPU. A method of achieving higher execution speed at same clock speed. Eng.Hamdy Ahmed Hamdy El-asawy
  • 82. Co processors • A Processor that supplements the function of the primary processor. • Ex: FPU Graphics processor Digital Signalprocessor Encryption processor Eng.Hamdy Ahmed Hamdy El-asawy
  • 83. System Bus • DataBus The set of lines carrying data and instructions to or fromthe CPU is called the databus. The number of lines in the data bus determines the maximum datawidththe CPU can handle in a single transaction an 8-bit data bus can transfer atmost one byte (or two nibbles) in a single transaction, and a 16-bit transaction would require two data bus transactions. Eng.Hamdy Ahmed Hamdy El-asawy
  • 84. System Bus • Address Bus The CPUinteracts with only one memory register or peripheral device at a time. Each register, either in memory or aperipheral device, is uniquely identified with an identifier called address. The set of lines transporting this address information form the addressbus.. Eng.Hamdy Ahmed Hamdy El-asawy
  • 85. System Bus • ControlBus The controlbusgroups all the lines carryingthe signalsthat regulate the system activity. Control signals include those used to indicate whether the CPU is performing a read or write access. For Example : Memory chip READ/WRITE (R/W)lines and Chip Select (CS)lines Eng.Hamdy Ahmed Hamdy El-asawy
  • 86. Microcontrollers • A microcontroller has seven main components: 1- Central processing unit (CPU) 2- Memory Unit ( RAM , ROM ) Eng.Hamdy Ahmed Hamdy El-asawy
  • 87. MemoryUnits • Memory is a part of a microcontroller used for data and program storage There are Two Basic Types of Memory RAM ROM Eng.Hamdy Ahmed Hamdy El-asawy
  • 88. ROM • ROM, read only memory, is non-volatile memory used for program information and permanent data. • The microcontroller uses ROM memory space to store program instructions it will execute when it is started or reset. • Program instructions must be saved in non-volatile memory so that they are not affectedby loss of power. Eng.Hamdy Ahmed Hamdy El-asawy
  • 89. ROM Types • Mask ROM (MROM)is a type of read-only memory (ROM)whose contents are programmed by the integrated circuit manufacturer (rather than by the user). • It is common practice to use rewritable non-volatile memory – such as UV-EPROM or EEPROM – for the development phase of a project, and to switch to mask ROM when the code has been finalized. Eng.Hamdy Ahmed Hamdy El-asawy
  • 90. MROM • The main advantage of mask ROM is its cost. Per bit, mask ROM is more compact than any other kind of semiconductor memory. Since the cost of an integrated circuit strongly depends on its size, mask ROM is significantly cheaper than any other kind of semiconductor memory. Design errors are costly: if an error in the data or code is found, the mask ROM is useless and must be replaced in order to change the code or data. Eng.Hamdy Ahmed Hamdy El-asawy
  • 91. One Time Programed Memory (OTP) (PROM) • Can be programed one time only • A typical PROM comes with all bits reading as "1". Burning a fuse bit during programming causes the bit to read as "0". The memory can be programmed just once after manufacturing by "blowing" the fuses, which is an irreversible process. Eng.Hamdy Ahmed Hamdy El-asawy
  • 92. UV EPROM • It enables data to be erased under strong ultraviolet light. • Aftera fewminutes it is possible to download a new program. Eng.Hamdy Ahmed Hamdy El-asawy
  • 93. EEPROM(Electrically ErasableProgrammableROM) • Can be erased by electricity • The content of This memory can be changed Like ( RAM ) but it can hold the data inside it even if in the case of no power Eng.Hamdy Ahmed Hamdy El-asawy
  • 94. RAM(Random Access Memory) • Volatile Memory • Faster Than Rom • Used to Store Temporary Programs • Also called Read/Write Memory, The term random access refers to the ability to access any memory cell directly. Eng.Hamdy Ahmed Hamdy El-asawy
  • 95. DRAM( Dynamic Random AccessMemory ) • The capacitor arrays will hold their charge only for a short period before it begins to diminish , Meaning that it always have to be refreshed to keep it’s content Eng.Hamdy Ahmed Hamdy El-asawy
  • 96. SRAM( StaticRandom AccessMemory ) • Doesn’t Need To Refresh it Self The Data instead will wait to be overwritten. • Consist of a 4~ 6 Transistors for each memory Cell More Expensive and Higher Performance than DRAM Eng.Hamdy Ahmed Hamdy El-asawy
  • 97. Non-Volatile RAM (NVRAM) • A Volatile Ram connected to an Emergency battery. Eng.Hamdy Ahmed Hamdy El-asawy
  • 98. FLASH Memory ( Hybrid Memory – Mix between Ram & ROM ) • Flash Memory is just like EEPROM the only Difference is in it’s erase cycle as flash is erased sector by sector ( Multiple Bytes ) • But EEPROM is erased Byte by Byte Eng.Hamdy Ahmed Hamdy El-asawy
  • 99. RAM is Divided into • Mapped General Purpose Registers • Mapped IO Registers • SRAM (Contains the Program Data) • Note thatin Some Arch Ram Contains The Code To be executed to but ithas to be copied from flash After each reset. Eng.Hamdy Ahmed Hamdy El-asawy
  • 100. Cpu Cache Cache memory, also called CPU memory, is random access memory (RAM) that a computer microprocessor can access more quickly than it can access regular RAM. This memory is typically integrated directly with the CPU chip or placed on a separate chip that has a separate bus interconnect with the CPU. Eng.Hamdy Ahmed Hamdy El-asawy
  • 102. Register File: A (usually) relatively small memory embedded on the CPU. It is used as a scratchpad for temporary storage of values the CPU is working with you could call it the CPU’s short term memory. Data Memory: For longer term storage, generic CPUs usually employ an external memory which is much larger than the register file. Data that is stored there may be short-lived, but may also be valid for as long as the CPU is running Instruction Memory: Likethe data memory, the instruction memory is usually a relatively large external memory (at least with general CPUs) Eng.Hamdy Ahmed Hamdy El-asawy
  • 103. Memory Management unit MMU • Translates Address From CPU Memory ( Virtual Memory ) to Physical Address on Memory • Provides Memory Protection Function • Typically the MMU is tightly coupled to the processor core . Eng.Hamdy Ahmed Hamdy El-asawy
  • 104. Memory Controller • The memory controller would handle the physical signaling involved in communicating to external memory. • Typically Memory controller is a peripheral on the uc internal bus. Eng.Hamdy Ahmed Hamdy El-asawy
  • 105. Direct Memory AccessDMA • A Co Processorthat Allows Data transfers without the interference of the processor • It can movedata betweenDifferent Memories or A Memory and an IO Device. • DMA Speed is limited by the speed of the slowest devicein the transferee. • Ex:- In a typical DMA transfer, some event (such as an incoming data-available signal from a UART) notifiesaseparatedevicecalledtheDMAcontrollerthatdataneedsto be transferredto memory. TheDMAcontrollerthenassertsaDMArequestsignalto theCPU, askingitspermissionto usethebus. TheCPU completesitscurrentbus activity,stopsdrivingthebus, andreturnsaDMAacknowledgesignaltotheDMA controller. TheDMAcontrollerthenreadsandwritesoneor more memory bytes,drivingtheaddress,data,andcontrolsignalsasif it were itselftheCPU. (The CPU's address,data,andcontroloutputsaretristatedwhiletheDMA controllerhascontrolof thebus.) Whenthetransferis complete,theDMAcontrollerstops drivingthebus andde assertstheDMArequestsignal. TheCPU canthenremoveitsDMAacknowledgesignalandresumecontrolof thebus. Eng.Hamdy Ahmed Hamdy El-asawy
  • 106. Microcontrollers • A microcontroller has seven main components: Central processing unit (CPU) ROM RAM Input and Output Timer Interrupt circuitry Eng.Hamdy Ahmed Hamdy El-asawy
  • 107. IO Devices • Microcontrollers cannot be used without a hardware to interface with I ex: • Send an information to an lcd • Receive an analogsignal • Send a digitalsignal • IO Modules do the work of exchanging information with the processors and external Hardware. • All signals passed to the Cpu should be Digital Signals but IO Devices can deal with digital – not digital signal. • Ex: if an analog signal is passed to uc a certain IO module called ADC translates the Analog signal to a digital code which the cpu can handle with. • Some IO Devices is small enough to be integrated in the same chip with the uc ( ADC , RTC ..ETC) and some cannot be integrateddue to size or differentinterface system ( LCD , Keypad , Speakers.. ETC) Eng.Hamdy Ahmed Hamdy El-asawy
  • 108. How To Access IOMemory Space • There are 2 Common Ways to Access An IO Space 1. Port Mapped IO • IO’s Have Their Own Mapping ( Address ) And Require special Assembly instruction to interface with them ( as in , out inst in AVR ) • Isn't common in Embedded System ( But Still used ) 2. Memory Mapped IO 1. Io’s Share Memory Mapping ( Memory segmentsand IO’s are in the Same Mapping ) using this way will make it easier to interface IO as we interface Memory ( Load , Store inst in AVR ). 2. Commonly used in Embedded Sysetms. Eng.Hamdy Ahmed Hamdy El-asawy
  • 109. How to Deal WithIO • There Are Commonly two ways to Deal With IO : • By Polling : • Write the Program to Continuously check IO for a Certain Event. • Less CPU Utilization • Have A Lot of Disadvantages • Don't Require extra Resources ( Interrupt pin) • Assigning them to an interrupt • The Program wont check the IO , when a certain event reaches the IO , the IO signals The Cpu That the event has occurred and then the Cpu handles it. Eng.Hamdy Ahmed Hamdy El-asawy
  • 110. Interrupts • Interrupts allow the microcontroller to interact with its environment. • An interrupt is a signal sent to the microcontroller which causes it to stop its current execution and perform another action. The chip stops executing your main program and executessome other code. Interrupts can be edge triggered (rising or falling) or level triggered. Eng.Hamdy Ahmed Hamdy El-asawy
  • 111. Interrupt handler • Code executed by an interrupt is not generally considered part of the main application. Since this code handles the cases where an interrupt occurs, it is called an interrupt handler or an interrupt service routine. Eng.Hamdy Ahmed Hamdy El-asawy
  • 112. SynchronousandAsynchronousInterrupt Acknowledgement • Most interrupt acknowledgement is synchronous, the instruction currently being executed is completed before the interrupt is acknowledged. • when the processor acknowledges an interrupt asynchronously it halts execution of the currentinstruction and immediately services theinterrupt. • The only asynchronously acknowledged interrupt is RESET. Since RESET erases the stateof the machine, it is a moot point whether the CPU actually halts execution of the current instruction or not. Eng.Hamdy Ahmed Hamdy El-asawy
  • 113. NestedInterrupts • To minimize the possibility of an interrupt handler being itself interrupted, the microcontroller will usually disable interrupts while executing an interrupt handler. • if we Enable it again then we have enabled interrupt nesting Eng.Hamdy Ahmed Hamdy El-asawy
  • 114. Power • Most microcontrollers support 4.5 to 5.5 Volt operation. There are also many low voltage parts which are designed to work at 3 volts or less. Brownout • Microcontrollers have an on-board circuit which provides brownout protection. A brownout occurs when the operating voltage falls below the defined brownout voltage. When a brownout occurs the device is reset and waits for the operating voltage to rise above the brownout voltage. Eng.Hamdy Ahmed Hamdy El-asawy
  • 115. Halt/Idle • Individual microcontrollers have specific modes which stop the execution of the program without affecting the power to themicrocontroller. In thesemodes less power is required and power consumption is reduced. Halt mode stops all activities and can be terminated by a reset or an interrupt. Idle mode Eng.Hamdy Ahmed Hamdy El-asawy
  • 116. Watch dog Timer Most embedded systems need to be self-reliant. It's not usually possible to wait for someone to reboot them if the software hangs. A watchdog timer is a piece of hardware that can be used to automatically detect software anomalies and reset the processor if any occur. Generally speaking, a watchdog timer is based on a counter that counts down from some initial value to zero. Eng.Hamdy Ahmed Hamdy El-asawy
  • 118. Software Eng.Hamdy Ahmed Hamdy El-asawy DEVICE DRIVER OS Middleware Application
  • 119. Eng.Hamdy Ahmed Hamdy El-asawy DEVICE DRIVER Low Level Device Driver High Level Device Driver Hardware Dependent OS Dependent
  • 120. Eng.Hamdy Ahmed Hamdy El-asawy Operating Systems Os is a Software That manages the Hardware Resources. Two Kinds of Operating Systems Could Be Used With Embedded sys: GPOS ( the Throughput is the AIM ) RTOS ( Meeting Tasks Deadline is the AIM)
  • 121. Eng.Hamdy Ahmed Hamdy El-asawy Middleware middleware is an abstraction layer generally used on embedded devices with two or more applications in order to provide flexibility, security, portability, connectivity, and intercommunication between applications.
  • 122. Eng.Hamdy Ahmed Hamdy El-asawy Application This is a Software Layer that provides User interface (UI) Uses the OS and Device Drivers
  • 123. Embedded SystemsConstrains • Number of Pins ( I/o) • Memory Size • Execution Time (speed ) • Sampling Rate • BuadRate • Cost • Performance ( Depend Clock Frequency , Power , Used memory size ) • Time To Market ( Depending on The Market window ) Eng.Hamdy Ahmed Hamdy El-asawy
  • 124. Embedded systems Life Cycle Eng.Hamdy Ahmed Hamdy El-asawy
  • 126. Any Questions ?? • Hamdy.elasawy@gmail.com • 01004750613 • https://www.linkedin.com/in/hamdyelasawy • www.Facebook.com/Hamdy.elasawy Eng.Hamdy Ahmed Hamdy El-asawy