by July 1, 2005 0 comments



There is a lot of flexibility in terms of the processing power and memory requirements when you code an application for a desktop, PC, workstation or a server. Jump into the embedded arena and all this flexibility comes to an end. As the name ’embedded’ suggests, embedded applications are usually burnt into the circuitry of hardware devices like machinery and control systems.

Processing and memory power is seldom available in abundance for embedded applications. Add to it almost mandatory requirements of low- level hardware access and real time parallel processing. This article delves further into the depth of these bottlenecks, and things to keep in mind while coding for embedded devices.

Size does matter
Perhaps, the biggest consideration is the size of an application. Usually embedded applications cannot afford to be more than a few hundred kilobytes in size because of their use in small footprint devices. The memory consideration includes not only the size of the application, but also the amount of main memory required for it to run. There will always be a never-ending need to optimize the application to make it the best fit.

Hardware access
Much of the software for embedded would be control software to control the hardware machinery. In the programming language you choose, you should be aware of all routines (functions/methods) to send inputs to and receive outputs from the hardware through I/O ports (for example serial, parallel). You should be able to manipulate the data at the bit level. It’s because it may be inefficient to use data structures like strings and integers for an embedded system, because of their size.

High performance
In the embedded systems used in defense and control systems, time is a critical factor. Hence processing should be fast. A missile-tracking system should be fast enough to calculate and predict the co-ordinates of a missile flying at several hundred kilometers per hour. For higher performance, besides relying solely on the power of processor, the program code itself should be optimized for extra gains in performance. You should know, how to use powerful, optimizing compilers that can optimize and translate the source code into native hardware instructions. To speed up critical code blocks, you should be able to readily embed low-level instructions (using Assembly language) within the code.

Parallel processing
An embedded application may need to perform more than one task simultaneously. For example, missile system may need to track missiles, predict the missile course, destroy an attacking missile and look up the maps to calculate the missile co-ordinates. A control system in a manufacturing unit should be able to accept new input of raw materials while processing the already fed and also while outputting the finished products. Hence to develop such a system, you should be able to parallelize your code efficiently in such a way that, none of the critical code chunk block due to the processing of another chunk. For this you should know how to use the libraries for multithreading and message passing.

Priority queues
Having talked about parallel processing, sometimes it may become essential to carry out one task before the other. The software system should be able to decide which task (from amongst a list of assigned ones) has higher priority. In software, such a concept is implemented as a queue-a data structure. A priority queue is one in which the tasks are arranged based on their priority. A least priority task is kept at the rear of the queue and the highest priority task is kept at the front.

Top five concerns of a developer

1. Memory and processing
optimized
2. Specific hardware
3. High precision
4. Parallel processing
5. Error handling

Tasks are worked upon from the front of the queue. So a thorough understanding of priority queues is mandatory.

Error handling
While it may not be possible to develop a 100% error-free program, it is surely possible to develop a program that can handle likely and preferably unlikely errors. While error handling is of utmost importance in all applications it becomes critical in embedded system especially those, which are used in defense and control systems

Hence, you must be able to use methods to trap the errors and perform counter measures to recover from it. For example, on detecting a failure in one of the components of the hardware, the software must switch over to another redundant component or report the error and still try to carry on with the next task.

Precision and accuracy
An embedded application must be precise and accurate for use in a control system.

Fail-safe booting: when embedded systems fail

Fail-safe booting involves providing an alternate mechanism for the system to boot up if anything goes wrong with the system and it is unable to boot up in normal fashion. This is accomplished by providing an image of the emergency boot system, either embedded on the controller chip itself or stored on a ROM module.
If the system fails to boot up normally, the user can reset the system, as often done by inserting a pin in some of the smaller systems. This erases the state or all configuration data stored in the system and resets the device to the ‘factory state’. Minor problems in the device are often solved by this simple procedure.
But not all problems are minor. Some of the more complex devices with advanced fail-safe booting techniques are programmed to present the user with a command line like interface for troubleshooting. This troubleshooting mode is designed to use as few system resources (hardware) as possible so as to reduce the dependency of the fail-safe mechanism to fewer ‘points of failure’. This ensures that even if a greater number of components of the system go down, as long as the critical ones (needed for fail-safe) are intact, the system can provide (at least) a useful interface.
Needless to say, the success of any fail-safe booting mechanism depends on ensuring that the fail-safe image and the controller survive the failure.

Processes may require precise mathematical calculations to arrive at the output. You should be able to use data structures to hold large integers and floating-point numbers. Especially when calculations involve decimal or floating-point numbers the decimal places must be preserved for accurate results, instead of rounding them off as in case of conventional desktop programming.

The Bottom Line: Programming for embedded is programming with memory constraints, accuracy, performance and error handling. You must understand the underlying device and its capabilities and adhere strictly to the specifications laid out during the project analysis.

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

<