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 and maintained using the C language.

The main objective of this chapter is to introduce new readers to the C language, through a simple overview of its fundamental features, in an attempt to start them programming early. The C language is described in a tutorial way, with many examples, in such a way that the readers can gain confidence and start coding immediately. However it is important for the reader to appreciate that C is a rich language with many features, and this is not a text book on C language, so only the parts relevant to future chapters of the book will be covered here.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.149.45