Experiment 15
Experiment 15
This can be decomposed into a sum of real components and a sum of imaginary components,
Let
1 − j2 π kn/N − j2 π kn/N
= (e )
− j2 π kn/ N
e +e
2
1
¿ ( e− j2 π kn/ N +e− j 2 π kn/ N +e j 2 π nk/ N −e j2 π kn/N )
2
1 1
¿ ( e + j 2 π kn/N +e− j 2π kn/N ) − (e j2 π kn/ N −e− j2 π kn/N )
2 2
where
1 1 1
cos(w )= (e jw +e− jw ) and sin( w )= (e jw−e− jw )⇒ j sin( w)= (e jw −e− jw )
2 2j 2
− j2 π kn/ N
e =cos(2 π kn / N )− j sin(2 π kn /N )
Eq (1) can be re written as:
N−1
X ( k )=DFT {x (n)}= ∑ x (n ) ( cos(2 π kn/ N )− j sin(2 π kn/ N ) ) k = 0,1,2,. . .. .. . .. . N-1
n=0
Or
N −1
Re {X (k )}= ∑ x (n)cos(2 π kn /N )
n=0
And
N−1
Im {X (k )}= ∑ x (n )sin (2 π nk / N )
n=0
Procedure:
1. To create the project file. Select Project New. Type DFT for the project name. This
project file is saved in the folder DFT (within D:\program files\myprojects).
2. To add files to the project. Select Project Add Files to Project. Look in the folder
support, Files of type Linker command files. Double-click on the Linker command file
C6713dsk.cmd to add it to the project. Click on the “+” symbol to the left of the Project
Files window within CCS to expand and verify that this Linker command file has been
added to the project.
3. Select File New Source File. This will open CCS editor, type the following
program in it and save it, in folder D:\program files\myprojects\DFT with
name DFT.C.
#include <stdio.h>
#include <math.h>
void dft(short *input, short k, float *out,float *outim);//function
prototype
#define N 6 //number of data
values
float pi = 3.1416;
int j;
short input[N] = {1,1,2,2,3,3};
void main()
{
int j;
while(1)
{
for (j = 0; j < N; j++)
{
dft(input,j,out,outim); //call DFT function
}
}
} _______________________________________________________________________________________________________________
FIGURE 2. DFT implementation program with input from a lookup table (DFT.c).
6. Linker Option
Click on Linker (from CCS Build Options).
I. Select the following for the compiler option with Basic (for Category):
a) Select Suppress banner
b) Select Exhaustively Read Library
c) For Output Filename (-o) type .\Debug\DFT.out
d) For Map Filename (-o) type .\Debug\DFT.map
e) For Autoinit Model: Select Run-Time Autoinitialization(-c)
f) For include Libraries type rts6700.lib
II. Click on the Advanced options
a) De-select Warn About Output Sections(-w)
Again Select View Quick Watch window, Type out, then click on “Add to
Watch.” This will display the real part of the output vector.
Figure 6 CCS Quick Watch Dialog for real part of output vector
Again Select View Quick Watch window, Type outim, then click on “Add to
Watch.” This will display the imaginary part of the output vector.
Figure 7 CCS Quick Watch Dialog for imaginary part of output vector
Right click on the quick watch window and select the option Float in Main Window.
Assignment#2
Calculate the DFT of the sample data sequence x(n) = {1, -1, 2, 1, -1, 3}
Reference:
(1) Introduction to Analog and Digital Communication (Simon Haykin, Michael Moher)
(2) Digital Signal Processing and Applications with the C6713 and C6416 DSK (Rulph
Chassaing)