Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

19/09/2022 R Meghana

20BEC1042

EXPERIMENT 8
CONVOLUTION AND CORRELATION USING CCS

Aim: To perform convolution and correlation using code composer studio


(CCS).

Software Required: Code composer studio (CCS)

Program code:
 Convolution
#include<stdio.h>
#include<math.h> #define
length1 4
#define length2 4
int X[2*length1-1]={1,2,3,1,0,0,0};
int H[2*length2-1]={1,2,1,-1,0,0,0};
int y[length1+length2-1];
int k;
int main(void)
{
int i,j=0;
for (i=0;i<length1+length2-1;i++)
{
y[i]=0;
for (j=0;j<=i;j++)
{
y[i]=y[i]+X[j]*H[i-j];
}
}
for (i=0;i<length1+length2-1;i++)
{
k=y[i];
printf("\n %d",k);
}
return 0;

ECE2006-Digital Signal Processing Lab


L31+L32
19/09/2022 R Meghana
20BEC1042
}
 Correlation
#include<stdio.h>
#include<math.h>
#define n 7
#define m 7
int X[n]={1,2,3,4,0,0,0};
int H[m]={2,1,3,1,0,0,0};
int h[m];
int k;
int y[n+m-1];

int main(void)
{
int i=0,j;
for (i=0;i<m;i++)
{
h[i]=H[(m-1)-i];
}
for (i=0;i<(n+m-1);i++)
{
y[i]=0;
for (j=0;j<=i;j++)
{
y[i]=y[i]+(X[j]*h[i-j]);
}
}
for (i=0;i<n+m-1;i++)
{
if(i>=3 && i<=9)
{
k=y[i];
printf("\n %d",k);
}
}
return 0;
}

ECE2006-Digital Signal Processing Lab


L31+L32
19/09/2022 R Meghana
20BEC1042

Output:

 Convolution

ECE2006-Digital Signal Processing Lab


L31+L32
19/09/2022 R Meghana
20BEC1042

 Correlation

Result: We have thus performed convolution and correlation using code


composer studio (CCS), and have observed the same. Also, the theoretical
calculations also match the simulated output.

Output Verification:

ECE2006-Digital Signal Processing Lab


L31+L32
19/09/2022 R Meghana
20BEC1042

ECE2006-Digital Signal Processing Lab


L31+L32

You might also like