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.

TMS320C6748: Real time FFT

Part Number: TMS320C6748

Hello everyone,

I have  performed non-real time FFT program in LCDKC6748. Is it possible to perform real time FFT in LCDKC6748?

  • FFT (1).c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    *=============================================================*
    * DESCRIPTION *
    * *
    * *
    * *
    * Number of points for FFT (PTS) 256 * *
    * *
    * *
    * *
    * ============================================================*/
    #define PTS 256 //# of points for FFT
    typedef struct {float real,imag;} COMPLEX;
    extern COMPLEX w[PTS]; //twiddle constants stored in w
    void FFT(COMPLEX *Y, int N) //input sample array, # of points
    {
    COMPLEX temp1,temp2; //temporary storage variables
    int i,j,k; //loop counter variables
    int upper_leg, lower_leg; //index of upper/lower butterfly leg
    int leg_diff; //difference between upper/lower leg
    int num_stages = 0; //number of FFT stages (iterations)
    int index, step; //index/step through twiddle constant
    i = 1; //log(base2) of N points= # of stages
    do
    {
    num_stages +=1;
    i = i*2;
    }while (i!=N);
    leg_diff = N/2; //difference between upper&lower legs
    step = (PTS*2)/N; //step between values in twiddle.h // 512
    for (i = 0;i < num_stages; i++) //for N-point FFT
    {
    index = 0;
    for (j = 0; j < leg_diff; j++)
    {
    for (upper_leg = j; upper_leg < N; upper_leg += (2*leg_diff))
    {
    lower_leg = upper_leg+leg_diff;
    temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
    temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
    temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
    temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
    (Y[lower_leg]).real = temp2.real*(w[index]).real
    -temp2.imag*(w[index]).imag;
    (Y[lower_leg]).imag = temp2.real*(w[index]).imag
    +temp2.imag*(w[index]).real;
    (Y[upper_leg]).real = temp1.real;
    (Y[upper_leg]).imag = temp1.imag;
    }
    index += step;
    }
    leg_diff = leg_diff/2;
    step *= 2;
    }
    j = 0;
    for (i = 1; i < (N-1); i++) //bit reversal for resequencing data
    {
    k = N/2;
    while (k <= j)
    {
    j = j - k;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    FFT256c (1).c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    *******************************************************************************
    *=============================================================*
    * DESCRIPTION *
    * *
    * *
    * *
    * Number of points for FFT (PTS) 256 * *
    * *
    * iobuffer --> input signal *
    * sample --> output of FFT function (don't use on graoh window)
    * x1 --> use in graph window *
    * ============================================================*/
    //FFT256c.c FFT implementation calling a C-coded FFT function
    #include <math.h>
    #define PTS 256 //# of points for FFT
    #define PI 3.14159265358979
    typedef struct {float real,imag;} COMPLEX;
    void FFT(COMPLEX *Y, int n); //FFT prototype
    float iobuffer[PTS]; //as input and output buffer
    float x1[PTS]; //intermediate buffer
    short i; //general purpose index variable
    short buffercount = 0; //number of new samples in iobuffer
    short flag = 0; //set to 1 by ISR when iobuffer full
    COMPLEX w[PTS]; //twiddle constants stored in w
    COMPLEX samples[PTS]; //primary working buffer
    main()
    {
    for (i = 0 ; i<PTS ; i++) // set up twiddle constants in w
    {
    w[i].real = cos(2*PI*i/(PTS*2.0)); //Re component of twiddle constants
    w[i].imag =-sin(2*PI*i/(PTS*2.0)); //Im component of twiddle constants
    }
    for (i = 0 ; i < PTS ; i++) //swap buffers
    {
    iobuffer[i] = sin(2*PI*30*i/PTS);/*10- > freq,100 -> sampling freq*/
    samples[i].real=0.0;
    samples[i].imag=0.0;
    }
    for (i = 0 ; i < PTS ; i++) //swap buffers
    {
    samples[i].real=iobuffer[i]; //buffer with new data
    /* iobuffer[i] = x1[i]; //processed frame to iobuffer*/
    }
    for (i = 0 ; i < PTS ; i++)
    samples[i].imag = 0.0; //imag components = 0
    FFT(samples,PTS); //call function FFT.c
    for (i = 0 ; i < PTS ; i++) //compute magnitude
    {
    x1[i] = sqrt(samples[i].real*samples[i].real
    + samples[i].imag*samples[i].imag);///32;
    }
    } //end of main
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Non -real time fft program is attached below.

  • Hi,

    I've notified the RTOS team .Their feedback will be posted here.

    Best Regards,
    Yordan
  • If you are performing FFT of fixed point samples then we have created a wiki to compute FFT using real input which you can refer from the link provided here:
    processors.wiki.ti.com/.../Efficient_FFT_Computation_of_Real_Input

    Regards,
    Rahul