Sunteți pe pagina 1din 56

EXPERIMENT: 1

TO STUDY THE ARCHITECTURE OF DSP CHIPS – TMS


320C 5X/6X INSTRUCTIONS

AIM: -
To study the architecture of DSP (TMS320C6713).

THEORY: -

The hardware experiments in the DSP lab are carried out on the Texas Instruments
TMS320C6713 DSP Starter
Kit(DSK),basedontheTMS320C6713floatingpointDSPrunningat225MHz. The basic clock
cycle instruction time is 1/(225 MHz)=4.44 nanoseconds. During each clock cycle, up to
eight instructions can be carried out in parallel, achieving up to 8
×225=1800 million instructions per second (MIPS).
The C6713 processor has 256KB of internal memory, and can potentially address
4GB of external memory. The DSK board includes a 16MB SDRAM memory and a 512KB
Flash ROM. It has an on-board16-bit audio stereo codec (the Texas Instruments AIC23B)
that serves both as an A/D and a D/A converter.
There are four 3.5 mm audio jacks for microphone and stereo line input, and speaker
and head-phone outputs. The AIC23 codec can be programmed to sample audio inputs at the
following sampling rates:
fs=8,16,24,32,44.1,48,96 kHz
The ADC part of the codec is implemented as a multi-bit third-order noise-shaping delta-
sigma converter that allows a variety of oversampling ratios that can realize the above
choices offs. The corresponding oversampling decimation filters act as anti-aliasing pre filters
that limit the spectrum of the input analog signals effectively to the
Nyquistinterval[−fs/2,fs/2]. The DAC part is similarly implemented as a multi-bit second-
order noise-shapingdelta-sigma converter whose oversampling interpolation filters act as
almost ideal reconstruction filterswith the Nyquist interval as their passband.
The DSK also has four user-programmable DIP switches and four LEDs that can be
used to control and monitor programs running on the DSP.All features of the DSK are
managed by the CCS, which is a complete integrated development environment (IDE) that
includes an optimizing C/C++ compiler, assembler, linker, debugger, and programloader. The
CCS communicates with the DSK via a USB connection to a PC. In addition to facilitating
allprogramming aspects of the C6713 DSP, the CCS can also read signals stored on the
DSP’s memory, orthe SDRAM, and plot them in the time or frequency domains.

Thefollowingblockdiagramdepictstheoveralloperationsinvolvedinallofthehardwareexp
erimentsin the DSP lab. Processing is interrupt-driven at the sampling ratefs, as explained
below.
The AIC23 codec is configured (through CCS) to operate at one of the above
sampling ratesfs. Eachcollected sample is converted to a 16-bit two’s complement integer
(ashortdata type in C).

The codecactually samples the audio input in stereo, that is, it collects two samples for
the left and right channels.At each sampling instant, the codec combines the two 16-bit
left/right samples into a single 32-bitunsigned integer word (anunsigned int,orUint32data
type in C), and ships it over to a 32-bit receive-register of the multichannel buffered serial
port (McBSP) of the C6713 processor, and then issues aninterrupt to the
processor.Uponreceivingtheinterrupt, theprocessor
executesaninterruptserviceroutine(ISR)thatimplementsa desired sample processing algorithm
programmed with the CCS (e.g., filtering, audio effects, etc.).During the ISR, the following
actions take place: the 32-bit input sample (denoted byxin the diagram) isread from the
McBSP, and sent into the sample processing algorithm that computes the corresponding32-bit
output word (denoted byy), which is then written back into a 32-bit transmit-register of
theMcBSP, from where it is transferred to the codec and reconstructed into analog format,
and finally theISR returns from interrupt, and the processor begins waiting for the next
interrupt, which will come atthe next sampling instant.Clearly, all processing operations
during the execution of the ISR must be completed in the timeinterval between samples, that
is,T=1/fs.
For example, iffs=44.1 kHz, then,T=1/fs=22.68μsec.Withan instruction cycle time
ofTc=4.44 nsec, this allowsnT/Tc=5108 cycles to be executed duringeach sampling instant,
or, up to 8×5108=40864 instructions, or half of that per channel.

RESOURCES:

Most of the hardware experiments in the DSP lab are based on C code.

LAB TASKS:
In this lab, you will learn how to use some basic features of the Code Composer
Studio (CCS), such ascreating projects, compiling and linking them to the run-time libraries,
loading them for execution onthe DSP chip, using GEL files for changing program
parameters during run-time.
You will hear what aliasing effects sound like (i.e., distortions arising from using the
wrong samplingrate). You will hear what quantization effects sound like (i.e., when you use
too few bits for your audiosamples). You will find out how the stereo A/D converter packs
the two 16-bit samples from the left andright audio channels into a 32-bit word and sends it
over to the processor, and how it gets unpackedinto the two individual 16-bit left/right words
by the processor. You will also study panning betweenspeakers, and several nonlinear
input/output functions such as fuzz (hard clipping) and tube amplifier(soft clipping) for guitar
distortion
Fig: TMS 320C6713 DSK Block Diagram

THE FULL CONTENTS OF THE KIT INCLUDE:

 C6713 DSP Development Board with 512K Flash and 16MB SDRAM
 C6713 DSK Code Composer Studio™ IDE including the Fast Simulators and access
to Analysis Toolkit on Update Advisor
 Quick Start Guide
 Technical Reference
 Customer Support Guide
 USB Cable
 Universal Power Supply
 AC Power Cord(s)
 MATLAB from The Mathworks 30 day free evaluation

Ordering Information: TMDSDSK6713 includes a standard US power cord,


TMDSDSK6713-0E version includes both UK & European power cords
FEATURES

The DSK features the TMS320C6713 DSP, a 225 MHz device delivering up to 1800
million instructions per second (MIPs) and 1350 MFLOPS. This DSP generation is designed
for applications that require high precision accuracy. The C6713 is based on
the TMS320C6000 DSP platform designed to needs of high-performing high-precision
applications such as pro-audio, medical and diagnostic. Other hardware features of the
TMS320C6713 DSK board include:

 Embedded JTAG support via USB


 High-quality 24-bit stereo codec
 Four 3.5mm audio jacks for microphone, line in, speaker and line out
 512K words of Flash and 16 MB SDRAM
 Expansion port connector for plug-in modules
 On-board standard IEEE JTAG interface
 +5V universal power supply

CC STUDIO EXECUTION PROCEDURE (SIMULATOR):


Open Setup CCStudio 3

Choose:

Family ---------- C67xx

Platform --------- Simulator

Endianness------- Little

Select ---- C6713 Device Cycle Accurate Simulator

Click Import and Save&Quit

1. To Create New Project:

Project ----- New

Check

Target---TMS320C67xx and Location of Project

2. To Create A Source File:


File --- New --- Source File

Flie Type --- C Source File (*.c,*.ccc)

3. To Add Source Files To The Project:

Project ----- Add files to project----select u'r file name

File Type ---- C source file(*.c,*.ccc)

4. To Add Library File:

Project ----- Add Files to Project ---- rts6700.Lib

File Type ---- Object and library file(*.o*,*.l*)

PATH: C:\CCStudio_v3.1\c6000\cgtools\lib\rts6700.lib

5. To Add Command and Linking File:

Project ----- Add files to project ---- hello.cmd

File Type ---- Linker command file(*.cmd,*.clf)

PATH: C:\CCStudio_v3.1\tutorial\DSK 6713\hello1\hello.cmd

6. To Compile:

Project ----- Compile file

7. ToBulid Or Link:

Project ----- Build

Project ----- Rebuild all

8. To Load And Run Program:

File ----- Load Program --- Debug ---- Projectname.Out

9. To Execute The Program:


Debug ----- Run
10. Results Available On Stdout Window
11. To View The Graph:

PATH:View --> Graph ---> Time/Frequency

TMS 320C6713 KIT EXECUTION PROCEDURE:


1. Connect signal generator / audio input to the LINE IN socket or connect a
microphone to the MIC IN socket.
2. Connect CRO/Desktop Speakers to the socket provided for LINE OUT or connect a
head phone to the headphone out socket.
3. Switch on DSK Kit and Open CC Studio on the PC.
4. Use Debug -----------> Connect
5. Create New project (aaaaaaaaaaa.pjt)
6. OpenFile --------- new ---------- DSP/BIOS configuration -----------select
“DSK6713.cdb” and save it as “XYZ.cdb”.
7. add “XYZ.cdb” to the current project
PATH: PROJECT --------- add files to the project-------XYZ.cdb
8. Automatically three files are added in the generated file folder in project name( .cmd,
.s62 & .c)
9. Open file-----New ------- source file--------- type code and save(aaaaaaaa.c)
10. Add saved file to project
PATH: PROJECT --------- add files to the project-------aaaaaaaaa.c
11. Add library file (dsk6713bsl.lib)
PATH: C---CC STUDIO 3.1---C6000---DSK6713---LIB-----dsk6713bsl.lib
12. Copy header files “dsk6713.h” and “dsk6713_aic23.h”and paste in current project
PATH: C---CC STUDIO 3.1---C6000---DSK6713---INCLUDE.
13. Copy the header file from generated file in project i.e.C and replace with source file
header file
14. To Compile:
Project ----- Compile file
15. To Bulid Or Link:
Project ----- Build
Project ----- Rebuild all
16. To Load And Run Program:
File ----- Load Program --- Debug ---- Projectname.Out
17. To Execute The Program:
Debug ----- Run
RESULT:

EXPERIMENT: 2
TO VERIFY LINEAR CONVOLUTION

AIM: -To write C code and verify linear convolution results using Code Composer Studio.

TOOLS:-

Kit TMS320C6713 Cranes kit


Software: Code Composer Studio
THEORY: -

A discrete time system performs an operation on an input signal based on predefined criteria
to produce an output signal.

𝑋(𝑛)
T
𝑌(𝑛) = 𝑇[𝑋(𝑛)]

If input to the system is a unit impulse i.e. x(n)=(n) then output of system is known as
impulse response denoted as h(n).

i.e h(n)=T[(n)].
Any arbitrary sequence x(n) can be represented as weighted sum of impulses.

𝑋(𝑛) = ∑ 𝑋(𝑘)𝛿(𝑛 − 𝑘)
−∞

The response of the system y(n) is given by𝑌(𝑛) = 𝑇[𝑋(𝑛)]


𝑌(𝑛) = 𝑇 [∑ 𝑋(𝑘)𝛿(𝑛 − 𝑘)]


−∞

𝑌(𝑛) = ∑ 𝑋(𝑘) 𝑇[𝛿(𝑛 − 𝑘)]


−∞

For ℎ(𝑛) = 𝑇[𝛿(𝑛 − 𝑘)]

For time invariant system

ℎ(𝑛, 𝑘) = ℎ(𝑛 − 𝑘).


𝑌(𝑛) = ∑ 𝑋(𝑘)𝛿(𝑛 − 𝑘)
−∞

This can be represented as

𝑦(𝑛) = 𝑥(𝑛) ∗ ℎ(𝑛).

This convolution helps us to calculate system output for any arbitrary excitation.

STEPS FOR FINDING LINEAR CONVOLUTION OF TWO SEQUENCES.

1) Choose the initial value of n .the starting time for evaluating output sequence y(n).If
x(n) starts at n=n1 and h(n) starts at n=n2,then choose n such that n=n1+n2.
2) Express both sequences in terms of k.
3) Fold h(k) about k=0 , to obtain h(-k) shift n to right if n is positive or shift by n to left
if n is negative to obtain h(n-k)
4) Multiply the two sequences x(k)and h(n-k) element by element and sum the products
to get y(n).
5) Increment the index n, shift the sequence h(n-k) to right by one sample and do step 4.
6) Repeat step 5 until the sum of products is zero for all remaining values of n.

METHODS OF FINDING THE CONVOLUTION

1) Convolution Sum method


2) Graph method
3) Table method.

CC STUDIO PROCEDURE:
Open Setup CCStudio 3

Choose:

Family ---------- C67xx

Platform --------- Simulator

Endianness ------- Little

Select ---- C6713 Device Cycle Accurate Simulator

Click Import and Save&Quit

1.To Create New Project:

Project ----- New

Check

Target---TMS320C67xx and Location of Project

2.To Create A Source File:

File --- New --- Source File

Flie Type --- C Source File (*.c,*.ccc)

3.To Add Source Files To The Project:

Project ----- Add files to project----select u'r file name

File Type ---- C source file(*.c,*.ccc)

4.To Add Library File:

Project ----- Add Files to Project ---- rts6700.Lib

File Type ---- Object and library file(*.o*,*.l*)

PATH: C:\CCStudio_v3.1\c6000\cgtools\lib\rts6700.lib

5.To Add Command and Linking File:

Project ----- Add files to project ---- hello.cmd

File Type ---- Linker command file(*.cmd,*.clf)

PATH: C:\CCStudio_v3.1\tutorial\DSK 6713\hello1\hello.cmd

6.To Compile:
Project ----- Compile file

7.To Bulid Or Link:

Project ----- Build

Project ----- Rebuild all

8.To Load And Run Program:

File ----- Load Program --- Debug ---- Projectname.Out

9.To Execute The Program:

Debug ----- Run

10.Results Available On Stdout Window.

11.To View The Graph:

PATH:View --> Graph ---> Time/Frequency

PROGRAM :
#include<stdio.h>

#include<math.h>

main()

{ int m=4; /*Lenght of i/p samples sequence*/

int n=4; /*Lenght of impulse response Co-efficients *

int i=0,j;

int x[10]={1,2,3,4,0,0,0,0}; /*Input Signal Samples*/

int h[10]={1,2,3,4,0,0,0,0}; /*Impulse Response Co-efficients*/

/*At the end of input sequences pad ‘M’ and ‘N’ no. of zero’s*/

int y[10];

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]);

TEST DATA: -
INPUT DATA:- x[n]={1, 2, 3, 4, 5, 6}

h[n]= {1, 2, 3, 4, 5, 6}

OUTPUT DATA:- y[n]={1, 4, 10, 20, 35, 56, 70, 76, 73, 60, 36}

RESULT:-
EXPERIMENT: 3
TO VERIFY THE CIRCULAR CONVOLUTION

AIM: -To write C code and verify circular convolution results using Code Composer
Studio.

TOOLS:-
Kit TMS320C6713 Cranes kit
Software: Code Composer Studio
THEORY: -

The methods that are used to find the circular convolution of two sequences are
1. Concentric Circle Method.
2. Matrix Multiplication Method.

Concentric Circle Method:


 Graph N samples of x1(n) as equally spaced points around an outer circle in
anticlock wise direction.
 Start at the same point as x1(n) graph N samples of x2(n) as equally spaced
points around an inner circle in clock wise direction.
 Multiply corresponding samples on the two circles and sum the products to
produce the output.
 Rotate the inner circle one sample at a time in anticlock wise direction and go
to step 3 to obtain the next value of the output.
 Repeat step 4 until the inner circle first sample lines up with the first sample of
the exterior circle once again.

Matrix Multiplication Method:

In this method, the circular convolution of two sequences x1(n) & x2(n) can be obtained by
representing the sequences in the matrix form as shown below

X2(0) X2(N-1) X2(N-2) _ _ _ _ _ X2(2) X2(1) X1(0) = Y(0)

X2 (1) X2 (0) X 2 (N-1) _ _ _ _ _ X 2 (3) X 2 (2) X1 (1) = Y(1)


X 2 (2) X2 (1) X2 (0) _ _ _ _ _ X2 (4) X2 (3) X1 (2) = Y(2)

X2 (N-2) X2 (N-3) X2 (N-4) _ _ _ _ X2 (0) X 2 (N-1) X1 (N-2) = Y(N-2)

X2 (N-1) X2 (N-2) X 2 (N-3) _ _ _ _ X2 (1) X2 (0) X1 (N-1) = Y(N-3)

The sequence X2(n) is repeated via circular shift of samples and represented in NxN matrix
form. The sequence X1(n) is repeated as column matrix. The multiplication of these two
matrices gives the sequence y(n).

CC STUDIO PROCEDURE:
Open Setup CCStudio 3

Choose:

Family ---------- C67xx

Platform --------- Simulator

Endianness------- Little

Select ---- C6713 Device Cycle Accurate Simulator

Click Import and Save&Quit

1. To Create New Project:

Project ----- New

Check

Target---TMS320C67xx and Location of Project

2. To Create A Source File:

File --- New --- Source File

Flie Type --- C Source File (*.c,*.ccc)

3. To Add Source Files To The Project:

Project ----- Add files to project----select u'r file name

File Type ---- C source file(*.c,*.ccc)

4. To Add Library File:

Project ----- Add Files to Project ---- rts6700.Lib

File Type ---- Object and library file(*.o*,*.l*)

PATH: C:\CCStudio_v3.1\c6000\cgtools\lib\rts6700.lib
5. To Add Command and Linking File:

Project ----- Add files to project ---- hello.cmd

File Type ---- Linker command file(*.cmd,*.clf)

PATH: C:\CCStudio_v3.1\tutorial\DSK 6713\hello1\hello.cmd

6. To Compile:

Project ----- Compile file

7. ToBulid Or Link:

Project ----- Build

Project ----- Rebuild all

8. To Load And Run Program:

File ----- Load Program --- Debug ---- Projectname.Out

9. To Execute The Program:

Debug ----- Run

10. Results Available On Stdout Window.

11. To View The Graph:

PATH: View --> Graph ---> Time/Frequency

PROGRAM:
#include<stdio.h>
intm,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");
anf("%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]);
}
TEST DATA: -
INPUT DATA:- x[n]={1,2,3,4,5}

h[n]={-1,-2,-3}

OUTPUT DATA:- y[n]={-23,-19,-10,-16,-22}

RESULT:-

EXPERIMENT: 4
TO DESIGN FIR FILTER (LP/HP) USING WINDOWING
TECHNIQUE
AIM: -
To design FIR filter (LP/HP) using windowing techniques

 Using Rectangular Window


 Using Triangular Window
 Using Keiser Window

TOOLS:-
Kit TMS320C6713 Cranes kit
Software Code Composer Studio
Function Generator and CRO.
THEORY: -
Steps to design linear phase FIR filter using windowing methods:
1. Clearly specify the filter specifications

a. Order of filter (N)


b. Sampling Rate (Fs)
c. Cutoff frequency (fc)
2. Compute the Cutoff frequency (c)
1. c=2*fc/Fs
3. Compute the desired impulse response h(n) using particular window.
LOWPASS FILTER WITH CUTOFF FREQUENCY(c): -

Coefficients of linear phase filter:


hd(n)= c/ for n=

= sin(c(n-))/((n-)) for n

Where =(N-1)/2.

Window Sequence :

 For Rectagular Window

W(n) =1 for 0  n  (N-1)


=0 otherwise

 For Triangular Window


W(n)=2n/(N-1) for 0  n  (N-1)/2

