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.

ADC total converting time

Hi all,

When i debug my program i found that ADC in 28335 is very strange.

This is my code in timer0 (with period is 250us)

unsigned int i;

	// Reset ADC_value before read
	ADC_value[0]	= 0;
	ADC_value[1] 	= 0;
	ADC_value[2] 	= 0;
	ADC_value[3] 	= 0;
	ADC_value[4]	= 0;
	ADC_value[5]	= 0;
	ADC_value[6] 	= 0;
	ADC_value[7] 	= 0;

	// Start SEQ1 convert
	AdcRegs.ADCTRL2.all = 0x2000;
// BP1
	for (i = 0; i < 65; i++)
	{
//BD2
		 while (AdcRegs.ADCST.bit.INT_SEQ1== 0) {} // Wait for interrupt
		 	 AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;

		 // Get ADC value
		 // Read AdcMirror.ADCRESULT register faster than AdcRegs.ADCRESULT
		 ADC_value[0]	+= (float)(AdcMirror.ADCRESULT0);
		 ADC_value[1] 	+= (float)(AdcMirror.ADCRESULT1);
		 ADC_value[2] 	+= (float)(AdcMirror.ADCRESULT2);
		 ADC_value[3] 	+= (float)(AdcMirror.ADCRESULT3);
		 ADC_value[4]	+= (float)(AdcMirror.ADCRESULT4);
		 ADC_value[5]	+= (float)(AdcMirror.ADCRESULT5);
		 ADC_value[6] 	+= (float)(AdcMirror.ADCRESULT6);
		 ADC_value[7] 	+= (float)(AdcMirror.ADCRESULT7);
	}

	// Get average value
// BP3
	ADC_value[0]	= ADC_value[0] / 65;
	ADC_value[1] 	= ADC_value[1] / 65;
	ADC_value[2] 	= ADC_value[2] / 65;
	ADC_value[3] 	= ADC_value[3] / 65;
	ADC_value[4]	= ADC_value[4] / 65;
	ADC_value[5]	= ADC_value[5] / 65;
	ADC_value[6] 	= ADC_value[6] / 65;
	ADC_value[7] 	= ADC_value[7] / 65;

At the first time, i put break point at BP1 and BP3, at DP1 timer0 value is 0x9200, press resume program stop at BP3 with timer0 value is 1A00 --> spent 0x7800 for for function. It is too long.

After that, i put only one break point at BP2 so i need press 65 times to run for function. when program run at BP3 timer0 value is 5400 --> spent 3E00 for for function and this value is match with my configuration for ADC module.

Why two values are different.

And in fact, my code run with value is 0x7800. Which this value, ADC module run too slow. Why is it.

