Chapter 3
C Programming Language
Microcontrollers can be programmed using one of several high-level languages. Some of the commonly used high-level languages are BASIC, PASCAL and C. Because of its ease of use and its power, C is probably the most commonly used high-level language for microcontroller programming. C has been used for the past 10 to 15 years and has gone through tremendous growth. Today, there seems to be an endless supply of low-cost, high-quality C compilers directed to any type of computer, from the PC to the smallest 8-pin microcontroller chip.
Before the development of the C language, microprocessors and microcontrollers were being programmed using the native Assembly language of the target chip. Assembly language was a difficult language to learn. Also, it was difficult and time consuming to develop and maintain complex applications using the Assembly language. For example, developing a mathematical application using floating point arithmetic took days, if not weeks. The developed code was so large that it was difficult to modify or maintain it. In addition, the code was specific for the target processor. If it was required to upgrade to a different processor then, in most cases, it was necessary to re-write the complete code, consuming a lot of time and effort. C, on the other hand, is a portable language. In general, a C program written for a specific processor can easily be modified and used for another processor. Highly complex programs can be developed ...