=2-{2n/(N-1) for (N-1)/2  n  (N-1)


 For Keiser Window
W(n)=I0 [((N-1)2/4-[n-(N-1)/2]2)1/2] / I0[(N-1)/2] for 0  n  (N-1)
=0 otherwise

Where  is the variable parameter whose choice control the tradeoff between side lobe
amplitude and side lobe width.

4 < [(N-1)/2] <9

The Impulse Responseh(n)=hd(n)*w(n)

HIGHPASS FILTER WITH CUTOFF FREQUENCY(c): -

Coefficients of linear phase filter:

hd(n)= 1-c/ for n=

= (1/((n-))) [sin((n-))-sin(c(n-))] for n

Where  = (N-1)/2.

 Window Sequence

 For Rectagular Window:

W(n) =1 for 0  n  (N-1)/2


=0 otherwise

 For Triangular Window


W(n)=2n/(N-1) for 0  n  (N-1)/2

=2-{2n/(N-1) for (N-1)/2  n  (N-1)

 For Keiser Window


W(n) = I0 [((N-1)2/4-[n-(N-1)/2]2)1/2] / I0[(N-1)/2] for 0  n (N-1)

=0 otherwise

where  is the variable parameter whose choice control the tradeoff between side lobe
amplitude and side lobe width.

4 < [(N-1)/2] < 9

The Impulse Response h(n)=hd(n)*w(n)

4. Convolve input sequence with truncated impulse response


x(n)*h(n).
EXECUTION PROCEDURE:-

18. Connect signal generator / audio input to the LINE IN socket or connect a
microphone to the MIC IN socket.
19. Connect CRO/Desktop Speakers to the socket provided for LINE OUT or connect a
head phone to the headphone out socket.
20. Switch on DSK Kit and Open CC Studio on the PC.
21. Use Debug -----------> Connect
22. Create New project (aaaaaaaaaaa.pjt)
23. Open File --------- new ---------- DSP/BIOS configuration -----------select
“DSK6713.cdb” and save it as “XYZ.cdb”.
24. add “XYZ.cdb” to the current project
PATH: PROJECT --------- add files to the project-------XYZ.cdb
25. Automatically three files are added in the generated file folder in project name( .cmd,
.s62 & .c)
26. Open file-----New ------- source file--------- type code and save(aaaaaaaa.c)
27. Add saved file to project
PATH: PROJECT --------- add files to the project-------aaaaaaaaa.c
28. Add library file (dsk6713bsl.lib)
PATH: C---CC STUDIO 3.1---C6000---DSK6713---LIB----- dsk6713bsl.lib
29. Copy header files “dsk6713.h” and “dsk6713_aic23.h” and paste in current project
PATH: C---CC STUDIO 3.1---C6000---DSK6713---INCLUDE.
30. Copy the header file from generated file in project i.e .C and replace with source file
header file
31. To Compile:
Project ----- Compile file
32. To Bulid Or Link:
Project ----- Build
Project ----- Rebuild all
33. To Load And Run Program:
File ----- Load Program --- Debug ---- Projectname.Out
34. To Execute The Program:
Debug ----- Run

PROGRAM :
Matlab Program to generate ‘FIR Filter-Low Pass’ Coefficients using FIR1

% FIR Low pass filters using rectangular, triangular and kaiser windows
% sampling rate - 8000
order = 30;
cf=[500/4000,1000/4000,1500/4000]; cf--> contains set of cut-off frequencies[Wc ]
% cutoff frequency - 500
b_rect1=fir1(order,cf(1),boxcar(31)); Rectangular
b_tri1=fir1(order,cf(1),bartlett(31)); Triangular
b_kai1=fir1(order,cf(1),kaiser(31,8)); Kaisar [Where 8-->Beta Co-efficient]
% cutoff frequency - 1000
b_rect2=fir1(order,cf(2),boxcar(31));
b_tri2=fir1(order,cf(2),bartlett(31));
b_kai2=fir1(order,cf(2),kaiser(31,8));
% cutoff frequency - 1500
b_rect3=fir1(order,cf(3),boxcar(31));
b_tri3=fir1(order,cf(3),bartlett(31));
b_kai3=fir1(order,cf(3),kaiser(31,8));
figure
freqz(b_rect2);
hold on
freqz(b_tri2);
freqz(b_kai2);

Matlab Program to generate ‘FIR Filter-high Pass’ Coefficients using FIR1


% FIR High pass filters using rectangular, triangular and kaiser windows
% sampling rate - 8000
order = 30;
cf=[400/4000,800/4000,1200/4000]; ;cf--> contains set of cut-off frequencies[Wc]
% cutoff frequency - 400
b_rect1=fir1(order,cf(1),'high',boxcar(31));
b_tri1=fir1(order,cf(1),'high',bartlett(31));
b_kai1=fir1(order,cf(1),'high',kaiser(31,8)); Where Kaiser(31,8)--> '8'defines the value of
'beta'.

% cutoff frequency - 800


b_rect2=fir1(order,cf(2),'high',boxcar(31));
b_tri2=fir1(order,cf(2),'high',bartlett(31));
b_kai2=fir1(order,cf(2),'high',kaiser(31,8));

% cutoff frequency - 1200


b_rect3=fir1(order,cf(3),'high',boxcar(31));
b_tri3=fir1(order,cf(3),'high',bartlett(31));
b_kai3=fir1(order,cf(3),'high',kaiser(31,8));
figure
freqz(b_rect2);
hold on
freqz(b_tri2);
freqz(b_kai2);

Fir.C :
#include "filtercfg.h"

#include "dsk6713.h"

#include "dsk6713_aic23.h"

float filter_Coeff [ ] ={0.000000,-0.001591,-0.002423,0.000000,0.005728,


0.011139,0.010502,-0.000000,-0.018003,-0.033416,-0.031505,0.000000,
0.063010,0.144802,0.220534, 0.262448, 0.220534,0.144802,0.063010,0.000000, -0.031505,-
0.033416,-0.018003,- 0.000000, 0.010502, 0.011139,0.005728, 0.000000,-0.002423,-
0.001591,0.000000 };

static short in_buffer[100];

DSK6713_AIC23_Config config = {\

0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline input channel volume */\

0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume*/\

0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */\

0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */\

0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */\

0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */\


0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */\

0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */\

0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */\

0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \

};

/*

* main() - Main code routine, initializes BSL and generates tone

*/

void main()

DSK6713_AIC23_CodecHandle hCodec;

Uint32 l_input, r_input,l_output, r_output;

/* Initialize the board support library, must be called first */

DSK6713_init();

/* Start the codec */

hCodec = DSK6713_AIC23_openCodec(0, &config);

DSK6713_AIC23_setFreq(hCodec, 1);

while(1)

{ /* Read a sample to the left channel */

while (!DSK6713_AIC23_read(hCodec, &l_input));

/* Read a sample to the right channel */

while (!DSK6713_AIC23_read(hCodec, &r_input));

l_output=(Int16)FIR_FILTER(&filter_Coeff ,l_input);

r_output=l_output;

/* Send a sample to the left channel */

while (!DSK6713_AIC23_write(hCodec, l_output));

/* Send a sample to the right channel */


while (!DSK6713_AIC23_write(hCodec, r_output));

/* Close the codec */

DSK6713_AIC23_closeCodec(hCodec);

signed int FIR_FILTER(float * h, signed int x)

int i=0;

signed long output=0;

in_buffer[0] = x; /* new input at buffer[0] */

for(i=30;i>0;i--)

in_buffer[i] = in_buffer[i-1]; /* shuffle the buffer */

for(i=0;i<32;i++)

output = output + h[i] * in_buffer[i];

return(output);

MATLAB GENERATED COEFFICIENTS FOR FIR LOW PASS


KAISER FILTER:
Cutoff -500Hz
Float b_kai1[31] ={-0.000019, -0.000170,-0.000609,-0.001451, -0.002593,-0.003511,-
0.003150, 0.000000, 0.007551, 0.020655, 0.039383, 0.062306, 0.086494, 0.108031,
0.122944,
0.128279, 0.122944, 0.108031, 0.086494, 0.062306, 0.039383, 0.020655, 0.007551,
0.000000,
-0.003150, -0.003511, -0.002593, -0.001451, -0.000609, -0.000170, -0.000019};
Cutoff -1000Hz
float b_kai2[31]={-0.000035, -0.000234, -0.000454, 0.000000, 0.001933, 0.004838,
0.005671,
-0.000000, -0.013596, -0.028462, -0.029370, 0.000000, 0.064504,
0.148863,0.221349,0.249983,
0.221349, 0.148863, 0.064504, 0.000000, -0.029370,-0.028462,-0.013596,-0.000000,
0.005671,
0.004838, 0.001933, 0.000000,-0.000454,-0.000234, -0.000035};
Cutoff -1500Hz
float b_kai3[31]={-0.000046,-0.000166,0.000246,0.001414,0.001046,-0.003421,-0.007410,
0.000000,0.017764,0.020126,-0.015895,-0.060710,-0.034909,0.105263,0.289209,0.374978,
0.289209,0.105263,-0.034909,-0.060710,-0.015895,0.020126,0.017764,0.000000,-0.007410,
-0.003421,0.001046,0.001414,0.000246,-0.000166, -0.000046};

MATLAB GENERATED COEFFICIENTS FOR FIR LOW PASS


RECTANGULAR FILTER
Cutoff -500Hz
float b_rect1[31]={-0.008982,-0.017782,-0.025020,-0.029339,-0.029569,-0.024895,
-0.014970, 0.000000, 0.019247, 0.041491, 0.065053, 0.088016, 0.108421, 0.124473,
0.134729,
0.138255, 0.134729, 0.124473, 0.108421, 0.088016, 0.065053, 0.041491, 0.019247,
0.000000,
-0.014970, -0.024895, -0.029569, -0.029339, -0.025020, -0.017782, -0.008982};
Cutoff -1000Hz
float b_rect2[31] ={-0.015752,-0.023869,-0.018176,0.000000,0.021481,0.033416,0.026254,-
0.000000,-0.033755,-0.055693,-0.047257,0.000000,0.078762,0.167080,0.236286,0.262448,
0.236286,0.167080,0.078762,0.000000,-0.047257,-0.055693,-0.033755,-0.000000,0.026254,
0.033416,0.021481,0.000000,-0.018176,-0.023869,-0.015752};
Cutoff -1500Hz
float b_rect2[31]={-0.020203,-0.016567,0.009656,0.027335,0.011411,-0.023194,-0.033672,
0.000000,0.043293,0.038657,-0.025105,-0.082004,-0.041842,0.115971,0.303048,0.386435,
0.303048,0.115971,-0.041842,-0.082004,-0.025105,0.038657,0.043293,0.000000,-0.033672,
-0.023194,0.011411,0.027335,0.009656,-0.016567,-0.020203};

MATLAB GENERATED COEFFICIENTS FOR FIR LOW PASS TRIANGULAR FILTER


Cutoff -500Hz
float b_tri1[31]={0.000000,-0.001185,-0.003336,-0.005868,-0.007885,-0.008298,-0.005988,
0.000000,0.010265,0.024895,0.043368,0.064545,0.086737,0.107877,0.125747,0.138255,
0.125747,0.107877,0.086737,0.064545,0.043368,0.024895,0.010265,0.000000,-0.005988,
-0.008298,-0.007885,-0.005868,-0.003336,-0.001185,0.000000};
Cutoff -1000Hz
float b_tri2[31]={0.000000,-0.001591,-0.002423,0.000000,0.005728,0.011139,0.010502,
-0.000000,-0.018003,-0.033416,-0.031505,0.000000,0.063010,0.144802,0.220534,0.262448,
0.220534,0.144802,0.063010,0.000000,-0.031505,-0.033416,-0.018003,-0.000000,0.010502,
0.011139,0.005728,0.000000,-0.002423,-0.001591,0.000000};
Cutoff -1500Hz
float b_tri3[31]={0.000000,-0.001104,0.001287,0.005467,0.003043,-0.007731,-0.013469,
0.000000,0.023089,0.023194,-0.016737,-0.060136,-0.033474,0.100508,0.282844,0.386435,
0.282844,0.100508,-0.033474,-0.060136,-0.016737,0.023194,0.023089,0.000000,-0.013469,
-0.007731,0.003043,0.005467,0.001287,-0.001104,0.000000};

MATLAB GENERATED COEFFICIENTS FOR FIR HIGH PASS


KAISER FILTER
Cutoff -400Hz
float b_kai1[31]={0.000050,0.000223,0.000520,0.000831,0.000845,-0.000000,-0.002478,
-0.007437,-0.015556,-0.027071,-0.041538,-0.057742,-0.073805,-0.087505,-0.096739,
0.899998,-0.096739,-0.087505,-0.073805,-0.057742,-0.041538,-0.027071,-0.015556,
-0.007437,-0.002478,-0.000000,0.000845,0.000831,0.000520,0.000223,0.000050};
Cutoff -800Hz
float b_kai2[31]={0.000000,-0.000138,-0.000611,-0.001345,-0.001607,-0.000000,0.004714,
0.012033,0.018287,0.016731,0.000000,-0.035687,-0.086763,-0.141588,-0.184011,0.800005,
-0.184011,-0.141588,-0.086763,-0.035687,0.000000,0.016731,0.018287,0.012033,0.004714,
-0.000000,-0.001607,-0.001345,-0.000611,-0.000138,0.000000};
Cutoff -1200Hz
float b_kai3[31]={-0.000050,-0.000138,0.000198,0.001345,0.002212,-0.000000,-0.006489,
-0.012033,-0.005942,0.016731,0.041539,0.035687,-0.028191,-0.141589,-
0.253270,0.700008,
-0.253270,-0.141589,-0.028191,0.035687,0.041539,0.016731,-0.005942,-0.012033,-
0.006489,
-0.000000,0.002212,0.001345,0.000198,-0.000138,-0.000050};

MATLAB GENERATED COEFFICIENTS FOR FIR HIGH PASS


RECTANGULAR FILTER
Cutoff -400Hz
float b_rect1[31]={0.021665,0.022076,0.020224,0.015918,0.009129,-0.000000,-0.011158,
-0.023877,-0.037558,-0.051511,-0.064994,-0.077266,-0.087636,-0.095507,-
.100422,0.918834,
-0.100422,-0.095507,-0.087636,-0.077266,-0.064994,-0.051511,-0.037558,-0.023877,
-0.011158,-0.000000,0.009129,0.015918,0.020224,0.022076,0.021665};

Cutoff -800Hz
float b_rect2[31]={0.000000,-0.013457,-0.023448,-0.025402,-0.017127,-0.000000,0.020933,
0.038103,0.043547,0.031399,0.000000,-0.047098,-0.101609,-0.152414,-0.188394,0.805541,
-0.188394,-0.152414,-0.101609,-0.047098,0.000000,0.031399,0.043547,0.038103,0.020933,
-0.000000,-0.017127,-0.025402,-0.023448,-0.013457,0.000000};
Cutoff -1200Hz
float b_rect3[31]={-0.020798,-0.013098,0.007416,0.024725,0.022944,-0.000000,-0.028043,
-0.037087,-0.013772,0.030562,0.062393,0.045842,-0.032134,-0.148349,-
0.252386,0.686050,
-0.252386,-0.148349,-0.032134,0.045842,0.062393,0.030562,-0.013772,-0.037087,-
0.028043,
-0.000000,0.022944,0.024725,0.007416,-0.013098,-0.020798};

MATLAB GENERATED COEFFICIENTS FOR FIR HIGH PASS


TRIANGULAR FILTER

Cutoff -400Hz
float b_tri1[31]={0.000000,0.001445,0.002648,0.003127,0.002391,-0.000000,-0.004383,
-0.010943,-0.019672,-0.030353,-0.042554,-0.055647,-0.068853,-0.081290,-0.092048,
0.902380,-0.092048,-0.081290,-0.068853,-0.055647,-0.042554,-0.030353,-0.019672,
-0.010943,-0.004383,-0.000000,0.002391,0.003127,0.002648,0.001445,0.000000};

Cutoff -800Hz
float b_tri2[31]={0.000000,-0.000897,-0.003126,-0.005080,-0.004567,-0.000000,0.008373,
0.017782,0.023225,0.018839,0.000000,-0.034539,-0.081287,-0.132092,-0.175834,0.805541,
-0.175834,-0.132092,-0.081287,-0.034539,0.000000,0.018839,0.023225,0.017782,0.008373,
-0.000000,-0.004567,-0.005080,-0.003126,-0.000897,0.000000};

Cutoff -1200Hz
float b_tri3[31]={0.000000,-0.000901,0.001021,0.005105,0.006317,-0.000000,-0.011581,
-0.017868,-0.007583,0.018931,0.042944,0.034707,-0.026541,-0.132736,-
0.243196,0.708287,
-0.243196,-0.132736,-0.026541,0.034707,0.042944,0.018931,-0.007583,-0.017868,-
0.011581,
-0.000000,0.006317,0.005105,0.001021,-0.000901,0.000000};

MATLAB GENERATED FREQUENCY RESPONSE


High Pass FIR filter(Fc= 800Hz).

Low Pass FIR filter (Fc=1000Hz)


RESULT:-

EXPERIMENT: 5
TO IMPLEMENT IIR FILTER (LP/HP) ON DSP
PROCESSORS.

AIM:

To write a MATLAB program for analog low pass and high pass filters and to plot the
frequency responses.

SOFTWARE TOOLS:

Operating system windows 98 and above versions

Software MAT LAB 6.5 and above versions

PROCEDURE:

 Open MATLAB 6.5 Version on screen


 Click the file and select new source file
 Type the code and save it
 Run the program
 Note the readings from displayed graph

THEORY :

A resistor–capacitor circuit (RC circuit), or RC filter or RC network, is an electric


circuit composed of resistors and capacitors driven by a voltage or current source. A first
order RC circuit is composed of one resistor and one capacitor and is the simplest type of RC
circuit.

RC circuits can be used to filter a signal by blocking certain frequencies and passing
others. The two most common RC filters are the high-pass filters and low-pass filters; band-
pass filters and band-stop filters usually require RLC filters, though crude ones can be made
with RC filters.

RC Low Pass Filter:

The low-pass RC filter, or integrator, is used to remove high frequencies from a


signal. Applications include the removal of RF pick-up noise and reducing ripple voltages on
power supplies. The circuit shown in fig 2(a) and model graphs shown in fig1.

The gain of the RC low pass filter is

Where

The phase of the RC Low pass filter is


Fig1: Relative magnitude (left) and phase (right) of the output ofan RC low-pass filter.

A)RC Low pass Filter B) RC High pass filter


Fig2: RC Low pass and high pass filter

RC High pass filter:

A high-pass filter is an electronic filter that passes signals with a frequency higher
than a certain cutoff frequency and attenuates signals with frequencies lower than the cutoff
frequency. The amount of attenuation for each frequency depends on the filter design. A
high-pass filter is usually modeled as a linear time-invariant system. It is sometimes called
a low-cut filter or bass-cut filter.The simple first-order electronic high-pass filter shown in
Figure 1 is implemented by placing an input voltage across the series combination of
a capacitor and a resistor and using the voltage across the resistor as an output. The product
of the resistance and capacitance (R×C) is the time constant (τ); it is inversely proportional to
the cutoff frequency fc, that is,

supplies. The circuit shown in fig 2(b) and model graphs shown in fig3.
The gain of the RC low pass filter is

Where
The phase of the RC Low pass filter is

Fig 3 Relative magnitude (left) and phase (right) of the output of an RC high -pass filter.

PROGRAM:
%% Generation of coefficients for analog low pass filter %%
r =1000;
c = 0.000001;
w1 = 1/(r*c);
h1 = [];
w2 = [];
theta1= [];
for w= 10:10:10000
h=(1/sqrt(1+(w/w1)^2));
theta=-atan(w/w1);
theta1=[theta1,theta];
deg=rad2deg(theta1);
h1=[h1,h];
w2=[w2,w];
end
subplot(2,1,1);
semilogx(w2,h1,'k-');
grid on;
xlabel('angular frequency');
ylabel('gain');
title('generation of low pass filter')
subplot(2,1,2);
plot(w2,deg,'k-');
grid on;
xlabel('frequency');
ylabel('phase angle');

%% Generation of coefficients for analog high pass filter %%


r = 10000;
c = 0.000001;
w1 = 1/(r*c);
h1 = [];
w2 = [];
theta1 = [];
for w = 10:10:10000
h = (1/sqrt(1+(w1/w)^2));
theta = atan(w1/w);
theta1 = [theta1,theta];
deg = rad2deg(theta1);
h1 = [h1,h];
w2 = [w2,w];
end
subplot(2,1,1);
semilogx(w2,h1,'k-');
grid on;
xlabel('angular frequency');
ylabel('gain');
title('generation of high pass filter')
subplot(2,1,2);
plot(w2,deg,'k-');
grid on; xlabel('frequency'); ylabel('phase angle');
NAME Theoretical cut off frequency Theoretical cut off frequency

LPF 1000 rad/sec 1000 rad/sec

HPF 100 rad/sec 100 rad/sec


RESULT:

EXPERIMENT: 6

N-POINT FFT ALGORITHM.

AIM: -
To write a C program to implement N-point FFT

TOOLS:-
Kit: TMS320C6713 Cranes kit
Software: Code Composer Studio

THEORY: -
Steps of DIT-FFT algorithm: -

 The number of input samples N=2^M, where M is an integer


 The input sequence is shuffled through bit reversal.
 The number of stages in the flow graph is given by M=log 2N
 Each stage of N/2 butterflies.
 Inputs/outputs for each butterfly are separated by 2^(m-1) samples, where ‘m’
represents the stage index, i.e., for 1st stage m=1 and for 2nd stage m=2 and so on.
 The number of complex multiplications is given by N/2*log2 N.
 The number of complex additions is given by N*log2 N.
 The twiddle factor exponents are a function of stage index ‘m’ and is given by
K=Nt/2^m t=0,1,2… 2^(m-1).
 The number of sets or sections of butterflies in each stage is given by the formula
2^(M-m).
 The exponent repeat factor (ERF), which is the number of times the exponent
sequence associated with ‘m’ is repeated is given by
2^(M-m).

FFT algorithm: -

1. Pad input sequence, of N samples, with Zero’s until the number of samples is the nearest
power of two.
2. Bits reverse the input sequence.
3. Compute (N / 2) two sample DFT's from the shuffled inputs.
4. Compute (N / 4) four sample DFT's from the two sample DFT's.
5. Compute (N / 2) eight sample DFT's from the four sample DFT's.

6. until the all the samples combine into one N-sample DFT

PROGRAM: -

Main.c (fft 256.c):

#include <math.h>

#define PTS 64 //# of points forFFT

#define PI 3.14159265358979

typedef struct {float real,imag;} COMPLEX;


void FFT(COMPLEX *Y, int n); //FFT prototype

float iobuffer[PTS]; //as input and output buffer

float x1[PTS]; //intermediate buffer

short i; //general purpose index variable

short buffercount = 0; //number of new samples in iobuffer

short flag = 0; //set to 1 by ISR when iobuffer full

COMPLEX w[PTS]; //twiddle constants stored in w

COMPLEX samples[PTS]; //primary working buffer

main()

for (i = 0 ; i<PTS ; i++) // set up twiddle constants in w

w[i].real = cos(2*PI*i/(PTS*2.0)); //Re component of twiddle constants

w[i].imag =-sin(2*PI*i/(PTS*2.0)); //Im component of twiddle constants

for (i = 0 ; i < PTS ; i++) //swap buffers

iobuffer[i] = sin(2*PI*10*i/64.0); /*10- > freq, 64 -> sampling freq*/

samples[i].real=0.0;

samples[i].imag=0.0;

for (i = 0 ; i < PTS ; i++) //swap buffers

samples[i].real=iobuffer[i]; //buffer with new data

}
for (i = 0 ; i < PTS ; i++)

