Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SE
EC
E,
KS
of
De
pt
Prepared By
Table of Contents
PART A
Verification of Sampling theorem.
11
15
18
21
23
26
10
29
11
32
12
De
pt
of
EC
E,
KS
SE
1
4
7
36
PART B
About the DSP Trainer Kit
SE
44
47
56
58
60
62
Viva Questions
64
De
pt
of
EC
E,
KS
5th Sem
KSSEM, Bangalore
PROGRAM 1
SE
Generate a sinusoidal wave of 1kHz. Calculate the Nyquist frequency, and verify
Sampling Theorem, showing output waveforms for undersampled, oversampled and right
sampled cases.
Theory:
( )=
KS
Sampling is the process of converting an continuous time signal into a discrete time signal.
In sampling, the values of the continuous time signal is recorded at discrete intervals of time
(usually equidistant). The number of samples taken during one second is called the sampling
rate.
(
<
<
E,
Where ( ) is the discrete-time signal obtained by sampling the analog signal every T
seconds. = 1/ is known as the Sampling Frequency.
EC
of
( ) = sin( ) = sin(2
Assume a band-limited signal
) with maximum
frequency component . The theorem says that, for a good reconstruction of the original
continuous time signal, the sampling frequency must be at least 2 . This frequency is known
as the Nyquist Rate.
Sampling this signal at
)=
sin
( )=
sin 2
2
De
pt
Now, assuming the sampling frequency is more than the Nyquist Frequency, the
continuous time signal can be reconstructed accurately using the interpolation function:
Dept of ECE
( )=
Page | 1
5th Sem
KSSEM, Bangalore
Whenever the Sampling frequency is greater than or equal to the Nyquist Frequency, the
signal can be reconstructed faithfully, capturing all the essential properties of the original
continuous-time signal. However, when < 2 , we encounter a problem called Aliasing,
where distortion is caused by high frequencies overlapping low frequencies. A lot of data is
lost in this process and the signal cannot be recovered.
%
%
%
%
%
KS
% Signal Parameters
f1 = 1000;
f2 = 1900;
fmax = max(f1,f2);
T = 1/min(f1,f2);
t = 0:0.01*T:2*T;
SE
MATLAB CODE:
% Composite Signal
% Oversampling Condition:
fs1 = 10*fmax;
EC
E,
x = cos(2*pi*t*f1)+ cos(2*pi*t*f2);
subplot(2,2,1);
plot(t,x); grid on;
title('Continuous signal');
xlabel('t');
ylabel('x(t)');
of
n1 = 0:1/fs1:2*T;
% Time scale
x1 = cos(2*pi*f1*n1)+cos(2*pi*f2*n1);
% Generating sampled signal
subplot(2,2,2);
stem(n1,x1);
hold on;
plot(n1,x1,'r'); grid on;
hold off;
title('Oversampling Condition : Fs = 10F');
xlabel('n');
ylabel('x(n)');
pt
De
n2 = 0:1/fs2:2*T;
x2 = cos(2*pi*f1*n2)+cos(2*pi*f2*n2);
subplot(2,2,3);
stem(n2,x2);
hold on;
plot(n2,x2,'r'); grid on;
hold off;
title('Sampling at Nyquist Frequency : Fs = 2F');
xlabel('n');
ylabel('x(n)');
Dept of ECE
Page | 2
5th Sem
KSSEM, Bangalore
n3 = 0:1/fs3:2*T;
x3 = cos(2*pi*f1*n3)+cos(2*pi*f2*n3);
subplot(2,2,4);
stem(n3,x3);
hold on;
plot(n3,x3,'r'); grid on;
hold off;
title('Undersampling Condition : Fs = 1.2 f');
xlabel('n');
ylabel('x(n)');
De
pt
of
EC
E,
KS
OUTPUT:
SE
Dept of ECE
Page | 3
5th Sem
KSSEM, Bangalore
PROGRAM 2
IMPULSE RESPONSE OF A GIVEN SYSTEM
Aim: To write the MATLAB code to find the impulse response of a given second-order
system whose difference equation representation is given.
SE
Theory:
KS
Impulse response of a system is defined as the output of a given system, when the input
applied to the system, is in the form of a unit impulse, or a Dirac delta function. The impulse
response completely characterizes the behaviour of any LTI system. The impulse response is
often determined from knowledge of the system configuration and dynamics, or can be
measured by applying and approximate impulse to the system input.
E,
Discrete-time LTI systems can also be described using Difference Equations. A linear
constant-coefficient difference equation can be of the form:
EC
[ ]=
[ ]
Where the integer N is termed the order of the difference equation, and corresponds to the
maximum memory involving the system output. The order generally represents the number of
energy storage devices in a physical system.
We can calculate the impulse response of the system using Z-transforms as shown in the
following example:
of
pt
( ) + 3 ( 1) 0.12 ( 2) =
De
Or:
( )+3
( )[1 + 3
Dept of ECE
0.12
( ) + 0.2 ( 1) 1.5 ( 2)
( ) = ( ) + 0.2
] = ( )[1 + 0.2
( ) 1.5
1.5
( )
]
Page | 4
5th Sem
KSSEM, Bangalore
( ) = 1 2.8
( ) [1 + 3
=
( ) [1 + 0.2
+ 7.02
0.12
1.5
21.4
]
]
+ 65.03
SE
( )=
7.02
21.4
65.03]
KS
[ ] = [1
MATLAB CODE:
E,
%
b
a
N
[h,t] = impz(b,a,N);
EC
pt
OUTPUT:
of
De
Dept of ECE
Page | 5
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 6
5th Sem
KSSEM, Bangalore
PROGRAM 3
LINEAR CONVOLUTION OF TWO GIVEN SEQUENCES
Aim: To write the MATLAB code to perform Linear Convolution upon two given discrete
time signals.
SE
Theory:
KS
Convolution is the process used to find the response of a Linear Time Invariant system to a
given input, assuming we already know the impulse response of that system. In case of
continuous-time signals, we can find the system response using the Convolution Integral,
while in case of discrete-time systems, the response can be calculated using the Convolution
Sum.
( ) be two discrete-time signals. The convolution sum of the two signals
Let ( ) and
can be calculated using the formula:
( ) = 1( ) 2( ) =
1( ) 2( )
E,
EC
of
pt
Assume two discrete-time sequences 1 and 2 in a Linear Time Invariant System, given
by:
1( ) = {1, 2, 1, 3} and 2( ) = {2,3, 2}
De
Dept of ECE
1 11
6}
Page | 7
5th Sem
KSSEM, Bangalore
MATLAB CODE:
1. Using conv function:
SE
E,
subplot(3,1,2);
stem(x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
KS
EC
subplot(3,1,3);
stem(y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
% Display the convolved Sequence in Command Window
disp('Convolved sequence:');
disp(y);
of
pt
De
N = n1+n2-1;
T = 1:N;
Dept of ECE
Page | 8
5th Sem
KSSEM, Bangalore
for n = 1:N
%
y(n) = 0R;
for k = 1:n
y(n)=y(n)+x1(k)*x2(n-k+1);
end
end
KS
subplot(3,1,2);
stem(T,x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
SE
subplot(3,1,3);
stem(T,y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
EC
E,
OUTPUT:
De
pt
of
Dept of ECE
Page | 9
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 10
5th Sem
KSSEM, Bangalore
PROGRAM 4
CIRCULAR CONVOLUTION OF TWO GIVEN SEQUENCES
Aim: To write the MATLAB code to perform Circular Convolution upon two given discrete
time signals.
SE
Theory:
KS
The Circular convolution, also known as cyclic convolution, of two aperiodic functions occurs
when one of them is convolved in the normal way with a periodic summation of the other
function. Circular convolution is only defined for finite length functions (usually equal in
length), continuous or discrete in time. In circular convolution, it is as if the finite length
functions repeat in time, periodically. Because the input functions are now periodic, the
convolved output is also periodic.
Circular convolution sum can be calculated using the formula:
1( ) 2 (
E,
= 0,1, . ,
For
( ) = 1( ) 2( ) =
EC
of
1. Using the expression for linear convolution sum, but assuming the signal repeats
periodically. This can be done by changing the negative indices of (n-k) to repetitions
of the latter portions of the original aperiodic signal.
2. Convolution in time domain corresponds to multiplication in frequency domain. To
make use of this property, we can calculate the DTFT of each of the aperiodic signals,
multiply these in the frequency domain, and find the IDFT of the product, to get the
periodic convolved signal in time domain.
Let us take the case of two discrete-time aperiodic signals given by:
1( ) = {2,1,2,1}
and
De
pt
2( ) = {1,2,3,4}
For m = 1:
For m = 2:
Dept of ECE
(0) =
(1) =
1( ) 2 ( )
1( ) 2 (1 )
= 14
= 16
Page | 11
5th Sem
(2) =
1( ) 2 (2 )
= 14
(3) =
1( ) 2 (3 )
= 16
SE
For m = 3:
KSSEM, Bangalore
( ) = {14,16,14,16}
KS
E,
EC
N = max(n1,n2);
T = 1:N;
of
De
pt
Dept of ECE
Page | 12
5th Sem
KSSEM, Bangalore
subplot(3,1,3);
stem(T,y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
KS
SE
E,
EC
of
subplot(3,1,3);
stem(y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
OUTPUT:
pt
De
Dept of ECE
Page | 13
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 14
5th Sem
KSSEM, Bangalore
PROGRAM 5
AUTOCORRELATION OF A GIVEN SEQUENCE
Aim: To write the MATLAB code to perform Autocorrelation on a given signal and to verify
its properties.
SE
Theory:
KS
E,
( ) ( )
= 0, 1, 2,
Where = ,
=0
EC
and
( )+
( )+
of
| |
( )] =
pt
De
( ) ( )
= 0,
( )
( )+
(0)+
( )| |
< 0.
( )+ 2
(0) + 2
(0)| =
( ) ( )
() 0
That is, autocorrelation sequence of a signal attains its maximum value at zero lag. This is
consistent with the notion that a signal matches perfectly with itself at zero shift.
Assume a signal
Dept of ECE
Page | 15
5th Sem
KSSEM, Bangalore
(0)
SE
KS
E,
EC
of
subplot(2,1,2);
stem(n2,rxx);
title('Autocorrelation Sequence');
xlabel('n'); ylabel('rxx(l)');
grid on;
De
pt
Dept of ECE
Page | 16
5th Sem
KSSEM, Bangalore
%Left Side of AC Sequence
OUTPUT:
Enter a finite-length signal sequence : [1 2 3 4]
4 11 20 30 20 11
KS
Autocorrelation Sequence :
SE
if rxx_r == rxx_l
disp('Autocorrelation Sequence is Even. Hence, verified.');
else
disp('Autocorrelation Sequence is not Even. Hence, not
verified.');
end
E,
De
pt
of
EC
Dept of ECE
Page | 17
5th Sem
KSSEM, Bangalore
PROGRAM 6
CROSS - CORRELATION OF A GIVEN SEQUENCE
Aim: To write the MATLAB code to perform cross-correlation on a given signal and to verify
its properties.
SE
Theory:
()=
KS
= 0, 1, 2,
=0
()=
and
( )+
( )] =
( ) ( )
= 0,
pt
( )
( )+
of
| |
EC
Where = ,
E,
(0)+
()
( )+ 2
(0) + 2
(0)
< 0.
(0) =
( ) ( )
() 0
.
Note that the shape of the autocorrelation sequence does not change with amplitude scaling
of input signals. Only the amplitude of the autocorrelation sequence changes accordingly.
De
Dept of ECE
()=
( )
Page | 18
5th Sem
KSSEM, Bangalore
MATLAB CODE:
% Experiment 6 : Cross-correlation of two Signals.
KS
SE
E,
EC
subplot(3,1,2);
stem(n2,x2);
title('Input Signal 2');
xlabel('n'); ylabel('x2(n)');
% Verifying
of
subplot(3,1,3);
stem(n3,rxy);
title('Cross - Correlation Sequence');
xlabel('n'); ylabel('rxy(l)');
grid on;
Cross-correlation properties:
De
pt
E1 = sum(x1.^2);
E2 = sum(x2.^2);
mid = ceil(length(rxy)/2);
E0 = abs(max(rxy));
fprintf('Energy of Input Signal
fprintf('Energy of Input Signal
fprintf('Max Amplitude of Cross
% Energy of signal 1.
% Energy of signal 2.
% Find index of centre of sequence
% Detect Max Amplitude of Sequence
X1 : %d\n',E1);
X2 : %d\n',E2);
- Correlation Sequence : %d\n',E0);
Dept of ECE
Page | 19
5th Sem
KSSEM, Bangalore
SE
OUTPUT:
De
pt
of
EC
E,
KS
Dept of ECE
Page | 20
5th Sem
KSSEM, Bangalore
PROGRAM 7
SOLVING A GIVEN DIFFERENCE EQUATION
Aim: To write the MATLAB code to solve a given difference equation, given the co-efficients
and initial values.
SE
Let us consider the difference equation as y (n) 3/2 y (n-1) + y (n-2) = x (n). Given
x(n) = (1/4)n *u(n). Assume initial conditions as y(-1) = 4, y(-2) = 10.
Theory:
KS
E,
EC
For n=0;
y(0) - 3/2 y(0-1) + 1/2 y(0-2) = x(0)
Substituting the initial conditions and the value of x(0) in the above equation we get,
y(0) = 1 + 6 - 5 = 2
Similarly,
MATLAB CODE:
of
pt
De
Dept of ECE
Page | 21
5th Sem
KSSEM, Bangalore
OUTPUT:
KS
subplot(2,1,2);
stem(n,Yout);
grid on;
title('Output Sequence y(n)');
xlabel('n'); ylabel('y(n)');
SE
E,
0.7305
De
pt
of
EC
Dept of ECE
Page | 22
5th Sem
KSSEM, Bangalore
PROGRAM 8
COMPUTATION OF N- POINT DFT
Aim: Computation of N point DFT of a given sequence and to plot magnitude and phase
spectrum.
SE
Theory:
DFT stands for Discrete Fourier Transform. It is used to find the amplitude and phase
spectrum of a discrete time sequence.
N-DFT
x(n)
KS
E,
( )=
For k=0,
( )
(1) =
= - j- 2 + 3j = -2 + j2
= (1)
pt
Similarly,
For k=2,
(2) =
of
For k=1,
( )
(0) =
EC
( )
De
= 0-1+2-3 = -2
= (1)
+ (1)
+ (1)
+ (2)
+ (2)
+ (3)
+ (3)
For k=3,
X(3) = -2 j2
Dept of ECE
Page | 23
5th Sem
KSSEM, Bangalore
MATLAB CODE:
SE
KS
EC
% Input Sequence
subplot (2,2,[1:2]);
stem(n, xn);
title('Input Sequence x(n)');
xlabel('n');ylabel('x(n)');
E,
%Time base
OUTPUT:
pt
of
De
-2.0000 + 2.0000i
-2.0000 - 0.0000i
-2.0000 - 2.0000i
Dept of ECE
Page | 24
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 25
5th Sem
KSSEM, Bangalore
PROGRAM 9
SE
Theory:
KS
E,
Therefore the linear convolution of two sequence is the N point IDFT of Y(k).
Soln: Given,
x(n)={1,2}
h(n)={1,2,3}
here L = 2, M = 3
N=L+M-1
EC
Ex: Find the linear convolution of x(n)={1,2} and h(n)={1,2,3} using DFT and IDFT method.
Therefore, N=4
of
pt
De
( ) = { 18 , 6 + 2j , 2 , 6 2j }
Page | 26
5th Sem
KSSEM, Bangalore
MATLAB CODE
SE
E,
KS
EC
subplot(3,1,2);
stem(x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
subplot(3,1,3);
stem(y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
pt
OUTPUT
of
De
Dept of ECE
Page | 27
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 28
5th Sem
KSSEM, Bangalore
PROGRAM 10
CIRCULAR CONVOLUTION USING DFT AND IDFT
Aim: To calculate the Circular Convolution of two sequences using DFT and IDFT
SE
Theory:
KS
Example: Find the circular convolution of x(n)={1,2,3,4} and h(n)={4,3,2} using DFT and
IDFT method.
Solution: Given two signals, x(n)={1,2,3,4} and h(n)={4,3,2}
EC
E,
MATLAB CODE
of
y(n) = { 22 , 19 , 20 , 29 }
pt
De
x1=[x1 zeros(1,N-n1)];
x2=[x2 zeros(1,N-n2)];
Dept of ECE
Page | 29
5th Sem
KSSEM, Bangalore
SE
KS
subplot(3,1,2);
stem(x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
subplot(3,1,3);
stem(y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)'); grid on;
E,
OUTPUT
De
pt
of
EC
Dept of ECE
Page | 30
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 31
5th Sem
KSSEM, Bangalore
PROGRAM 11
Aim: To design and implement a FIR Filter for the given specifications.
SE
Theory:
KS
A linear-phase is required throughout the passband of the filter to preserve the shape of the
given signal in the passband. A causal IIR filter cannot give linear-phase characteristics and
only special types of FIR filters that exhibit center symmetry in its impulse response give the
linear-space. An FIR filter with impulse response h(n) can be obtained as follows:
EC
E,
Hamming window:
of
De
pt
Problem: Using MATLAB design an IIR filter to meet the following specifications choosing
Hamming window:
Window length, N = 27
Stop band attenuation = 50dB
Cut-off frequency = 100 Hz
Sampling frequency = 1000 Hz
Dept of ECE
Page | 32
5th Sem
KSSEM, Bangalore
MATLAB CODE
% Experiment 11 : Designing a FIR Filter (Hamming Window)
SE
%Nyquist Frequency
%Create a N-point symmetric Hamming
KS
EC
E,
% Display Values
disp('Hamming Window Co-efficients : ');
disp(Wh);
disp('Unit Sample Response of FIR Filter h(n) : ');
disp(b);
% Plot Frequency response of Butterworth Filter.
freqz(b);
title('Hamming Filter Frequency Response');
OUTPUT
of
De
pt
Dept of ECE
Page | 33
5th Sem
KS
SE
0.8843
0.9473
0.9866
1.0000
0.9866
0.9473
0.8843
0.8013
0.7031
0.5954
0.4846
0.3769
0.2787
0.1957
0.1327
0.0934
0.0800
KSSEM, Bangalore
EC
E,
0.0890
0.1429
Columns 15 through 21
0.1840 0.1429 0.0890
0.0374
Columns 22 through 27
-0.0142 -0.0058 -0.0000
0.0022
0.0023
0.1840
0.1994
0.0019
De
pt
of
Columns 8 through 14
-0.0185 0.0000 0.0374
Dept of ECE
Page | 34
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 35
5th Sem
KSSEM, Bangalore
PROGRAM 12
Aim: To design and implement a IIR Filter for the given specifications.
SE
Theory:
KS
E,
BUTTERWORTH FILTERS:
EC
Butterworth filters have very smooth passband, which we pay for with a relatively wide
transition region. A Butterworth filter is characterized by its magnitude frequency response,
De
pt
of
where N is the order of the filter and c is defined as the cutoff frequency where the filter
magnitude is 1/2 times the dc gain (=0)
Dept of ECE
Page | 36
5th Sem
KSSEM, Bangalore
SE
KS
Chebyshev filters are equiripple in either the passband or stopband. Hence the magnitude
response oscillates between the permitted minimum and maximum values in the band a
number of times depending upon the order of filters. There are two types of chebyshev filters.
The chebyshev I filter is equiripple in passband and monotonic in the stopband, whereas
Chebyshev II is just the opposite.
De
pt
of
EC
E,
Dept of ECE
Page | 37
5th Sem
KSSEM, Bangalore
SE
Using MATLAB design an IIR filter with passband edge frequency 1500Hz and stop band
edge at 2000Hz for a sampling frequency of 8000Hz, variation of gain within pass band 1db
and stopband attenuation of 15 db. Use Butterworth prototype design and Bilinear
Transformation.
MATLAB CODE :
KS
E,
: ');
: ');
');
');
');
EC
p = poles)
of
OUTPUT:
pt
De
Dept of ECE
Page | 38
5th Sem
KSSEM, Bangalore
EC
E,
KS
SE
of
Using MATLAB design an IIR filter with passband edge frequency 1500Hz and stop band
edge at 2000Hz for a sampling frequency of 8000Hz, variation of gain within pass band 1 db
and stopband attenuation of 15 db. Use Chebyshev prototype design and Bilinear
Transformation.
pt
DESIGN:
W1 = (2*pi* F1 )/ Fs = 2*pi*100)/4000 = 0.05 rad
W2 = (2*pi* F2 )/ Fs = 2*pi*500)/4000 =0.25 rad
De
Prewarp:
T=1sec
1 = 2/T tan (w1/2) = 0.157 rad/sec
2 = 2/T tan (w2/2) = 0.828 rad/sec
Dept of ECE
Page | 39
5th Sem
KSSEM, Bangalore
n = log10
= 0.765
A= 10-As/20 , A = 1020/20 , A=10
g= (A2 - 1) / , g = 13.01
r= 2 / 1 r=0.828/0.157 = 5.27 rad\sec
)
/ log10{r + (
Cut-off Frequency:
EC
H(s)=[bo / 1+ 2 ] / [ s2+b1s+b0]
= 0.505/[ s2+0.8s+0.036]
E,
c = p = 1 = 0.157 rad\sec
Normalized Transfer Function:
)}
KS
n= 1.388
Therefore n= 2.
SE
= 10
Order:
of
Apply BLT:
H(Z) = H(s)|s=(2/T)[(1-z-1)/(1+z-1)]
pt
De
Dept of ECE
Page | 40
5th Sem
KSSEM, Bangalore
MATLAB CODE:
KS
: ');
: ');
');
');
');
SE
p = poles)
EC
E,
OUTPUT:
pt
of
De
Dept of ECE
Page | 41
5th Sem
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 42
5th Sem
KSSEM, Bangalore
KS
SE
De
pt
of
EC
E,
PART B:
Exercises using the
DSP Kit
Dept of ECE
Page | 43
V Semester
KSSEM, Bangalore
TMS320C6748 DSP
BOARD
EC
E,
KS
SE
Package content:
of
pt
The C6748 DSP kit has a TMS320C6748 DSP onboard that allows full-speed verification of
code with Code Composer Studio. The C6748 DSP kit provides:
De
A USB Interface
128MB DDRAM and ROM
An analog interface circuit for Data conversion
(AIC) An I/O port
Embedded JTAG emulation support
Connectors on the C6748 DSP kit provide DSP external memory interface (EMIF) and
peripheral signals that enable its functionality to be expanded with custom or third party daughter
boards.
Dept of ECE
Page | 44
V Semester
KSSEM, Bangalore
The C6748 DSP kit includes a stereo codec. This analog interface circuit (AIC) has the
following characteristics:
SE
KS
E,
EC
The 6748 DSP KIT kit is a low-cost standalone development platform that enables customers
to evaluate and develop applications for the TI C67XX DSP family. The DSP KIT also serves
as a hardware reference design for the TMS320C6748 DSP. Schematics, logic equations and
application notes are available to ease hardware development and reduce time to market.
of
An on-board AIC3106 codec allows the DSP to transmit and receive analog signals.
McASP is used for the codec control interface and for data. Analog audio I/O is done through
two 3.5mm audio jacks that correspond to line input, and line. The analog output is driven to
the line out .McASP1 can be re-routed to the expansion connectors in software.
The DSP KIT includes 2 LEDs and 8 DIP switches as a simple way to provide the user with
interactive feedback.
De
pt
Dept of ECE
Page | 45
KSSEM, Bangalore
E,
EC
of
KS
SE
V Semester
IEEE-1149.1 (JTAG
) Boundary-Scan-Compatible
De
pt
Dept of ECE
Page | 46
V Semester
KSSEM, Bangalore
1. Launch ccs
KS
SE
Launch the CCS v4 icon from the Desktop or goto All Programs ->Texas Instruments >CCSv4
2.
EC
E,
Choose the location for the workspace, where your project will be saved.
3.
De
pt
of
Click the CCS icon from the welcome page to go the workbench, it is marked in the below
picture.
Dept of ECE
Page | 47
EC
E,
KS
SE
Specify any arbitrary target name. For Eg., 6748config.ccxml (Extension should be
.ccxml).. Click Finish then you will get configuration window for the created target.
*
Check the box
TMS320C674
8 and finally
Click Save.
De
pt
of
B.
1. Select the Connection: Texas instruments XDS100v1 USB Emulator
2. Select the Device: TMS320C6748. To make search easier type 6748 in device block.
Dept of ECE
Page | 48
goto Advanced tab give the suitable Gel file path as shown below.
C. Next
E,
KS
SE
C:\6748support\c6748.gel
D.
pt
of
EC
De
Dept of ECE
Page | 49
Step P1:
Change the Perspective Debug to C/C++ from the right corner of the CCS
EC
Step P3:
Specify the name of the project in the
space provided .and Click Next
E,
KS
SE
Step P2:
Go to File New CCS Project.
De
pt
of
Dept of ECE
Page | 50
E,
KS
SE
Click Next
De
pt
of
EC
*However our target is based on C6000 family, Based on the family we need to select the
Project
Type.
Set the project settings window as shown below.
Click finish
Dept of ECE
Page | 51
KS
SE
EC
E,
B. Specify the arbitrary source file name. It should be in the source folder (current project
name.).
pt
of
Note:
Extension of the source file must be the language what we preferred to write the code.
Eg:
For c-> .c
C++ -> .cpp
Assembly -> .asm
De
Dept of ECE
Page | 52
7. BUILD
KS
SE
EC
E,
If your code doesnthave any errors and warnings, a message will be printed in the console
window that
De
pt
of
Dept of ECE
Page | 53
8. DEBUG
After successful Build, Debug your code. During this step ccs will connect to target and it
will
load program on to target.
E,
KS
SE
of
EC
pt
Now press reset button on the 6748 hardware , then click on retry.
De
Once you click on retry ccs will load program on to processor and then ccs will guide
us to debug mode, if it is not done automatically.
Change the Perspective C/C++ to Debug
from the right corner of the CCS.
Dept of ECE
Page | 54
9.RUN
E,
KS
SE
Now you can run the code, by selecting the option run from the dialog box else you can
Go to Target Run
De
pt
of
EC
Once you run the program the output will be printed in the Console
Dept of ECE
Page | 55
V Semester
KSSEM, Bangalore
PROGRAM 1
LINEAR CONVOLUTION OF TWO GIVEN SEQUENCES
SE
Aim: To write the C code to perform Linear Convolution upon two given discrete time
signals.
C Code:
E,
KS
#include<stdio.h>
int y[20];
main()
{
int m=6;
/*Length of i/p samples sequence*/
int n=6;
/*Length of impulse response Coefficients*/
int i=0,j;
/*Input Signal Samples*/
int x[15]={1,2,3,4,5,6,0,0,0,0,0,0};
/*Impulse Response Coefficients*/
int h[15]={1,2,3,4,5,6,0,0,0,0,0,0};
of
EC
/*Calculate Values*/
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
pt
/* Display Values*/
printf("Sequence 1: \n");
for(i=0;i<m;i++)
printf("%d\t",x[i]);
De
printf("\nSequence 2: \n");
for(i=0;i<n;i++)
printf("%d\t",h[i]);
printf("\nConvolved Sequence: \n");
for(i=0;i<m+n-1;i++)
printf("%d\t",y[i]);
Dept of ECE
Page | 56
V Semester
KSSEM, Bangalore
20
35
56
70
76
73
60
36
SE
Sequence 1:
1
2
3
Sequence 2:
1
2
3
Convolved Sequence:
1
4
10
OUTPUT:
Procedure:
1. Open Code Composer Studio v4.
KS
4. Create new source file and type the code linear.c and save it.(step 6)
E,
5. Now perform steps 7, 8and 9.Once you run the program you can watch convolution
result in the console window.
EC
of
Start Address: y
pt
8. Click : Ok
9. Note down the output waveform.
De
NOTE : Follow the same procedure for the rest of the experiments.
Dept of ECE
Page | 57
V Semester
KSSEM, Bangalore
PROGRAM 2:
SE
Aim: To write the C code to perform Circular Convolution upon two given discrete time
signals.
C Code:
EC
E,
KS
De
pt
of
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;
}
/*Initialize Array of Zeros*/
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
/* Convert linear sequence to circular sequence*/
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++)
/* folding h(n) to h(-n) */
a[j]=h[n-j];
Dept of ECE
Page | 58
V Semester
KSSEM, Bangalore
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
SE
for(k=1;k<n;k++)
{
y[k]=0;
KS
/*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];
}
EC
E,
}
/* displaying the result */
printf("\nConvolved Sequence:\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
OUTPUT:
of
16
14
16
De
14
pt
Convolved Sequence:
Dept of ECE
Page | 59
V Semester
KSSEM, Bangalore
PROGRAM 3:
SE
C Code:
EC
E,
KS
#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("\nEnter the sequence\n");
for(i=0;i<N;i++)
scanf("%d",&x[i]);
for(k=0;k<N;k++)
{
sumre=0;
sumim=0;
De
pt
of
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("DFT of the Sequence :\n");
printf("X([%d])=\t%f\t+\t%fi\n",k,out_real[k],out_imag[k]);
Dept of ECE
Page | 60
V Semester
KSSEM, Bangalore
OUTPUT:
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 61
V Semester
KSSEM, Bangalore
PROGRAM 4:
SE
KS
#define Order 1
#define Len 10
float y[Len] = {0,0,0}, sum;
main()
{
E,
int j,k;
float b[Order+1]={1, 3};
/*Input Coefficients*/
float a[Order+1]={1, 0.2}; /*Output Coefficients*/
printf("Impulse Response Coefficients:\n");
for(j=0;j<Len;j++)
{
OUTPUT:
pt
of
EC
sum = 0;
for (k=1;k<=Order;k++)
{
if ((j-k)>=0)
sum=sum+(b[k]*y[j-k]);
}
if(j<=Order)
y[j]=a[j]-sum;
else
y[j]=-sum;
printf("Response [%d] = %f\n",j,y[j]);
}
}
De
Dept of ECE
Page | 62
V Semester
KSSEM, Bangalore
C Code:
#define Order 2
#define Len 10
SE
#include <stdio.h>
KS
main()
{
EC
E,
int j,k;
float b[Order+1]={1, 3, -0.12}; /*Input Coefficients*/
float a[Order+1]={1, 0.2, -1.5}; /*Output Coefficients*/
printf("Impulse Response Coefficients:\n");
for(j=0;j<Len;j++)
{
sum = 0;
for (k=1;k<=Order;k++)
{
if ((j-k)>=0)
sum=sum+(b[k]*y[j-k]);
}
if(j<=Order)
y[j]=a[j]-sum;
else
y[j]=-sum;
printf("Response [%d] = %f\n",j,y[j]);
}
OUTPUT:
of
De
pt
Dept of ECE
Page | 63
V Semester
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 64
V Semester
KSSEM, Bangalore
De
pt
of
EC
E,
KS
SE
Dept of ECE
Page | 65