Page 149 - Programming Microcontrollers in C
P. 149
134 Chapter 3 What Are Microcontrollers?
exactly those peripherals required. The smallest microcontroller has
only a 15-bit timer, and the most complete MC68HC05 part has
everything but a SPI system. All varieties in between these extremes
exist. In the larger chips, some of the basic requirements for the
microcontroller change. We will see these larger chips in later chapters.
Programming Microcontrollers
The preceding brief description of what microcontrollers are gives
a rather bleak picture of a potential programming environment from
a computer standpoint. Most programmers are used to having an
operating system that handles such mundane things as I/O, memory
management, time management, program loading, error processing,
interdevice or intertask communications, and so forth. Be prepared
for a giant step backwards when you address the microcontroller.
There is usually no operating system, no libraries of useful functions,
no I/O handling, nothing but a bare-bones computer with a bunch of
hard-to-tame peripheral components onboard the single-chip device.
C compilers for the microcontrollers have been available long
enough that they are thoroughly tested and do a good job of creating
proper code. Anyone who has programmed a microcontroller in
assembly language knows that the programs must be very direct and
have no fancy overhead. Memory is strictly limited, and the compiler
must generate assembly code that is as resourceful as can be created
by any thoroughly qualified assembly language programmer for the
machine.
The development environment, while quite sophisticated in terms
of how it works, does little for the programmer in terms of direct
help in debugging a program. There are two different types of
development systems that are in common use. Both of these systems
require a host computer to run the device. The simplest of these
systems goes by names like evaluation module, evaluation system,
or evaluation board. These devices are usually board-level products
that require a power supply in addition to a host computer.
The software to run the development boards is merely a good
terminal emulator. Assemblers and linkers for the different chips are
provided as part of the development board. The programmer writes
the code for the part in the host computer. This code is assembled,
compiled, and linked in the host computer. The code is then