You are currently viewing FFT 8 Point DIF using TMS320C6745 DSP

FFT 8 Point DIF using TMS320C6745 DSP

Spread the love

Aim

To perform the 8 point FFT using DIF process from a given discrete sequence in TMS320C6745 KIT

Requirements

☞CCS v 4

TMS320C6745 KIT

☞USB Cable

☞5V Adapter

Theory

A fast Fourier transform (FFT) is an efficient algorithm to compute the discrete Fourier transform (DFT) and its inverse. There are many distinct FFT algorithms involving a wide range of mathematics, from simple complex number arithmetic to group theory and number theory.

A DFT decomposes a sequence of values into components of different frequencies. This operation is useful in many fields (see discrete Fourier transform for properties and applications of the transform) but computing it directly from the definition is often too slow to be practical. An FFT is a way to compute the same result more quickly: computing a DFT of N points in the naive way, using the definition, takes O(N2) arithmetical operations, while an FFT can compute the same result in only O(N log N) operations. The difference in speed can be substantial, especially for long data sets where N may be in the thousands or millions—in practice, the computation time can be reduced by several orders of magnitude in such cases, and the improvement is roughly proportional to N / log(N). This huge improvement made many DFT based algorithms practical; FFTs are of great importance to a wide variety of applications, from digital signal processing and solving partial differential equations to algorithms for quick multiplication of large integers.

The most well known FFT algorithms depend upon the factorization of N, but there are FFTs with O(N log N) complexity for all N, even for prime N. Many FFT algorithms only depend on the fact that e¯ 2∏ i /N is an th primitive root of unity, and thus can be applied to analogous transforms over any finitue field, such as number theoretic transforms. Since the inverse DFT is the same as the DFT, but with the opposite sign in the exponent and a 1/N factor, any FFT algorithm can easily be adapted for it.

Procedure for build a project on FFT 8 Point DIF using TMS320C6745 DSP

1. Open Code Composer Studio v4 .

2. In WorkSpace Launcher.

BROWSE → Select the project location and make one new folder, MAKE NEW FOLDER → Type the Workspace name, OK → OK.

3. FILE → NEW → CCS PROJECT

☞Project name: Type your project name.

☞Tick use default location. → NEXT

☞Project type: C6000.

☞Tick Debug And Release. → NEXT → NEXT.

☞Output type: Executable.

☞Device Variant : generic C67XX Device.

☞Device Endianness : little

☞Code Generation Tools: TI v6.1.12.

☞Run time support library: automatic.

☞Target content: none. → FINISH

4.FILE → NEW → SOURCE FILE

☞Source file: Type your projectname.c( .c extension is must ).

☞Type the program.

FILE → SAVE.

5. Paste the following board library files in workspace location.

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. Paste the Linker file in the project location.(linker file is available in cd)

Note: Those folders and linker file are availble at cd.

7. PROJECT → PROPERTIES → C/C++ BUILD → BASIC OPTION

☞Target processor version(–silicon version, -mv) : 6400+ OK.

☞IN C/C++ BUILD, INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select the add icon and add the following three path by indivdually    –  “${Diag}../../common/header”    –  “${XDAIS_CG_ROOT}/packages/ti/xdais”    –  “${C6000_CSL_CG_ROOT}/include”

8. FILE → NEW → TARGET CONFIGURATION FILE

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: TMS320C6745. → SAVE → TARTGET CONFIGURATION → C674X_0 → BROWSE, browse the workspace location, open the gel folder and select the GEL file. → OPEN → SAVE.

9. In C/C++ Project window, Right click the project → REBUILD PROJECT.

10. Connections

☞Connect the usb cable, PC to TMS320C6745 KIT.

☞Connect the 5v adapter.

☞Power on the kit.

11. TARGET DEBUG ACTIVE PROJECT.

12. VIEW MEMORY

13. In right side, memory window will open. Type the adrress and give the input at particular location.

Give the input as follow:

Enter An Address:0xC0001000 → Enter.(Input) X(n)

0xC0001000 – 00000001 

0xC0001004 – 00000002

0xC0001008 – 00000003 

0xC000100C – 00000004

0xC0001010 – 00000004

0xC0001014 – 00000003

0xC0001018 – 00000002

0xC000101C – 00000001

14. View Watch window watch1.

☞Type the following array variable.

☞tr( real part output)

☞ti( imaginary part output)

15.TARGET RUN.

16.TARGET HALT.

See the Output at Particular location:

Example :

Enter An Address:0xC0001030 Enter.(Real part output)

0xC0001030 – 00000014

0xC0001034 – FFFFFFFB

0xC0001038 – 00000001

0xC000103C – 00000000

0xC0001040 – 00000000

0xC0001044 – 00000000

0xC0001048 – 00000000

0xC000104C – FFFFFFFB  

Enter An Address:0xC0001050 → Enter.(Imaginary part output)

0xC0001050 – 00000000

0xC0001054 – FFFFFFFFE

0xC0001058 – 00000000

0xC000105C – 00000000

0xC0001060 – 00000000

0xC0001064 – 00000000

0xC0001068 – 00000000

0xC000106C - 00000002

17. Or see the ouput at watch window.

