PLEASE (NEATLY) SHOW ALL WORK! Comment All Code Well. Do Not Make The
PLEASE (NEATLY) SHOW ALL WORK! Comment All Code Well. Do Not Make The
PLEASE (NEATLY) SHOW ALL WORK! Comment all code well. Do not make the
grader guess what your doing! All code should be typed.
To ensure proper grading & return, you must attach the included cover sheet!
Refererence: Davies Ch 9.2-3, 9.7, MSP430x55xx User's Guide Ch. 28, class notes,
examples, TI code examples
a. Which of the ACD12_A's analog input channels (ADC12NCHx) are external input
channels? List the Ports and Pins each of these input channels uses when selected to be
in function mode (i.e. PxSEL.y = 1)
b. Which of the ACD12_A's analog input channels (ADC12NCHx) are internal analog
inputs? List what each internal input channel is attached to.
c. Now, for the ADC12_A as configured below what are the specific (10 pts)
ADC12CTL0 = ADC12SHT0_9|ADC12SHT1_9|ADC12REFON|ADC12ON;
ADC12CTL1 = ADC12SHP;
P7SEL |= BIT0;
ADC12MCTL7 = ADC12SREF_1 + ADC12INCH_12;
ADC12CTL0 |= (ADC12SC|ADC12ENC);
a. To what analog input channel is the variable arm of the potentiometer connected?
And what digital IO port and pin does the potentiometer use?
b. Explain the operation of the potentiometer circuit. Specifically, to what logic value
must the digital IO pin be set for a voltage drop to be evident across the
potentiometer?
c. Write a CCS C function that will return read the value of the scroll wheel. Your
function must configure the digital IO pin and set its value, and then use ADC12_A to
read in from the potentiometer (single channel, single conversion) using analog Vcc as
Vref+ and ground as Vref-.
a) What is the Full Scale Range of the accelerometer in g's? What is the FSR of the
ADC12 in volts as it is configured above?
b) Given the settings in the code above, what is the resolution (in volts/bit) of ADC12_A?
c) What is the output of the ADC12 in hex for tilt readings of 0o, 45o, 90o and 180o.
d) Given the information and the diagram above, write the C function calc_tilt()
that converts the ADC12 output in adc_tilt to a tilt angle from 0 to 180 degrees.
You may assume the C math library <math.h> is available. Code must be typed to be
graded.
e) Can your tilt measurement system detect a 1 degree tilt from horizontal (0o to 1o)?
What is the smallest tilt from horizontal that you can measure?
void tiltMeter()
{
unsigned int adc_tilt;
P6SEL |= BIT6;
ADC12CTL0 = ADC12SHT0_9|ADC12REFON|ADC12REF2_5V|ADC12ON;
ADC12CTL1 = SHP;
ADC12MCTL0 = SREF_1 + INCH_6;
calc_tilt(adc_tilt);
...
}
You must document the following in your solution -- what input channels
(ADC12INCHx) are used, what memory conversion registers are used, are you using
single channel or sequential channel mode, continuous or one-shot conversion. Also list
you choice for the reference voltage Vref. You may use code similar to the TimerA2 stop
watch example to measure time. You do not have to use ADC12_A interrupts but you
may. As is often the case, there are multiple approaches to this problem.
ECE2049 Homework #4
Submitted by:__________________________________
Date:_______________________________
Question Grade
1-20
2-30
3-25
4-25
Total: