DFT/ FFT Using TMS320C5515 TM eZDSP USB Stick: Via CCS and Matlab
DFT/ FFT Using TMS320C5515 TM eZDSP USB Stick: Via CCS and Matlab
Xk = ∑ xn . e−2πkn/N , 𝒌 ∈ 𝒁
0
The DFT can be computed efficiently in practice using a fast Fourier transform (FFT) algorithm.
FFT algorithms are so commonly employed to compute DFTs that the term "FFT" is often used
to mean "DFT" in colloquial settings. Formally, there is a clear distinction: "DFT" refers to a
mathematical transformation or function, regardless of how it is computed, whereas "FFT"
refers to a specific family of algorithms for computing DFTs.
In this lab session, we will generate and calculate 128-DFT of the following signal:
x(t)=-2 cos(400πt) + cos(200πt) - 1.5cos(600πt)
Using Matlab, TMS320C5515 eZDSPTM USB Stick Development Tool. The signal is also generated
by VIRTIN Multi-Instrument 3.2. Then, the results of Matlab and C5515 are compared.
FLOW CHART
Calculate 4-DFT/FFT in IC
int i,n,j;
scanf("%d",&n); // range of x for (i=0; i<n ;i++ ) scanf("%f",&x[i]);
for (i=0; i<4 ;i++ )
{
x1[i]=0;
for (j=0 ;j<3 ;j++ )
{
x1[i]=x1[i]+x[i+4*j];
}
}
result_real[0]=x1[0]+x1[1]+x1[2]+x1[3]; result_real[1]=x1[0]-x1[2];
result_real[2]=x1[0]-x1[1]+x1[2]-x1[3]; result_real[3]=x1[0]-x1[2];
result_image[0]=0;
result_image[1]=-x1[1]+x1[3]; result_image[2]=0;
result_image[3]=x1[1]-x1[3]; for (i=0;i<4 ;i++ ) {
printf("%f %fi\n",result_real[i],result_image[i]);
}
freopen("result.txt","w",stdout); for
(i=0;i<4 ;i++ )
{
printf("%f\n%f\n",result_real[i],result_image[i]);
}
fclose(stdout);
}
2. Code on matlap:
n=12;
fileID = fopen('kk.c','w');
fclose(fileID);
fileID = fopen('aa.c','w');
fprintf(fileID,'%d\n',n);
for i=0:1:3
fprintf(fileID,'%f ',i*2);
end
for i=4:1:9
fprintf(fileID,'%f ',(i*i)./4);
end
fprintf(fileID,'%f ',0);
fprintf(fileID,'%f ',0);
fclose(fileID);
while fopen('result.txt','r')==-1
end
fileID=fopen('result.txt','r');
fclose(fileID);
fileID=fopen('result.txt','r');
A=fscanf(fileID,'%f')
figure;
hold on;
grid on;
for x=1:2:7
stem( A(x),A(x+1),'r*');
end
xlabel('real');
ylabel('imaginary');
fclose(fileID);
Result
We have the result on CCS like that:
https://en.wikipedia.org/wiki/Discrete_Fourier_transform
https://en.wikipedia.org/wiki/Fast_Fourier_transform