Module 3
Module 3
MICROCONTROLLER AND
EMBEDDED SYSTEMS
MODULE 3
INTRODUCTION TO
EMBEDDED SYSTEMS
1
INTRODUCTION TO
EMBEDDED SYSTEMS
» An embedded system is
» An electronic/ electro-mechanical system
M
» Every embedded system is unique
» Telecommunications
» medical equipment
» industrial control
» consumer products.
3
» Characteristics of Embedded Systems:
» Embedded Systems
4
EMBEDDED SYSTEMS versus
GENERAL COMPUTING SYSTEMS
General Computing System Embedded System
1. A combination of generic hardware and 1. A combination of special purpose hardware
a
embedded OS for executing a specific set of
General Purpose Operating System (GPOS) for
applications.
executing a variety of applications.
1. Applications are alterable (programmable) by 1. The firmware is pre-programmed and it is non-
the user. alterable by the end-user (there may be exceptions).
1. Performance is the key deciding factor in the 1. Application-specific requirements (like performance,
selection of the system. Always, ‘Faster is Better’. power requirements, memory usage, etc.).
1. Less/ not at all tailored towards reduced 1. Highly tailored to take advantage of the power
operating power requirements. saving modes supported by the hardware and the
operating system.
1. Need not be deterministic in execution behavior; 1. Execution behavior is deterministic for certain
response requirements are not time critical. types of embedded systems like ‘Hard
Real
MP,
CS Time’
E, VCET systems. 5
HISTORY OF EMBEDDED SYSTEMS
» Embedded systems were existing even before the Information Technology
revolution.
» Initially, embedded systems were built around vacuum tube and transistor
technologies
6
» Apollo Guidance Computer (AGC)
» AGC included –
» Lunar Excursion Module (LEM-to go down to the moon surface and land
there safely).
» The first microprocessor, the Intel 4004, was designed for calculators and other
small systems; but still required many external memory and support chips.
» Early 1990, cell phones having five or six DSPs and CPUs emerged.
8
CLASSIFICATION OF
EMBEDDED SYSTEMS
» Classification based on Generation:
Generation with Example Description
First Generation (1G) 8-bit microprocessor and 4-bit microcontroller like 8085 and Z80
- Digital telephone keypads was used in 1G.
- Stepper motor Hardware circuit was simple.
Assembly code is used for developing firmware.
10
» Classification based on Complexity & Performance:
» Embedded technology has acquired a new dimension from its first generation
model, the Apollo Guidance Computer, to the latest radio navigation system
combined with in-car entertainment technology and wearable computing
devices (Apple watch, Microsoft band, Fitbit fitness trackers, etc.).
» The application areas and the products in the embedded domain are
countless.
A few of the important domains and products are listed below:
13
1. Consumer Electronics: Camcorders, cameras, etc.
14
9. Healthcare: Different kinds of scanners, EEG, ECG machines, etc.
11. Banking & Retail: Automatic teller machines (ATM) and currency counters,
point of sales (POS).
12. Card Readers: Barcode, smart card readers, hand held devices, etc.
13. Wearable Devices: Health and fitness trackers, Smartphone screen extension
for notifications, etc.
15
PURPOSE OF EMBEDDED SYSTEMS
» Embedded systems are used in various domains like consumer electronics,
home automation, telecommunications, automotive industry, healthcare,
control & instrumentation, retail and banking applications, etc.
2. Data Communication
4. Monitoring
5. Control
16
» Purpose of Embedded Systems:
» Data Collection, Storage, Representation
Data is collection of facts, such as values or measurements. It can be
numbers, words, measurements, observations, or even just description of
things.
Purpose of embedded system design is data collection.
It performs acquisition of data from the external world.
Data collection is usually done for storage, analysis,
manipulation, and transmission.
Data can be analog or digital.
17
» Purpose of Embedded Systems:
» Data Collection, Storage, Representation
Embedded systems with analog data capturing techniques collect data
directly in the form of analog signal; whereas embedded systems with
digital data collection mechanism convert the analog signal to
corresponding digital signal using analog to digital (A/D) converters.
If the data is digital, it can be directly captured by digital embedded system.
A digital camera is a typical example of an embedded system with data
collection, storage, and representation of data. Images are captured and
captured image may be stored within the memory of the camera. The
captured image can also be presented to the user through a graphic LCD
(Liquid Crystal Display) unit.
18
» Purpose of Embedded Systems:
» Data Communication
Embedded data communication systems are deployed in
ranging from simple home networking applications systems
communication systems. to complex
Network hubs, routers, switches are satellite
examples of dedicated data
transmission embedded systems.
Data transmission is in the form of wire medium or wireless medium.
Initially wired medium is used by embedded systems; and as technology
changes, wireless medium becomes de-facto standard in embedded systems.
USB, TCP/ IP are examples of wired communication; and BlueTooth,
ZigBee and Wi-Fi are examples for wireless communication.
19
» Purpose of Embedded Systems:
» Data (Signal) Processing
Embedded systems with signal processing functionalities are employed in
applications demanding signal processing like speech coding, audio-video
codec, transmission applications, etc.
A digital hearing aid is a typical example of an embedded system
employing data processing.
20
» Purpose of Embedded Systems:
» Monitoring
Almost all embedded products coming under
functions.
Patient heart beat is monitored by Electro
cardiogram (ECG) machine.
Digital CRO, digital multi-meters, and logic analyzers are examples of
monitoring embedded systems.
21
» Purpose of Embedded Systems:
» Control
Sensors and actuators are used for controlling the system.
Sensors are connected to the input port for capturing the changes in
environmental variable or measuring variable.
Actuators connected to output port are controlled
according to the
changes in input variable.
Air conditioner system used in our home to control the room temperature to
a specified limit is a typical example for embedded system for control
purpose. The air conditioner’s compressor unit (actuator) is controlled
according to the current room temperature (sensor) and the desired room
temperature set by the user.
22
» Purpose of Embedded Systems:
» Application Specific User Interface
These are embedded systems with application-specific user interfaces like
buttons, switches, keypad, lights, bells, display units, etc.
Mobile phone is an example for this.
In mobile phone, the user interface is provided through the keypad,
graphic LCD module, system speaker, vibration alert, etc.
23
THE TYPICAL EMBEDDED SYSTEM
» A typical embedded system (shown in the following Figure) contains a single
chip controller, which acts as the master brain of the system.
24
The controller can be
• a Microprocessor (Intel 8085) or
Key boards, push button switches, etc. are examples for common user interface input devices
LEDs, liquid crystal displays, piezoelectric buzzers, etc. are examples for common user interface output devices
25
CORE OF THE EMBEDDED SYSTEM
» Embedded systems are domain and application specific and are built around a
central core. The core of the embedded system falls into any one of the
following categories:
26
» General Purpose and Domain Specific Processors:
» Almost 80% of the embedded systems are processor/ controller based. The
processor may be a microprocessor or a microcontroller or a digital signal
processor, depending on the domain and application.
» The CPU contains the Arithmetic and Logic Unit (ALU), control unit and
working registers.
27
» Intel claims the credit for developing the first microprocessor unit, Intel 4004, a
4-bit processor which was released in November 1971 – designed for older
day’s calculators.
» In April 1974, Intel launched the first 8-bit processor, the Intel 8080, with 16-
bit address bus and program counter and seven 8-bit registers.
» Intel 8080 was the most commonly used processors for industrial control and
other embedded applications in the 1975s.
» Immediately after the release of Intel 8080, Motorola also entered the market
with their processor, Motorola 6800 with a different architecture and
instruction set compared to 8080.
» In 1976 Intel came up with the upgraded version of 8080 – Intel 8085, with
two newly added instructions, three interrupt pins and serial I/0.
» Clock generator and bus controller circuits were built-in.
28
» In July 1976 Zilog entered the microprocessor market with its Z80 processor as
competitor to Intel.
» Intel still leads the market with cutting edge technologies in the processor
industry.
29
» Microcontrollers: A Microcontroller is a highly integrated chip that contains a
CPU, scratch pad RAM, special and general purpose register arrays, on chip
ROM/ FLASH memory for program storage, timer and interrupt control units
and dedicated I/O ports.
» they are cheap, cost effective and are readily available in the market.
30
» Texas Instrument's TMS 1000 (1974) is considered
as the world's first microcontroller.
» TI followed Intel's 4004, 4-bit processor design and added some amount of
RAM, program storage memory (ROM) and 1/O support on a single chip.
» Intel came out with its most fruitful design in the 8-bit microcontroller domain-
the 8051 family and its derivatives.
» 8051 is the most popular and powerful 8-bit microcontroller ever built.
» Developed in the 1980s and was put under the family MCS-51.
» Almost 75% of the microcontrollers used in the embedded domain were 8051
family based controllers during the 1980-90s.
31
» 8051 processor cores are used in more than 100 devices by more than 20
independent manufacturers like Maxim, Philips, Atmel, etc. under the license
from Intel.
» Due to the low cost, wide availability, memory efficient instruction set, mature
development tools and Boolean processing (bit manipulation operation)
capability
32
» Microprocessors versus Microcontrollers
Microprocessors Microcontrollers
Microprocessors generally does not have RAM, ROM and Microcontroller is ‘all in one’ processor, with RAM, I/O
I/O pins. ports, all on the chip.
Microprocessors, generally do not have power saving Microcontrollers have power saving system, like idle mode
system. or power saving; mode so overall it uses less power.
The overall cost of systems made with Microprocessors is Microcontrollers are made by using complementary metal
high, because of the high number of external components oxide semiconductor technology; so they are far cheaper
required. than Microprocessors.
Processing speed of general microprocessors is above 1 Processing speed of Microcontrollers is about 8 MHz to 50
GHz; so it works much faster than Microcontrollers. MHz.
» the speed of execution depends primarily on the clock for the processors.
» Data Memory: Working memory for storing temporary variables and data/
signal to be processed.
» Incorporates multiple hardware shifters for shifting operands and thereby saves
execution time.
» I/O Unit: Acts as an interface between the outside world and DSP.
35
» Audio video signal processing, telecommunication and multimedia applications
are typical examples where DSP is employed.
36
» RISC versus CISC Processors/ Controllers: The term RlSC stands for
Reduced Instruction Set Computing.
» Here, the instruction set is complex and instructions are high in number.
37
» Atmel AVR microcontroller is an example for a RISC processor and its
instruction set contains only 32 instructions.
» There are some other factors like pipelining features, instruction set type,
etc., for determining the RISC/ CISC criteria.
38
» CISC versus RISC
CISC RISC
1. Complex instructions, taking multiple clock 1. Simple instructions, taking single clock
4. Variable format instructions, single register 4. Fixed format instructions, multiple register
set and many instructions sets and few instructions
40
» Microprocessors/ Controllers based on the Harvardarchitecture
will have separate data bus and instruction bus.
» This allows the data transfer and program fetching to occur simultaneously on
both buses.
» The data memory can be read and written while program memory is being
accessed.
» These separated data memory and code memory buses allow one instruction
to
execute while the next instruction is fetched ("pre-fetching").
41
» Harvard versus Von-Neumann Processor/ Controller Architecture
» Endianness specifies the order in which the data is stored in the memory by
processor operations in a multi-byte system (Processors whose word size is
greater than one byte).
» Suppose the word length is two byte; then data can be stored in memory in two
different ways:
» Higher order of data byte at the higher memory and lower order of data byte at
location just below the higher memory – Little-Endian. E.g.: a 4 byte long integer
Byte3 Byte2 Byte1 Byte0 will be stored in the memory as follows:
43
» Big-Endian versus Little-Endian Processors/ Controllers:
» Little-Endian. E.g.: a 4 byte long integer Byte3 Byte2 Byte1 Byte0 will be stored in
the memory as follows:
» Lower order of data byte at the higher memory and higher order of data byte at
location just below the higher memory – Big-Endian. E.g.: a 4 byte long integer
Byte3 Byte2 Byte1 Byte0 will be stored in the memory as follows:
44
» Load Store Operation and Instruction Pipelining:
» The memory access related operations are performed by the special instructions
load and store.
45
» Load Store Operation and Instruction Pipelining:
» Suppose x, y and z are memory locations and we want to add the contents of
x
and y and store the result in location z.
» Under the load store architecture the same is achieved with 4 instructions
as
shown in following Figure.
46
» The conventional instruction execution by the processor follows the fetch-
decode-execute sequence; where
» 'fetch' part fetches the instruction from program memory or code memory,
» ‘decode’ part decodes the instruction to generate the necessary control signals
» ‘execute’ stage reads the operands, perform ALU operations and stores the
result.
» In case of jump or branch instruction, the new location is known only after
completion of the jump or branch instruction.
47
» Depending on the stages involved in an instruction (fetch, read register and
decode, execute instruction, access an operand in data memory, write back the
result to register, etc.), there can be multiple levels of instruction pipelining.
» The following Figure illustrates the concept of Instruction pipelining for single
stage pipelining.
48
» Application Specific Integrated Circuits (ASICs):
» Application Specific Integrated Circuit is a microchip designed to perform a
specific or unique application.
» Integrates several functions into a single chip and there by reduces the system
development cost.
» As a single chip, ASIC consumes a very small area in the total system.
49
» ASIC based systems are profitable only for large volume commercial
productions.
50
» If Non-Recurring Engineering Charges (NRE) is borne by a third party and the
Application Specific Integrated Circuit (ASIC) is made openly available in the
market, the ASIC is .referred as Application Specific Standard Product
(ASSP).
ASICs ASSPs
1. If third party is ready to pay NRE
1. Microchip designed to cost
perform specific application and ASIC is made available into the
market, the ASIC referred as ASSP
1. Most of the ASICs are
1. Openly available in the market
proprietary product
51
» General Purpose Processor (GPP) versus Application-Specific Instruction
Set Processor (ASIP):
» GPP contains an Arithmetic and Logic Unit (ALU) and Control Unit (CU).
» Fixed
» programmable.
» PLDs offer customers much more flexibility during the design cycle
» because design iterations are simply a matter of changing the programming file, and
results of design changes can be seen immediately in working parts.
» PLDs do not require customers to pay for large NRE costs and purchase
expensive mask sets
» PLD suppliers incur those costs when they design their programmable devices.
» PLDs allow customers to order just the number of parts they need, when they
need them, allowing them to control inventory.
» FPGAs offer the highest amount of logic density, the most features, and the
highest performance.
55
» CPLD versus FPGA
CPLDs FPGAs
1. Logic blocks are used for construction of
1. PLD is used for construction of CPLD
FPGA
3. FPGA is better than ASIC when building 3. Cost of ASIC is low only when it
is
low volume production circuits
produced in large qualtity
4. Once created, ASIC can no longer
4. FPGA is alterable be
Altered
5. FPGAs are useful for research and
5. ASICs are not suitable for research and
de3velopment activities. Prototype
development purpose, as they are
fabrication using FPGA is affordable and
» Commercial Off-the-Shelf Components
(COTS):
» A COTS product is one which is used 'asis'.
» COTS products are designed in such a way to provide easy integration and
interoperability with existing system components.
58
» Major
Advantage:
» COTS are cheap
» Developer can cut down his/ her development time to a great extent.
» which reduces the time to market your embedded systems.
» Examples:
» The TCPIIP plug-in module available from various manufactures like 'WIZnet', 'Freescale',
'Dynalog', etc are very good examples of COTS product (see Figure).
59
MEMORY
» Memory is an important part of a processor/ controller based embedded
systems.
» Some of the processors/ controllers contain built in memory and this memory
is referred as on-chip memory.
» Others do not contain any memory inside the chip and requires external
memory to be connected with the controller/processor to store the control
algorithm. It is called off-chip memory.
» Also some working memory is required for holding data temporarily during
certain operations.
60
» Program Storage Memory (ROM):
» The code memory retains its contents even after the power to it is turned off.
It
is generally known as non-volatile storage memory.
61
1. Masked Memory (MROM): A one-time programmable device, Uses
hardwired technology for storing data, Factory programmed by masking and
metallization process at the time of production.
» Advantage: Low cost for high volume production, Least expensive type of solid
state memory.
» Different mechanisms are used for the masking process of the ROM, like
62
» Applications: Masked ROM is a good candidate for storing the embedded
firmware for low cost embedded devices.
» Once the design is proven and the firmware requirements are tested and frozen,
the binary data (The firmware cross compiled/ assembled to target processor
specific machine code) corresponding to it can be given to the MROM
fabricator.
» Limitations: with MROM based firmware storage is the inability to modify the
device firmware against firmware upgrades.
» Since the MROM is permanent in bit storage, it is not possible to alter the bit
information.
63
2. Programmable Read Only Memory (PROM)/ One Time Programmable
Memory (OTP): Not pre-programmed by the manufacturer, End user is
responsible for programming .
» Fuses which are not blown/ burned, represents logic "1"; whereas fuses which
are blown/ burned represents a logic "0". The default state is logic "1".
64
» Applications: OTP is widely used for commercial production of embedded
systems whose proto-typed versions are proven and the code is finalized.
» Limitations: OTPs are not useful and worth for development purpose. During
the development phase, the code is subject to continuous changes and using an
OTP each time to load the code is not economical.
65
3. Erasable Programmable Read Only Memory (EPROM): EPROM gives
the flexibility to reprogram the same chip.
» EPROM stores the bit information by charging the floating gate of an FET.
» EPROM contains a quartz crystal window for erasing the stored information. If
the window is exposed to ultraviolet rays for a fixed duration, the entire
memory will be erased.
66
4. Electrically Erasable Programmable Read Only Memory (EEPROM): The
information contained in the EEPROM memory can be altered by using
electrical signals at the register/Byte level.
» These chips include a chip erase mode; and in this mode, they can be erased in
a few milliseconds.
67
5. FLASH: FLASH is the latest ROM technology and is the most popular
ROM
technology used in today's embedded designs.
69
» Read-Write Memory/ Random Access memory (RAM):
» RAM is volatile, meaning when the power is turned off, all the contents are
destroyed.
» RAM is a direct access memory, meaning we can access the desired memory
location directly without the need for traversing through the entire memory
locations to reach the desired memory position (i.e. random access of memory
location).
» This is in contrast to the Sequential Access Memory (SAM), where the desired
memory location is accessed by either traversing through the entire memory or
through a 'seek' method.
70
» RAM generally falls into three categories: Static
RAM (SRAM), dynamic RAM (DRAM) and non-volatile
RAM (NVRAM).
71
1. Static RAM (SRAM): Static RAM stores data in the form of voltage.
» Made up of flip-flops
» Four of the transistors are used for building the latch (flip-flop) part of the
memory cell and
72
» In simplest representation an SRAM cell can be visualized as shown in the
following Figure:
73
» This implementation in its
simpler form can
visualized be as
coupled two-cross
read/ inverters
write
control through with
» The four transistors in the
transistors.
middle form the cross-
coupled inverters.
» To write a value, apply the desired value to the bit control lines (For writing
1, make B = 1 and B\ =0; For writing 0, make B = 0 and B\ =1) and assert
the Word Line (Make Word line high).
» For reading the content of the memory cell, assert both B and B\ bit lines to
1 and set the Word line to 1.
» Limitations: SRAM are low capacity and high cost. Since a minimum of six
transistors are required to build a single memory cell, imagine how many
memory cells we can fabricate on a silicon wafer.
75
2. Dynamic RAM (DRAM): Stores data in the form of charge.
» Advantages: of DRAM are its high density and low cost compared to SRAM.
» Disadvantage: since the information is stored as charge it gets leaked off with
time; and to prevent this, they need to be refreshed periodically.
76
» The following Figure illustrates the typical implementation of a DRAM
cell.
» The MOSFET acts as the gate for the incoming and outgoing data,
whereas
the capacitor acts as the bit storage unit.
77
SRAM Cell DRAM Cell
1. Made up of 6 CMOS transistors 1. Made up of a MOSFET and
a
(MOSFET)
Capacitor
1. Doesn’t require refreshing 1. Requires refreshing
1. More expensive 1. Less expensive
1. Slow in operation due to refresh
1. Fast in operation, typical access requirement, typical access time
time is 10 ns is 60 ns; write operation is faster
than read operation
78
3. Non-volatile RAM is a random access memory with
NVRAM: battery
backup.
» It contains static RAM based memory and a minute battery for
providing supply to the memory in the absence of external power supply.
79
» Memory According to the Type of Interface:
» a parallel interface (the parallel data lines (DO-D7) for an 8 bit processor/
controller will be connected to DO-D7 of the memory) [memory density is
expressed in terms of kilobytes] or
» a SPI (Serial Peripheral Interface, 2+n line interface where n stands for the
total number of SPI bus devices in the system)
» Why both RAM and ROM are needed for holding the same data?
» The answer is: RAM is volatile and it cannot hold the configuration data which
is copied from the BIOS when the power supply is switched off.
» But for high system performance, it should be accessed from a RAM instead of
accessing from a ROM.
82
» Memory Selection for Embedded Systems:
» data memory for holding variables and temporary data during task
execution,
and
» memory for holding non•volatile data (like configuration data, look up table,
etc.) which are modifiable by the application.
» As a rule of thumb,
84
» Example: A simple electronic toy design:
» As the complexity of requirements are less and data memory requirement are
minimal
» » There
a few bytes
is no needoffor
EEPROM
externa1(if required)
memory for designing the system.
at all.
85
» Example: Embedded design based on an RTOS
» RTOS requires certain amount of RAM for its execution and ROM for storing
the RTOS image.
» Binary code for RTOS kernel containing all the services is stored in a non-
volatile memory (like FLASH) as either compressed or non-compressed
data.
» During boot-up of the device, the RTOS files are copied from the program
storage memory, decompressed if required and then loaded to the RAM for
execution.
» The supplier of the RTOS usually gives a rough estimate on the run time
RAM requirements and program memory requirements for the RTOS.
86
» On a safer side, always add a buffer value to the total estimated RAM and
ROM size requirements.
» Suppose 64MB RAM and 128MB ROM are the minimum requirements for
running the Windows mobile device;
» indeed you need extra RAM and ROM for running user applications.
» So while building the system, count the memory for that also and arrive at a
value which is always at the safer side, so that you won't end up in a situation
where you don't have sufficient memory to install and run user applications.
87
» There are two parameters for representing a memory (Size of the memory chip
& Word size of the memory) –
Size of the memory chip: Memory chips come in standard sizes, like
512bytes, 1024bytes (1 kilobyte), 2048bytes (2 kilobytes), 4Kb, 8Kb, 16Kb,
32Kb, 64Kb, 128Kb, 256Kb, 512Kb, 1024Kb (1 megabytes), etc.
Suppose your embedded application requires only 750 bytes of RAM,
you don't have the option of getting a memory chip with size 750 bytes;
the only option left with is to choose the memory chip with a size closer
to the size needed. Hence, 1024 bytes is the least possible option.
A processor/ controller with 16-bit address bus can addressed 216 =
65536 bytes = 64Kb. Hence, it is meaningless to select a 128Kb memory
chip for a processor with 16-bit wide address bus.
88
» There are two parameters for representing a memory (Size of the memory chip
& Word size of the memory) –
Word size of the memory: The word size refers to the number of memory
bits that can be read/write together at a time. 4, 8, 12, 16, 24, 32 etc., are the
word sizes supported by memory chips. Ensure that the word size supported
by the memory chip matches with the data bus width of the processor/
controller.
» FLASH memory is the popular choice for ROM (program storage memory) in
embedded applications. It is a powerful and cost-effective solid-state storage
technology for mobile electronics devices and other consumer applications.
» The EEPROM data storage memory is available as either serial interface or parallel
interface chip. If the processor/ controller of the device supports serial interface and the
amount of data to write and read to and from the device is less, it is better to have a
serial EEPR0M chip.
SENSORS AND ACTUATORS
» An embedded system is in constant interaction with the Real world, and the
controlling/ monitoring functions, executed by the embedded system is
achieved in accordance with the changes happening to the Real world. The
changes in system environment or variables are detected by the sensors
connected to the input port of the embedded system.
» A sensor is a transducer device that converts energy from one form to another,
for any measurement or control purpose.
Sensor which counts steps for pedometer functionality is an
Accelerometer sensor.
Sensor used in smart watch devices to measure the high intensity is an
Ambient Light Sensor (ALS).
90
» If the embedded system is designed for any controlling purpose, the system will
produce some changes in the controlling variable to bring the controlled
variable to the desired value. It is achieved through an actuator connected to
the output port of the embedded system.
91
» If the embedded system is designed for monitoring purpose only, then there is
no need for including an actuator in the system.
» For example, take the case of an ECG machine. It is designed to monitor the heart beat
status of a patient and it cannot impose a control over the patient's heart beat and its
order. The sensors used here are the different electrode sets connected to the body of the
patient. The variations are captured and presented to the user (may be a doctor) through
a visual display or some printed chart.
Sensors Actuators
1. Sensor is an input device 1. Actuator is an output device
2. Convert a physical parameter to 2. Convert an electrical signal to a physical
an
Output
electrical output
3. A device that detects events or changes in 3. A component of a machine that
is
the environment and send the information
responsible for moving and controlling
to another electronic device
mechanisms
4. Sensor help to monitor the changes in the 4. Actuator helps to control the environment
» The I/O Subsystem:
» The I/O subsystem of the embedded system facilitates the interaction of the
embedded system with the external world. As mentioned earlier the interaction
happens through the sensors and actuators connected to the input and output
ports respectively of the embedded system.
» Light Emitting Diode (LED): LED is an important output device for visual
indication in any embedded system. LED can be used as an indicator for the
status of various signals or situations.
» Typical examples are indicating the presence of power conditions like 'Device
ON', 'Battery Low' or 'Charging of Battery' for a battery operated handheld
embedded devices.
» Light Emitting Diode is a p-n junction diode and it contains an anode and a
cathode. For proper functioning of the LED, the anode of it should be
connected to +ve terminal of the supply voltage and cathode to the –ve
terminal of supply voltage. A resister is used in series between the power
supply and the LED to limit the current through the LED.
» Out of the 8 LED segments, 7 are used for displaying alpha-numeric characters
and 1 is used for representing ‘decimal point'.
» circuit isolation,
» The different stepping modes supported by stepper motor are explained below:
» When a voltage is applied to the relay coil, current flows through the coil,
which in turn generates a magnetic field. The magnetic field attracts the
armature core and moves the contact point. The movement of the contact
point changes the power/ signal flow path.
» The Single Pole Single Throw configuration has only one path for
information
flow. The path is either open or dosed in normal condition.
» For normally open Single Pole Single Throw relay, the circuit is
normally
open and it becomes closed when the relay is energized.
» For normally closed Single Pole Single Throw configuration, the circuit is
normally closed and it becomes open when the relay is energized.
» 10
5
» The Relay is controlled using a relay driver circuit connected to the port pin of
the processor/ controller. A transistor is used for building the relay driver
circuit.
» Piezoelectric buzzers are available in two types. 'Self• driving' and 'External
driving'.
» A piezo buzzer can be directly interfaced to the port pin of the processor/
control. Depending on the driving current requirements, the piezo buzzer can
also be interfaced using a transistor based driver circuit as in the case of a
» Push Button Switch: Push button switch is an input device. Push button switch
comes in two configurations, namely 'Push to Make' and 'Push to Break'.
» In the 'Push to Make' configuration, the switch is in the open state and it makes a
circuit contact when it is pushed or pressed.
» In the 'Push to Break' configuration, the switch is in the closed state and it
breaks the circuit contact when it is pushed or pressed.
» The push button stays in the 'closed' (for Push to Make type) or 'open' (For Push
to Break type) state.
» Depending on the way in which the push button interfaced to the controller, it
» Push button is used for generating a momentary pulse.
» In embedded application push button is generally used as reset and start switch
and pulse generator. The Push button is normally connected to the port pin of
the host processor/ controller.
» Depending on the way in which the push button interfaced to the controller, it
can generate either a 'HIGH' pulse or a 'LOW' pulse.
» The following Figure Illustrates how the push button can be used for generating
'LOW' and 'HIGH' pulses.
» Keyboard: Keyboard is an input device 'HIGH'
Pulse generator for user interfacing.
» If the number of keys required is very limited, push button switches can be
used and they can be directly interfaced to the port pins for reading.
However, there may be situations demanding a large number of keys for user
input (e.g. PDA device with alpha-numeric keypad for user data entry).
In such situations it may not be possible to interface each keys to a port pin
due to the limitation in the number of general purpose port pins available
for the processor/ controller in use and moreover it is wastage of port pins.
Matrix keyboard is an optimum solution for handling large key requirement.
It greatly reduces the number of interface connections.
» For example, for interfacing 16 keys, in the direct interfacing technique, 16 port
pins are required, whereas in the matrix keyboard only 8 lines are required.
» The 16 keys are arranged in a 4 column x 4 Row matrix. The following Figure
illustrates the connection o keys in a matrix keyboard.
» In a matrix keyboard, the keys are arranged in matrix fashion. For detecting a
key press, the keyboard uses the scanning technique, where each row of the
matrix is pulled low and the columns are read. After reading the status of each
columns corresponding to a row, the row is pulled high and the next row is
pulled low and the status of the columns are read.
» This process is repeated until the scanning for all rows are completed. When a
row is pulled low and if a key connected to the row is pressed, reading the
column to which the key is connected will give logic 0. Since keys are
mechanical devices, proper key de-bouncing technique should be applied.
» Programmable Interface (PPI): Programmable Peripheral
Peripheral
Interface devices are used for extending the I/O capabilities of processors/
controllers.
» Most of the processors/ controllers provide very limited number of I/O and data
ports.
» 8255A supports 24 I/O pins, and these I/O pins can be grouped as either three 8-
bit parallel ports (Port A, Port B and Port C) or two 8-bit parallel ports (Port A
and Port B) with Port C in any one of the following configurations:
» (2) Two 4-bit ports; namely Port CUPPER (Cu) and Port CLOWER (CL).
» This is configured by manipulating the control register of 8255A. The control
register holds the configuration for Port A, Port B and Port C.
» Some embedded systems are self-contained units and they don't require
any
interaction and data transfer with other sub-systems or external world.
» a wired medium – Infrared (IR), Bluetooth (BT), Wireless LAN (Wi-Fi), Radio
Frequency waves (RF), GPRS/ 3G/ 4GLTE, etc.
» a wireless media – RS-232C/ RS-422/ RS-485, USB, Ethernet IEEE 1394 port,
Parallel port, CF-II interface, SDIO, PCMCIA/ PCIex, etc.
» Onboard Communication Interfaces:
» 1-Wire Interface
» Parallel Interface
» Inter Integrated Circuit (I2C) Bus: The Inter Integrated Circuit Bus (I2C-
Pronounced 'I square C') is a synchronous bidirectional half duplex (one-
directional communication at a given point of time) two wire serial interface
bus.
» The concept of I2C bus was developed by 'Philips Semiconductors' in the early
1980s. The original intention of I2C was to provide an easy way of connection
between a microprocessor/ microcontroller system and the peripheral chips in
television sets.
» The I2C bus comprise of two bus lines, namely; Serial Clock-SCL and Serial
Data-SDA.
SCL line is responsible for generating synchronization clock pulses.
SDA is responsible for transmitting the serial data across devices.
» I2C bus is a shared bus system to which many number of I2C devices can be
connected.
» Devices connected to the I2C bus can act as either 'Master' device or 'Slave'
device.
The 'Master' device is responsible for controlling the communication by
initiating/ terminating data transfer, sending data and generating necessary
synchronization clock pulses.
'Slave' devices wait for the commands from the master and respond upon
receiving the commands.
» 'Master' and 'Slave' devices can act as either transmitter or receiver; regardless
whether a master is acting as transmitter or receiver, the synchronization clock
signal is generated by the 'Master' device only.
I2C supports multi-masters on the same bus.
»
1. The master device pulls the clock line (SCL) of the bus to 'HIGH ‘
2. The master device pulls the data line (SDA) 'LOW', when the SCL line is at
logic 'HIGH' (This is the 'Start' condition for data transfer)
3. The master device sends the address (7-bit or 10-bit wide) of the 'slave' device
to which it wants to communicate, over the SDA line. Clock pulses are
generated at the SCL line for synchronizing the bit reception by the slave
device. The MSB of the data is always transmitted first. The data in the bus is
valid during the 'HIGH' period of the clock signal
4. The master device sends the Read or Write bit (Bit value = 1 Read operation;
Bit value = 0 Write operation) according to the requirement
5. The master device waits for the acknowledgement bit from the slave device
6. The slave device with the address requested by the master device responds by
sending an acknowledge bit (Bit value = 1) over the SDA line
7. Upon receiving the acknowledge bit, the master device sends the 8-bit data to
the slave device over SDA line, if the requested operation is 'Write to device'.
If the requested operation is 'Read from device', the slave device sends data to
the master over the SDA line
8. The master device waits for the acknowledgement bit from the device upon
byte transfer complete for a write operation and sends an acknowledge bit to
the Slave device for a read operation
9. The master device terminates the transfer by pulling the SDA line ‘HIGH'
when the clock line SCL is at logic 'HIGH' (Indicating the 'STOP' condition).
» Serial Peripheral Interface (SPI): Serial Peripheral Interface Bus (SPI) is
asynchronous bi-directional full duplex four-wire serial interface bus. The
concept of SPI was introduced by Motorola.
» Master In Slave Out (MISO): Signal line carrying the data from slave to
master
device. It is also known as Slave Output (SO/ SDO).
» Slave Select (SS): Signal line for slave device select. It is an active low signal.
» The bus interface diagram is shown in the following Figure, illustrates the
connection of master and slave devices on the SPI bus.
» The master device is responsible for generating the clock signal. It selects the required
slave device by asserting the corresponding slave device's slave select signal 'LOW'.
The data out line (MISO) of all the slave devices when not selected floats at high
impedance state.
» SPI works on the principle of 'Shift Register'. The master and slave devices contain a
special shift register for the data to transmit or receive. The size of the shift register is
device dependent. Normally it is a multiple of 8.
» During transmission from the master to slave, the data in the master's shift register is
shifted out to the MOSI pin and it enters the shift register of the slave device through
the MOSI pin of the slave device. At the same time, the shifted out data bit from the
slave device's shift register enters the shift register of the master device through MISO
pin. In summary, the shift registers of 'master' and 'slave' devices form a circular buffer.
» When compared to I2C, SPI bus is most suitable for applications requiring transfer of
data in 'streams'. The only limitation is SPI doesn’t support an acknowledgement
mechanism.
» Universal Asynchronous Receiver Transmitter (UART): Universal
Asynchronous Receiver Transmitter (UART) based data transmission is an
asynchronous form of serial data transmission.
» The serial communication settings (Baud rate, number of bits per byte, parity,
number of start bits and stop bit and flow control) for both transmitter and
receiver should be set as identical.
» The start and stop of communication is indicated through inserting special bits
in the data stream.
» While sending a byte of data, a start bit is added first and a stop bit is added at
the end of the bit stream. The least significant bit of the data byte follows the
'start' bit.
» The 'start' bit informs the receiver that a data byte is about to arrive. The
receiver device starts polling its 'receive line' as per the baud rate settings.
» If the baud rate is 'x' bits per second, the time slot available for one bit is 1/x
seconds.
» The receiver unit polls the receiver line at exactly half of the time slot available
for the bit.
» If parity is enabled for communication, the UART of the transmitting device
adds a parity bit (bit value is 1 for odd number of 1s in the transmitted bit
stream and 0 for even number of 1s). .
» The UART of the receiving device calculates the parity of the bits received and
compares it with the received parity bit for error checking.
» The UART of the receiving device discards the 'Start', 'Stop' and 'Parity' bit
from the received bit stream and converts the received serial bit data to a word.
» For proper communication, the 'Transmit line' of the sending device should be
connected to the 'Receive line' of the receiving device.
» The following Figure illustrates the same.
» One of the key feature of 1-wire bus is that it allows power to be sent along the
signal wire as well.
» The 1-wire slave devices incorporate internal capacitor (typically of the order of
800 pF) to power the device from the signal line.
» The 1-wire interface supports a single master and one or more slave devices on
the bus.
» The bus interface diagram shown in the following Figure illustrates the
connection of master and slave devices on the 1-wire bus.
2. The slave device(s) present on the bus respond with a 'Presence' pulse.
3. The master device sends a ROM command (Net Address Command followed by the
64-bit address of the device). This addresses the slave device(s) to which it wants to
initiate a communication.
4. The master device sends a read/ write function command to read/ write the internal
memory or register of the slave device.
5. The master initiates a Read data/ Write data from the device or to the device.
» The host processor/ controller of the embedded system contains a parallel bus
and the device which supports parallel bus can directly connect to this bus
system.
» The communication through the parallel bus is controlled by the control signal
interface between the device and the host.
» The 'Control Signals' for communication includes 'Read/ Write' signal and
device select signal.
» The device normally contains a device select line and the device becomes
active only when this line is asserted by the host processor.
» The direction of data transfer (Host to Device or Device to Host) can be
controlled through the control signal lines for 'Read' and 'Write'. Only the host
processor has control over the 'Read' and 'Write' control signals.
» The device is memory mapped to the host processor and a range of address is
assigned to it. An address decoder circuit is used for generating the chip select
signal for the device.
» The processor then can read or write from or to the device by asserting the
corresponding control line (RD\ and WR\ respectively). Strict timing
characteristics are followed for parallel communication.
» Parallel data communication offers the highest speed for data transfer.
» The bus interface diagram shown in the following Figure, illustrates the
interfacing of devices through parallel interface.
» External Communication
Interfaces:
» The External Communication Interface refers to the different communication
channels/ buses used by the embedded system to communicate with the
external world.
» RS-232 C & RS-485
» Infrared (IrDA)
» Bluetooth (BT)
» Wi-Fi
» ZigBee
» UART uses the standard TTL/ CMOS logic (Logic 'High' corresponds to bit
value 1 and Logic 'Low' corresponds to bit value 0) for bit transmission;
whereas RS-232 follows the EIA standard for bit transmission.
As per the EIA standard, a logic '0' is represented with voltage between +3
and +25V and a logic' 1' is represented with voltage between -3 and -25V.
In EIA standard, logic '0' is known as 'Space' and logic '1' as 'Mark'.
The RS-232 interface defines various handshaking and control signals for
communication apart from the 'Transmit' and. 'Receive' signal lines for data
» The RS-232 interface defines various handshaking and control signals for
communication apart from the 'Transmit' and. 'Receive' signal lines for data
communication.
» The following Figure illustrates the connector details for DB-9 and DB-25.
» RS-232 is a point-to-point communication interface and the device involved in
RS-232 communication are called 'Data Terminal Equipment (DTE)' and 'Data
Communication Equipment (DCE)'.
» The Data Terminal Ready (DTR) signal is activated by DTE when it is ready to
accept data. The Data Set Ready (DSR) is activated by DCE when it is ready
for establishing a communication link. DTR should be in the activated state
before the activation of DSR.
» The Data Carrier Detect (DCD) control signal is used by the DCE to indicate the
DTE that a good signal is being received.
» RS-232 supports only point-to-point communication and not suitable for multi-
drop communication.
• It uses single ended data transfer technique for signal transmission and thereby
more susceptible to noise and it greatly reduces the operating distance.
» RS-422 is another serial interface standard from EIA for differential data
communication. It supports data rates up to l00Kbps and distance up to 400 ft.
» The first version of USB (USB 1.0) was released in 1995 and was
created by the USB core group members consisting of Intel,
Microsoft, IBM, Compaq, Digital and Northern Telecom.
» The physical connection between a USB peripheral device and master device is
established with a USB cable. The USB cable in USB 2.0 supports
communication distance of up to 5 meters.
» The USB 2.0 standard uses two different types of connector at the ends of the
USB cable for connecting the USB peripheral device and host device.
'Type A' connector is used for upstream connection (connection with host) and Type
B connector is used for downstream connection (connection with slave device).
The USB connector present in desktop PCs or laptops are examples for 'Type A'
USB connector.
» USB uses differential signals for data transmission. It improves the noise
immunity.
» USB interface has the ability to supply power to the connecting devices. Two
connection lines (Ground and Power) of the USB interface are dedicated for
carrying power. It can supply power up to 500 rnA at 5 V.
» USB supports four different types of data transfers, namely; Control, Bulk,
Isochronous and Interrupt.
» Control transfer is used by USB system software to query, configure and issue
commands to the USB device.
» Bulk transfer is used for sending a block of data to a device. Bulk transfer
supports error checking and correction.
Transferring data to a printer is an example for bulk transfer.
» Interrupt transfer mechanism makes use of polling technique to see whether the
USB device has any data to send.
» The frequency of polling is determined by the USB device and it varies from
1
to 255 milliseconds.
Devices like Mouse and Keyboard, which transmits fewer amounts of data,
uses Interrupt transfer.
IEEE 1394 (Firewire): IEEE 1394 is a wired isochronous high speed serial
communication bus. It is also known as High Performance Serial Bus
(HPSB).
» The research on 1394 was started by Apple Inc. in 1985 and the standard for
this was coined by IEEE.
» There are two differential data transfer lines A and B per connector.
» The data- rate supported by 1394 is far higher than the one supported by
USB2.0 interface.
» IrDA is in use from the olden days of communication and you may be very
familiar with it.
The remote control of your TV, VCD player, etc., works on Infrared data
communication principle.
» Infrared Light Emitting Diode (LED) is the IR source for transmitter and at the
receiving end a photodiode acts as the receiver.
» Both transmitter and receiver unit will be present in each device supporting
IrDA communication for bidirectional data transfer. Such IR units are known
as 'Transceiver'.
» Bluetooth operates at 2.4GHz of the Radio Frequency spectrum and uses the
Frequency Hopping Spread Spectrum (FHSS) technique for communication.
» When a network is formed with one Bluetooth device as master and more than
one device as slaves, it is called a Piconet.
» Wi-Fi follows the IEEE 802.11 standard. Wi-Fi is intended for network
communication and supports Internet Protocol (IP) based communication. It is
essential to have device identities in a multi-point communication to address
specific devices for data communication.
» Wi-Fi operates at 2.4GHz or 5GHz of radio spectrum and they co-exist with
other ISM band devices like Bluetooth.
» ZigBee is targeted for low power, low data rate and secure applications for
Wireless Personal Area Networking (WPAN).
» ZigBee Router (ZR)/ Full Function Device (FFD): Responsible for passing
information from device to another device or to another ZR.
» ZigBee End Device (ZED)/ Reduced Function Device (RFD): End device
containing ZigBee functionality for data communication. It can talk only
with a ZR or ZC and doesn't have the capability to act as a mediator for
transferring data from one device to another.
» The following Figure gives an overview of ZC, ZED and ZR in a ZigBee
network:
» General Packet Radio Service (GPRS), 3G, 4G, LTE: General Packet Radio
Service is a communication technique for transferring data over a mobile
communication network like GSM.
» At the receiving end the data is re-constructed by combining the received data
packets.
» There are various methods available for developing the embedded firmware.
They are listed below:
1. Write the program in high level languages like Embedded C/ C++ using an
Integrated Development Environment (IDE)
» The IDE will contain a editor, compiler, linker, debugger, simulator, etc.
» IDEs are different for different family of processors/ controllers.
» For example, Keil microvision3 IDE is used for all family member of 8051
microcontroller, since it contains the generic 8051 compiler C51.
» The instruction set for each family of processor/ controller is different and the
program written in either of the methods given above should be converted into
a processor understandable machine code before loading it into the program
memory.
» The process of converting the program written in either a high level language or
processor/ controller specific Assembly code to machine readable binary code
is called 'HEX File Creation'.
» The methods used for 'HEX File Creation' is different depending on the
programming techniques used.
» Also third party tools are available, which may be of free of cost, for this
conversion.
» For a beginner in the embedded software field, it is strongly recommended to
use the high level language based development technique. The reasons for this
being:
» Writing codes in a high level language is easy, the code written in high level
language is highly portable which means you can use the same code to run
on different processor/ controller with little or less modification. The only
thing you need to do is re-compile the program with the required processor's
IDE, after replacing the include files for that particular processor.
» Also the programs written in high level languages are not developer
dependent. Any skilled programmer can trace out the functionalities of the
program by just having a look at the program. It will be much easier if the
source code contains necessary comments and documentation lines. It is
very easy to debug and the overall system development time will
be
reduced to a greater extent. 168
» The embedded software development process in assembly language is tedious
and time consuming.
• The developer needs to know about all the instruction sets of the processor/
controller or at least s/he should carry an instruction set reference manual with
her/ him. A programmer using assembly language technique writes the
program according to his/ her view and taste. Often he/ she may be writing a
method or functionality which can be achieved through a single instruction as
an experienced person's point of view, by two or three instructions in his/ her
own style. So the program will be highly dependent on the developer. It is
very difficult for a second person to understand the code written in Assembly
even if it is well documented.
OTHER SYSTEM COMPONENTS
» The other system components refer to the components/ circuits/ ICs
which
are necessary for the proper functioning of the embedded system.
» Some of these circuits may be essential for the proper functioning of the
processor/ controller and firmware execution.
» The reset signal brings the internal registers and the different hardware systems
of the processor/ controller to a known state and starts the firmware execution
from the reset vector (Normally from vector address 0x0000 for conventional
processors/ controllers.
» Since the processor operation is synchronized to a clock signal, the reset pulse
should be wide enough to give time for the clock oscillator to stabilize before
the internal reset state starts.
» The reset signal to the processor can be applied at power ON
through an external passive reset circuit comprising a Capacitor
and Resistor or through a standard Reset IC like MAX810 from
Maxim Dallas. Select the reset IC based on the type of reset
signal and logic level (CMOS/ TTL) supported by the processor/
controller in use.
» It is essential for battery powered devices since there are greater chances for the
battery voltage to drop below the required threshold. The processor behavior
may not be predictable if the supply voltage falls below the recommended
operating voltage. It may lead to situations like data corruption.
» Certain devices may not contain built-in oscillator unit and require the clock
pulses to be generated and supplied externally.
» The speed of operation of a processor is primarily dependent on the clock
frequency. However we cannot increase the clock frequency blindly for
increasing the speed of execution. The logical circuits lying inside the
processor always have an upper threshold value for the maximum clock at
which the system can run, beyond which the system becomes unstable and non
functional.
» The accuracy of program execution depends on the accuracy of the clock signal.
» The following Figure illustrates the usage of quartz crystal/ ceramic resonator
and external oscillator chip for clock generation.
» Real-Time Clock (RTC): Real-Time Clock is a system component responsible
for keeping track of time. RTC holds information like current time (In hours,
minutes and seconds) in 12-hour/ 24-hour format, date, month, year, day of the
week, etc. and supplies timing reference to the system.
» The RTC chip contains a microchip for holding the time and date related
information and backup battery cell for functioning in the absence of power, in
a single IC package. The RTC chip is interfaced to the processor or controller
of the embedded system.
» For Operating System based embedded devices, a timing reference is essential
for synchronizing the operations of the OS kernel.
» The RTC can interrupt the OS .kernel by asserting the interrupt line of the
processor/controller to which the RTC interrupt line is connected. The OS
kernel identifies the interrupt in terms of the Interrupt Request (IRQ) number
generated by an interrupt controller. One IRQ can be assigned to the RTC
interrupt and the kernel can perform necessary operations like system date time
updating, managing software timers etc when an RTC timer tick interrupt
occurs.
» We have a watchdog to monitor the firmware execution and reset the system
processor/ microcontroller when the program execution hangs up. A watchdog
timer, or simply a watchdog, is a hardware timer for monitoring the firmware
execution.
» If the firmware execution completes before the expiration of the watchdog, you
can reset the count by writing a 0 (for an up counting watchdog timer) to the
watchdog timer register.
» If the processor/ controller doesn't contain a built in watchdog timer, the same
can be implemented using an external watchdog timer IC circuit.
» The external watchdog timer uses hardware logic for enabling/ disabling,
resetting the watchdog count, etc., instead of the firmware based 'writing' to the
status and watchdog timer register.