EE 308 -- LAB 12
The 68HC11 Analog to Digital Converter
The analog to digital converter is described in Section 12 of the HC11
reference manual. The analog to digital converter can have up to eight
inputs on pins Port E0 through Port E7. The A/D converter also uses two
dedicated pins VRL and VRH for high and low voltage references
respectively. An input voltage of VRL gives an output of 0x00, and an
input of VRH gives an output of 0xFF. If we measure a voltage between
VRL and VRH, we can compute the value by simple ratios
measurement * (V - V )
RH RL
voltage = -------------------------- + V
255 RL
For example, if VRH = 5 volts, and VRL volts, and the
measurement is 0xAC, then the measured voltage is
172 * (5V - 0V)
voltage = ------------------ + 0V = 3.37 V
255
There are two cautions from Section 12.3 of the Reference Manual you should be
aware of:
-
You should have a 1 to 10 kOhm resistor in series with the A/D
input pin to prevent damage if your input voltage rises above VRH.
-
You should never, never allow the voltage at the A/D pin to go below
VRL.
- Write a program to take a 0 to 5 Volt analog input from PE3 and
output the converted digital value on Port B of your 6821 PIA. Use your
LED's to display this value.
-
Connect a voltage from a pot to PE3, so you can vary PE3 from 0 to 5 Volts.
Compare the value displayed on the LEDs with multimeter measurements for
several different input voltages.
-
Write a program which uses the TOI interrupt. The TOI interrupt service
routine should increment a counter (or generate some other pattern of
your choice). If PIA Port A0 is high display this pattern on PIA Port B.
If PIA Port A0 is low, read the A/D converter for input PE3 and display
this on PIA Port B. (Connect a dip switch to PIA Port A so you can
change it.)
-
Add a TOC routine to output a 732 Hz square wave on OC2. Show this on the
logic analyzer while simultaneously doing the A/D conversion and the TOI
pattern display.
-
The A/D conversion measurements can be improved by averaging the values in
the registers ADR1 through ADR4. In your TOI routine, average the 4 values.
Display the average value if PIA Port A1 is low, and display a single
value if PIA Port A1 is high. Are the LEDs more stable in the averaged mode?
Bill Rison,
<rison@ee.nmt.edu >
Wed Apr 9 1997
© 1997, New Mexico Tech