samples[i].imag = 0.0; //imag components = 0

FFT(samples,PTS); //call function FFT.c

for (i = 0 ; i < PTS ; i++) //compute magnitude

x1[i] = sqrt(samples[i].real*samples[i].real

+ samples[i].imag*samples[i].imag);

} //end of main

FFT.C:

#define PTS 64 //# of points for FFT

typedef struct {float real,imag;} COMPLEX;

extern COMPLEX w [PTS]; //twiddle constants stored in w

void FFT(COMPLEX *Y, int N) //input sample array, # of points

COMPLEX temp1,temp2; //temporary storage variables

int i,j,k; //loop counter variables

int upper_leg, lower_leg; //index of upper/lower butterfly leg

int leg_diff; //difference between upper/lower leg


int num_stages = 0; //number of FFT stages (iterations)

int index, step; //index/step through twiddle constant

i = 1; //log(base2) of N points= # of stages

do

num_stages +=1;

i = i*2;

}while (i!=N);

leg_diff = N/2; //difference between upper&lower legs

step = (PTS*2)/N; //step between values in twiddle.h

for (i = 0;i < num_stages; i++) //for N-point FFT

index = 0;

for (j = 0; j < leg_diff; j++)

for (upper_leg = j; upper_leg < N; upper_leg += (2*leg_diff))

