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.

TMS320F28379D: ADC reading too noisy

Part Number: TMS320F28379D

Hi all, I purchased a C2000 microcontroller with its controlcard as well as the experimenter's kit. When I tried to use ADC of the MCU, I met following problem:

I tried to connect the ADC to a wave generator. The waveform was generated by National Instrument's DAQ NI-USB-6356 (analog output).

Basically, I copied the example code for the MCU. I set the ADC to continuous sampling mode, and stored 512 sampling points to the memory. Then, I use the UART port to show the value of the 512 points to the terminal (which is on my host computer).

I used 16bit, single ended ADC setup. The connection is illustrated below:

I found the ADC's result was quite noisy. The result is shown below:

 Here is the code I used:

    do
    {

        //
        //enable ADCINT flags
        //
		EALLOW;
        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;
        AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;
        AdcaRegs.ADCINTSEL3N4.bit.INT3E = 1;
        AdcaRegs.ADCINTSEL3N4.bit.INT4E = 1;
        AdcaRegs.ADCINTFLGCLR.all = 0x000F;
		EDIS;

        //
        //initialize results index
        //
        resultsIndex = 0;

        //
        //software force start SOC0 to SOC7
        //
        AdcaRegs.ADCSOCFRC1.all = 0x00FF;

        //
        //keep taking samples until the results buffer is full
        //
        while(resultsIndex < RESULTS_BUFFER_SIZE)
        {
            //
            //wait for first set of 8 conversions to complete
            //
            while(0 == AdcaRegs.ADCINTFLG.bit.ADCINT3);

            //
            //clear both INT flags generated by first 8 conversions
            //
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT3 = 1;

            //
            //save results for first 8 conversions
            //
            //note that during this time, the second 8 conversions have
            //already been triggered by EOC6->ADCIN1 and will be actively
            //converting while first 8 results are being saved
            //
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT0;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT1;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT2;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT3;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT4;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT5;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT6;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT7;

            //
            //wait for the second set of 8 conversions to complete
            //
            while(0 == AdcaRegs.ADCINTFLG.bit.ADCINT4);

            //
            //clear both INT flags generated by second 8 conversions
            //
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT4 = 1;

            //
            //save results for second 8 conversions
            //
            //note that during this time, the first 8 conversions have
            //already been triggered by EOC14->ADCIN2 and will be actively
            //converting while second 8 results are being saved
            //
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT8;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT9;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT10;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT11;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT12;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT13;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT14;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT15;
        }

        //
        //disable all ADCINT flags to stop sampling
        //
		EALLOW;
        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 0;
        AdcaRegs.ADCINTSEL1N2.bit.INT2E = 0;
        AdcaRegs.ADCINTSEL3N4.bit.INT3E = 0;
        AdcaRegs.ADCINTSEL3N4.bit.INT4E = 0;
		EDIS;

		for(i=0;i<RESULTS_BUFFER_SIZE;i++)
		{
	        scia_xmit_int(AdcaResults[i]);
		}

        //
        //at this point, AdcaResults[] contains a sequence of conversions
        //from the selected channel
        //

        //
        //software breakpoint, hit run again to get updated conversions
        //
        //asm("   ESTOP0");

	    scia_xmit('\n');
	    scia_xmit('\n');
	    scia_xmit('\n');
		DELAY_US(5000000);
    }while(1);    do
    {

        //
        //enable ADCINT flags
        //
		EALLOW;
        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;
        AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;
        AdcaRegs.ADCINTSEL3N4.bit.INT3E = 1;
        AdcaRegs.ADCINTSEL3N4.bit.INT4E = 1;
        AdcaRegs.ADCINTFLGCLR.all = 0x000F;
		EDIS;

        //
        //initialize results index
        //
        resultsIndex = 0;

        //
        //software force start SOC0 to SOC7
        //
        AdcaRegs.ADCSOCFRC1.all = 0x00FF;

        //
        //keep taking samples until the results buffer is full
        //
        while(resultsIndex < RESULTS_BUFFER_SIZE)
        {
            //
            //wait for first set of 8 conversions to complete
            //
            while(0 == AdcaRegs.ADCINTFLG.bit.ADCINT3);

            //
            //clear both INT flags generated by first 8 conversions
            //
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT3 = 1;

            //
            //save results for first 8 conversions
            //
            //note that during this time, the second 8 conversions have
            //already been triggered by EOC6->ADCIN1 and will be actively
            //converting while first 8 results are being saved
            //
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT0;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT1;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT2;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT3;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT4;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT5;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT6;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT7;

            //
            //wait for the second set of 8 conversions to complete
            //
            while(0 == AdcaRegs.ADCINTFLG.bit.ADCINT4);

            //
            //clear both INT flags generated by second 8 conversions
            //
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;
            AdcaRegs.ADCINTFLGCLR.bit.ADCINT4 = 1;

            //
            //save results for second 8 conversions
            //
            //note that during this time, the first 8 conversions have
            //already been triggered by EOC14->ADCIN2 and will be actively
            //converting while second 8 results are being saved
            //
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT8;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT9;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT10;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT11;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT12;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT13;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT14;
            AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT15;
        }

        //
        //disable all ADCINT flags to stop sampling
        //
	EALLOW;
        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 0;
        AdcaRegs.ADCINTSEL1N2.bit.INT2E = 0;
        AdcaRegs.ADCINTSEL3N4.bit.INT3E = 0;
        AdcaRegs.ADCINTSEL3N4.bit.INT4E = 0;
	EDIS;

		for(i=0;i<RESULTS_BUFFER_SIZE;i++)
		{
	        scia_xmit_int(AdcaResults[i]);
		}

        //
        //at this point, AdcaResults[] contains a sequence of conversions
        //from the selected channel
        //

        //
        //software breakpoint, hit run again to get updated conversions
        //
        //asm("   ESTOP0");

	    scia_xmit('\n');
	    scia_xmit('\n');
	    scia_xmit('\n');
		DELAY_US(5000000);
    }while(1);

  • Hi Zhaokai,

    This is just an ADC, so you probably need to condition the input signal locally on the ControlCard base (using an op-amp to buffer the signal). Also, are you using shielded cables to go between the signal source and the ADC?

    The other thing to look at is this erratum for the ControlCard:
    e2e.ti.com/.../576301