DSP Lab Experiments Using Code Composer Studio On TMS320C6745
DSP Lab Experiments Using Code Composer Studio On TMS320C6745
EXPERIMENTS USING
CODE COMPOSER
STUDIO ON
TMS320C6745
NAME: P. Vedesh
REG : 14BEC0103
FACULTY: DR.SHANKAR GANESH SIR
Experiment 1 : (SINE WAVE GENERATION)
Aim : To generate a sinusoidal wave using code composer on
TMS320C6745.
Algorithm :
1. Generating a sinusoidal signal.
2. Create a matrix which can store 100 floating values.
3. Assign the sine function for each time period to each matrix
element.
4. Build and Debug the program.
5. Add expression y and use graph command to obtain the graph.
CODE:
#include<stdio.h>
#include<math.h>
float y[100];
int main(void) {
int i;
for(i=0;i<100;i++)
{
y[i]=sin(2*3.14*i/100);
}
return 0;
}
Output :
OUTPUT:
Output :
ALGORITHM :
1. Create 3 matrices.
2. Input the dimensions.
3. Input the values for 2 matrices.
4. Zero Padding is done if the number of elements are not equal.
5. Perform Circular Convolution Operation of 2 matrices and
store it in the third.
6. Display the result.
7. Build and debug the program and run it.
CODE:
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j, k,x2[30],a[30];
void main()
{
printf(" enter the length of the first sequence\n");
scanf("%d",&m);
printf(" enter the length of the second sequence\n");
scanf("%d",&n);
printf(" enter the first sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" enter the second sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0)
/*If length of both sequences are not equal*/
{
if(m>n)
/* Pad the smaller sequence with zero*/
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++)
/*folding h(n) to h(-n)*/
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" the circular convolution is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
OUTPUT:
EXPERIMENT-5: (DFT)
Aim: To perform DFT operation using code composer on
TMS320C6745.
Algorithm:
1. Input the elements of the sequence.
2. Find the DFT and the real & imaginary part.
3. Build and debug the program and run it.
4. Add the expressions of real and imaginary parts and
observe the graph.
CODE:
#include <stdio.h>
#include <math.h>
#define K 16
#define PI2 6.2832
int main()
{
// time and frequency domain data arrays
intn,k,j,i;
printf("enter the number of elements in the sequence \n");
scanf("%d",&i);
float x[K]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
float P[K],Abs[K];
printf("enter the elements of the sequence\n");
for(j=0;j<i;j++)
{
scanf("%f",&x[j]);
}
floatXre[K], Xim[K]; // DFT of x (real and imaginary parts)
for (k=0 ; k<K ; ++k)
{
// Real part of X[k]
Xre[k] = 0;
for (n=0 ; n<K ; ++n) Xre[k] += x[n] * cos(n * k * PI2 / K);
// Imaginary part of X[k]
Xim[k] = 0;
for (n=0 ; n<K ; ++n) Xim[k] -= x[n] * sin(n * k * PI2 / K);
// Power at kth frequency bin
P[k] = Xre[k]*Xre[k] + Xim[k]*Xim[k];
Abs[k]=sqrt(P[k]);
}
FILE *f = fopen("dftplots.txt", "w");
fprintf(f, "n = [0:%d];\n", K-1);
fprintf(f, "x = [ ");
for (n=0 ; n<K ; ++n) fprintf(f, "%f ", x[n]);
fprintf(f, "];\n");
fprintf(f, "Abs = [ ");
for (k=0 ; k<K ; ++k) fprintf(f, "%f ", Abs[k]);
fprintf(f, "];\n");
fclose(f);
return 0;
}
OUTPUT: