C Programming for Embedded Systems-introduction
Even if C is losing its position as the mainstream programming language for general application development, embedded programming is still its stronghold. Students and programmers new to embedded programming, though proficient in general C programming, are often clueless about C programming for embedded systems. This article offers an introduction.
Every embedded system has software and hardware elements that are very closely dependent, and this affects how we program an embedded device. Based on this fact, we’ll look at the hardware
characteristics of embedded devices, how the hardware affects the language chosen to write programs for it, how C is used differently for embedded programming and, finally, we’ll cover how GCC is used for embedded systems.
Characteristics of embedded devices
Programming for embedded systems is quite different from general programming (for PCs). The main difference is due to the underlying hardware. The important characteristics of embedded systems when compared to regular PCs are:
- Embedded devices have significant resource constraints; typically, less memory, less processing power and limited hardware devices compared to regular desktop computers. [But this is slowly changing; the latest embedded devices have considerably more resources (such as a huge memory) and are more powerful than ever before. Nowadays, with smart mobile phones, we can browse the Internet, play games, make phone calls, and even do programming—so, handheld devices are becoming as powerful as a PC, blurring the difference between embedded systems programming and general programming.
- The hardware components used are not the same as the ones used for a PC: the components in an embedded device are lighter, cooler, smaller and less powerconsuming. To be specific, the processor used in an embedded system is rarely the same used in a PC; and heavy I/O devices such as keyboards and monitors are not used in embedded systems.
- Embedded systems are more tied to the hardware/OS vendor than the PCs. PCs are general-purpose machines and we can take the availability of applications and programming tools for granted. However, embedded systems are typically more tied to the hardware or OS vendor and, hence, the common applications or tool chains need not be widely or freely available.
- Embedded systems should be more reliable and efficient. If a program in a PC fails, we can restart the program and nothing serious happens. However, for many embedded system programs, if they fail, they can make the device useless. And sometimes they can
cause serious harm -- imagine what could happen if an embedded program in a pacemaker device fails.
No comments:
Post a Comment