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.

LAUNCHXL-F28027F: ADC sample rate to 1MHz

Part Number: LAUNCHXL-F28027F
Other Parts Discussed in Thread: TMS320F28027

There is a problem about ADC sample rate with TMS320F28027.

Our goal is sampling analog signal at 1Mbps, so we modified ADC_SOC example. Sample rate in ADC_SOC is triggered by EPWM, SYSTEMCLK Frequency is 50MHz, and we set PWMCLkDiv to 1, TBPRT to 49,  CmpA to 25, used countup mode. The desired frequency of EPWM is TBCLK/(TBPRT+1), that is 1MHz.

But I set and clear gpio every time goes to adc_isr and captured by DSO, only about 122KHz detected. So confused.

Then I change TBPRT to 499 and 4999, frequency detected is 25KHz and 2.5KHz, which seems normal.

Can anyone help us to trigger adc with a sample rate at 1MHz. If EPWM can not genrate 1MHz trigger, is there anyother way to set the ADC working at 1MHz?

Thanks!

  • Hi Jiahui,

    Your ISR takes too long.  This device CPU is 60MHz, so taking an interrupt at 1MHz allows for only 60 cycles per ISR.  However, the context switch overhead is already 14 cycles each way (not including any overhead inserted by the compiler) so you really don't have much room to do anything in the ISR.  

    For a frequency that high you are much better off with a spin-wait loop along the lines of:

    //tight inner loop
    while(1){
    
       //(optional overflow check) if ADCINT is already set, loop is too slow 
       overflow |= Adca.ADCINT1;
       
       //wait for SOC to complete
       while(!Adca.ADCINT1);
       
       //clear ADCINT1 for next time
       Adca.ADCINT1CLEAR = 1;
       
       //toggle for each sample
       GpioDataRegs.GpioX.toggle = 1;
      
       //other code for each sample
       ...
    
    }  

    I'm also not sure if you are using driverlib or bitfield style coding (or a mix) but I'd recommend trying bitfields to toggle the GPIO, read the ADC results, and check the ADCINT flag as the efficiency difference will be important in a tight high-speed loop like this.   You should also crank up the compiler optimization settings to the max for speed.