Thanks for helping me.

  • Hi Phien,

    What ADC clock value are you using?

    Regards,

    Gautam

  • Hi Gautam,

    I use 150MHz,  ADC module configuration as: 12.5MHz and S/H is 3.

    Thank you,

    Phien

  • I use 150MHz,  ADC module configuration as: 12.5MHz and S/H is 3.

    Then ADC clock is pretty fast! Also, instead of using timers try with toggling GPIOs before and after conversions. There's one more alternate; you can use Clock profiler for check the conversion time.

    Regards,

    Gautam

  • Hi Gautam, 

    I try with ADC clock is 6.25MHz and S/H is 16, value in timer counter is the same. And if i increase '65' to '70' or more, my program can not return main because time need run program in timer more than 250us. I don't understand with  a very fast ADC module why it needs very long time to read ADC.

    Best regards,

    Phien

  • I don't understand with  a very fast ADC module why it needs very long time to read ADC.

    Phien, did you confirm the same using Clock profiler?  250us is very very high!

  • Hi Gautam,

    This is my code config for timer0:

    void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)
    {
        Uint32  temp;
    
        // Initialize timer period:
        Timer->CPUFreqInMHz = Freq;
        Timer->PeriodInUSec = Period;
        temp = (long) (Freq * Period);
        Timer->RegsAddr->PRD.all = temp;
    
        // Set pre-scale counter to divide by 1 (SYSCLKOUT):
        Timer->RegsAddr->TPR.all  = 0;
        Timer->RegsAddr->TPRH.all  = 0;
    
        // Initialize timer control register:
        Timer->RegsAddr->TCR.bit.TSS = 1;      // 1 = Stop timer, 0 = Start/Restart Timer
        Timer->RegsAddr->TCR.bit.TRB = 1;      // 1 = reload timer
        Timer->RegsAddr->TCR.bit.SOFT = 1;
        Timer->RegsAddr->TCR.bit.FREE = 1;     // Timer Free Run
        Timer->RegsAddr->TCR.bit.TIE = 1;      // 0 = Disable/ 1 = Enable Timer Interrupt
    
        // Reset interrupt counter:
        Timer->InterruptCount = 0;
    }
    
    // This is code config for timer in main.c
    ConfigCpuTimer(&CpuTimer0, 150, 250);

    And code select clock for chip i used as example in control suite only change target is F28335.

    Please help me.

  • That's fine Phien! I want you to check with clock profiler. Check this link:

    http://processors.wiki.ti.com/index.php/Profile_clock_in_CCS

    Regards,

    Gautam

  • Thank you very much Gautam, 

    I will check it.

  • No problem. Do let me know!

  • Hi Gautam,

    I checked it with clock profiler and this is result:

    When I use number of ADC sample is 1 in for function: it's 865, when number of sample is 10: it's 11677.

    And here is the detail for number of sample is 1:

    unsigned int i;                                 -->0(number of clock)
    
        // Reset ADC_value before read
        ADC_value[0]    = 0;                        -->6
        ADC_value[1]    = 0;                        -->13
        ADC_value[2]    = 0;                        -->18
        ADC_value[3]    = 0;                        -->19
        ADC_value[4]    = 0;                        -->24
        ADC_value[5]    = 0;                        -->25
        ADC_value[6]    = 0;                        -->30
        ADC_value[7]    = 0;                        -->31
    
        // Start SEQ1 convert
        AdcRegs.ADCTRL2.all = 0x2000;               -->36
    // BP1
        for (i = 0; i < 1; i++)                        -->38                        -->254(check condition of i at the second time i=1)
        {
    //BD2
             while (AdcRegs.ADCST.bit.INT_SEQ1== 0) {} // Wait for interrupt                        -->55
                 AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;                        -->72
    
             // Get ADC value
             // Read AdcMirror.ADCRESULT register faster than AdcRegs.ADCRESULT
             ADC_value[0]   += (float)(AdcMirror.ADCRESULT0);                        -->78
             ADC_value[1]   += (float)(AdcMirror.ADCRESULT1);                        -->100
             ADC_value[2]   += (float)(AdcMirror.ADCRESULT2);                        -->120
             ADC_value[3]   += (float)(AdcMirror.ADCRESULT3);                        -->146
             ADC_value[4]   += (float)(AdcMirror.ADCRESULT4);                        -->166
             ADC_value[5]   += (float)(AdcMirror.ADCRESULT5);                        -->188
             ADC_value[6]   += (float)(AdcMirror.ADCRESULT6);                        -->208
             ADC_value[7]   += (float)(AdcMirror.ADCRESULT7);                        -->234
        }
    
        // Get average value
    // BP3
        ADC_value[0]    = ADC_value[0] / 1;                        -->266
        ADC_value[1]    = ADC_value[1] / 1;                        -->352
        ADC_value[2]    = ADC_value[2] / 1;                        -->433
        ADC_value[3]    = ADC_value[3] / 1;                        -->518
        ADC_value[4]    = ADC_value[4] / 1;                        -->599
        ADC_value[5]    = ADC_value[5] / 1;                        -->684
        ADC_value[6]    = ADC_value[6] / 1;                        -->765
        ADC_value[7]    = ADC_value[7] / 1;                        -->850

    Best regards,

    Phien

  • When I use number of ADC sample is 1 in for function: it's 865, when number of sample is 10: it's 11677.

    865 = 865*6.67nS = 5.7uS

    11677 = 11677*6.67nS = 77uS

    This seems fine but still feel its a bit more.

    Regards,

    Gautam