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.

Using FFT in DM6437

Other Parts Discussed in Thread: CCSTUDIO

Hi! i'm trying to implement my code fft function. but i couldn't get right results. i looked at the fft example in wiki but result is same. 

is anyone use fft function in dm6437? simple usage code will be greatful. so that i can see my faults.

Thanks

  • Have you seen this wiki note that comes with usage example:

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

     

    Have you seen the example provided with the DSPLIB (http://focus.ti.com/docs/toolsw/folders/print/sprc265.html)

    ([INSTALL_DIR]\c64plus\dsplib_v210)

    Which FFT kernel are you using?

     

    The common challenge that I have seen is that the input data is not correctly scaled when using the FFT kernel. Note, the o/p of FFT can grow therefore it is important that the expected o/p can be represented by the fixed point data format selected

     

    Regards,

    Gagan

     

  • Hi Gagan when im trying to build fft example you said in wiki. i have this errors;

    >> C:\\CCStudio_v3.3\\c64plus\\dsplib_v210\\example\\fft_example\\lnk.cmd, line 43:   error: 

                   syntax error

    >> C:\\CCStudio_v3.3\\c64plus\\dsplib_v210\\example\\fft_example\\lnk.cmd, line 43:   error: 

                   section GROUP_1 not built

    >> C:\\CCStudio_v3.3\\c64plus\\dsplib_v210\\example\\fft_example\\lnk.cmd, line 43:   error: 

                   section GROUP_1 not built

    >> C:\\CCStudio_v3.3\\c64plus\\dsplib_v210\\example\\fft_example\\lnk.cmd, line 43:   error: 

                   section GROUP_1 not built

    >> C:\\CCStudio_v3.3\\c64plus\\dsplib_v210\\example\\fft_example\\lnk.cmd, line 44:   error: 

                   section GROUP_1 not built

    >> C:\\CCStudio_v3.3\\c64plus\\dsplib_v210\\example\\fft_example\\lnk.cmd, line 48: warning: 

                   multiple definitions of SECTION named '.bss'

          }>

    >> C:\\CCStudio_v3.3\\c64plus\\dsplib_v210\\example\\fft_example\\lnk.cmd, line 48:   error: 

                   syntax error

     

    im trying to add dsp lib to linker but i'm taking errors again. what is my wrong? 

  • Ayhan, I just tried building the code and it builds fine. See below the log

    --------------------------  fft_example.pjt - Debug  --------------------------
    [gen_twiddle_fft16x16.c] "C:\Program Files\Texas Instruments\C6000 Code Generation Tools 7.0.4\bin\cl6x" -g -fr"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/Debug" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../.." -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x16" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x32" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft32x32" -d"_DEBUG" -mv6400+
    -@"../../example/fft_example/Debug.lkf" "gen_twiddle_fft16x16.c"

    [gen_twiddle_fft16x32.c] "C:\Program Files\Texas Instruments\C6000 Code Generation Tools 7.0.4\bin\cl6x" -g -fr"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/Debug" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../.." -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x16" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x32" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft32x32" -d"_DEBUG" -mv6400+ -@"../../example/fft_example/Debug.lkf" "gen_twiddle_fft16x32.c"

    [gen_twiddle_fft32x32.c] "C:\Program Files\Texas Instruments\C6000 Code Generation Tools 7.0.4\bin\cl6x" -g -fr"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/Debug" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../.." -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x16" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x32" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft32x32" -d"_DEBUG" -mv6400+ -@"../../example/fft_example/Debug.lkf" "gen_twiddle_fft32x32.c"

    [fft_example.c] "C:\Program Files\Texas Instruments\C6000 Code Generation Tools 7.0.4\bin\cl6x" -g -fr"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/Debug" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../.." -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x16" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft16x32" -i"C:/CCStudio_v3.3/c64plus/dsplib_v210/example/fft_example/../../src/DSP_fft32x32" -d"_DEBUG" -mv6400+ -@"Debug.lkf" "fft_example.c"

    [Linking...] "C:\Program Files\Texas Instruments\C6000 Code Generation Tools 7.0.4\bin\cl6x" -@"Debug.lkf"
    <Linking>

    Build Complete,
      0 Errors, 0 Warnings, 0 Remarks.


    Can you provide complete log for your build step?
    What CCS version and Compiler version are you using?

    Regards,

    Gagan

     

  • thanks for your help gagan.

    i'm using ccs3.3. i solved the problem chanching cmd file. now i can build too.

    but my problem is still fft. i added fft functions to video_preview example. i'm taking all frame's fft like example. but when i compare fft image with matlab fft out image they aren^t same. what do you think my problem is? if you have example for this could you send me?

    thanks 

  • Ayhan, great that you are making progress!
    The easiest way for me to explain what is going on is if you can provide a simple example on what you do, what you get and what you expect. Can you do below:

    * Provide a small buffer (say 16 samples)
    * Suggest what DSP API you call and how
    * Provide the result you get
    * Provide the result you expect to get

    I can then help you understand what is going on.

    Regards,
    Gagan

     

     

     

     

  • My project codes are in my office computer. tomorrow i will send you my source code. i think i'm doing this steps but i'm missing something. if you check my code tomorrow. it will be wonderful.

    thanks.

  • Hi! i'm adding my source code's most important parts. could you check is there a problem?

    And i wanna ask you something else why fft's out is short?

    Matlab fft function's out is float type. You can say dm6437 works fixed point . so how it be real fft if values only change between 0- 255? am i thinking wrongly?

    Thanks!

     

    //main

    //Frame sizes for capture and display

    int height = 256;

    int width = 256;

    //FFT arrays

    short FFTin[256 * 256 * 2];

    short twiddle[2 * 256 *256]

     

    gen_twiddle_fft16x16(twiddle,( 256 * 256));

     

     

      while ( status == 0 ) 

    {

     

     

        FVID_exchange(hGioVpfeCcdc, &frameBuffPtr);

     

        phaseCorrelation( (void*)(frameBuffPtr->frame.frameBufferPtr), height, width);

        FVID_exchange(hGioVpbeVid0, &frameBuffPtr);

    }

     

    void phaseCorrelation(void* currentFrame,int yRows,int xPixels)

    {

    int i = 0, k = 0; 

    FILE *out = NULL;

    FILE *in = NULL;

    FILE *fft = NULL;

      

        for( i = 1; i < (256 * 256)*2; i+=2 )

    {

    *( ( FFTin ) + k) = *( ( (unsigned char*)currentFrame ) + i ) ; 

    k++;

        }

     

       DSP_fft16x16t(twiddle, (256* 256),(short *)FFTin,(short *) FFTin);

    for( i = 1; i < (256 * 256)*2; i+=2 )

    {

    *( ( (unsigned char*)currentFrame ) + i ) = *( ( FFTin) + k); 

    k++;

        }

    printf("Frame Captured\n");

    fflush(stdout);

     

    }

     

  • Ayhan :

            Hi!

            How can you get the real fft result ? Were the results same with matlab 's results?

    Regards

    --Tiny

  • Hi Tiny.

     

    That time i coulndt realize that fft input array must be complex form: real,imag,real,imag,real,imag....

    after making this results will be same with the matlab results but just integer parts. reason of this is fixed poind cpu.

     

  •  

    Ayhan:

     

        Hi!

        I have some other quesitions .After the 'fft32*32' function , the output  data is Q31 . How can I transform it ? And after the transformation ,the results are the same with the matlab' result. I read the sheet, I found the input and output are the Q31 formation. How can I use this function? Should I transform the input data to Q.31 and scale it ? In 'fft32*32',I found the input data need scale N. 

    By the way , I use the davinci DM6446.    It's fixed point cpu.

     And are you chinese? I'm a chinese student.So my english is broken . Sorry!

        Regards,

        Tiny

     

  • Tiny im using DSP_fft16x32. you dont have scale fft result if you use this fft. if you really need to use 32x32 or 16x16 u have to scale results. 

    no im from Turkey. 

  • Ayhan:

      Nice to meet you!

     I will test fft16*32 . Thanks for your help.

    Do you have a mail address? And  I can exchange some problems with you expediently.My mail address  is wguoxd@gmail.com

     

    Regards,

    Tiny