Page 8 - Programming Microcontrollers in C
P. 8
Introduction to First Edition
Early detractors of the C language often said that C was little more
than an over-grown assembler. Those early disparaging remarks were to
some extent true and also prophetic. C is indeed a high level language and
retains much of the contact with the underlying computer hardware that is
usually lost with a high level language. It is this computer relevance that
makes people say that C is a transform of an assembler, but this computer
relevance also makes C the ideal high level language vehicle to deal with
microcontrollers. With C we have all of the advantages of an easily
understood language, a widely standardized language, a language where
programmers are readily available, a language where any trained program
mer can understand the work of another, and a language that is very
productive.
The main purpose of this book is to explore the use of C as a
programming tool for microcontrollers. We assume that you are familiar
with the basic concepts of programming. A background in C is not
necessary, but some experience with a programming language is required.
I have been teaching C programming for microcontrollers for several
years, and have found that my students are usually excellent programmers
with many years of experience programming microcontrollers in assembly
language. Most have little need or interest in learning a new language. I
have never had a class yet where I was able to jump into programming
microcontrollers without providing substantial background in the C lan
guage. In many instances, students believe that a high-level language like
C and microcontrollers are incompatible. This forces me, unfortunately, to
turn part of my class into a sales presentation to convince some students
that microcontrollers and C have a future together. I am usually able to
show that the benefits gained from using C far outweigh the costs attrib
uted to its use. The first two chapters are included for those who are
unfamiliar with C. If you are already familiar with C, feel free to skip
ahead to Chapter 3.
C is a very powerful high level language that allows the programmer
access to the inner workings of the computer. Access to computer details,
memory maps, register bits, and so forth, are not usually available with
high level languages. These features are hidden deliberately from the
programmer to make the languages universal and portable between ma
chines. The authors of C decided that it is desirable to have access to the
heart of the machine because it was intended to use C to write operating
systems. An operating system must be master of all aspects of the machine
ix