Page 311 - Programming Microcontrollers in C
P. 311
296 Chapter 6 Large Microcontrollers
#define ABLE (*(Register *) 0x2000)
is too complicated for most programmers to understand. The ap
proach that they use is nonportable, and the latter approach is
completely portable among ANSI compliant compilers. It is recom
mended that, even though the header files contain some code that
might be difficult to explain, you should use the approach presented
here to create code that is as portable as possible.
Some of the sections that follow will show how portable code can
be used. Examples from both the MC68HC11 and the MC68HC05
will be used on the MC68HC16, and you will see that much of the
code will be transferred with little change. Where would you expect
changes? Recall the recommendation that each program be broken
into three sections: the initialization section, the applications section,
and the asynchronous service section. Each section will be subject to
some change when moving from one machine to another, but the ap
plications section will probably suffer little change and the other two
sections will see the most changes when the code is moved. For ex
ample, you will see that the initialization of theMC68HC16 is somewhat
different from that of the MC68HC11, but the interrupt service rou
tines will be nearly the same. In fact, in some cases the isr for the
two parts is identical. On the other hand, the way that things are handled
on the MC68HC05 is so different that the initialization and isr will
probably have to be completely rewritten when moving code to one of
the larger machines. However, here the machine-independent portions
of the applications routine can be moved with little change.
System Integration Module (SIM)
A brief examination of the names of most of the modules will
reveal their use. There is one notable exception—what is a system
integration module (SIM)? The SIM is sort of the interface between
the IMB and the outside world. It is very useful, and contains much
of the circuitry that a hardware designer would have to incorporate
to make a computer out of a microprocessor. The object of the chip
designer with the introduction of the SIM was to make it possible to
use the MC68HC16 in a system with a minimum of external cir
cuitry. This section is not to provide you with a complete description
of the SIM. The SIM Reference Manual is a 200-page document,
and I’m not intending to duplicate that manual here. The following