lower_leg = upper_leg+leg_diff;

temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;

temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;

temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;

temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;

(Y[lower_leg]).real = temp2.real*(w[index]).real

-temp2.imag*(w[index]).imag;

(Y[lower_leg]).imag = temp2.real*(w[index]).imag
+temp2.imag*(w[index]).real;

(Y[upper_leg]).real = temp1.real;

(Y[upper_leg]).imag = temp1.imag;

index += step;

leg_diff = leg_diff/2;

step *= 2;

j = 0;

for (i = 1; i < (N-1); i++) //bit reversal for resequencing data

k = N/2;

while (k <= j)

j = j - k;

k = k/2;

j = j + k;

if (i<j)

temp1.real = (Y[j]).real;

temp1.imag = (Y[j]).imag;

(Y[j]).real = (Y[i]).real;

(Y[j]).imag = (Y[i]).imag;
(Y[i]).real = temp1.real;

(Y[i]).imag = temp1.imag;
}
}
return;
}

MODEL GRAPHS:

Input:

Output:
RESULT:-

EXPERIMENT: 7
TO COMPUTE POWER DENSITY SPECTRUM OF A
SEQUENCE

AIM: -
To write a C program to calculate power spectral density for a given sequence .
TOOLS:-
Kit TMS320C6713 Cranes kit
Software Code Composer Studio
THEORY: -
Finite energy signals possesses a fourier transform and are characterized in spectral
domain by their energy density spectrum. But on other hand the important class of signals
characterized as random process do not have finite energy and hence do not possess a fourier
transforms. Such signals have finite average power and hence are characterized by power
spectral density
The power spectral density spectrum of a random signal is fourire transform of auto
correlation function. The total area under the Power Spectrum or PSD is equal to the total
avg. power of the signal.
To compute PSD:
The value of the auto-correlation function at zero-time equals the total power in the signal. To
compute PSD We compute the auto-correlation of the signal and then take its FFT. The auto-
correlation function and PSD are a Fourier transform pair. (Another estimation method called “period
gram” uses sampled FFT to compute the PSD.)

