18CS44 MES Module4
18CS44 MES Module4
18CS44 MES Module4
MICROCONTROLLER
AND EMBEDDED
SYSTEMS
MODULE 4
CHARACTERISTICS AND
QUALITY ATTRIBUTES
Dr. Mahesh Prasanna
K.
» No matter whether it is an embedded or a non-embedded system, there will
be a set of characteristics describing the system.
MP, CSE, 2
VCET
CHARACTERISTICS OF AN
EMBEDDED SYSTEM
» Embedded Systems possess certain specific characteristics and
these
characteristics are unique to each embedded system.
4. Distributed
6. Power concerns
MP, CSE, 3
VCET
» Application and Domain
Specific:
» Each embedded system is having certain functions to perform.
» Embedded systems are developed to do only intended functions.
For example, you cannot replace the embedded control unit of your
microwave oven with your air conditioners embedded control unit.
» Also you cannot replace an embedded control unit developed for a particular
domain say telecom with another control unit designed to serve another
domain like consumer electronics.
MP, CSE, 4
VCET
» Reactive and Real Time:
» Embedded systems are in constant interaction with the Real world through
sensors and user defined input devices which are connected to the input port
of the system.
Any changes happening in the Real world (which is called an Event) are
captured by the sensors or input devices in Real Time and the control
algorithm running inside the unit reacts in a designed manner to bring the
controlled output variables to the desired level.
MP, CSE, 5
VCET
» Real Time System operation means the timing behavior of the system should
be deterministic; meaning the system should respond to requests or tasks in a
know amount of time.
» A Real Time system should not miss any deadlines for tasks or operations.
» The design of an embedded Real Time system should take the worst case
scenario into consideration.
MP, CSE, 6
VCET
» Operates in Harsh Environment:
» Systems placed in such areas should be capable to withstand all these adverse
operating conditions.
» The design should take care of the operating conditions of the area where
the
system is going to implement.
For example, if the system needs to be deployed in a high temperature
zone, then all the components used in the system should be of high
temperature grade. MP, CSE, 7
VCET
» Here we cannot go for a compromise in cost. Also proper shock absorption
techniques should be provided to systems which are going to be
commissioned in places subject to high shock.
» Power supply fluctuations, corrosion and component aging, etc. are the other
factors that need to be taken into consideration for embedded systems to work
in harsh environments.
MP, CSE, 8
VCET
» Distributed:
» The term distributed means that, embedded systems may be a part of larger
systems.
MP, CSE, 9
VCET
Another example is the Automatic Teller Machine (ATM). An
ATM
contains a reader embedded unit, responsible for reading
card and
validating the user's AIM card, transaction unit for performing
transactions, a currency counter for dispatching/ vending currency to the
authorized person and a printer unit for printing the transaction details.
Another typical example of a distributed embedded system is the
Supervisory Control And Data Acquisition (SCADA) system used in
Control & Instrumentation applications, which contains physically
distributed individual embedded control units connected to a supervisory
module.
MP, CSE, 10
VCET
» Small Size and Weight:
» Most of the application demands small size and low weight products.
MP, CSE, 11
VCET
» Power Concerns:
» Nowadays ultra low power components are available in the market. Select the
design according to the low power components like low dropout regulators,
and controllers/ processors with power saving modes.
MP, CSE, 13
VCET
»The Operational Quality » The Non-Operational
Attributes Quality
represent the quality Attributes needs to be addressed for
relevant related the product 'not ' on-the basis
attributeswhen ittois in
system thethe operational
embedded of
operational aspects are
grouped
mode or 'online' mode.
under this category.
1. Response 1. Testability & debug-ability
2. Throughput 2. Evolvability
3. Reliability 3. Portability
6. Safety
MP, CSE, 14
VCET
» 1. Response: is a measure of quickness of the system. It gives an idea about
how fast your system is tracking the changes in input variables.
» Most of the embedded systems demand fast response which should be almost
Real Time.
For example, an embedded system deployed in flight control application
should respond in a Real Time manner. Any response delay in the system
will create potential damages to the safety of the flight as well as the
passengers.
» Mean Time Between Failures (MTBF) and Mean Time To Repair (MTTR)
are the terms used in defining system reliability.
MTBF gives the frequency of failures in hours/ weeks/ months.
MTTR specifies how long the system is allowed to be out of order
following a failure.
MP, CSE, 17
VCET
» 4. Maintainability: deals with support and maintenance to the end user or
client in case of technical issues and product failures or on the basis of a
routine system checkup.
» In any embedded system design, the ideal value for availability is expressed
as
MP, CSE, 20
VCET
» 5. Security: aspect covers ‘Confidentiality’, 'Integrity', and 'Availability' (The
term 'Availability' mentioned here is not related to the term 'Availability'
mentioned under the 'Maintainability' section).
» Integrity deals with the protection of data and application from unauthorized
modifications.
MP, CSE, 21
VCET
If it is a shared one, there should be some mechanism in the form of
user name and password to access into a particular person's profile – An
example of' Availability.
» Also all data and applications present in the PDA need not be accessible to all
users. Some of them are specifically accessible to administrators only. For
achieving this, Administrator and user levels of security should be
implemented – An example of Confidentiality.
» Some data present in the PDA may be visible to all users but there may not be
necessary permissions to alter the data by the users. That is Read Only access
is allocated to all users – An example of Integrity.
MP, CSE, 22
VCET
» 6. Safety: 'Safety' and 'Security' are confusing terms. Sometimes you may feel
both of them as a single attribute. But they represent two unique aspects in
quality attributes.
Safety deals with the possible damages that can happen to
the operators,
public and the environment;
due to
the breakdown of an embedded system,
the emission of radioactive or hazardous materials from the embedded
products.
MP, CSE, 23
VCET
» The breakdown of an embedded system may occur due to a hardware failure
or a firmware failure.
» Some of the safety threats are sudden (like product breakdown) and some of
them are gradual (like hazardous emissions from the product).
MP, CSE, 24
VCET
» 1. Testability & Debug-ability: deals with how easily one can test his/ her
design, application; and by which means he/ she can test it.
MP, CSE, 25
VCET
» Debug-ability has two aspects in the embedded system development context,
namely, hardware level debugging and firmware level debugging.
Hardware debugging is used for figuring out the issues created by
hardware problems whereas firmware debugging is employed to figure out
the probable errors that appear as a result of flaws in the firmware.
MP, CSE, 26
VCET
» 3. Portability: is a measure of 'system independence'.
MP, CSE, 27
VCET
» If the firmware is written in a high level language like 'C' with little target
processor-specific functions (operating system extensions or compiler
specific utilities), it is very easy to port the firmware for the new processor by
replacing those 'target processor-specific functions' with the ones for the new
target processor and re-compiling the program for the new target processor•
specific settings. Re-compiling the program or the new target processor
generates the new target processor-specific machine codes.
MP, CSE, 28
VCET
» If you look into various programming languages for application development
for desktop applications, you will see that certain applications developed on
certain languages run only on specific operating systems and some of them
run independent of the desktop operating systems.
MP, CSE, 29
VCET
» 4. Time to Prototype and Market: is the time elapsed between the
conceptualization of a product and the time at which the product is ready for
selling (for commercial product) or use (for non-commercial products).
MP, CSE, 30
VCET
» Also, embedded technology is one where rapid technology change is
happening. If you start your design by making use of a new technology and if
it takes long time to develop and market the product, by the time you market
the product, the technology might have superseded with a new technology.
MP, CSE, 32
VCET
» The Product Life Cycle (PLC): Every embedded product has a product
life
cycle which starts with the design and development phase.
» During the design and development phase there is only investment and
no
returns.
» Once the product is ready to sell, it is introduced to the market. This stage is
known as the Product Introduction stage.
» During the initial period the sales' and revenue will be low. There won't be
much competition and the product sales and revenue increases with time. In
the growth phase, the product grabs high market share.
MP, CSE,
VCET
33
» During the maturity phase, the growth and sales will be steady and the
revenue reaches its peak.
» The Product retirement/ Decline phase starts with the drop in sales volume;
market share and revenue. The decline happens due to various reasons like
competition from similar product with enhanced features or technology
changes, etc. At some point of the decline stage, the manufacturer announces
discontinuing of the product.
» The different stages of the embedded products life cycle-revenue, unit cost
and profit in each stage-are represented in the following Product Life-cycle
graph.
MP, CSE, 34
VCET
MP, CSE, 35
VCET
18CS44
MICROCONTROLLER AND
EMBEDDED SYSTEMS
MODULE 4
EMBEDDED SYSTEMS –
APPLICATION-
AND DOMAIN-
Dr. Mahesh Prasanna
SPECIFIC K.MP,
CSE,
» Embedded systems are application and domain specific, meaning; they are
specifically built for certain applications in certain domains like consumer
electronics, telecom, automotive, industrial control, etc.
» Embedded systems are highly specialized in functioning and are dedicated for
a specific application. Hence it is not possible to replace an embedded system
developed for a specific application in a specific domain with another
embedded system designed for some other application in some other domain.
MP, CSE, 37
VCET
WASHING MACHINE–APPLICATION-
SPECIFIC EMBEDDED SYSTEM
» An embedded system contains sensors, actuators, control unit and application-
specific user interfaces like keyboards, display units, etc. One can see all these
components in a washing machine. Some of them are visible and some of them
may be invisible.
» The sensor part consists of the water temperature sensor, level sensor, etc.
» The control part contains a micro• processor/ controller based board with
interfaces to the sensors and actuators.
MP, CSE, 38
VCET
» The sensor data is fed back to the control unit and the control unit
generates
the necessary actuator outputs.
» selecting the type of material to be washed like light, medium, heavy duty,
etc.
» User feedback is reflected through the display unit and LEDs connected to
the
control board.
MP, CSE, 39
VCET
» Functional block diagram of
washing
MP, CSE, 40
VCET
Washing machine comes in two models, top loading and front loading.
» In top loading models the agitator of the machine twists back and forth and
pulls the cloth down to the bottom of the tub. On reaching the bottom of the
tub the clothes work their way back up to the top of the tub where the agitator
grabs them again and repeats the mechanism.
» In the front loading machines, the clothes are tumbled and plunged into the
water over and over again. This is the first phase of washing.
» In the second phase of washing, water is pumped out from the tub and the
inner tub uses centrifugal force to wring out more water from the clothes by
spinning at several hundred Rotations Per Minute (RPM). This is called a
'Spin Phase'.
MP, CSE, 41
VCET
General principle of working of the washing machine:
MP, CSE, 42
VCET
» Input interface includes the keyboard which consists of wash type selector:
Wash, Spin and Rinse; clothe selector: Light, Medium, Heavy duty and
washing time setting, etc.
» The output interface consists of LED/ LCD displays, status indication LEDs,
etc. connected to the I/O bus of the controller.
» The other types of I/O interfaces which are invisible to the end user are
different kinds of sensor interfaces: water temperature sensor, water level
sensor, etc., and actuator interface including motor control for agitator and
tub movement control, inlet water flow control, etc.
MP, CSE, 43
VCET
AUTOMOTIVE – DOMAIN-SPECIFIC
EMBEDDED SYSTEM
» The major application domains of embedded systems are consumer, industrial,
automotive, telecom, etc. The following Figure gives an overview of the various
types of electronic control units employed in automotive applications.
MP, CSE, 44
VCET
» Inner Working of Automotive Embedded Systems:
» Automotive embedded systems are the one where electronics take control over
the mechanical systems. The presence of automotive embedded system in a
vehicle varies from simple mirror and wiper controls to complex air bag
controller and antilock brake systems (ABS).
MP, CSE, 46
VCET
» Automotive Communication Buses:
MP, CSE, 47
VCET
» 1. Controller Area Network (CAN): The CAN bus was originally proposed
by Robert Bosch, pioneer in the Automotive embedded solution providers.
» CAN supports medium speed (ISO 11519-class B with data rates up to 125
Kbps) and high speed (ISO 11898 class C with data rates up to 1Mbps) data
transfer.
MP, CSE, 48
VCET
» 2. Local Interconnect Network (LIN): LIN bus is a single master
multiple
slave (up to 16 independent slave nodes) communication interface.
» LIN bus is employed in applications like mirror controls, fan controls, seat
positioning controls, window controls, and position controls where response
time is not a critical issue.
MP, CSE, 49
VCET
» 3. Media Oriented System Transport (MOST) Bus: MOST is targeted for
automotive audio/ video equipment interfacing, used primarily in European
cars.
» The MOST bus specifications define the physical (electrical and optical
parameters) layer as well as the application layer, network layer, and media
access control.
» MOST bus is an optical fibre cable connected between the Electrical Optical
Converter (EOC) and Optical Electrical Converter (OEC), which would
translate into the optical cable MOST bus.
MP, CSE, 50
VCET
» Key Players of the Automotive Embedded Market:
» 1. Silicon Providers: are responsible for providing the necessary chips which
are used in the control application development.
» Some applications may require specific chips and they are manufactured as
Application Specific Integrated Chip (ASIC).
MP, CSE, 51
VCET
» 2. Tool and Platform Providers: are manufacturers and suppliers of various
kinds of development tools and Real Time Embedded Operating Systems for
developing and debugging different control unit related applications.
MP, CSE, 52
VCET
18CS44
MICROCONTROLLER AND
EMBEDDED SYSTEMS
MODULE 4
HARDWARE SOFTWARE
CO-DESIGN AND
PROGRAM MODELING
Dr. Mahesh Prasanna
K.
» In the traditional embedded system development approach, the hardware
software partitioning is done at an early stage and engineers from the
software group take care of the software architecture development and
implementation, whereas engineers from the hardware group are responsible
for building the hardware required for the product.
» There is less interaction between the two teams and the development happens
either serially or in parallel. Once the hardware and software are ready, the
integration is performed.
» The increasing competition in the commercial market and need for reduced
'time-to-market' the product calls for a novel approach for embedded system
design in which the hardware and software are co-developed instead of
independently developing both.
MP, CSE, 54
VCET
FUNDAMENTAL ISSUES IN
HARDWARE SOFTWARE CO-DESIGN
» The hardware software co-design is a problem statement and when we try to
solve this problem statement in real life we may come across multiple issues in
the design.
MP, CSE, 55
VCET
» Selecting the Model: In hardware software co-design, models are used for
capturing and describing the system characteristics.
MP, CSE, 56
VCET
» Selecting the Architecture: A model only captures the system characteristics
and does not provide information on 'how the system can be manufactured?’
» The state register holds the present state and the combinational circuits
implement the logic for next state and output.
» The Datapath Architecture is best suited for implementing the data flow
graph model where the output is generated as a result of a set of predefined
computations on the input data.
MP, CSE, 58
VCET
» The Finite State Machine Datapath (FSMD) architecture combines the
controller architecture with datapath architecture.
» The controller generates the control input, whereas the datapath processes
the data.
» the second I/O port interfaces the datapath with external world for
data input
and data output.
MP, CSE, 59
VCET
» The Complex Instruction Set Computing (CISC) architecture uses an
instruction set representing complex operations.
MP, CSE, 60
VCET
» The Reduced Instruction Set Computing (RISC) architecture reuses
instruction set representing simple operations and it requires the execution of
multiple RISC instructions to perform a complex operation.
» The data path of RISC architecture contains a large register file for storing
the operands and output.
MP, CSE, 61
VCET
» Parallel Processing architecture implements multiple concurrent Processing
Elements (PEs) and each processing element may associate a datapath
containing register and local memory.
» On the other hand, the processing elements of the MIMD architecture execute
different instructions at a given point of time. The MIMD architecture forms
the basis of multiprocessor systems.
MP, CSE, 62
VCET
» Selecting the Language: A programming language captures a
'Computational Model' and maps it into architecture. There is no hard and fast
rule to specify which language should be used for capturing this model. A
model can be captured using multiple programming languages like C, C++,
C#, Java, etc. for software implementations and languages like VHDL,
System C, Verilog, etc. for hardware implementations.
» On the other hand, a single language can be used for capturing a variety of
models.
» Various hardware software trade-offs are used for making a decision on the
hardware-software partitioning.
MP, CSE, 64
VCET
COMPUTATIONAL MODELS IN
EMBEDDED DESIGN
» Different Computational Models used in Embedded System design are
–
6. Object-Oriented model
MP, CSE, 65
VCET
» Data Flow Graph/ Diagram (DFG) Model: The DFG model translates the
data processing requirements into a data flow graph.
» The Data Flow Graph model is a data driven model in which the program
execution is determined by data. This model emphasizes on the data and
operations on the data transform the input data to output data.
» Indeed Data Flow Graph is a visual model in which the operation on the data
(process) is represented using a block (circle) and data flow is represented
using arrows. An inward arrow to the process (circle) represents input data
and an outward arrow from the process (circle) represents output data in DFG
notation.
» Embedded applications which are computational intensive and data driven are
modeled using the DFG model.
MP, CSE, 66
VCET
» Suppose one of the functions in an application contains the computational
requirement x = a + b; and y = x – c. The following Figure illustrates the
implementation of a DFG model for implementing these requirements.
» In a DFG model, a data path is the data flow path from input to output.
» The Control DFG (CDFG) model is used for modeling applications involving
conditional program execution. CDFG models contains both data operations
and control operations.
» The CDFG uses Data Flow Graph (DFG) as element and conditional
(constructs) as decision makers. CDFG contains both data flow nodes and
decision nodes, whereas DFG contains only data flow nodes.
MP, CSE, 68
VCET
» The control node is represented by a
'Diamond' block which is the decision
making element in a normal flow chart
based design.
MP, CSE, 69
VCET
» State Machine Model: The State Machine model is used for modeling
reactive or event-driven embedded systems whose processing behavior is
dependent on state transitions. Embedded systems used in the control and
industrial applications are typical examples for event driven systems.
» The State Machine model describes the system behavior with 'States',
'Events', 'Actions' and 'Transitions'.
State is a representation of a current situation.
An event is an input to the state. The event acts as stimuli
for state transition.
Transition is the movement from one state to another.
Action is an activity to be performed by the state machine.
MP, CSE, 70
VCET
» A Finite State Machine (FSM) model is one in which the number of states
are finite.
As an example let us consider the design of an embedded system for
driver/ passenger 'Seat Belt Warning' in an automotive using the FSM
model. The system requirements are captured as.
When the vehicle ignition is turned on and the seat belt is not fastened within
10 seconds of ignition ON, the system generates an alarm signal for 5 seconds.
The Alarm is turned off when the alarm time (5 seconds) expires or if the
driver/ passenger fasten the belt or if the ignition switch is turned off,
whichever happens first.
Here the states are 'Alarm Off', 'Waiting' and 'Alarm On' and the events are
'Ignition Key ON', 'Ignition Key OFF', 'Timer Expire', 'Alarm Time Expire' and
'Seat Belt ON'.
MP, CSE, 71
VCET
Using the FSM, the system requirements can be modeled as given in following
Figure.
The 'Ignition Key ON' event triggers the 10 second timer and transitions the
state to 'Waiting'.
If a 'Seat Belt ON' or 'Ignition Key OFF' event occurs during the wait state, the
state transitions into 'Alarm Off'.
When the wait timer expires in the waiting state, the event 'Timer Expire' is
generated and it transitions the state to 'Alarm On' from the 'Waiting' state.
MP, CSE, 72
VCET
The 'Alarm On' state continues until a 'Seat Belt ON' or 'Ignition Key OFF'
event or 'Alarm Time Expire' event, whichever occurs first. The occurrence of
any of these events transitions the state to 'Alarm Off'.
The wait state is implemented using a timer. The timer also has certain set of
states and events for state transitions. Using the FSM model, the timer can be
modeled as shown in the following Figure.
MP, CSE, 73
VCET
As seen from the FSM, the timer state can be either 'IDLE' or 'READY' or
'RUNNING'.
During the normal condition when the timer is not running, it is said to be in
the 'IDLE' state.
The timer is said to be in the 'READY' state when the timer is loaded with the
count corresponding to the required time delay. The timer remains in the
'READY' state until a 'Start Timer' event occurs.
The timer changes its state to 'RUNNING' from the 'READY' state on receiving
a 'Start Timer' event and remains in the 'RUNNING' state until the timer count
expires or a 'Stop Timer' even occurs. The timer state changes to 'IDLE' from
'RUNNING' on receiving a 'Stop Timer' or 'Timer Expire' event.
MP, CSE, 74
VCET
Example 1: Design an automatic tea/ coffee vending machine based on FSM
model for the following requirement.
» The tea/ coffee vending is initiated by user inserting a 5 rupee coin. After
inserting the coin, the user can either select 'Coffee' or 'Tea' or press 'Cancel'
to cancel the order and take back the coin.
» The FSM representation for the above requirement is given in the following
Figure.
MP, CSE, 75
VCET
» The FSM representation contains four states namely; 'Wait for coin' 'Wait for
User Input', 'Dispense Tea' and 'Dispense Coffee'.
» The event 'Insert Coin' (5 rupee coin insertion), transitions the state to 'Wait
for User Input'. The system stays in this state until a user input is received
from the buttons 'Cancel', 'Tea' or 'Coffee'.
» If the event triggered in 'Wait State' is 'Cancel' button press, the coin is
pushed out and the state transitions to 'Wait for Coin'. If the event received in
the 'Wait State' is either 'Tea' button press, or 'Coffee' button press, the state
changes to 'Dispense Tea' or 'Dispense Coffee' respectively.
» Once the coffee/ tea vending is over, the respective states transitions back to
the 'Wait for Coin' state.
MP, CSE, 76
VCET
Example 2: Design a coin operated public telephone unit based on FSM
model for the following requirements.
» After lifting the phone the user needs to insert a 1 rupee coin to make the call
» If the line is busy, the coin is returned on placing the receiver back on the
hook (on-hook)
» If the line is through, the user is allowed to talk till 60 seconds and at the end
of 45th second, prompt for inserting another 1 rupee coin for continuing the
call is initiated
» If the user doesn't insert another 1 rupee coin, the call is terminated on
completing the 60 seconds time slot
MP, CSE, 77
VCET
» The system is ready to accept new call request when the receiver is placed
back on the hook (on-hook)
» The system goes to the 'Out of Order' state when there is a line fault.
is a simple representation.
MP, CSE, 78
VCET
» Most of the time state machine model translates the requirements into
sequence driven program and it is difficult to implement concurrent
processing with FSM. This limitation is addressed by the Hierarchical/
Concurrent Finite State Machine model (HCFSM).
» HCFSM uses statecharts for capturing the states, transitions, events and
actions.
» The Harel Statechart, UML State diagram, etc. are examples for popular
statecharts used for the HCFSM modeling of embedded systems.
MP, CSE, 79
VCET
» Sequential Program Model: In the sequential programming Model, the
functions or processing requirements are executed in sequence. It is same as
the conventional procedural programming.
» Here the program instructions are iterated and executed conditionally and the
data gets transformed through a series of operations.
» Another important tool used for modeling sequential program is Flow Charts.
MP, CSE, 80
VCET
MP, CSE, 81
VCET
» Communicating Process Model: The concurrent or
Concurrent/
communicating process model models concurrently executing
tasks/
processes.
» If the task is split into multiple subtasks, it is possible to tackle the CPU usage
effectively, when the subtask under execution goes to a wait or sleep mode,
by switching the task execution.
2. Task for checking the ignition key status (ignition key status
monitoring task)
3. Task for checking the seat belt status (seat belt status monitoring task)
4. Task for starting and stopping the alarm (alarm control task)
MP, CSE, 83
VCET
» We need to start the alarm only after the expiration of the 10 seconds wait
timer and that too only if the seat belt is OFF and the ignition key is ON.
Hence the alarm: control task is executed only when the wait timer is expired
and if the ignition key is in the ON state and seat belt is in the OFF state.
» One way of implementing a concurrent model for the 'Seat Belt Warning'
system is illustrated in the following Figure.
MP, CSE, 84
VCET
MP, CSE, 85
VCET
» Object-Oriented Model: The object-oriented model is an object based model
for modeling system requirements. It disseminates a complex software
requirement into simple well defined pieces called objects.
MP, CSE, 86
VCET
» A class represents the state of an object through member variables and object
behavior through member functions. The member variables and member
functions of a class can be private, public or protected.
Private member variables and functions are accessible only within the
class, whereas public variables and functions are accessible within the
class as well as outside the class.
The protected variables and functions are protected from external access.
» However classes derived from a parent class can also access the protected
member functions and variables.
» The concept of object and class brings abstraction, hiding and protection.
MP, CSE, 87
VCET
18CS44
MICROCONTROLLER AND
EMBEDDED SYSTEMS
MODULE 4
EMBEDDED FIRMWARE
DESIGN AND
DEVELOPMENT
Dr. Mahesh Prasanna
K.
» The embedded firmware is responsible for controlling the various peripherals
of the embedded hardware and generating response in accordance with the
functional requirements mentioned in the requirements for the particular
embedded product.
» configuration and register details of various hardware chips used and some
programming language (low level assembly language or a high level
languages like C/C++/JAVA).
MP, CSE, 89
VCET
» Embedded firmware development process starts with
MP, CSE, 90
VCET
EMBEDDED FIRMWARE DESIGN
APPROACHES
» The firmware design approaches for embedded product is purely dependent on
the complexity of the functions to be performed, the speed of operation
required, etc.
» Two basic approaches are used for embedded firmware design. They are
MP, CSE, 91
VCET
» The Super Loop Based Approach:
» The task, listed at the top of the program code, is executed first and the tasks,
just below the top are executed after completing the first task. This is a true
procedural one.
MP, CSE, 92
VCET
» The firmware execution flow for this will be
–
1. Configure the common parameters and perform
initialization for
various hardware components memory, registers, etc.
5. :
6. :
8. Jump back to the first task and follow the same flow.
» From the above 'C' code you can see that the
tasks 1 to n are performed one after another
and when the last task (nth task) is executed,
the firmware execution is again re-directed
to Task 1 and it is repeated forever in the
loop.
MP, CSE, 94
VCET
» Since the tasks are running inside an infinite loop, the only way to come out
of the loop is either a hardware reset or an interrupt assertion.
» A hardware reset brings the program execution back to the main loop.
» The 'Super loop based design' doesn't require an operating system, since there
is no need for scheduling which task is to be executed and assigning
priority to each task. In a super loop based design, the priorities are
fixed and the order in which the tasks to be executed are also fixed.
» Hence the code for performing these tasks will be residing in the code
memory without an operating system image.
MP, CSE, 95
VCET
» Super loop based design is deployed in low cost embedded products and
products where response time is not time critical. Some embedded products
demand this type of approach.
For example, reading/ writing data to and from a card using a card reader
requires a sequence of operations like checking the presence of card,
authenticating the operation, reading/writing, etc.
A typical example of a 'Super loop based' product is an electronic video
game toy containing keypad and display unit. The program running inside
the product may be designed in such a way that it reads the keys to detect
whether the user has given any input and if any key press is detected the
graphic display is updated. Even if the application misses a key press, it
won't create any critical issues; rather it will be treated as a bug in the
firmware.
MP, CSE, 96
VCET
» The 'Super loop based design' is simple and straight forward without any OS
related overheads.
» The major drawback of this approach is that any failure in any part of a task
will affect the total system. If the program hangs up at some point while
executing a task, it may remain there forever and ultimately the product stops
functioning.
» Another major drawback of 'Super loop based design' approach is the lack
of
real timeliness.
» There are corrective measures for this also. The best advised option in use
interrupts for external events requiring real time attention.
MP, CSE, 97
VCET
» The Embedded Operating System (OS) Based
Approach:
» The Operating System (OS) based approach contains operating systems,
which can be either a General Purpose Operating System (GPOS) or a Real
Time Operating System (RTOS) to host the user written application
firmware.
MP, CSE, 98
VCET
» OS based applications also require 'Driver software' for different hardware
present on the board to communicate with them.
» Processors deal only with binaries (1s and 0s). Machine language is a
binary
representation.
» The Opcode tells the processor/ controller what to do and the Operands
provide the data and information required to perform the action specified by
the opcode.
Example: MOV A, #30 – This instruction mnemonic moves decimal value 30 to
the 8051 Accumulator register. Here MOV A is the Opcode and 30 is the operand.
The same instruction when written in machine language: 01110100 00011110 –
where the first 8-bit binary value 01110100, represents the opcode MOV A and the
second 8-bit binary value 00011110 represents the operand 30.
The mnemonic INC A is an example for instruction holding operand implicitly in
the Opcode. The machine language representation of the same is 00000100.
» Each line of an assembly language program is split into four fields as given
below:
» The Assembly program contains a main routine and it may or may not
contain subroutines. The example given above is a subroutine, which can be
invoked by a main program by the Assembly instruction:
» Label can also be directly replaced by putting the desired address first and
then writing the Assembly code, as given below:
» Any text editor like 'notepad' or 'WordPad' from Microsoft® or the text editor
provide by an Integrated Development (IDE) tool can be used for writing the
assembly instructions.
» When a program is too complex or too big; the entire code can be divided
into sub-modules and each module can be re-usable (called as Modular
Programming). Modular programs are usually easy to code, debug and alter.
» Linker is a program which combines the target program with the code of
other programs (modules) and library routines.
» During the process of linking, the absolute object module is created. The
object module contains the target code and information about other programs
and library routines that are required to call during the program execution.
» The absolute object file is used for creating hex files for dumping into the
code memory of the processor/ controller.
» 'BL51' from Keil Software is an example for a Linker & Locater for A51
Assembler/ C51 Compiler for 8051 specific controller.
» HEX files are ASCII files that contain a hexadecimal representation of target
application.
» Hex file is created from the final 'Absolute Object File' using the Object to
Hex File Converter utility.
» 'QH51' from Keil software is an example for Object to Hex File Converter
utility
for A51 Assembler/ C51 Compiler for
MP, 8051
VCET
CSE, specific controller. 109
» Advantages of Assembly » Drawbacks of Assembly
Language Based Development: Language Based Development:
» ‘C’ is the well defined, easy to use high level language with extensive cross platform
development tool support. Nowadays Cross-compilers for C+ + is also emerging out.
» The various steps involved in high level language based embedded firmware
development is same as that of assembly language based development;
» except that the conversion of source file written in high level language to
object file is done by a cross-compiler, whereas in Assembly language
based
development, it is carried out byMaP,nCSaEs, 111
» The various steps involved in the conversion of a program written in high
level language to corresponding binary file/ machine language is illustrated in
the following Figure.
» High level language and assembly languages are usually mixed in three
ways; namely,
2. Use the SRC directive ( #PRAGMA SRC at the top of the file) so that
the
C compiler generates an .SRC file instead of an .OBJ file.
3. Compile the C file. Since the SRC directive is specified, the .SRC file is
generated. The .SRC file contains the assembly code generated for the C
code you wrote.
5. Edit the .A51 file and insert the assembly code you want to execute in
the
body of the assembly function shell included in the .A51 file.
MP, CSE, 116
VCET
» Mixing High level language with Assembly (e.g. 'C' with
Assembly
Language): Mixing the code written in a high level language like 'C' and
Assembly language is useful in the following scenarios:
1. The source code is already available in Assembly language and a routine written
in a high level language like 'C' needs to be included to the existing code.
2. The entire source code is planned in Assembly code for various reasons like
optimized code, optimal performance, efficient code memory utilization and
proven expertise in handling the Assembly, etc. But some portions of the code
may be very difficult and tedious to code in Assembly. For example 16-bit
multiplication and division in 8051 Assembly Language.
3. To include built in library functions written in 'C' language provided by the cross
compiler. For example: Built in Graphics library functions and String operations
supported by 'C'.
» This avoids the delay in calling an assembly routine from a ‘C’ code.
» Special keywords are used to indicate the start and end of Assembly
instructions.
» C51 uses the keywords #pragma asm and #pragma endasm to indicate
a block of code written in assembly.
» It should be noted that the standard ANSI 'C' library implementation is always
tailored to the target processor/ controller library files in Embedded C.
» Here the operating system, the complier program and the application making
use of the source code run on the same target processor.