0% found this document useful (0 votes)
24 views7 pages

Chapter 4 Real Time and

Real time evaluation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views7 pages

Chapter 4 Real Time and

Real time evaluation
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Department of Computer Science and Engineering

JIGJIGA University
Real Time and Embedded Systems
Hand-out of Chapter 4
------------------------------------------------------------------
Embedded Firmware

 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 as below.
1. Write the program in high level languages like Embedded C/C++
using an Integrated Development Environment (The IDE will
contain 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'.
 The methods used for 'HEX File Creation'' is different depending on
the programming techniques used.
 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 proces-
sor/controller vendors to convert the source code into HEX File.
 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.

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.
 Watchdog timer, Reset IC (or passive circuit), brown-out protection
IC (or passive circuit), etc. are examples of circuits/ICs which are
essential for the proper functioning of the processor/controllers.
 Some of the controllers or SoCs integrate these components within a
single IC and doesn't require such components externally connected to
the chip for proper functioning.
 Depending on the system requirement, the embedded system may
include other integrated circuits for performing specific functions, level
translator ICs for interfacing circuits with different logic levels, etc.
 The essential circuits for the proper functioning of the
processor/controller of the embedded system are:
Reset Circuit
 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 (Normally from
vector address 0x0000 for conventional processors/controllers. The
reset vector can be relocated to an address for processors/controllers
supporting boot loader).
 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.

Brown-out Protection Circuit


 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.
 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.
 A brown-out protection circuit holds the processor/controller in reset
state, when the operating voltage falls below the threshold, until it
rises above the threshold voltage.
 Certain processors/controllers support built in brown-out protection
circuit which monitors the supply voltage internally.

Oscillator Unit
 A microprocessor/microcontroller is a digital device made up of
digital combinational and sequential circuits.
 The instruction execution of a microprocessor/controller occurs in
sync with a clock signal.
 It is analogous to the heartbeat of a living being which synchronizes
the execution of life.
 For a living being, the heart is responsible for the generation of the
beat whereas the oscillator unit of the embedded system is responsible
for generating the precise clock for the processor.
 Certain processors/controllers integrate a built-in oscillator unit and
simply require an external ceramic resonator/quartz crystal for
producing the necessary clock signals.
 Quartz crystals and ceramic resonators are equivalent in operation,
however they possess physical difference.

Real-Time Clock (RTC)


 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.
 RTCs are available in the form of Integrated Circuits from different
semiconductor manufacturers like Maxim/Dallas, ST Microelectronics
etc.
 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.

Watchdog Timer
 In desktop Windows systems, if we feel our application is behaving in
an abnormal way or if the system hangs up, we have the 'Ctrl + Alt +
Del to come out of the situation.
 What if it happens to our embedded system? Do we really have a
'Ctrl + Alt + Del to take control of the situation? Of course not
 But 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.
 Depending on the internal implementation, the watchdog timer in-
crements or decrements a free running counter with each clock pulse
and generates a reset signal to reset the processor if the count reaches
zero for a down counting watchdog, or the highest count value for an
up counting watchdog.
 If the watchdog counter is in the enabled state, the firmware can
write a zero (for up counting watchdog implementation) to it before
starting the execution of a piece of code (subroutine or portion of code
which is susceptible to execution hang up) and the watchdog will start
counting.
 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).
 If the firmware execution completes before the expiration of the
watchdog timer you can reset the count by writing a 0 (for an up
counting watchdog ' timer) to the watchdog timer register.
 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.

Embedded Firmware Design Approaches and Development


Languages:
 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
o Conventional Procedural Based Firmware Design
o Embedded Operating System (OS) Based Design'.
 The conventional procedural based design is also known as Super
Loop Model.
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 (embedded systems where missing deadlines are
acceptable).
 It is very 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 tasks just below the top are executed after completing the first
task.
 This is a true procedural one.
 In a multiple task based system, each task is executed in serial in this
approach.
 The firmware execution flow for this will be
1. Configure the common parameters and perform initialization 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 follow the same flow

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.
 The General Purpose OS (GPOS) based design is very similar to a
conventional PC based application development where the device
contains an operating system (Windows/Unix/ Linux, etc. for Desktop
PCs) and you will be creating and running user applications on top of it.
 Real Time Operating System (RTOS) based design approach is
employed in embedded products demanding Real-time response.
 RTOS respond in a timely and predictable manner to events.
 Real Time operating system contains a Real Time kernel responsible
for performing pre-emptive multitasking, scheduler for scheduling
tasks, multiple threads, etc.
 A Real Time Operating System (RTOS) allows flexible scheduling of
system resources like the CPU and memory and offers some way to
communicate between tasks.
 MicroC/OS, Embedded Linux, Symbian etc. are examples of RTOS
employed in embedded product development.
 Mobile phones, PDAs (Based on Windows CE/Windows Mobile
Platforms), handheld devices, etc. are examples of Embedded Products
based on RTOS.
 Most of the mobile phones are built around the popular RTOS
Symbian.

EMBEDDED FIRMWARE DEVELOPMENT LANGUAGES


Assembly Language based Development
 'Assembly language' is the human readable notation of 'machine
language, whereas 'machine language' is a processor understandable
language.
 Processors deal only with binaries (1s and 0s).
 Machine language is a binary representation and it consists of 1s and
0s.
 Machine language is made readable by using specific symbols called
'mnemonics'.
 Hence machine language can be considered as an interface between
processor and programmer.
 Assembly language and machine languages are processor/controller
dependent and an assembly program written for one
processor/controller family will not work with others.
 Assembly language programming is the task of writing processor
specific machine code in mnemonic form, converting the mnemonics
into actual processor instructions (machine language) and associated
data using an assembler.
 Processor/controller independent language (Like C, C++, JAVA, etc.
commonly known as High Level Languages)
 A combination of Assembly and High level Language.

You might also like