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.

Several troubles on using the C28x FFT lib

Other Parts Discussed in Thread: CONTROLSUITE

 

Hi, guys,

I have some questions and problems about using the FFT-LIB:

*********1. **********

I tried a list of procedures to invoke this fft-lib, and compared the results to what MATLAB produced, so, they were much different.

I convinced that, MATLAB would not wrong, .....neither would this lib, so, it's me,......please help me to point out my blind spot. I guess my misusing of IQ-format.

I attached the entire example file (where using F2812 simulator) and the error screen-snapshot included.

 6431.TI C2000 FFTLib.zip

Also, the code snippet is as follows:

 By the way, I have tried the input signal shifted left by 16-bit, but still no correct result. And I have verified that function fft.mag works fine - it needs L16 shifted-data.

 

#include "sgen.h"
#include "fft.h"
#include "iqmathlib.h"

/* Create an instance of Signal generator module    */
SGENTI_1 sgen = SGENTI_1_DEFAULTS;                                      // single channel, tbl look-up, interpolation

/* Create an Instance of FFT module                 */
#define     N   128

#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag, "FFTmag");

long ipcb[N+2];
long mag[N/2+1];

RFFT32  fft=RFFT32_128P_DEFAULTS;

/* Define window Co-efficient Array  and place the
.constant section in ROM memory    */
const long win[N/2]=HAMMING128;

/* Create an instance of FFTRACQ module             */
RFFT32_ACQ  acq=FFTRACQ_DEFAULTS;

extern const long samples[4096];

long i=0, xn=0;

