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.

Help using the library sprc081 to perform a FFT.

Hi, I am a new programer on the DSP F2812, i trying to use the library sprc081 to implement FFT for detect frequency. I did what the sample says but i don´t have success. I can see that only acq.input  and the flags are working  but nothing on the fft. I apreciate any advice to how perform the FFT over F2812 or an example. Thanks in advance.

#include "DSP281x_Device.h"  
#include "IQmathLib.h"
#include "fft.h"

#define N 128                         //FFT Length
#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag,"FFTmag");
RFFT32 fft=RFFT32_128P_DEFAULTS;
long ipcb[N+2];                        //In place computation buffer
long mag[N/2+1];                        //Magnitude buffer

const long win[N/2]=HAMMING128;        //Window coefficient array  

RFFT32_ACQ acq=FFTRACQ_DEFAULTS;    //Instance the module

void main(void)
{
//....................

/* Initialize acquisition module                    */
        acq.buffptr=ipcb;
        acq.tempptr=ipcb;
        acq.size=N;
        acq.count=N;
        acq.acqflag=1;

/* Initialize FFT module                            */
        fft.ipcbptr=ipcb;
        fft.magptr=mag; 
        fft.winptr=(long *)win;
        fft.init(&fft);

    while(1)
    {   
          static Uint16 i=0; 
          EALLOW;
        SysCtrlRegs.WDKEY = 0xAA;        // and serve watchdog #2       
        EDIS;

         if (acq.acqflag==0)     // If the samples are acquired     
            {  

                    RFFT32_brev(ipcb,ipcb,N);  // Input after windowing
   
                fft.calc(&fft);
                fft.split(&fft);
                fft.mag(&fft);
                  for(i=0;i<N;i++)
                    {
               
                        mag[i]=sqrt(mag[i]);
                    }
                acq.acqflag=1;      // Enable the next acquisition     
             
            }
     }
}

interrupt void ADC_FIR_INT_ISR(void)       
{                                         

            acq.input=AdcBuf[ibuf];
            acq.update(&acq);  
   
                ibuf++;                                    // Increment the index
                if(ibuf == AdcBufLen) ibuf = 0;            // Rewind the pointer to beginning
}

 

aleaguir@gmail.com

thanks

  • I apologize for the delayed response.

    Based on my reading of the FFT Library Modules User's Guide provided with the SPRC081 package, the fft.win() function already assumes a bit-reversed data sequence which the Acquisition module facilitates already.
    Therefore, I don't believe you need to run the RFFT32_brev() function.  I would remove the call to RFFT32_brev().

    Secondly, the example provided with SPRC081 C:\ti\tidcs\c28\dsp_tbox\fft\cstb\fft128r has the acquisition input of the real part shifted left 16 bits.  Therefore, perhaps your ADC_FIR_INT_ISR() routine should look like:

    aleaguir said:

    interrupt void ADC_FIR_INT_ISR(void)       
    {                                         

                acq.input= ((unsigned long)AdcBuf[ibuf]) << 16 ;
                acq.update(&acq);  
       
                    ibuf++;                                    // Increment the index
                    if(ibuf == AdcBufLen) ibuf = 0;            // Rewind the pointer to beginning
    }

  • 可不可以给我一个sprc081  谢谢