E.g.: For a process x(n) correlation is defined as:

R ( )  E{x ( n) x ( n   )}
N
1
 lim
N  N
 x ( n) x ( n   )
n 1

Power Spectral Density is a Fourier transform of the auto correlation

N 1
S ( )  FT ( R( ))  lim
N 


 N 1
ˆ ( )e  j
R

1
R ( )  FT 1 ( S ( ))   S ( )e d
j

2
CC STUDIO PROCEDURE:-
Open Setup CCStudio 3
Choose:
Family ---------- C67xx
Platform --------- Simulator
Endianness ------- Little
Select ---- C6713 Device Cycle Accurate Simulator
Click Import and Save&Quit
1. To Create New Project:
Project ----- New
Check
Target---TMS320C67xx and Location of Project
2. To Create A Source File:
File --- New --- Source File
Flie Type --- C Source File (*.c,*.ccc)
3. To Add Source Files To The Project:
Project ----- Add files to project----select u'r file name
File Type ---- C source file(*.c,*.ccc)
4. To Add Library File:
Project ----- Add Files to Project ---- rts6700.Lib
File Type ---- Object and library file(*.o*,*.l*)
PATH: C:\CCStudio_v3.1\c6000\cgtools\lib\rts6700.lib
5. To Add Command and Linking File:
Project ----- Add files to project ---- hello.cmd
File Type ---- Linker command file(*.cmd,*.clf)
PATH: C:\CCStudio_v3.1\tutorial\DSK 6713\hello1\hello.cmd
6. To Compile:
Project ----- Compile file
7. To Bulid Or Link:
Project ----- Build
Project ----- Rebuild all
8. To Load And Run Program:
File ----- Load Program --- Debug ---- Projectname.Out

9. To Execute The Program:


Debug ----- Run
10. Results Available On Stdout Window.
11. To View The Graph:
PATH:View --> Graph ---> Time/Frequency

PROGRAM
#include <stdio.h>
#include <math.h>
#define PTS 128
#define PI 3.14159265358979
typedef struct {float real,imag;} COMPLEX;
float x[PTS],x1[PTS],x2[PTS],x3[PTS];
COMPLEX samples[PTS]; //primary working buffer
main( )
{
int k,i; /****************Input Signal X(n) *************************/
for(i=0,;i<PTS;i++)

{
x[i] = sin(2*PI*5*i/PTS);
} /********************Auto Correlation of X(n)=R(t) ***********/
for(i=0;i<PTS;i++)
{
X2[i]=0;
for(k=0;k<PTS-i;k++)
{
X2[i]= X2[i]+(x[k]*x[i+k]); // Auto Correlation R(t)
}
} /********************** FFT of R(t) **********************/
for (i = 0 ; i < PTS ; i++) //swap buffers
{
samples[i].real=0;
samples[i].imag = 0;
for (k= 0 ; k < PTS ; k++)
{
samples[i].real+=x2[k]*cos(2*PI*i*k/PTS);
samples[i].imag+=(-1)*x2[k]*sin(2*PI*i*k/PTS);
}
}
/******************** PSD ********************/
for (i = 0 ; i < PTS ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real + samples[i].imag*samples[i].imag);
x3[i]=-atan(samples[i].imag/ samples[i].real);
}
} //end of main

