Page 11 - Programming Microcontrollers in C
P. 11
xii Introduction to First Edition
background is complete. The background on the chosen microcontrollers
is presented briefly, as this book is not intended to be a text on
microcontrollers. Therefore, the chapters that cover specific microcontrollers
are to the point. The references found in each chapter contain texts and
data books that will cover the various microcontrollers discussed. This
book grew out of my teaching activities, so chapters include several
exercises suitable for classroom as well as individual use. The only way to
learn programming is to program, and the exercises are designed to let you
put the material in each chapter to use in typical microcontroller program
ming situations.
Chapters 1 and 2 contain a background on ANSI C. Data in these
chapters is basic to all C programs. There is no specific coverage for
microcontroller programming. Chapter 3 contains a brief background on
microcontrollers, and it also contains general programming guidelines that
should be used when writing code for microcontrollers.
Chapter 4 is devoted to writing programs for the MC68HC05 family.
In this chapter, the use of microcontroller specific header files is intro
duced. These header files are written for a specific part, and must be
included in any program for the part.
In Chapter 5 you will find techniques for programming the MC68HC11
family of parts. Several of the peripherals on these parts are examined, and
code to access these peripherals is written.
More complex microcontrollers are found in the MC68HC16 and the
MC68300 families. Programming the MC68HC16 is discussed in Chapter
6. This part contains an internal bus with several peripherals placed on this
bus. Access to these peripherals is through memory mapped registers and
how these peripherals are accessed will be found in Chapter 6.
There are several appendices. Appendix A contains several header
files that are useful in programming MC68HC05 programs. Appendix B
contains some code that demonstrates the power of the types defined by
structures, and how these types can be made into very convenient new
types by the typedef keyword.
One of the advantages of a high level language is that it isolates the
programmer from the details of the computer being programmed. There
are both plusses and minuses to this idea. First, as a programmer, you do
not need to know details of the register map and the programmers model
of the computer being programmed because the language takes care of
these details for you. On the other hand, microcontrollers all have periph
erals and other components that must be accessed by the program. The
programmer must be able to write C code that will set and reset bits and
flags in control registers for these parts. It would be desirable to write this
book with no detailed discussion of the insides of the microcontrollers you