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. (Port~E0 is used by BUFFALO at startup to determine whether to execute BUFFALO or EEPROM code. You should not use Port~E0 as an A/D input unless all other seven inputs are being used.) The A/D converter also uses two dedicated pins VRL and VRH for high and low voltage references respectively. On your HC11 board, VRH is connected to VCC, and VRL is connedted to GND. 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

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

There are two cautions from Section 12.3 of the Reference Manual you should be aware of:

  1. 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.

  2. 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.

  3. 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.)

  4. 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.

  5. 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, < >
Tue Apr 6 1998
© 1998, New Mexico Tech