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.

MSP430F6659 internal ADC Issue

Other Parts Discussed in Thread: MSP430F6659

Hi,

We are using MSP430F6659 controller in our project.

In our project we are using ADC12_A internal ADC for reading input

pressure sensor1   on P6.0 ADC Pin

Pressure sensor 2  on P6.1 ADC pin

Pressure sensor 3  on P6.2 ADC Pin

Pressure sensor 4  on P6.3 ADC Pin

current                       on P6.4 ADC Pin

feedback                   on  P6.5 ADC Pin

and internal Temperature sensor.

But we are not getting proper sample counts on P6.0 to P6.3, only on P6.4 and P6.5 pins getting proper counts with 10 sample floating.

Actually without connecting  pressure input also we are getting some sample counts  on these ADC pins(P6.0,P6.1,P6.3,P6.4).

We are not getting default counts when there is no input connection.

 Find the attached code we are using, for your  reference.

 

6787.ADC_Test.c
#include <msp430.h>

#define   Num_of_Results   8

volatile unsigned int A0results[Num_of_Results];
volatile unsigned int A1results[Num_of_Results];
volatile unsigned int A2results[Num_of_Results];
volatile unsigned int A3results[Num_of_Results];
volatile unsigned int A4results[Num_of_Results];
volatile unsigned int A5results[Num_of_Results];
volatile unsigned int A6results[Num_of_Results];

main()
{
	Init_ADC12();

	while(1)
	{
		CollectADCsamples();
	}

}

void Init_ADC12(void)
{
 
	P6SEL = 0x3F;                             // Enable A/D channel inputs

	REFCTL0 &= ~REFMSTR;
	ADC12CTL0 &= ~ADC12ENC;

	ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_15+ADC12REFON; // Turn on ADC12, extend sampling time
                                      					 // to avoid overflow of results
	ADC12CTL1 = ADC12SHP+ADC12CONSEQ_1+ADC12CSTARTADD_0;   // Use sampling timer, sequence of channels

	ADC12MCTL0 =  ADC12INCH_0 + ADC12SREF_2;    
	ADC12MCTL1 =  ADC12INCH_1 + ADC12SREF_2;   
	ADC12MCTL2 =  ADC12INCH_2 + ADC12SREF_2;   
	ADC12MCTL3 =  ADC12INCH_3 + ADC12SREF_2;        			
	ADC12MCTL4 =  ADC12INCH_4 + ADC12SREF_2;                 
	ADC12MCTL5 =  ADC12INCH_5 + ADC12SREF_2;
	ADC12MCTL6 =  ADC12INCH_10+ ADC12SREF_2+ADC12EOS;

	ADC12IE = 0x40;                           // Enable ADC12IFG.3
	ADC12CTL0 |= ADC12ENC;                    // Enable conversions
	ADC12CTL0 |= ADC12SC;                     // Start convn - software trigger

	//__bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, Enable interrupts
	__no_operation();                         // For debugger
  }


