3–400
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
ALLINIT Function
The ALLINIT function disables the COP for this version of
software, sets the data direction bits, and disables the data to
the LCD and turns off the LCD enable line. It also sets up the
microcontroller’s internal clock to half the speed of the bus
clock. See Section 15, Computer Operating Properly, of the
MC68908QT4 datasheet for information on utilizing the COP
module to help software recover from runaway code.
WARMUP Function
The WARMUP function alternates the blinking of the two
LEDs ten times. This gives the LCD some time to warm up.
Then the function “warmup” calls the LCD initialization
function, “l(fā)cdinit”.
bintasc Function
The “binasc” function converts a binary value to its ascii
representation.
A/D Functions
The A/D functions are used to input the amplified voltage
from the pressure sensor from channel 0 of the A/D converter.
The function “adcbyti” will set the A/D control register, wait for
the A/D reading and load the data from the A/D data register
into the accumulator. The function “adcbyta” is used to obtain
an averaged A/D reading by calling “adcbyti” 256 times and
returning the resulting average in the accumulator.
LCD Functions
The LCD hardware is set up for multiplexing 3 pins from the
microcontroller using an 8–bit shift register. Channels 3, 4,
and 5 are used on port A for the LCD enable (E), the LCD reset
(RS), and the shift register clock bit, respectively. The clock
bit is used to manually clock data from channel 4 into the 8–bit
shift register. This is the same line as the LCD RS bit because
the MSB of the data is low for a command and high for data.
The RS bit prepares the LCD for instructions or data with the
same bit convention. When the 8 bits of data are available on
the output pins of the shift register, the LCD enable (E) is
toggled to receive the data.
The LCD functions consist of an initialization function
“l(fā)cdinit” which is used once when the system is started and five
output functions. The functions “l(fā)cdcmdo” and “l(fā)cdchro” both
send a byte of data. The function “shiftA” is called by both
“l(fā)cdcmdo” and “l(fā)cdchro” to manually shift 8 bits of data into the
shift register. The function “l(fā)cdnibo” converts the data to
binary before displaying. The “l(fā)cdbyto” displays a byte of data
by calling “l(fā)cdnibo” for each nibble of data. The function
“l(fā)cdstro” enables strings to be easily added to the software for
display. The function accepts a comma–delimited string of
data consisting of 1–2 commands for clearing the screen and
positioning the cursor. It then continues to output characters
from the string until the “@” symbol is found, signally the end
of the string.
Conclusion
The water level reference design uses a MPXM2010GS
pressure sensor in the low cost MPAK package, the low cost,
8–pin microcontroller, and a quad op–amp to amplify the
sensor output voltage. This system uses very few
components, reducing the overall system cost. This allows for
a solution to compete with a mechanical switch for water level
detection but also offer additional applications such as
monitoring water flow for leak detection, and the other
applications for smart washing machines.
F
Freescale Semiconductor, Inc.
n
.