Embedded Firmware (Unit - Iii)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

EMBEDDED FIRMWARE (UNIT – III)

Embedded firmware refers to the control algorithm (Program


instructions) and/or the configuration settings that an embedded
system developer dumps into the code (program) memory of the
embedded system. It is an un-avoidable part of an embedded system.
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. The IDE contains an
editor, compiler, linker, debugger, simulator, etc. IDEs are different
for different family of processors/controllers. For example, keil micro
vision3 IDE is used for all family members of 8051 microcontroller,
Since it contains the generic 8051 compiler C51.
2. Write the program in Assembly language using the instructions
supported by your application’s target processor/controller.
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’.
 If the program is written in Embedded C/C++ using an IDE, the
cross compiler included in the IDE converts it into corresponding
processor/controller understandable ‘HEX File’.
 If you are following the Assembly language based programming
technique, you can use the utilities supplied by the
processor/controller vendors to convert the source code into ‘HEX
File’. Also third party tools are available, which may be free of cost,
for this conversion.
The other system components refer to the components/circuits/ICs
which are necessary for the proper functioning of the embedded
system.
1) Reset Circuit
2) Brown-out Protection Circuit
3) Oscillator Unit
  4) Real- Time Clock (RTC)
5) Watchdog Timer are examples of circuits/ICs which are essential
for the proper functioning of the processor/controllers.

The reset circuit is essential to ensure that the device is not


operating at a voltage level where the device is not guaranteed to
operate, during system power ON. 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
The reset signal can be either active high (The processor
undergoes reset when the reset pin of the processor is at logic high)
or active low (The processor undergoes reset when the reset pin of
the processor is at logic low). 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.
 Some microprocessors/controllers contain built-in internal reset
circuitry and they don’t require external reset circuitry. Figure
illustrates a resistor capacitor based passive reset circuit for active
high and low configurations. The reset pulse width can be adjusted
by changing the resistance value R and capacitance value C.
RC BASED RESET CIRCUIT
 The brown-out protection circuit prevents the processor/controller
from unexpected program execution behavior when the supply
voltage to the processor/controller falls below a specified voltage.
 The Oscillator unit generates clock signals for synchronizing the
operations of the processor.
 Real-Time Clock (RTC) 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. RTC is intended to function even in the absence of power.
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
A watchdog is to monitor the firmware execution and reset the
system processor/microcontroller when the program execution hangs
up or generates an Interrupt in case the execution time for a task is
exceeding the maximum allowed limit.
 If the firmware execution doesn’t complete due to malfunctioning,
within the time required by the watchdog to reach the maximum
count, the counter will generate a reset pulse and this will reset the
processor (if it is connected to the reset line of the processor).
 Most of the processors implement watchdog as a built-in
component and provides status register to control the watchdog timer
(like enabling and disabling watchdog functioning) and watchdog
timer register for writing the count value. If the processor/controller
doesn’t contain a built in watchdog timer, the same can be
implemented using an external watchdog timer IC circuit.
EMBEDDED FIRMWARE DESIGN
APPROACH
The firmware design approach for embedded product is purely
dependent on the complexity of the functions to be performed etc.
Two basic approaches are used for embedded firmware design.
They are:
1) Conventional procedural based firmware design.
(Super loop model)
2) Operating system based design.
THE SUPER LOOP BASED APPROACH
The super loop based firmware development approach is adopted
for applications that are not time critical and where the response
time is not so important. It is similar to a conventional
procedural programming where the code is executed task by
task. The task listed at the top of the program code is executed
first and the task below the top are executed after completing the
first task.
In a multiple task based system, each task is executed in serial in this
approach. The execution flow for this will be.
1) Configure the common parameters and perform initialisation for
various hardware components memory, registers,etc.
2) Start the first task and execute it
3) Execute the second task
4) Execute the next task
5) :
6) :
7) Execute the last defined task
8) Jump back to the first task and fallow the same task
Almost all tasks in embedded application are non-ending and are
repeated infinitely throughout the operation.
This repetition is achieved by using an infinite loop like WHILE(1)
{} loop.
Since the tasks are running inside the loop, the only way to come out
of the loop is either a hardware reset or an interrupt assertion.
 The super loop based design doesn’t require an operating system.
 This type of design is deployed in low cost embedded products
and products where response time is not critical.
 The major drawback of this approach is that any failure in any
part of a single task will affect the total system.
 If the program hangs up at some point while executing a task, it
will remain there forever and ultimately the product stops
functioning.
 Another major drawback of the super loop design approach is the
lack of real timeliness. if the number of tasks to be executed
within the application increases, the time at which each task is
repeated also increases.
THE EMBEDDED OPERATING SYSTEM BASED
APPROACH
The operating system based approach contains operating system,
which can be either GPOS or RTOS to host the user written
application firmware.
GPOS based design is very similar to a conventional PC based
application development where the device contains an
OS(Windows/Unix/Linux, etc for desktop PCs) and you will be
creating and running user application on top of it. OS based
applications also requires DRIVER SOFTWARE for different
hardware present on the board to communicate with them.
 RTOS based design approach is employed in embedded products
demanding real time response.
 RTOS responds in a timely and predictable manner to events.
 RTOS contains a real time kernel responsible for performing pre-
emptive multitasking, scheduler for scheduling tasks, multiple
threads etc.
A RTOS allows flexible scheduling of system resources like the
CPU and memory and offers some way to communicate between
tasks. Some examples of RTOS are,
 Windows CE, pSOS, VxWorks , ThreadX, MicroC/OS-II,
Embedded Linux,Symbian etc.
 Most of the mobile phones are built around the popular RTOS
Symbian.

EMBEDDED FIRMWARE DEVELPOMENT


LANGUAGE
 You can use either a target processor/controller specific language
(generally known as Assembly language or low level language).
A target processor/controller independent language like C, C++,
JAVA, etc. Commonly known as high level languages.
 A combination of Assembly and high level language.
ASSEMBLY TO MACHINE LANGUAGE CONVERSION PROCESS

LIBRARY
FILE

SOURCE FILE
MODULE OBJECT FILE
(asm or.src file)
MODULE1
ASSEMBLER 1

SOURCE FILE OBJECT FILE


MODULE
(asm or.src file)
ASSEMBLER 2
MODULE2

OBJEC TO ABSOLUTE
LINKER/
HEX FILE OBJECT
CONVERTER LOADER
FILE
MACHINE CODE
(HEX FILE)
HIGH LEVEL TO MACHINE LANGUAGE
CONVERSION PROCESS

LIBRARY
FILE

SOURCE FILE MODULE


OBJECT FILE
(.C or .C++ etc) CROSS 1
MODULE 1 COMPLIER

SOURCE FILE MODULE


OBJECT FILE
(.C or .C++ etc) CROSS
2
MODULE 2 COMPLIER

OBJEC TO
ABSOLUTE LINKER/
HEX FILE
OBJECT FILE LOADER
CONVERTER

MACHINE CODE
(HEX FILE)

You might also like