#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
  static unsigned int index = 0;
	
  switch(__even_in_range(ADC12IV,34))
  {
  case  0: break;                           // Vector  0:  No interrupt
  case  2: break;                           // Vector  2:  ADC overflow
  case  4: break;                           // Vector  4:  ADC timing overflow
  case  6: break;                           // Vector  6:  ADC12IFG0
  case  8: break;                           // Vector  8:  ADC12IFG1
  case 10: break;                           // Vector 10:  ADC12IFG2
  case 12: break;                                 // Vector 12:  ADC12IFG3
  case 14: break;                           // Vector 14:  ADC12IFG4
  case 16: break;									// Vector 16:  ADC12IFG5
  case 18: 
		A0results[index] = ADC12MEM0;           // Move A0 results, IFG is cleared
		A1results[index] = ADC12MEM1;           // Move A1 results, IFG is cleared
		A2results[index] = ADC12MEM2;           // Move A2 results, IFG is cleared
		A3results[index] = ADC12MEM3;           // Move A3 results, IFG is clearedA2results[index] = ADC12MEM2;           // Move A2 results, IFG is cleared
		A4results[index] = ADC12MEM4;           // Move A3 results, IFG is cleared
		A5results[index] = ADC12MEM5;           // Move A3 results, IFG is clearedA2results[index] = ADC12MEM2;           // Move A2 results, IFG is cleared

		l_Input_Sensor1_U16  = A0results[index];
		l_output_Sensor1_U16 = A1results[index];
		l_output_Sensor2_U16 = A2results[index];
		l_Spool_Sensor4_U16  = A3results[index];

		l_PVCount_U16 = A4results[index];
		l_SVCount_U16 = A5results[index];
		fl_temp_f     = A6results[index];

		index++;                                // Increment results index, modulo; Set Breakpoint1 here

		if (index == 8)
		{
		(index = 0);
		}
	
	break;									 // Vector 18:  ADC12IFG6
  case 20: break;                           // Vector 20:  ADC12IFG7
  case 22: break;                           // Vector 22:  ADC12IFG8
  case 24: break;                           // Vector 24:  ADC12IFG9
  case 26: break;                           // Vector 26:  ADC12IFG10
  case 28: break;                           // Vector 28:  ADC12IFG11
  case 30: break;                           // Vector 30:  ADC12IFG12
  case 32: break;                           // Vector 32:  ADC12IFG13
  case 34: break;                           // Vector 34:  ADC12IFG14
  default: break; 
  }  
}
void CollectADCsamples(void)
{
	static float  fl_PrevAverageSV_f=CLEAR;
    static float  fl_PrevAveragePV_f=CLEAR;
    
    static float  fl_PrevAverageinputsensor1_f=CLEAR;
    static float  fl_PrevAverageoutputsensor1_f=CLEAR;
    static float  fl_PrevAverageoutputsensor2_f=CLEAR;
    static float  PrevAverageSpool_Sensor4=CLEAR;

	fl_temp_f = (float)(((long)fl_temp_f - CALADC12_15V_30C) * (85 - 30)) /
	(CALADC12_15V_85C - CALADC12_15V_30C) + 30.0f;

	f1_temp_value_f = fl_temp_f;

	l_AverageSV_f = (fl_PrevAverageSV_f+((l_SVCount_U16-fl_PrevAverageSV_f)/1));       
	l_AveragePV_f = (fl_PrevAveragePV_f+((l_PVCount_U16-fl_PrevAveragePV_f)/1));

	l_Averageinputsensor1_f = (fl_PrevAverageinputsensor1_f+((l_Input_Sensor1_U16-fl_PrevAverageinputsensor1_f)/1));
	l_Averageoututsensor1_f = (fl_PrevAverageoutputsensor1_f+((l_output_Sensor1_U16-fl_PrevAverageoutputsensor1_f)/1));
	l_Averageoutputsensor2_f = (fl_PrevAverageoutputsensor2_f+((l_output_Sensor2_U16-fl_PrevAverageoutputsensor2_f)/1));
	l_AverageSpool_Sensor4 =   (PrevAverageSpool_Sensor4+((l_Spool_Sensor4_U16-PrevAverageSpool_Sensor4)/3));

	fl_temp_f1=fl_temp_f;
	fl_PrevAverageSV_f  =  l_AverageSV_f;
	fl_PrevAveragePV_f  = l_AveragePV_f;
		
	fl_PrevAverageinputsensor1_f=l_Averageinputsensor1_f;
	fl_PrevAverageoutputsensor1_f=l_Averageoututsensor1_f;
	fl_PrevAverageoutputsensor2_f=l_Averageoutputsensor2_f;
	PrevAverageSpool_Sensor4 = l_AverageSpool_Sensor4;

	ADC12CTL0 |= ADC12SC; 
	
}

Awaiting for your valuable response.

  • In your code, you are not synchronizing collecting the next set of sensor data with the end of a conversion sequence. Since you are not doing any averaging in the current code state, this only gives duplicate outputs, but once you do, the results will be wrong (aliasing effects).

    What do you mean with ‘default counts’?
    What values do you get (unmodified raw readings, to exclude calculation problems)
    What values do you expect? What is the external reference and what is your sensor output? Also, I don’t see you updating A6results, but then you use it.

**Attention** This is a public forum