CODE COMPOSER STUDIO (CCS)
I. CODE COMPOSER STUDIO (CCS) 5.3 setup in simulation
Mode
Following are the steps to be followed for executing a program in CCS 5.3
1. Open code composer studio CCS 5.3.
2. Click on view----Target Configuration
If a .ccxml file already exits under user defined, delete it.
3. In order to define a new Target Configuration file:
Click on file-new- Target Configuration file-[Link]finish
4. Under Basic Settings:
Connection: Texas Instrument Simulator
Board/Device: C6713 Device Cycle Accurate Simulator, Little Endian
After making these changes click on SAVE
5. Under Advance setting:
Select TMS320C6713
GO to CPU properties:Browse
Path: ccstudioV3.1CCgel[Link](open)
6. After these settings in user defined window we get [Link] file.
Right click on this file and select Launch Target/ Selected configuration.
In order to create a new CCS project
7. Click on file newotherCCS:CCS project
Project name: abc
Output type: Executable
Family: C6000
Variant: TMS320C6713
Connection: texas instrument simulator
Select empty project with main.c
8. Write the C code in main.c and save it.
9. Go to viewProject Explorer
Click on Project Name(abc)ProjectBuild project
10. Go to project explorer. Right click on [Link] file and launch selected configuration.
11. Click on runLoadBrowse
Select [Link] file and click on OK
12. Go to run Resume
IN ORDER TO VIEW A GRAPH/PLOT
13. Go to tools - graph properties single time
Acquisition buffer size and Display data size must be set to maximum size of output
array
DSP data type: 32-bit floating point number
Start Address: Output variable in the code
II. Steps for Real Time Implementation on DSK6713 Processor Kit.
Following are the steps for for Real Time Implementation on DSK6713 Processor Kit.
Part I:
1. Open CCS 5.3 version.
2. Click on view Target configuration.
If a Click on view----Target Configuration
If a .ccxml file already exits under user defined, delete it.
3. In order to define a new Target Configuration file:
Click on file-new- Target Configuration file-[Link]finish
4. Under Basic Settings:
Connection: Texas Instrument Simulator
Board/Device: C6713 Device Cycle Accurate Simulator, Little Endian
After making these changes click on SAVE
5. Under Advance setting:
Select TMS320C6713
GO to CPU properties:Browse
Path: ccstudioV3.1CCgel[Link](open)
6. After these settings, in User defined we obtain [Link]
7. Go to run- connect target
On the right corner of the screen, A message appears “ USB Enumeration”.
PART-2: PROJECT CREATION
1. Click on filenewCCS project
Name: xyz
Connection: spectrum digital DSK EVM EZ DSP onboard DSP emulator
Output type: Executable
Family: C6000
Variant: TMS320C67XX
Connection: AS mentioned above
Select empty project with main.c
2. Select project name right clickAdd files
ccs 3.1C6000dsk6713lib[Link] (Board Support library)
Copy files and click on OK
3. Again right click on project name: Add file
ccs 3.1C6000csllib[Link]
(chip select library)
4. Right click on project name
Go to propertiesC6000 compilerInclude options
Note: If already exists a path, delete it
Click on Addfile systemccs 3.1C6000cslincludeokok
5. Again right click on project nameProperties
Select C6000 compilerAdvance optionspredefined symbolsadd
CHIP_6713ok
1. DIFFERENCE EQUATION
Description:-An Nth order linear constant – coefficient difference equation can be represented as
If we assume that the system is causal a linear difference equation provides an explicit
relationship between the input and output..this can be seen by rewriting above equation.
C Program to Implement Difference Equation
#include <stdio.h>
#include<math.h>
#define FREQ 400
float y[3]={0,0,0};
float x[3]={0,0,0};
float z[128],m[128],n[128],p[128];
main()
{
int i=0,j;
float a[3]={ 0.072231,0.144462,0.072231};
float b[3]={ 1.000000,-1.109229,0.398152};
for(i=0;i<128;i++)
{
m[i]=sin(2*3.14*FREQ*i/24000);
}
for(j=0;j<128;j++)
{
x[0]=m[j];
y[0] = (a[0] *x[0]) +(a[1]* x[1] ) +(x[2]*a[2]) - (y[1]*b[1])-(y[2]*b[2]);
z[j]=y[0];
y[2]=y[1];
y[1]=y[0];
x[2]=x[1];
x[1] = x[0];
}
}
Note: To verify the Difference Equation , Observe the output for high frequency and low
frequency by changing variable “FREQ” in the program.
2. LINEAR CONVOLUTION
Description:-Linear Convolution Involves the following operations.
1. Folding
2. Multiplication
3. Addition
4. Shifting
These operations can be represented by a Mathematical Expression as follows:
x[ ]= Input signal Samples
h[ ]= Impulse response co-efficient.
y[ ]= Convolution output.
n = No. of Input samples
h = No. of Impulse response co-efficient.
Algorithm to implement ‘C’ or Assembly program for Convolution:
Eg: x[n] = {1, 2, 3, 4}
h[k] = {1, 2, 3, 4}
Where: n=4, k=4. ;Values of n & k should be a multiple of 4.
If n & k are not multiples of 4, pad with zero’s to make
multiples of 4
r= n+k-1 ; Size of output sequence.
= 4+4-1
= 7.
Output: y[r] = { 1, 4, 10, 20, 25, 24, 16}.
NOTE: At the end of input sequences pad ‘n’ and ‘k’ no. of zero’s
C PROGRAM TO IMPLEMENT LINEAR CONVOLUTION
/* prg to implement linear convolution */
#include<stdio.h>
#include<math.h>
int y[20];
main()
{ int m=6; /*Lenght of i/p samples sequence*/
int n=6; /*Lenght of impulse response Co-efficients */
int i=0,j;
int x[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Input Signal Samples*/
int h[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Impulse Response Co-efficients*/
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
3. CIRCULAR CONVOLUTION
Description:-
Steps for Cyclic Convolution
Steps for cyclic convolution are the same as the usual convolution, except all index calculations
are done "mod N" = "on the wheel"
Step1: “Plot f[m] and h[−m]
Step 2: "Spin" h[−m] n times Anti Clock Wise (counter-clockwise) to get h[n-m]
(i.e. Simply rotate the sequence, h[n], clockwise by n steps)
Step 3: Point wise multiply the f[m] wheel and the h[n−m] wheel. Sum=y[n]
Step 4: Repeat for all 0≤n≤N−1
Example 1: Convolve (n = 4)
Figure 3: Two discrete-time signals to be convolved
h[−m] =
Multiply f[m] and sum to yield: y[0] =3
h[1−m]
Figure 5
Multiply f[m] and sum to yield: y[1] =5
h[2−m]
Figure 6
Multiply f[m] and sum to yield: y[2] =3
h[3−m]
Figure 7
Multiply f[m] and sum to yield: y[3] =1
C Program to Implement Circular Convolution
#include<stdio.h>
#include<math.h>
int m,n,x[30],h[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 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]);
}
IN PUT:Eg: x[4]={1, 2, 3,4} h[4]={1, 2, 3,4} OUT PUT y[4]={26, 28, 26,20}
Additional Programs
Generation of Sinusoid
#include<math.h>
#define FREQ 1000
float a[128];
main()
{
int i=0;
for(i=0;i<128;i++)
{
a[i]=sin(2*3.14*FREQ*i/24000);
printf("%f",a[i]);
}
}
Direct Implementation of DFT equation
Program for DFT
#include<stdio.h>
#include<math.h>
int N,k,n,i;
float pi=3.1416,sumre=0, sumim=0,out_real[8]={0.0}, out_imag[8]={0.0};
int x[32];
void main(void)
{
printf(" enter the length of the sequence\n");
scanf("%d",&N);
printf(" enter the sequence\n");
for(i=0;i<N;i++)
scanf("%d",&x[i]);
for(k=0;k<N;k++)
{
sumre=0;
sumim=0;
for(n=0;n<N;n++)
{
sumre=sumre+x[n]* cos(2*pi*k*n/N);
sumim=sumim-x[n]* sin(2*pi*k*n/N);
}
out_real[k]=sumre;
out_imag[k]=sumim;
printf("X([%d])=\t%f\t+\t%fi\n",k,out_real[k],out_imag[k]);
}
}