Note: watch window will show exact decimal values, processor memory location will show a hexadecimal values.

Program for FFT 8 Point DIF using TMS320C6745 DSP

#include 
#define PI     3.14159
float x[8],tr[8],ti[8],s1r[8],s1i[8],s2r[8],s2i[8],Xr[8],Xi[8],Yr[8],Yi[8];
const float W0r = 1,
                        W0i = 0,
                        W1r = 0.707,
                        W1i = -0.707,
                        W2r = 0,
                        W2i = -1,                       
                        W3r = -0.707,
                        W3i = -0.707;
void main()
{
        int *Input,*Real_out,*Imag_out;
        int i=0;
        Input = (int *)0xC0001000;
        Real_out = (int *)0xC0001030;
        Imag_out = (int *)0xC0001050;
        for(i=0;i<8;i++)
        {              
                        x[i] = 0;
                        x[i] = *(Input + i);
        }
// stage one process
        s1r[0] = (int)(x[0] + x[4]);
        s1i[0] = 0;
        s1r[1] = (int)(x[1] + x[5]);
        s1i[1] = 0;
        s1r[2] = (int)(x[2] + x[6]);
        s1i[2] = 0;
        s1r[3] = (int)(x[3] + x[7]);
        s1i[3] = 0;
        s1r[4] = (int)(x[0] - x[4]) * W0r;
        s1i[4] = 0;
        s1r[5] = (int)(x[1] - x[5]) * W1r;
        s1i[5] = (int)(x[1] - x[5]) * W1i;
        s1r[6] = 0;
        s1i[6] = (int)(x[2] - x[6]) * W2i;
        s1r[7] = (int)(x[3] - x[7]) * W3r;
        s1i[7] = (int)(x[3] - x[7]) * W3i;
// stage two process
        s2r[0] = (s1r[0] + s1r[2]);                                                                                                                                                                                                             
        s2i[0] = (s1i[0] + s1i[2]);
        s2r[1] = (s1r[1] + s1r[3]);
        s2i[1] = (s1i[1] + s1i[3]);
        s2r[2] = (s1r[0] - s1r[2]) * W0r;
        s2i[2] = 0; // (s1i[0] - s1i[2]) * W0i;
        s2r[3] = 0; // (s1r[1] - s1r[3]) * W2r;
        s2i[3] = (s1r[1] - s1r[3]) * W2i;
        s2r[4] = (s1r[4] + s1r[6]);
        s2i[4] = (s1i[4] + s1i[6]);
        s2r[5] = (s1r[5] + s1r[7]);
        s2i[5] = (s1i[5] + s1i[7]);
        s2r[6] = (s1r[4] - s1r[6]) * 1;
        s2i[6] = (s1i[4] - s1i[6]) * 1;
                Yr[0] = s1r[5] - s1r[7];
                Yi[0] = s1i[5] - s1i[7];
                Yr[1] = ((Yr[0] * W2r) - (Yi[0] * W2i));
                Yi[1] = ((Yr[0] * W2i) + (Yi[0] * W2r));
        s2r[7] = Yr[1];
        s2i[7] = Yi[1];
//  output
Xr[0] = (s2r[0] + s2r[1]);                                                                                                                                                                                                            
        Xi[0] = (s2i[0] + s2i[1]);
        Xr[1] = (s2r[0] - s2r[1]);                                                                                                                                                                                                            
        Xi[1] = (s2i[0] - s2i[1]);
        Xr[2] = (s2r[2] + s2r[3]);                                                                                                                                                                                                            
        Xi[2] = (s2i[2] + s2i[3]);
        Xr[3] = (s2r[2] - s2r[3]);                                                                                                                                                                                                            
        Xi[3] = (s2i[2] - s2i[3]);
        Xr[4] = (s2r[4] + s2r[5]);                                                                                                                                                                                                            
        Xi[4] = (s2i[4] + s2i[5]);
        Xr[5] = (s2r[4] - s2r[5]);                                                                                                                                                                                                             
        Xi[5] = (s2i[4] - s2i[5]);
        Xr[6] = (s2r[6] + s2r[7]);                                                                                                                                                                                                             
        Xi[6] = (s2i[6] + s2i[7]);
        Xr[7] = (s2r[6] - s2r[7]);                                                                                                                                                                                                             
        Xi[7] = (s2i[6] - s2i[7]);
// bit reversal
tr[0] = Xr[0];
        ti[0] = Xi[0];
        tr[1] = Xr[4];
        ti[1] = Xi[4];
        tr[2] = Xr[2];
        ti[2] = Xi[2];
        tr[3] = Xr[6];
        ti[3] = Xi[6];
        tr[4] = Xr[1];
        ti[4] = Xi[1];
        tr[5] = Xr[5];
        ti[5] = Xi[5];
        tr[6] = Xr[3];
        ti[6] = Xi[3];
        tr[7] = Xr[7];
        ti[7] = Xi[7];
// sending output array to memory location        
        for(i=0;i<8;i++)
        {      
                *Real_out ++= tr[i];
                *Imag_out ++= ti[i];
        }   
        for(;;);
}

Result

Thus, the 8 point FFT of a given discrete sequence has performed and the result is stored at memory location(0xC0001030 and 0xC0001050).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.