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.

MSP432WARE: Trouble with ADC14 in MSP432P401R

Part Number: MSP432WARE

Hi all,

I am now creating a project with ADC14 but the AD result seems like a wrong value.

These are the code,

I have set P8SEL0 and P8SEL1 of ADC input channel.

unsigned long AD_Converter(unsigned short channel)
{
    unsigned long temp;
    unsigned short loop;

    temp=0;
    for(loop=0;loop<100;loop++)
    {
        __enable_irq();
        NVIC->ISER[0] |= 1 << ((ADC14_IRQn) & 31); //Enable ADC interrupt in NVIC module
        ADC14->CTL0 = ADC14_CTL0_SHT0_2 | ADC14_CTL0_SHP | ADC14_CTL0_ON; // Sampling time, S&H=16, ADC14 on
        ADC14->CTL1 = ADC14_CTL1_RES_3; // Use sampling timer, 14-bit conversion results
        switch(channel)
        {
            case Base:
                ADC14->MCTL[0] |= ADC14_MCTLN_INCH_21; // A21 ADC input select; Vref=AVCC
                break;
            case Back:
                ADC14->MCTL[0] |= ADC14_MCTLN_INCH_20; // A20 ADC input select; Vref=AVCC
                break;
            case Leg:
                ADC14->MCTL[0] |= ADC14_MCTLN_INCH_19; // A19 ADC input select; Vref=AVCC
                break;
        }
        ADC14->IER0 |= ADC14_IER0_IE0; // Enable ADC conv complete interrupt
        ADC_Flag=0;
        ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC; // Start sampling/conversion
        while(ADC_Flag==0); // Use sampling timer, 14-bit conversion results
        temp+=ADC14->MEM[0];
    }
    temp=temp/100;
    return temp;
}

void ADC14_IRQHandler(void)
{
    ADC_Flag=1;
    ADC14->IER0 &= ~ADC14_IER0_IE0; // Disable ADC conv complete interrupt
}

The schematic wiring is a 15K-Ohm resistor and a VR connected to 3V3 power and GND.

Using ADC14 to transfer analog signal to digital signal.

I do not change VR but I got difference values of the ADC result.

Even I add a capacitance between ADC input channel and GND.

I have used a meter to measure the voltage of ADC channel and the voltage is the same value.

The following figures are the screenshot of the CCS debug environment.

I did not adjust the VR and the voltage value was not changed but I got the difference AD result.

How can I solve the problem?

Are there any mistake with my code?

BR,

Yu-Chuan, Chen

  • Hi Yu-Chuan,

      MSP432P is no longer available from ti.com and therefore the support for this device will be limited. With that said, I will suggest you please:

     - try some of the examples in MSP432WARE library? Will you see the same problem? If they work then reference these examples to build your application.

     - If these examples also fail on your board then it is likely a hardware issue. In that case, do you have the problem on only one channel or other channels are reading wrong values too? Please try other channels to confirm. 

      - Can you repeat the same problem on a different board?

  • I'm not sure I understand your wiring, but if you have 15K input impedance coming into the pin then SHT0=2 is probably too short for the sampling capacitor to settle.

    TRM (SLAU356I) Sec 22.2.6.3 gives a formula for the required sample/hold time based on the input impedance. As a quick experiment, try setting SHT0 to something large and see if your symptom changes.

  • Hi Charles,

    Thanks for the reply.

    How can I get into the MSP432WARE library?

    I usually get sample code on each MCU of ti.com technical support.

    BTW,

    I have solved the problem with the following method.

    Using multi-channel sampling and get every result of AD channels I have used.

    And I can get the correct AD result for the application.

    unsigned long AD_Converter(unsigned short channel)
    {
    	unsigned long temp,temp0,temp1,temp2;
    	unsigned short loop;
    
    	temp0=0;
    	temp1=0;
    	temp2=0;
    	for(loop=0;loop<100;loop++)
    	{
    		__enable_irq();
    		NVIC->ISER[0] |= 1 << ((ADC14_IRQn) & 31);							//Enable ADC interrupt in NVIC module
    
    	    ADC14->CTL0 = ADC14_CTL0_ON |										//ADC14 on
    	            ADC14_CTL0_MSC |											//ADC14 multiple sample and conversion
    	            ADC14_CTL0_SHT0__192 |										//extend sampling time
    	            ADC14_CTL0_SHP |											//ADC14 sample-and-hold pulse-mode select
    	            ADC14_CTL0_CONSEQ_3;										//Repeat-sequence-of-channels
    		//ADC14->CTL1 = ADC14_CTL1_RES_2;										// Use sampling timer, 12-bit conversion results
    		ADC14->CTL1 = ADC14_CTL1_RES_3;										// Use sampling timer, 14-bit conversion results
    		ADC14->MCTL[0] |= ADC14_MCTLN_INCH_21;								// A21 ADC input select; Vref=AVCC
    		ADC14->MCTL[1] |= ADC14_MCTLN_INCH_20;								// A20 ADC input select; Vref=AVCC
    		ADC14->MCTL[2] |= ADC14_MCTLN_INCH_19 | ADC14_MCTLN_EOS;			// A19 ADC input select; Vref=AVCC, end seq.
    		ADC_Flag=0;
    		ADC14->IER0 |= ADC14_IER0_IE2;										// Enable ADC conv complete interrupt
    		ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC;						// Start sampling/conversion
    		Back_Timer=0;
    		while(ADC_Flag==0)								// Use sampling timer, 14-bit conversion results
    		{
    			if(Back_Timer>1)//avoid stuck
    				break;
    		}
    		temp0+=ADC14->MEM[0];
    		temp1+=ADC14->MEM[1];
    		temp2+=ADC14->MEM[2];
    	}
    	temp0=temp0/100;
    	temp1=temp1/100;
    	temp2=temp2/100;
    	switch(channel)
    	{
    		case Base:
    			temp = temp0;
    		break;
    		case Back:
    			temp = temp1;
    		break;
    		case Leg:
    			temp = temp2;
    		break;
    	}
    	return temp;
    }

    BR,

    Yu-Chaun, Chen

  • Hi Norten,

    How can I get into the MSP432WARE library?

      Please download MSP432P SimpleLink SDK from https://www.ti.com/tool/download/SIMPLELINK-MSP432-SDK/3.40.01.02

  • Hi Charles,

    Thanks for the reply.

    I have installed the MSP432P SimpleLink SDK.

    I prefer using classic way to coding, so I could not get the meanings of the code without registers setting.

    Although that, I using another way for the same application and it work.

    The code is in the reply that I pressed resolved, thanks for your help.

    I would check the example code in the SimpleLink SDK.

    BR,

    Norton