Designer Reference Manual
USB08 Evaluation Board
48
Software Module Descriptions
MOTOROLA
Software Module Descriptions
3.5 Main Module U08MAIN.C
Which variant to be compiled is specified at the head of this module
using the macro USE_USB_PIPE. If defined, the USB version will be
produced; otherwise, the RS232 version will be produced.
The two versions are formed by merging different “#include” files. In
addition, the names of the interface functions used in the main program
are standardized. For example:
•
If the RS232 version is active, the getSSCI() (for receiving a
character via RS232) is renamed by a macro to getPipe().
•
If the USB version is active, getPipe() is mapped to getUSB().
This enables the use of uniform function names in the main program,
independent of the version selected in each case.
The function main() contains the continuous loop of the master program.
As usual, it is called by the C startup module after all fundamental
hardware and system initializations are finished. Also, at the beginning
of these initializations, the C startup module calls the function
_HC08Setup(). In this function, all register accesses and initializations,
which must take place immediately after system resets, are
summarized. The summarizing of these initializations within its own
function keeps the C startup module static. It has the advantage that the
C startup module does not have to be changed and retranslated, even if
further initialization steps become necessary.
At the beginning of function main() the peripheral modules used by the
program are initialized:
•
initPipe() — communication module (RS232 or USB)
•
initLED() — LED readouts
•
initKey() — keyboard entry
•
initSADC() — software analog-to-digital converter (ADC)
Subsequently, the I flag is deleted to enable global interrupts.