0% found this document useful (0 votes)
166 views11 pages

DSP Lab Experiments Using Code Composer Studio On TMS320C6745

The document contains 6 experiments performed using Code Composer Studio on the TMS320C6745 digital signal processor. The experiments include: 1) Generating a sinusoidal wave 2) Finding the sum of products of matrices 3) Performing linear convolution on matrices 4) Performing circular convolution on matrices 5) Calculating the discrete Fourier transform (DFT) of a sequence 6) Performing cross-correlation on sequences For each experiment, the document provides the aim, algorithm, code, and output. The experiments cover common digital signal processing tasks such as signal generation, matrix operations, convolution, Fourier analysis, and correlation.

Uploaded by

vedesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
166 views11 pages

DSP Lab Experiments Using Code Composer Studio On TMS320C6745

The document contains 6 experiments performed using Code Composer Studio on the TMS320C6745 digital signal processor. The experiments include: 1) Generating a sinusoidal wave 2) Finding the sum of products of matrices 3) Performing linear convolution on matrices 4) Performing circular convolution on matrices 5) Calculating the discrete Fourier transform (DFT) of a sequence 6) Performing cross-correlation on sequences For each experiment, the document provides the aim, algorithm, code, and output. The experiments cover common digital signal processing tasks such as signal generation, matrix operations, convolution, Fourier analysis, and correlation.

Uploaded by

vedesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

DSP LAB

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 :

EXPERIMENT -2 : (Sum Of Products)


Aim : To find the sum of products of given matrices using code
composer on TMS320C6745.
Algorithm :
1. Create 3 matrices.
2. Enter values for 2 Matrices.
3. Find the product of the two matrices and store it in the third matrix.
4. Create a variable to store the sum of the elements in the third
matrix.
5. Display the Sum.
Code :
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main(void)
{
inti=0,x[5]={1,2,3,4,5},y[5]={1,2,3,4,5},r[5]={0,0,0,0,0},h=0;
for(i=0;i<5;i++)
{
printf("%d",x[i]);
printf("%d",y[i]);
r[i]=x[i]*y[i];
}
for(i=0;i<5;i++)
{
h=h+r[i];
}
printf("%d",h);
return 0;
}

OUTPUT:

EXPERIMENT- 3 :(LINEAR CONVOLUTION)


Aim : To find Linear Convolution using code composer on
TMS320C6745.
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 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 x[15],h[15],y[15];
main()
{
inti,j,m,n;
printf("\n enter value for m");
scanf("%d",&m);
printf("\n enter value for n");
scanf("%d",&n);
printf("Enter values for i/p x(n):\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for i/p h(n) \n");
for(i=0;i<n; i++)
scanf("%d",&h[i]);
// padding of zeors
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
/* convolution operation */
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
}
}
//displaying the o/p
for(i=0;i<m+n-1;i++)
printf("\n%d",y[i]);
}

Output :

EXPERIMENT-4 :(CIRCULAR CONVOLUTION)


Aim :To perform Circular Convolution using code composer on
TMS320C6745.

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:

Experiment 6: (CROSS CORRELATION)


Aim: To perform correlation operation using code composer on
TMS320C6745.
CODE:
#include<stdio.h>
int m,n,X[30],RXY[30],Y[30],i,j,temp[30],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 secound sequence\n");
for(j=0;j<n;j++)
scanf("%d",&Y[j]);
for(i=n;i<m+n-1;i++)
X[i]=0;
for(i=m;i<n+m-1;i++)
Y[i]=0;
if(m>n)
a=m;
else
a=n
for(l=0;l<a;l++)
{
RXY[l]=0;
for(n=0;n<a;n++)
{
RXY[l]+=X[n+l]*X2[n];
}
}
printf("the correlation is\n");
for(i=0;i<n;i++)
printf("%d\t",RXY[i]);
}

You might also like