This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Why would an MSP430x2xx ADC12 give wildly variable readings of a constant source?

Other Parts Discussed in Thread: MSP430F2619

I am using the ADC12 on an MSP430F2619 to sample, convert, and display an analog input signal.  

When I test the ADC12 using a stable external voltage source (verified stable by a digital multimeter), I get wildly varying codes, with much more variability than the +-5 bits the datasheet claims for total unadjusted error.  For example, here is a sequence of codes I read with the debugger with a constant voltage input:

2451, 2458, 2464, 2447, 2444, 2427, 2452, 2462, 2466, 2371, 2449, 2455, 2462

I know from the multimeter that none of the voltages are actually changing.  I am using an MSP-TS430PM64 target board and USB programmer, with all my signals routed through jumper wires.  

My question is whether there is anything in my code that would suggest software problem, or if this is a hardware issue.  What suggests to me that it isn't a hardware problem is that even with a constant voltage I can't get the ADC to convert properly.

Here is my ADC initialization:

void ConfigADC(void)

{

ADC12CTL0 = ADC12ON+SHT0_3+MSC;     // Turn on ADC12, sample and hold = 32 cycles, enable multiple conversions 

   ADC12CTL1 = SHP+CONSEQ_2;                 // SAMPCON from timer, conversion sequence repeat single channel

   ADC12IE = 0x01;                           // Enable interrupts on channel 1

ADC12MCTL0 = INCH_0 + SREF_2; // Mem0 sample channel 1, use external reference

P6SEL |= 0x01; // Set P6.1 to ADC input

}

Here are my timer and ADC interrupts, in this code I'm trying to take the median value to smooth the conversion, but the raw data is too variable for this to work.

// Timer_A2 interrupt service routine

#pragma vector=TIMERA0_VECTOR

__interrupt void Timer_A (void)

{

   ADC12CTL0 |= ENC + ADC12SC; // Enable ADC and start conversion

CCR0 += 4000;                            // Add time to CCR0

}

 

#pragma vector=ADC12_VECTOR

__interrupt void ADC12ISR (void)

{

  static unsigned int index = 0;

  static unsigned int i=0;

  static unsigned int temp=0;

static unsigned int codematrix [Num_of_Results];

  ADCcode = ADC12MEM0;

codematrix[index] = ADCcode;

i = index;

while(i>0){

if(codematrix[i]>codematrix[i-1]){

temp = codematrix[i-1];

codematrix[i-1]=codematrix[i];

codematrix[i] = temp;

i --;

} else{

i = 0;

}

}

  index = (index+1)%Num_of_Results;         // Increment results index, modulo; Set Breakpoint1 here

  if (index == 0){

   ADC12CTL0 &= ~ENC;

   ADCcode = codematrix[median_result];

   if(ADCcode != oldcode){

oldcode = ADCcode;

pow = 10 *(slope * ADCcode + intercept);

dispFloat(pow);

   ADCcodesum = 0;

  }  

}

 

Thanks, any help you can provide would be greatly appreciated!

**Attention** This is a public forum