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.

TMS320F28388D: Changing the ADC resolution does not change the processing time.

Part Number: TMS320F28388D


I am investigating ADC using TMS320F28388D.
The time to write the result register after AD conversion returns the same time for both 12bit and 16bit.

Time from trigger to interrupt flag check
  12bit = 1.8us
  16bit = 1.8us


After the ADC is completed, processing proceeds based on the data written to the result register.
The interrupt is set to occur at the timing when the result register is written. (INTPULSEPOS = 1)

The interrupt is not processed, but only the interrupt flag is used to make a decision.
There should be a change in the conversion time with the 12-bit/16-bit settings, but the interrupt timing does not change.
Is there something I am missing in the settings?

==================================================================

(Setting)

EALLOW;
// write configurations
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to / 4
ADC_setMode(ADCA_BASE, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED); // !!!!!!!! or 16bit
EDIS;

uint16_t acqps_A;

if ( 0 == AdcaRegs.ADCCTL2.bit.RESOLUTION ) { // 0 = 12bit, 1 = 16bit
acqps_A = 19; // margin(5) + 14 = (-1) + 15 = sysclk / 75ns(DataSheet)
}
else { //resolution is 16-bit
acqps_A = 68; // margin(5) + 63 = (-1) + 64 = sysclk / 320ns(DataSheet)
}

EALLOW;

// ADC-A
AdcaRegs.ADCSOCPRICTL.bit.SOCPRIORITY = 0x2;

AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2;
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps_A;
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0x5;
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 1;
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

AdcaRegs.ADCSOC1CTL.bit.CHSEL = 3;
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps_A;
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 0x5;
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;
AdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 1;
AdcaRegs.ADCINTSEL1N2.bit.INT2CONT = 1;
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;

AdcaRegs.ADCSOC2CTL.bit.CHSEL = 4;
AdcaRegs.ADCSOC2CTL.bit.ACQPS = acqps_A;
AdcaRegs.ADCSOC2CTL.bit.TRIGSEL = 0x5;

AdcaRegs.ADCSOC3CTL.bit.CHSEL = 5;
AdcaRegs.ADCSOC3CTL.bit.ACQPS = acqps_A;
AdcaRegs.ADCSOC3CTL.bit.TRIGSEL = 0x5;

// Set pulse positions to late
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Interrupt Pulse Generate Timing. Conversion End Timing.
// power up the ADCs
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;

EDIS;

DEVICE_DELAY_US(1000);
=================================================================

(process)

!! TRIGGER !!
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;
Timer Start

while (1) { if ( AdcaRegs.ADCINTFLG.bit.ADCINT2 == 1 ) break; }

Timer End

=================================================================

  • Hi Guoki,

    How were you able to measure 1.8uS exactly?  Please refer to the timing diagrams in TRM section 20.  ADC throughput calculation starts from when SOC trigger is received.  This will connect the input channel to the ADC sampling capacitor for charging for a duration of ACQPS+1 (ADC H+H in the timing diagram) and after this duration has passed the sampling switch is opened and the charge in the sampling capacitor will be quantized by the ADC module for the duration of tLAT (in the timing diagram).  After tLAT, the ADC results will be available in the ADC results register.  There are two timing tables in the same TRM section, one for 12-bit and another for 16-bit mode and you can get tLAT information from the timing tables depending on ADC prescaler used.


    Based from the settings you provided (and assuming that SYSCLK is 200MHz, 5nS period) and using the timing diagrams and tables, the time it takes for the results to be available in the results register is given below:

    12-bit: t = ((ADC S+H) + tLAT) * 5nS = (19 + 1 + 44)*5nS = 330nS

    16-bit: t = ((ADC S+H) + tLAT) * 5nS = (68 + 1 + 120)*5nS = 945nS

    If you are not getting above conversion times, check that your measurement methodology is measuring the actual time from when trigger is provided until time when interrupt from end of conversion (tEOC) has occured.  There are probably some overhead that are included in your routine that adds up to the conversion time that you are measuring.

    Regards,

    Joseph

  • Hi Joseph.

    I use an oscilloscope to check.
    It outputs the "Timer Start - Timer End" time described in (Process) in the main text.
    Regardless of the resolution, the same time is output here.

    I thought the interrupt flag would turn ON in "330ns*2" time when using 12bit, but
    It is taking the same time as at 16bit.

    As for the trigger, it is based on PWM, but in the form that the PWM interrupt operates at the same time as the trigger.
    ADC interrupt flag clearing is done in that.
    The PWM cycle is 25us cycle.

    (In 12bit, ADCINT1 == 1 before initializing the ADC flag, so the judgment is performed only by ADCINT2.)
    ================================================================
    __interrupt void epwm1_isr()
    {
      GpioDataRegs.GPASET.bit.GPIO21 = 1; // Timer Start

      /* ADC Interrupt flag Clear. */
      AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
      AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;

      flag1 = 1;

      // Clear INT flag for this timer
      EPwm1Regs.ETCLR.bit.INT = 1;
      // Acknowledge this interrupt to receive more interrupts from group 3
      PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
    }

    main()
    {
      (Setting)

      while(1)
      {
        if( flag1 == 1 ){
          while (1) { if ( AdcaRegs.ADCINTFLG.bit.ADCINT2 == 1 ) break; } // check ADCINT2
          GpioDataRegs.GPACLEAR.bit.GPIO21 = 1; // Timer End
          flag = 0;
        }
      }
    ]
    =================================================================

    Since this is the first process after the interrupt flag,
    and since there is no other interrupt present,
    I do not expect it to be disturbed.

    Regards.

  • Hi Gouki,

    There will be latency in the epwm ISR (clearing/acknowledging interrupt) that happens after start timer is set (GPIO21).  It might not be the best place to put the start marker.  One option you can try too is use external trigger (TRIGSEL = 4) where you can either use a GPIO externally toggle the conversion and use it as well as the timer marker.

    Regards,

    joseph

  • Hi Joseph.

    I checked the ADC processing time in main without interrupts.
    I confirmed that the ADC processing time is changing in 12b/16b.
    It just so happens that the processing time is exactly the same for 12b/16b, but in fact it seems to be changing properly.

    I think my code is doing something wrong around PWM.
    Thx regards.