RESULT:-

EXPERIMENT:
CODAC
AIM: -
To design FIR filter (LP/HP) using windowing techniques

 Using Rectangular Window


 Using Triangular Window
 Using Keiser Window
TOOLS:-
Kit TMS320C6713 Cranes kit
Software Code Composer Studio
Function Generator and CRO.

EXECUTION PROCEDURE:-

35. Connect signal generator / audio input to the LINE IN socket or connect a
microphone to the MIC IN socket.
36. Connect CRO/Desktop Speakers to the socket provided for LINE OUT or connect a
head phone to the headphone out socket.
37. Switch on DSK Kit and Open CC Studio on the PC.
38. Use Debug -----------> Connect
39. Create New project (aaaaaaaaaaa.pjt)
40. Open File --------- new ---------- DSP/BIOS configuration -----------select
“DSK6713.cdb” and save it as “XYZ.cdb”.
41. add “XYZ.cdb” to the current project
PATH: PROJECT --------- add files to the project-------XYZ.cdb
42. Automatically three files are added in the generated file folder in project name( .cmd,
.s62 & .c)
43. Open file-----New ------- source file--------- type code and save(aaaaaaaa.c)
44. Add saved file to project
PATH: PROJECT --------- add files to the project-------aaaaaaaaa.c
45. Add library file (dsk6713bsl.lib)
PATH: C---CC STUDIO 3.1---C6000---DSK6713---LIB----- dsk6713bsl.lib
46. Copy header files “dsk6713.h” and “dsk6713_aic23.h” and paste in current project
PATH: C---CC STUDIO 3.1---C6000---DSK6713---INCLUDE.
47. Copy the header file from generated file in project i.e .C and replace with source file
header file
48. To Compile:
Project ----- Compile file
49. To Bulid Or Link:
Project ----- Build
Project ----- Rebuild all
50. To Load And Run Program:
File ----- Load Program --- Debug ---- Projectname.Out
51. To Execute The Program:
Debug ----- Run

PROGRAM :
#include "xyzcfg.h"

#include "DSK6713.h"

#include "DSK6713_AIC23.h"

DSK6713_AIC23_Config config={

0x0017, 0x0017, 0x00d8, 0x00d8, 0x0011, 0x0000, 0x0000, 0x0043, 0x0081, 0x0001,

};

void main()

DSK6713_AIC23_CodecHandle hCodec;

int l_input,r_input,l_output,r_output;

DSK6713_init();

hCodec=DSK6713_AIC23_openCodec(0,&config);

DSK6713_AIC23_setFreq(hCodec,3);

while(1)

while(!DSK6713_AIC23_read(hCodec,&l_input));

while(!DSK6713_AIC23_read(hCodec,&r_input));

while(!DSK6713_AIC23_write(hCodec,l_input));

while(!DSK6713_AIC23_write(hCodec,r_input));

DSK6713_AIC23_closeCodec(hCodec);

}
RESULT:-

AUTO CORRELATION
AIM: -
To write a C program to calculate autocorrelation between two sequences.
TOOLS:-
Kit TMS320C6713 Cranes kit
Software Code Composer Studio
THEORY: -
Finite energy signals possesses a fourier transform and are characterized in spectral
domain by their energy density spectrum. But on other hand the important class of signals
characterized as random process do not have finite energy and hence do not possess a fourier
transforms. Such signals have finite average power and hence are characterized by power
spectral density
The power spectral density spectrum of a random signal is fourire transform of auto
correlation function. The total area under the Power Spectrum or PSD is equal to the total
avg. power of the signal.
TO COMPUTE PSD:
The value of the auto-correlation function at zero-time equals the total power in the
signal. To compute PSD We compute the auto-correlation of the signal and then take its FFT.
The auto-correlation function and PSD are a Fourier transform pair. (Another estimation
method called “period gram” uses sampled FFT to compute the PSD.)

E.g.: For a process x(n) correlation is defined as:

R ( )  E{x ( n) x ( n   )}
N
1
 lim
N  N
 x ( n) x ( n   )
n 1

Power Spectral Density is a Fourier transform of the auto correlation

N 1
S ( )  FT ( R( ))  lim
N 


 N 1
ˆ ( )e  j
R

1
R ( )  FT 1 ( S ( ))   S ( )e d
j

2

PROCEDURE:-
Open Setup CCStudio 3
Choose:
Family ---------- C67xx
Platform --------- Simulator
Endianness ------- Little
Select ---- C6713 Device Cycle Accurate Simulator
Click Import and Save&Quit
1. To Create New Project:
Project ----- New
Check
Target---TMS320C67xx and Location of Project
2. To Create A Source File:
File --- New --- Source File
Flie Type --- C Source File (*.c,*.ccc)
3. To Add Source Files To The Project:
Project ----- Add files to project----select u'r file name
File Type ---- C source file(*.c,*.ccc)
4. To Add Library File:
Project ----- Add Files to Project ---- rts6700.Lib
File Type ---- Object and library file(*.o*,*.l*)
PATH: C:\CCStudio_v3.1\c6000\cgtools\lib\rts6700.lib
5. To Add Command and Linking File:
Project ----- Add files to project ---- hello.cmd
File Type ---- Linker command file(*.cmd,*.clf)
PATH: C:\CCStudio_v3.1\tutorial\DSK 6713\hello1\hello.cmd
6. To Compile:
Project ----- Compile file
7. To Bulid Or Link:
Project ----- Build
Project ----- Rebuild all
8. To Load And Run Program:
File ----- Load Program --- Debug ---- Projectname.Out
9. To Execute The Program:
Debug ----- Run
10. Results Available On Stdout Window.
11. To View The Graph:
PATH:View --> Graph ---> Time/Frequency

PROGRAM
#include <stdio.h>
#include <math.h>
#define PTS 128
#define PI 3.14159265358979
typedef struct {float real,imag;} COMPLEX;
float x[PTS],x1[PTS],x2[PTS],x3[PTS];
COMPLEX samples[PTS]; //primary working buffer
main( )
{
int k,i; /****************Input Signal X(n) *************************/
for(i=0,;i<PTS;i++)

{
x[i] = sin(2*PI*5*i/PTS);
} /********************Auto Correlation of X(n)=R(t) ***********/
for(i=0;i<PTS;i++)
{
X2[i]=0;
for(k=0;k<PTS-i;k++)
{
X2[i]= X2[i]+(x[k]*x[i+k]); // Auto Correlation R(t)
}
} /********************** FFT of R(t) **********************/
for (i = 0 ; i < PTS ; i++) //swap buffers
{
samples[i].real=0;
samples[i].imag = 0;
for (k= 0 ; k < PTS ; k++)
{
samples[i].real+=x2[k]*cos(2*PI*i*k/PTS);
samples[i].imag+=(-1)*x2[k]*sin(2*PI*i*k/PTS);
}
}
/******************** PSD ********************/
for (i = 0 ; i < PTS ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real + samples[i].imag*samples[i].imag);
x3[i]=-atan(samples[i].imag/ samples[i].real);
}
} //end of main
RESULT:-

S-ar putea să vă placă și