Page 401 - Programming Microcontrollers in C
P. 401
386 Chapter 7 Advanced Topics
You will notice that the file shown in Listing 7-17 is the only file
in which the header file hc12.h is included. None of the other code
depends in any way on the bit field structures that control all of the
peripherals on the chip. There are a few places throughout the code
where there are some specific differences between the two programs.
The first line of code in the header phone.h is
#define DOS
This line is left intact whenever the program is compiled to run under
DOS. When the program is compiled to run on the HC12, this line is
removed. Then sequences like the following found in monitor.c
#ifndef DOS
inituart(); /* initialize the uart to 9600 b/s */
#endif
will cause the execution of inituart() to be ignored when
compiled for DOS but it will be included when the program is
compiled for the HC12. Such inclusions will be found throughout
the various functions that are linked to form the program.
Putting It All Together
The above programs were all compiled, linked and tested with
1
the DOS-based compiler provided by MIX Software . This reliable
compiler created satisfactory test code to run on any PC-style
computer. When everything was working as desired, the code was
moved to the HC12 system. The compiler used in this case was the
COSMIC compiler . This compiler was provided by the same
2
company that provided the compilers used in Chapters 5 and 6. Cosmic
provides two software packages that are very useful. The first is called
IDEA12. This package is a so-called Integrated Development
Environment, IDE. Within the IDE, you can specify things like the
default directory, and provide a list of files for a make utility. The
make utility will compile all source files that are newer than the
corresponding object files. Therefore, as you debug various files in
1 Mix Software, 1132 Commerce Drive, Richardson, TX 75081, (972) 783-6001.
2 Cosmic Software, 400 W. Cummings Park, Ste. 6000, Woburn, MA 01801-6512, (781) 932-2556 x15.