// ek307ad.c // This file contains several useful commands that you can insert in your code // so that you can perform analog-to-digital (A/D) conversion using the MSP430 P1DIR=0 // Assumes pin P1.0 is used as the analog input. // Add these SETUP COMMANDS to the main(void) part of your program: //Set conversion to single channel, and continuous-sampling mode ADC10CTL1 |= CONSEQ1; //Set the Sample-and-Hold time, specify 10-bit conversion, and continuous sampling: ADC10CTL0 |= ADC10SHT_2 + ADC10ON + MSC; //Choose P1.0 (channel A0) as the analog input pin: ADC10AE0 |= 1; //Add these executable commands to the INTERUPT main portion) of your code: // Start A/D conversion; Result appears in memory variable "ADC10MEM" ADC10CTL0 |= ADC10SC + ENC; // SET VARIABLE n TO THE RESULT OF THE A/D CONVERSION: n = ADC10MEM; // (NOTE THAT the variable ADC10MEM is a signed integer type, // so its maximum positive value is 512.)