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.

About DSPF_sp_fftSPxSP in 6678?

When I used this function to calculate fft, I got wrong result:

void FFTTEST(float * real, float * fftOut)

{

       int i = 0;

      float fftIn[512]={0.0};

     DSPF_sp_fftSPxSP(256,&fftIn[0],&wforFFT[0],fftOut,brev,4,0,256);

real is a floating-point array of 256 real data, wforFFT is a floating-point array of length 512 created by tw_genSPxSPfft , brev is a 64-entry bit-reverse data table, and fftOut is a floating-point array of length 512.

Would somebody tell me how to get the right fft result?

Thanks a lot,

  • Maybe there is a clerical error: the input data are not copied in the fftIn array as input to the fft function. Also pay attention to the data aligament: fft requires 8 bytes in, out, twiddle and it overwrites its inputs.

     enum { MAX_FFT =512};

    #pragma DATA_ALIGN(8)

    static float wforFFT[MAX_FFT] ;

    #pragma DATA_ALIGN(8)

    static float fftIn[MAX_FFT];

    #pragma DATA_ALIGN(8)

    static float fftOut[MAX_FFT];

    void FFTEST(float* real_in, float* real_out)  //Warning: static work buffers - non reentrant

    {

      memcpy(fftIn, real_in, sizeof(float)*256;

      DSPF_sp_fftSPxSP(256,&fftIn[0],&wforFFT[0],fftOut,brev,4,0,256);  //brev can be 0 for the C66xx version

      memcpy(real_out, fftOut, sizeof(float)*256);

    }


  • May,

    If I read correctly, you want to do a 256 pt FFT, using real data as input.  This routine is a complex FFT.  It expects complex data and will give complex output.  For 256 point FFT it expects 256 complex inputs and will produce 256 complex outputs (that's 512 input points and 512 outputs.)  You can use this w/ real inputs, but you will get complex outputs.  You'd need to have the input array in the form of real, imag,, real, imag., ... w/ the imaginary values set to 0.

    Best Regards,

    Chad

    PS: Here's a small cut and paste form the description in the header of the file.

    /* NAME                                                                    */
    /*     DSPF_sp_fftSPxSP -- Single Precision floating point mixed radix          */
    /*     forwards FFT with complex input                                     */
  • Chad,

     I have this function destroys the data in the input buffer. So it should be?

    Dmitry.

  • Dmitry,

    I don't understand what you're asking, please clarify the question.  If it's not related to the above thread, please start a new thread.

    Best Regards,
    Chad

  • Dmitry Cooper said:

    Chad,

     I have this function destroys the data in the input buffer. So it should be?

    Dmitry.

    Yes, the fft function destroy the input. See my previous reply, where I posted an example of use (the input data are copied in a buffer, also to respect the 8 bytes aligned constrain on the input and output buffer).