Professional Documents
Culture Documents
8th Chapter Embedded Systems
8th Chapter Embedded Systems
Prior to design, we must construct a specification of the ES to meet such requirements properties
as:
1) Completeness.
2) Time (timing constraints response time, reactive time, and deadlines – soft vs. Hard)
4) Knowledge of microprocessor speed – can the microprocessor run the IR 1200 times per sec?
5) Need all the software engineering skill you have, plus such properties as: structures,
6) Testing and debugging ES requires specialized hardware tools and software tools and
techniques
Principles – 1
Even lowest priority IR’s are handled before the highest priority task code (minimize task
code response time)
IR’s are error prone and hard to debug (due to hardware dependent software parts) Parts
IR code requiring immediate / quick response should be in the core of IR code; parts
needing ‘longer’ processing and not so urgent response should be done a task (signaled
by the IR)
More tasks means frequent context switching (overhead) and less throughput
More tasks mean frequent calls to the RTOS functions (major overhead adds up).
For quicker response time using task prioritization – high priority for time critical ones,
and low priority for others.
A dedicated task to encapsulate the handling of each shared device (e.g., printer display
unit) or a common data structure (e.g., an error log) Parts of a target hardware storing
data in a flash memory – a single task encapsulates the handling of permission to write to
flash (set / reset of flash at given times)
Need many small, simple tasks? But worry about data sharing, inter task comm.
8th chapter
Useful in conventional OS’s for ‘fairness’ to user programs In ES’s fairness is not an
issue, response time is!
Time slicing causes context switching – time consuming and diminishes throughput.
Where the RTOS offers an option to turn time slicing off, turn it off!
Customize the RTOS features to your needs (Note: the RTOS and your ES gets linked
and located together into same address space of ROM/RAM .If possible write ES
functions to interface with RTOS select features to minimize excessive calls to several
RTOS functions (increases opportunity for errors).
Develop a shell around the RTOS functions, and let your own ES tasks call the shell (and
not the RTOS directly) – improves portability since only the shell may be rewritten fro
RTOS to RTOS.
System of 8 underground tanks Measures read: temperature of gas (thermometer) read at any
time float levels (float hardware) interrupted periodically by the microprocessor. Calculate the
number of gallons per tank using both measures. Set an alarm on leaking tank (when level slowly
and consistently falls over time). Set an alarm on overflow (level rising slowly close to full
level). User interface:
a) 16 button control panel, LCD, thermal printer System can override user display options
and show warning messages. Histories of levels and temperature over time can be
requested by user (3050 lines long) and user can queue up ‘several’ reports. Issuing
commands require 2 or 3 buttons, and system can prompt the display in the middle of a
user command sequence. Buttons interrupt the microprocessor. One low priority task that
handles all # gallons calculations and detects leaks as well (for all tanks – 1 at a time). A
high priority overflow detection task (higher than a leak detection task). A high priority
8th chapter
float hard ware task, using semaphores to make the level calc and overflow detection task
wait on it for reading (semaphores will be simpler, faster than queuing requests to read
levels).
A high priority button handling tasks – need a state machine model (an IR? With internal static
data structures, a simple wait on button signal, and an action which is predicated on sequence of
button signals) since semaphores won’t work
A high priority display task – to handle contention for LCD use Turning the alarm bell on/off by
the level calculation, overflow, and user button is typically non contentious – an atomic op –
hence do not need a separate alarm bell task However, need a module with BellOn(), BellOff()
functions to encapsulate the alarm hardware
Guaranteeing that the system will meet hard deadlines – comes from writing fast code
Issues: fast algorithms, efficient data structures, code in assembly (if possible)
Characterizing real time systems:
Made of n tasks that execute periodically every Tank units of time Each task worst case
execution time, Cn units of time and deadline of Dn Assume task switching time is 0 and
non-blocking on semaphore.
Each task has priority Pn Predicting Cn is very important, and depends on avoiding
‘variability’ in Execution times for tasks, functions, access time of data structures/buffers,
Semaphore blocking – any operation that can’t be done in the same time units on each
execution/access.
7. Saving Power
Some embedded systems run on battery, turning battery off for some or all devices is
good.
Generally, how to do you save power?
Look for the power saving modes (enablers) which the manufacturers provide
Software can put microprocessor in one the modes – via special instruction or
writing a code to special register in the processor. The software must be fast!!
Power saving modes: sleep, low power, idle, standby, etc. Typical: microprocessor stops
running, all built in devices, and clock circuit (but leave static RAM power on since the
wattage is very small)
Waking microprocessor up is done by special circuitry and software (to avoid restart and
reset – write special code to RAM address and let software check if it is cold start or
restart from power saving mode)
Alternative: microprocessor stops running but all devices stay alive, microprocessor is
resume by interrupt (this is less a hassle that stopping all devices)
If software turns power of devices back on, status data for resumption must be in
EEROM, and for those devices Turn off built-in devices that signal frequently from high
low, low hi power hungry!