Designer Reference Manual USB08 Evaluation Board
54 Software Module Descriptions MOTOROLA
Software Module Descriptio ns
the ground potential at the resistors via the port pins PTD[3..5]
(calibration cycle) and PTD[6] (measuring cycle).
Before the software of the ADC module can be used, the initialization
function initSADC() has to be called. In addition, the main timer is
required to run with 3 MHz (prescaler 0). The clocking of three impulses
per microsecond is the basis of the time measurement in this module.
The function responsible for the A/D conversion of one channel at a t ime
is getSADC(). The channel number (1..3) is handled as a parameter.
The A/D conversion is performed in the two mentioned step s: calibration
and measurement.
The desired 8-bit range for the results (values of 0255) is a result of
scaling of the A/D output. In order to keep the run time of the necessary
division and multiplication operations small, the scaling function is
implemented using some in-line assembler directives.
A detailed discussion of the software A/D converter used here is
contained in the application note entitled Simple A/D for MCUs without
Built-in A/D Converters, Motorola document order number AN477/D.
This application note can be found on the World Wide Web at:
http://www.motorola.com/semiconductors/
3.11 RS232 Communication Mod ule U08232.C
The RS232 communication module performs the sending and the
receiving of data to the host PC. The RS232 implementation is o ne of the
two possible alternatives. By the definition of the macro
USE_USB_PIPE in the main module U08MAIN.C, it is possible to switch
from the RS232 version to the USB version of the communication
module.
Since the MC68HC908JB8 does not have a hardware serial
communications interface (SCI) peripheral module, an RS232
transceiver has to be implemented by a software-based SCI module.
Two general-purpose I/O pins are used as receiving and transmission
lines. The timing necessary for the desired baud rate is derived from a
time loop.