void main_test(void){

    /* Signal Generator module initialisation           */
    sgen.offset=0;
    sgen.gain=0x7fff;                                                   /* gain=1 in Q15 */
    sgen.freq=10000;                                                    /* freq = (Required Freq/Max Freq)*2^15       *///?
                                                                        /*      = (931/3051.7)*2^15 = 10000           *///?
    sgen.step_max=10000;                                                /* Max Freq= (step_max * sampling freq)/65536 */
                                                                        /* Max Freq = (10000*20k)/65536 = 3051.7      */

    /* 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.tfptr=ipcb;
    fft.magptr=mag;
    fft.winptr=(long *)win;
    fft.init(&fft);


    while (1){


#if 1
        sgen.calc(&sgen);
        xn=sgen.out;
#else
        if (i>=128) i=0;
        xn=samples[i++];
#endif


        acq.input=xn;               // ((unsigned long)xn)<<16;
        acq.update(&acq);

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

            fft.calc(&fft);
            fft.split(&fft);
            fft.mag(&fft);

            acq.acqflag=1;          // Enable the next acquisition

        }
    }
}

*********2. **********

Are there ways to modify the fft-lib to support 8-point to 64-point samples? And does this fft-lib support zero-padding condition? Any concerns?

*********3. **********

The manual says that the CFFT would zero the imaginary part of input data, what if I want to fft against on the same data consecutively, that is,

first fft on a real-signal data and a complex freq-domain signal result was obtained, and then, fft on the result again?

As I know, on the outer perspective, the difference between this CFFT and this RFFT is how they treat the input data, e.g., CFFT: real | imag | real | imag |...; RFFT: real | real | ..;

CFFT remains manipulating on the real only?

The manual also says 2 additional data would stuff on the 1st index and the middle position of the FFT buffer(ipcb), but I only found that magnitude buffer did, ipcb didn't?

*********4. **********

As I know, there are memory-allocated restrictions on FFT-lib, why are these restrictions?(although, not important...)

I list some:

"Exactly X" alignment of the ipcb buffer.

Some must be in the NVRAM.

All are in the same mem blocks area?

*********5. **********

As I know, IQmath tries to keep the MSB at most, it only supports Q1 to Q30. How if I have an entire-bit effective data, all the 32-bit are possible, what format can I use?

Q31 or Q0?

If Q1 to Q30 within, are used, at the very beginning, 1 bit would already be discarded?

How can I manipulate the entire various calculation process by only using Q format and use one-time IQ-to-float at last, is it possible?

The RFFT use Q15 for input, FFT on it in Q31, magnitude on it in Q30..........so how do I treat my original data and it's succeeding format?

For example, if some function of the lib needs Q15 for input, but I have a variable being 32-bit effective, e.g., what I have to convert to from this value -2000000001 or this value -21?

 

Thanks a lot for your help.

 

Ken.

 

 

 

 

 

 

  • You should use the fixed point fft library under controlSUITE rather than use this obsolete version.

  • Yu Cai said:

    You should use the fixed point fft library under controlSUITE rather than use this obsolete version.

     

    Hi, Cai,

    I tried what you told, but I still got incorrect results; I tried various sample data formats, it always fail/incorrect.  (I inspected the fft result (real,imag).)

    In addition, over and over again, the program reloads the same samples (128) to ipcb buffer, but before fft-cal-process, I found what the buffer stored was different at each time, also I don't know why.

    I have no idea what's wrong with my program.

    Appreciates for any help,

    Thanks.

    7853.Project_01.zip

    Ken.

     

     

  • these codes have been tested under 28335 platform. I think for 2812 you need to do some changes on CMD file. Please check your memory map is working or not. And please don't use simulator to do this. Try to get an evaluation board of 2812, for example, ezDSP.

    Thanks

    Yu Cai

  • Yu Cai said:

    these codes have been tested under 28335 platform. I think for 2812 you need to do some changes on CMD file. Please check your memory map is working or not. And please don't use simulator to do this. Try to get an evaluation board of 2812, for example, ezDSP.

    Thanks

    Yu Cai

     

    Hoo~~~finally~

    I probably found the cause.

    It's simulator. Because the program ran correctly by using F28035 control card.

    Why I persisted in using simulator rather than the fantastic piccoloB is its RAM poor to accommodate my prog (an intended complaint).

    I guess the incorrect results obtained from simulator is because of not supporting ROM / IQMathTable /...

    Thank you, Cai.

     

     

     

     

  • Hi!

    Does anyone have an example on how to setup the command file for e.g. 2812 DSP for this FFT algorithm ?

    Where to specify FFTipcb, FFTmag, and perhaps FFTtf ?

    Also, working example for e.g. 128 point RFFT for 2812 DSP or similar as described above would be much appreciated with both source code example and *.cmd file.

    Many thanks!

    /Andy

  • 3750.sub-sys.rar

     

    As attached.

    Have fun!

  •  

    Hi, All,

    The attached file is a complete project about 1D & 2D FFT-processing on F2812. (everything, incl. source code).

    It includes a Windows' control GUI which communicates with F2812 & receives data(and draw it) from F2812 in a much higher baud-rate.

    You know, 4Mbps(even higher) UART is possible....but..., in this project. If u watch/concentrate on this project enough, u'd see how & why.

    Is this project a proprietary? Yes but no.

    I developed it when I was a research assistant in some University.

    I convinced that this project became a ....... garbage, after I leaving this job. None could take over of this F2812 project.

    The intended Whole project (an RF-transceiver main-sys + the F2812 sub-sys), I convinced too, unfinished & gone!

    So, this F2812's, continuously is a garbage, which I did much efforts over a half of a year.

    You might see, though, this garbage extremely squeezes every single drop of F2812's processing energy.

    I convinced too, u'll learn/obtain something from it.

    Yes I show it off, but...actually I need a job = =


    ( the source code is embedded in the .doc file )

    ( because there are also binaries in this file, I RAR it with a 6-letter-password: "kenwoo" )

    ( if u worry about vii, use Sandboxie to eliminate yours, download from here: "www.sandboxie.net" )


    once C2000FAE@Yosun@TW.

     

  • Thank you Mr. Woo!

    I will study your excellent code more in detail. One more question regarding twiddle factors.

    It seems that in the *.cmd file I should specify an area in FLASH where the twiddle factors can be stored.

    E.g

    FFTtf   : > FLASH,      PAGE = 0

    When I call fft.init as below I get illegal address trap. Seems like the fft.init routine is makeing a jump to address zero.

    fft.init(&fft);           /* Twiddle factor pointer initialization  */

    What am I doing wrong?

    Do I need to specify fft.tfptr (i.e. where to point) before doing the call ? 

    Do I need to create a table of twiddle factors or is fft.init() taking care of this ?

    Thanks for any input! I am struggling to get strarted.

    Best regards

    Andy

     

  • Andr��� Row���us said:

    When I call fft.init as below I get illegal address trap. Seems like the fft.init routine is makeing a jump to address zero.

    fft.init(&fft);           /* Twiddle factor pointer initialization  */

    What am I doing wrong?

     

    You might not prepare the required fft-data (e.g., functor, const, etc.) properly.

    Trace the fft procedure in that proj, would give you infos you need:

        RFFT32_ACQ tmp2=FFTRACQ_DEFAULTS;
        RFFT32 tmp3=RFFT32_1024P_DEFAULTS;

        MemCopy((Uint16*)(&tmp3), ((Uint16*)(&tmp3))+sizeof(tmp3), (Uint16*)(&fft));
        MemCopy((Uint16*)(&tmp2), ((Uint16*)(&tmp2))+sizeof(tmp2), (Uint16*)(&acq_org));

    ....

    ...., and so on.

     

    Do I need to specify fft.tfptr (i.e. where to point) before doing the call ? 

    Do I need to create a table of twiddle factors or is fft.init() taking care of this ?

    Yes, for example:

    cfft32i.asm --> _CFFT32_init (MOVL    *+XAR4[2],XAR5          ; tfptr->TF_1024P_CFFT )      -->

       -->     .sect   "FFTtf"  (alloc properly?)

       -->     .if(TF_QFMAT==Q31) (which one / defined?)

     

    Situations (sorry I forgot which ones would; I'm away from c2k > 2 years:p) get illegal address trap, which cause, might be from outsider (!fft).

    if you still get the problem, check if cmd file prepared well; if somewhere in your code planted some potential exception; wrong use something; etc.

     

  • Hi!

    Here's a more detailed description of my problem:

    I get an 'illegal address' when calling :

    fft.init(&fft);

     

    The problem is that when making declaration of fft with default define as:

    RFFT32  fft=RFFT32_128P_DEFAULTS;   

    and in fft.h we have the following definition:

    #define RFFT32_128P_DEFAULTS    { (long *)NULL,\
            (long *)NULL,\
            64,\
            6,\
            (long *)NULL,\
            (long *)NULL,\
            0,\
            0,\
            16,\
            (void (*)(void *))CFFT32_init,\
            (void (*)(void *))CFFT32_calc,\
            (void (*)(void *))RFFT32_split,\
            (void (*)(void *))RFFT32_mag,\
            (void (*)(void *))RFFT32_win}

     

    The specific problem seems to be that CFFT32_init contains all zeros, so when it is trying to jump to the routine it jumps to address 0, which gives illegal address.

    In the map file I can see that it has properly allocated flash memory as:

    003e3d9b   _CFFT32_init

    But instead of jumping to the address above it contains all zeros from the RFFT32_128P_DEFAULTS definition.

    I think that it should work so that the compiler/linker actually replaces (void (*)(void *))CFFT32_init,\ with the correct address. But it does not seem to be the case. Any ideas why ?

    Do I need to add all *.asm files to my project as well or is this handled automatically by adding fft.lib  to my project ?

    (I've included the lib by drag & drop and also added

    l fft.lib  (in  *.cmd file)

    Perhaps the problem is related to the compiler which is an old version 3.3.1 ?

     

    And additional question. How do I change TF_QFMAT ?

    I think it is defined in one of the *.asm files - but these are 'baked' into the lib. How do I manually alter this setting ? Do I include the *.asm files to my project and alter then manually to perform this ? Do I need to rebuild the *.lib somehow after making the change.

    Thanks for any help!

    /Andy

     

     

     

  • Hi,

    I'm sorry about that uploaded a cumbersome project bothering you for a while.

    Now I upload another similar one and try to solve your troubles:

    There are three folders in the package, which also encrypted with a password "kenwoo".

    Compare the folders "_usage1" & "_usage2" inside, would answer your questions about fft library & IQmath.

    And the folder "_simplify" probably answers your remaining questions.

    I guess your trouble may from this: "C28x doesn't initiate global variable when using flash".

    Besides, because the fft-lib I applied is old; there might be newer fft-lib versions, if any, that I suggest to use since that might be easier to use than the old one.

    Ken.

    2703.sol_01.rar

    I show 2 pics from the "_simplify project" data.