Student Seminar Report & Project Report With Presentation (PPT,PDF,DOC,ZIP)

Full Version: COMPUTATION OF N POINT DFT OF A GIVEN SEQUENCE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
#include <stdio.h>
#include <math.h>
short x[8];
void dft(short *x, short k, int *out); //function prototype
#define N 8 //number of data values
float pi = 3.1416;
int sumRe,sumIm;
short x[N] = {1,2,3,4,5,6,7,8}; //1-cycle cosine
int out[2] = {0,0};
int real[8],imag[8],k=0; //init Re and Im results
void dft(short *x, short k, int *out) //DFT function
{
int sumRe = 0, sumIm = 0; //init real/imag components
float cs = 0, sn = 0; //init cosine/sine components
int i = 0;
for (i = 0; i < N; i++) //for N-point DFT
{
cs = cos(2*pi*(k)*i/N); //real component
sn = sin(2*pi*(k)*i/N); //imaginary component
sumRe = sumRe + x[i]*cs; //sum of real components
sumIm = sumIm - x[i]*sn; //sum of imaginary components
}
out[0] = sumRe; //sum of real components
out[1] = sumIm;
real[k]= sumRe;
imag[k]= sumIm;
k++;
if(k>N)k=0;
//printf("\n%d",sumRe);
//printf("\n%d",sumIm);
printf("\n%d",out[0]);
// printf("\n%d",out[1]); //sum of imaginary components
}
void main()
{
int j;
for (j = 0; j < N; j++)
{
dft(x,j,out); //call DFT function
}
}

PROCEDURE:
 Open Code Composer Studio, make sure the DSP kit is turned on.
 Use the Debug  Connect menu option to open a debug connection to the DSK board
 Start a new project using ‘Project-new ‘ pull down menu, save it in a
separate directory(C:\CCStudio_v3.1\myprojects) with name dft.pjt.
 Add the source files dft.c
 to the project using ‘Projectadd files to project’ pull down menu.
 Add the linker command file hello.cmd .
(Path: C:\CCStudio_v3.1\tutorial\dsk6713\hello1\hello.cmd)
 Add the run time support library file rts6700.lib
(Path: C:\CCStudio_v3.1\c6000\cgtools\lib\rts6700.lib)
 Compile the program using the ‘Project-compile’ pull down menu or by
clicking the shortcut icon on the left side of program window.
 Build the program using the ‘Project-Build’ pull down menu or by
clicking the shortcut icon on the left side of program window.
 Load the program(dft.out) in program memory of DSP chip using the
‘File-load program’ pull down menu.
Procedure for Real time Programs :
1. Connect a Signal Generator/audio input to the LINE IN Socket or connect a microphone to the MIC IN Socket.
Note:- To use microphone input change the analog audio path control register value (Register no. 4) in Codec Configuration settings of the Source file (Codec.c) from 0x0011 to 0x0015.
[attachment=13341]
2. Connect CRO/Desktop Speakers to the Socket Provided for LINE OUT or connect a headphone to the Headphone out Socket.
3. Now Switch on the DSK and Bring Up Code Composer Studio on the PC.
4. Use the Debug  Connect menu option to open a debug connection to the DSK board
5. Create a new project with name codec.pjt.
6. Open the File Menu  new  DSP/BIOS Configuration select
“dsk6713.cdb” and save it as “xyz.cdb”
7. Add “xyz.cdb” to the current project.
Project Add files to project xyz.cdb
8. Automatically three files are added in the Generated file folder in project pane
xyzcfg.cmd Command and linking file
xyzcfg.s62  optimized assembly code for configuration
xyzcfg_c.c  Chip support initialization
9. Open the File Menu  new  Source file
10. Type the code in editor window. Save the file in project folder. (Eg: Codec.c).
Important note: Save your source code with preferred language extension. For ASM codes save the file as code(.asm) For C and C++ codes code (*.c,*.cpp) respectively.
11. Add the saved “Codec.c” file to the current project which has the main function and calls all the other necessary routines.
Project  Add files to Project  Codec.c
12. Add the library file “dsk6713bsl.lib” to the current project
Path  “C:\CCStudio_v3.1\C6000\dsk6713\lib\dsk6713bsl.lib”
Files of type  Object and library files (*.o*, *.l*)
13. Copy header files “dsk6713.h” and “dsk6713_aic23.h” from and paste it in current project folder.
C:\CCStudio_v3.1\C6000\dsk6713\include.
14. Add the header file generated within xyzcfg_c.c to codec.
Note:- Double click on xyzcfg_c.c. Copy the first line header (eg.#include “xyzcfg.h”) and paste that in source file (eg.codec.c).
15. Compile the program using the ‘Project-compile’ pull down menu or by
Clicking the shortcut icon on the left side of program window.
16. Build the program using the ‘Project-Build’ pull down menu or by clicking the shortcut icon on the left side of program window.
17. Load the program (Codec. Out) in program memory of DSP chip using the
‘File-load program’ pull down menu.
18. Debug Run
19. You can notice the input signal of 500 Hz. appearing on the CRO verifying the codec configuration.
20. You can also pass an audio input and hear the output signal through the speakers.
21. You can also vary the sampling frequency using the DSK6713_AIC23_setFreq Function in the “codec.c” file and repeat the above steps.