DOC PREVIEW
NMT EE 308 - EE308 Lab 4 – Part 3

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 New Mexico Tech Spring 2011 Lab 4 – Part 3 9S12 Subsystems: Analog to Digital Converter Introduction and Objectives The analog to digital converter is described in the ATD Block Users Guide. The MC9SS12DP256B has two eight-channel ten-bit A/D converters, ATD0 and ATD1. The Dragon12-Plus board has a potentiometer connected to Bit AD7 of Port ATD0. We will use that potentiometer to put a variable analog signal into our MC9S12. (Remember that Bits AD0 and AD1, part of ATD0, are used by DBug 12 at start up to determine whether to execute DBug12, or to run code from EEPROM or the bootloader. Do not connect an analog signal to either of those two inputs.) The A/D converter also uses two dedicated pins VRH and VRL for high and low voltage references respectively. On your Dragon12-Plus MC9S12 board, VRH is connected to VCC (+5V), and VRL is connected to GND. When the MC9S12 is set up to do ten-bit (1024) conversions, an input voltage of VRL gives an output of 0x000, and an input of VRH gives an output of 0x3FF. (This assumes that the DJM bit of ATD1CTL5 register is set, so that the data is right-justified in the results registers.) If we measure a voltage between VRL and VRH, we can compute the value by simple ratios Vin = Z · (VRH − VVRL)/2n + VRL where Vin is the voltage, Z is the measurement value, n is the number of bits. For example, if VRH = 5V, VRL = 0V, n = 10 and the measurement is 0x2B0,i.e., (688)10, then the measured voltage is 688· (5 − 0)/1024+ 0 = 3.359V 1. The Lab 1. Set up the A/D converter so it measures in analog input on Port AN7. It should convert one channel (AD7), with a sequence of 8 conversions, and scan continuously. 2. Write a program which uses the TOF interrupt. The TOF should generate an interrupt every 174 ms. The TOF interrupt service routine should set a global flag which tells the main program the interrupt has occurred. In your TOF interrupt service you should read the value from the A/D conversion of Port AN7 and save it to a global variable. Display the A/D value to the first line of the LCD, and convert it to voltage in millivolts and write it to the second line of the LCD. 3. Vary the voltage on Bit AN7 by turning the potentiometer on the Dragon12-Plus board. Compare the value displayed on the terminal with multimeter measurements for several different input voltages. 4. The A/D conversion measurements can be improved by averaging the values in the registers ATD0DR0 through ATD0DR7. In an RTI routine, average the 8 values. Display the averaged ten bit value on theEE 308 New Mexico Tech Spring 2011 first line of the LCD and the converted value to millivolts to the second line. In the main program, write the averaged ten bit value to the terminal. Is the value more stable than it was when you displayed the unaveraged value? 5. The Dragon12-Plus board has a light sensor in the form of a photodiode, Q1. The output of the light sensor is connected to Bit 4 of ATD0. Modify your program from Part4 to display the output from Bit 4 of ATD0 rather than Bit 7 of ATD0. What is the voltage out of Q1 when the sensor is covered? What is the voltage out of Q1 when the sensor is exposed to a bright


View Full Document

NMT EE 308 - EE308 Lab 4 – Part 3

Documents in this Course
Load more
Download EE308 Lab 4 – Part 3
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view EE308 Lab 4 – Part 3 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EE308 Lab 4 – Part 3 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?