I've written a function to perform a single conversion using the ADC12. I pass the channel that I want to convert into the function (for example, analog input A3). The function works the first time I call it, but I get inconsistent and wrong results on subsequent calls to the function. I've read through the users guide and do not see anything wrong with my code. Can someone please take a look at the code below? Thanks.
int ADCread(int Channel)
{
ADC12CTL0 |= ADC12ON; // ADC12 core on
ADC12CTL0 &= ~ADC12ENC; // Disable conversion
ADC12CTL1 |= ADC12SHP; // Use sample timer
ADC12CTL0 |= ADC12SHT02 + ADC12SHT01 + ADC12SHT00; // sample time = 192 clocks
ADC12MCTL0 |= ADC12SREF2; // select external reference
ADC12MCTL0 |= Channel; // select input channel
ADC12CTL0 |= ADC12ENC + ADC12SC; // enable and start conversion
while (ADC12CTL1 & ADC12BUSY); // Wait for conversion to complete
ADC12CTL0 &= ~ADC12ON; // ADC12 core off
return ADC12MEM0; // Return conversion result
}