CONTACT US | JOIN | DOWNLOAD FORMS | CALENDAR | SEARCH   

IPENZ Engineers New Zealand

   

New Zealand Engineering 1998 March

Software Development for Embedded Systems</h3> <!-- WebSmith Ltd. http://www.websmith.co.nz magazine - web specialists --> <!-- On Wed Apr 01 17:20:19 1998 from "Untitled-9" --> Software Development for Embedded Systems <HR><strong>Paul Wilson </strong>formerly senior lecturer and <br /><strong>John Collins</strong> principal lecturer in software engineering, Electrotechnology Department, Auckland Institute of Technology </p> <p><IMG SRC="../gifs/comp.GIF" NOSAVE BORDER=0 HEIGHT=166 WIDTH=208 ALIGN=RIGHT><em>There may be some confusion among many people between the use of the terms "embedded system" and "micro-controller". In general terms an embedded system has a programmable processor used for real time control. The embedded controller may be a general purpose processor or a specialised device designed for a specific category of applications. An example of the specialised type is the digital signal processor (DSP) commonly found in video and audio applications.</em></p> <p>In contrast, a micro-controller is a general purpose, commonly single chip, microcomputer system that can be used for a variety of applications. Some examples of these single chip micro-controllers are the Intel 8051 and Motorola 68HC11 families. Different micro-controllers provide varying sub-systems, apart from the semi-standard RAM and ROM, which may include parallel and serial I/O, programmable timers and analog to digital conversion. These sub-systems obviously determine the suitability of the micro-controller for particular applications. The micro-controller can be, and most often is, used as an embedded system processor.</p> <p>Another option for developers of embedded systems is the use of a "standard" PC as the controller. This is perhaps best exemplified by the PC/104 system. The PC/104 cards are much smaller (3.6x3.8 inches) than standard ISA bus PC systems and stack together, thus eliminating the need for a motherboard or back-plane.</p> <p>The single common factor for all these various options for providing a controller is that they all require programming. Unlike many applications programs it is uncommon for an embedded system program to be altered once it has been developed. An example of this is the embedded system in most modern washing machines - how often is this program updated once it has been installed? Obviously there are a few larger systems, such as those using a PC/104 system perhaps for plant control, that will have periodic upgrades or enhancements where the plant itself is altered.</p> <p>When designing an embedded system controller program, especially for single chip micro-controllers, there is a requirement to make the code as efficient as possible. The requirement for efficient programs is two-fold. Firstly, memory size of both ROM and RAM is limited in micro-controllers and efficient programs require less memory for storage and execution. Secondly, efficient programs run faster which can provide the real-time performance required.</p> <p>Programs can be written in two types of language _ assembly language or a high level language such as the C programming language. Assembly language has a close correspondence to the native machine language of the microprocessor. High level languages are easier for programmers to use, but the price paid for ease of use is programs which require more memory and which run more slowly than assembly language programs. This is particularly true for small programs where the overheads incurred by using a high level language are often a large proportion of the size of the final program code.</p> <p>Assembly costs</p> <p>Using assembly language has its own costs however. Assembly language programs are more difficult to write and test. If the program is going to be installed in thousands or even millions of units then the additional cost of developing the program in assembly language may be small compared with the cost savings to be made from obtaining a smaller program. For example, a small assembly language program may require 2000 bytes of program memory whereas the same program written in a high level language may require 3000 bytes. The assembly language program can then be stored in a cheaper microcontroller than the high level language program. In a large production run, the cost savings of the cheaper hardware may be much larger than the additional cost of developing in assembly language.</p> <p>Another cost of developing in assembly language is the cost of maintenance. Maintenance is the changing of the program to incorporate new requirements in the system specification. It does not include fixing errors in the original program or design. Most products evolve over time as users develop new requirements, or as new features are added by the manufacturer. The cost of maintaining an assembly language program is higher than for a high level language program. This is particularly so if the original programmer is not available to do the job, and is even more so if the original programmer is not even available for consultation.</p> <p>Maintenance is easier if the program is well documented and if programming standards are used. Well structured high level languages, such as C, impose their inherent structure on the programmer. Assembly language allows the programmer much more freedom in the way code is written, so the programmer must be more disciplined to produce a well structured program. The programmer must design and write the program to avoid the "spaghetti code" which results from the undisciplined use of jump and branch instructions. One way to do this is to design the program using the program constructs available in high level languages, and then code these constructs in assembly language. This effectively limits the use of jump and branch instructions to well structured selection statements (if statements) and loops (for and while statements). Combined with well written program comments and accurate design documentation, this approach results in an assembly language program which is easier to test, debug and maintain.</p> <p>Where program execution speed is an important issue, it is possible to write programs as a combination of assembly language and a high level language. Parts of the program which require high speed may be written in assembly language and linked with the rest of the program written in a high level language. This results in lower software development costs than writing the whole program in assembly language, although the program will still be larger than if it is written completely in assembly language.</p> <p>Portability</p> <p>Another issue that may need to be considered is code portability. This is the ability of the program to be ported (transferred) to a different microprocessor. Assembly languages are very specific to a microprocessor family and assembly language programs need to be rewritten if the program is to be ported to another microprocessor. High level languages for different microprocessors are very similar so only a small number of program changes are required when porting a program to another microprocessor. For both languages, porting will also require program changes that reflect the architectural differences between the original microprocessor and the new microprocessor.</p> <p>High level languages for embedded systems now have direct access to all hardware facilities of the microcontroller including interrupt handling and bit manipulation when this is supported by the microcontroller. These are no longer reasons for choosing to program in assembly language.</p> <p>The choice of programming language for an embedded system now is to use assembly language when program memory space is limited, to use assembly language (possibly in conjunction with a high level language) when high program execution speed is required, and to use a high level language in other situations to obtain the advantages of lower development cost, easier testing and debugging, and easier maintenance. </p> <HR> </td> </tr> <tr> <td width="30"><img src="/ipenz/images/front/1x1tr.gif" alt="Blank space" width="30" height="50"></td> <td width="160" valign="top" align="left"><img src="/ipenz/images/front/1x1tr.gif" alt="Blank space" width="160" height="50"></td> <td width="20"><img src="/ipenz/images/front/1x1tr.gif" alt="Blank space" width="20" height="50"></td> <td width="400" align="left" valign="top" class="bodya"><img src="/ipenz/images/front/1x1tr.gif" alt="Blank space" width="400" height="50"></td> <td align="right" valign="top" width="250"> </td> </tr> </table> <div id="footer"> <strong>© 1996 - 2010 IPENZ</strong> </div> </div> </body> </html>