EE 308 - LAB 11 Preliminary versiom from 2001
The 68HC12 Analog to Digital Converter
Note: Do this lab without your memory expansion board.
The analog to digital converter is described in Section 17 of the M68HC12B
Family Manual. The analog to digital converter can have up to eight inputs on
pins Port AD0 through Port AD7. (Ports AD0 and AD1 are used by
DBug-12 at startup to determine whether to execute DBug12 or run code from
EEPROM or the bootlaoder. You should not use Ports AD0 or AD1 as
A/D inputs unless all other six inputs are being used.) The A/D converter also
uses two dedicated pins VRH and
VRLfor high and low voltage references respectively.
On your HC12 board, VRHis connected to
VCC, and VRL is connected 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 = 0 volts, and the
measurement is 0x2B0, then the measured voltage is
Note that the above equations apply when the A/D converter is used in 10-bit
mode. When used in 8-bit mode, replace the 1023 by 255.
To make sure that you do not damage the A/D converter on your HC12
you should be sure to do the following:
-
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 allow the voltage at the A/D pin to go below
VRL.
- 1.
- Write a program to take a 0 to 5 Volt analog input from PAD3, convert
it to an 8-bit digital number, and
output the 8 bits of the converted digital value on Port A
of your HC12. Set the A/D converter to do continuous conversion of the single
channel AD3. Thus, all of the result registers will contain converted values
from channel 3.
Use your LED's to display one of the result registers. Display the A/D output
once every 64 ms. Use the RTI function of the HC12 to do this.
- 2.
- Connect a voltage from a pot to PAD3, so you can vary PAD3 from 0 to 5 Volts.
Compare the value displayed on the LEDs with multimeter measurements for
several different input voltages.
- 3.
- The A/D conversion measurements can be improved by averaging the values in
the registers ADR0H through ADR7H. Display the average of the 8 result
registers on Port B. Is the value more stable than it was when you displayed
the unaveraged value?
- 4.
- Change your program to do the conversions in 10-bit mode.
With an input voltage of about 2.5 volts, record the values in the eight
results register ADR0 through ADR7. How much do they vary?
Bill Rison
2000-04-14