Professional Documents
Culture Documents
LIST OF EXPERIMENTS
ADDITIONAL EXPERIMENTS
16 Linear Convolution Using TMS320c5515 Processor 123
17 Circular Convolution Using TMS320c5515 Processor 125
START
STOP
START
STOP
5
Aim:
To write a program in MATLAB to generate the following signals
(1) Unit impulse function.
(2) Unit step function.
(3) Unit ramp and exponential function.
(4) Sine and cosine wave function.
(5) Random and correlation sequences.
Software and Hardware Required:
1. Computers installed with MATLAB 7.7(R2008b)
Algorithm: Unit Impulse Function:
(1) Get the time interval.
(2) Give the respective impulse function zeros and ones function.
(3) Subplot and stem the sequence.
(4) Give X-label, Y-label and title.
(5) Stop the program and execute it.
Unit Step Function:
(1) Get the length of the of sequence.
(2) Get the time interval.
(3) Give the matrix using one’s function.
(4) Subplot and stem the sequence.
(5) Give the X- label, Y-label and title.
(6) Stop the program.
6
STOP
START
STOP
7
STOP
START
STOP
9
Cosine Function:
(1) Enter the length of sinusoidal sequence.
(2) Enter the number of cycles.
(3) Get the interval and obtain sinusoidal waveform using cosine function.
(4) Subplot and plot the sequence.
(5) Give X-label, Y-label and title.
(6) Stop the program.
Exponential Function:
(1) Set the exponential function.
(2) Plot the exponential sequence in discrete domain.
(3) Give the xlabel, ylabel and title.
(4) Stop the program.
Output:
Enter the n value 4
Enter the length of ramp sequence 4
Enter the length of exponential sequence 4
Enter the ‘a’ value 1
10
OUTPUT WAVEFORMS
0.9
0.8
0.7
0.6
0.5
SampleValues
0.4
0.3
0.2
0.1
0
0 10 20 30 40 50 60 70 80 90 100
Samples
figure(); stem(t,t);
ylabel('Amplitude');
xlabel('(c) n');
%Program for the generation of exponential sequence
n2=input('Enter the length of exponential sequence');
t=0:n2;
a=input('Enter the a value');
y2=exp(a*t);
figure();stem(t,y2);
ylabel('Amplitude');
xlabel('(d) n');
%Program for the generation of sine sequence
t=0:.01:pi;
y=sin(2*pi*t);figure(2);
figure();plot(t,y);
ylabel('Amplitude'); xlabel('(e) n');
%Program for the generation of cosine sequence
t=0:.01:pi;
y=cos(2*pi*t);
figure();plot(t,y);
ylabel('Amplitude'); xlabel('(f) n');
%Program for the generation of random sequence
L=100; %Sample length for the random signal
mu=0;
X=rand(L,1)+mu;
figure(); stem(X);
title(['White noise : \mu_x=',num2str(mu)]);
figure(); plot(X); title(['White noise : \mu_x=',num2str(mu),' \sigma^2=',num2str(sigma^2)]);
xlabel('Samples'); ylabel('Sample Values');
Result:
The program for various signals is executed and output is verified using MATLAB.
13
Aim:
To write a MATLAB program to perform linear and circular convolution.
Software and Hardware Required:
1. Computers installed with MATLAB 7.7(R2008b)
Algorithm: Linear Convolution
(1) Get the first input sequence and its range.
(2) Get the second input sequence and its range.
(3) Convolve the two sequences and assign in ‘Y’
(4) Display the discrete form of ‘Y’.
(5) Give the X-label, Y-label.
(6) Display the result.
Algorithm: Circular Convolution
(1) Start the program.
(2) Get the two input sequence.
(3) Calculate n1=max (n1, n2) where n1 is length of first sequence and n2 is length of
second sequence.
(4) Check if n3 is greater than zero. Calculate ‘h’ or compute ’g’.
(5) Find circular Convolution and display the output.
(6) Stop the program.
14
START
STOP
15
50
40
Amplitude
30
20
10
0
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3
time axis
16
START
GET TWO
SEQUENCES
’g’ & ‘h’
y=CCONV (g, h, n)
DISPLAY CONVOLUTED
SEQUENCE
STOP
18
71 80 83 80 71 56
19
clc;
close all;
clear all;
g=input('Enter the first sequence');
subplot(2,2,1);stem(g);
ylabel('Amplitude');xlabel('g(n)');
h=input('Enter the second sequence');
subplot(2,2,2);stem(h);
ylabel('Amplitude');xlabel('h(n)');
n1=length(g);
n2=length(h);
n=max(n1,n2);
n3=n1-n2;
if(n3>0)
h=[h,zeros(1,n3)];
end
if(n3<0)
g=[g,zeros(1,-n3)];
end
y=cconv(g,h,n);
disp('The circular convoluted sequence is given by');
disp(y);
subplot(2,2,3);stem(y);
ylabel('Amplitude');xlabel('output sequence');
Result:
The MATLAB program for Linear and Circular convolution is executed and their waveforms
are plotted.
20
(2) Compute auto correlation and cross correlation using xcorr(x), xcorr(x,y)
12
10
-2
1 2 3 4 5 6 7 8 9
Flowchart: Coerrelation
START
STOP
Result:
The MATLAB program for auto correlation and cross-correlation is executed and their
waveforms are plotted.
22
Aim:
To write the MATLAB program for the given sequence to compute and plot DFT of
sequence using FFT and IDFT using IFFT.
Algorithm: FFT
(1) Start the program
(2) Generate a signal with different frequencies
(3) Plot the input sequence x(n).
(4) Compute DFT of sequence using FFT algorithm.
(5) Display DFT sequence.
(6) Plot the real and imaginary parts.
(7) Use abs command to obtain magnitude plot.
(8) Use angle command to obtain phase plot and plot it.
(9) Stop the program.
Algorithm: IFFT
(1) Start the program
(2) Enter the sequence X(k).
(3) Plot the input sequence X(k).
(4) Compute IDFT of sequence using FFT algorithm.
(5) Display IDFT sequence.
(6) Plot the real and imaginary parts.
(7) Use abs command to obtain magnitude plot.
(8) Use angle command to obtain phase plot and plot it.
(9) Stop the program.
23
STOP
24
STOP
25
clc;
close all;
clear all;
fs=5000;
ts=1/fs;
length=100000;
t=(0:length-1)*ts;
y= 0.2*cos(2*pi*100*t)+ 0.5*cos(2*pi*500*t)+ 2*sin(2*pi*1000*t);
figure(1);
plot(y(1:100));
title('spectrum of the input signal');
xlabel('time');
ylabel('amplitude');
nfft=2^(nextpow2(length));
z=fft(y,nfft)/length;
f=(fs/2)*linspace(0,1,(nfft/2)+1)
z1=2*abs(z(1:(nfft/2)+1));
figure(2);
plot(f,z1);
title('spectrum of the input signal');
xlabel('frequncy');
ylabel('amplitude');
z2=ifft(z,nfft)*length;
figure(3);
plot(z2(1:100));
title('Input signal recovered');
xlabel('time');
ylabel('amplitude');
26
Output: FFT
Input signal
3
1
amplitude
-1
-2
-3
0 10 20 30 40 50 60 70 80 90 100
time
1.6
1.4
1.2
1
amplitude
0.8
0.6
0.4
0.2
0
0 500 1000 1500 2000 2500
frequncy
27
Output: IFFT
1
amplitude
-1
-2
-3
0 10 20 30 40 50 60 70 80 90 100
time
Result:
The MATLAB program to compute FFT and IFFT for the given sequence is executed and its
response is plotted successfully.
28
To design and plot the FIR filter using rectangular window technique.
(1) For the given length N, calculate alpha=(N-1)/2 and assign eps=0.001 and cut-off frequency
wc.
(6) Calculate the rectangular window coefficient (wh) using rectangular functions.
(8) Calculate the frequency and plot it separately for LPF, HPF, BPF and BSF.
29
STOP
30
Output:
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
Rectangular bandpass filter Rectangular bandstop filter
1.5 1.5
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
31
plot(w/pi,abs(h));hold on;
title('Rectangular bandstop filter');
xlabel('Normalised frequency\omega\/pi');
ylabel('Magnitude');
Result:
The program to design and plot the FIR filter response using rectangular window technique
is executed and verified successfully using MATLAB.
34
Aim:
To design and plot the FIR filter using hamming window technique.
(i) For the given length N, calculate alpha=(N-1)/2 and assign eps=0.001 and cut-off frequency
wc=0.5*pi.
(vi) Calculate the hamming window coefficient (wh) using hamming functions.
(viii) Calculate the frequency and plot it separately for LPF, HPF, BPF and BSF.
35
STOP
36
Output:
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
Hamming bandpass filter Hamming bandstop filter
1.5 1.5
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
37
plot(w/pi,abs(h));hold on;
title('Hamming bandstop filter');
xlabel('Normalised frequency\omega\/pi');
ylabel('Magnitude');
Result:
The program to design and plot the FIR filter using Hamming window technique is
executed and output is verified successfully.
40
Aim:
To design and plot the FIR filter using Hanning window technique.
(1) For the given length N, calculate alpha= (N-1)/2 and assign eps=0.001 and cut-off frequency
wc.
(6) Calculate the hamming window coefficient (wh) using hanning functions.
(8) Calculate the frequency and plot it separately for LPF, HPF, BPF and BSF.
41
STOP
42
Output:
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
Hanning bandpass filter Hanning bandstop filter
1.5 1.5
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
43
plot(w/pi,abs(h));hold on;
title('Hanning bandstop filter');
xlabel('Normalised frequency\omega\/pi');
ylabel('Magnitude');
Result:
The program to design and plot the FIR filter using Hanning window technique is
executed and output is verified successfully.
46
Aim:
To design and plot the FIR filter using Blackmann window technique.
(1) For the given length N, calculate alpha= (N-1)/2 and assign eps=0.001 and cut-off frequency
wc.
(6) Calculate the blackmann window coefficient (wh) using hanning functions.
(8) Calculate the frequency and plot it separately for LPF, HPF, BPF and BSF.
47
STOP
48
Output:
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
Blackman bandpass filter Blackman bandstop filter
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
49
plot(w/pi,abs(h));hold on;
title('Blackman bandstop filter');
xlabel('Normalised frequency\omega\/pi');
ylabel('Magnitude');
Result:
The program to design and plot the FIR filter using Blackmann window technique is
executed and output is verified successfully.
52
Aim:
To design and plot the FIR filter using Bartlett window technique.
(i) For the given length N, calculate alpha= (N-1)/2 and assign eps=0.001 and cut-off frequency
wc.
(vi) Calculate the bartlett window coefficient (wh) using hanning functions.
(viii) Calculate the frequency and plot it separately for LPF, HPF, BPF and BSF.
53
STOP
54
Output:
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
Hillbert using bandpass filter Hillbert using bandstop filter
1 1
Magnitude
Magnitude
0.5 0.5
0 0
0 0.5 1 0 0.5 1
Normalised frequency\omaga\/pi Normalised frequency\omaga\/pi
55
plot(w/pi,abs(h));hold on;
title('Hillbert using bandstop filter');
xlabel('Normalised frequency\omega\/pi');
ylabel('Magnitude');
Result:
The program to design and plot the FIR filter using Bartlett window technique is executed
and output is verified successfully.
Aim:
To write a MATLAB program to design Butterworth low pass, high pass, band pass and band
reject filter.
(4) Calculate cut off frequency and order of filter using buttord function.
START
CALCULATE CUT OFF FREQUENCY AND ORDER OF FILTER USING BUTTORD FUNCTION
ASSIGN w=0:0.01:pi
STOP
START
CALCULATE CUT OFF FREQUENCY AND ORDER OF FILTER USING BUTTORD FUNCTION
ASSIGN w=0:0.01:pi
STOP
(3) Calculate cut off frequency and order of filter using buttord function.
(2) Assign the value of α1=2, α2=20, wp= [0.2*pi, 0.4*pi], ws= [0.1*pi, 0.5*pi].
(3) Calculate cut off frequency and order of filter using buttord function.
START
ASSIGN w=0:0.01:pi
STOP
64
START
ASSIGN w=0:0.01:pi
STOP
65
(2) Assign the value of α1=2, α2=20, wp= [0.2*pi, 0.4*pi], ws= [0.1*pi, 0.5*pi].
(3) Calculate cut off frequency and order of filter using buttord function.
OUTPUT:
-100 -20
Gain in db
Gain in db
-200 -40
-300 -60
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
IIR Band pass filter IIR Band stop filter
0 0
-20 -20
Gain in db
Gain in db
-40 -40
-60 -60
-80 -80
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
67
plot(om/pi,20*log(m));grid on;
title('IIR High pass filter');
ylabel('Gain in db');
xlabel('Normalised frequency');
%Butterworth band pass filter
wp=[0.2*pi,0.4*pi]; ws=[0.1*pi,0.5*pi];
[n,wn]=buttord(wp/pi,ws/pi,alpha,alphas);
[b,a]=butter(n,wn);
w=0:0.001:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,2,3);
plot(ph/pi,m);grid on;
title('IIR Band pass filter');
ylabel('Gain in db');
xlabel('Normalised frequency');
%Butterworth band stop filter
wp=[0.2*pi,0.4*pi];
ws=[0.1*pi,0.5*pi];
[n,wn]=buttord(wp/pi,ws/pi,alpha,alphas);
[b,a]=butter(n,wn,'stop');
w=0:0.001:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,2,4);
plot(ph/pi,m);grid on;
title('IIR Band stop filter');
ylabel('Gain in db');
xlabel('Normalised frequency');
69
Result:
The program to design Butterworth low pass, high pass, band pass and band reject filter is
executed and output is verified successfully.
70
Aim:
To write a MATLAB program to design chebyshev1 IIR low pass, high pass, band pass and
band reject filter.
START
CALCULATE wp=0.2*pi,ws=0.3*pi
ASSIGN w=0:0.01:pi
STOP
72
START
CALCULATE wp=0.2*pi,ws=0.3*pi
ASSIGN w=0:0.01:pi
STOP
73
START
CALCULATE wp=0.2*pi,0.4*pi,ws=0.1*pi,0.5*pi
ASSIGN w=0:0.01:pi
STOP
75
START
ASSIGN α1 and α2
CALCULATE wp=0.2*pi,0.4*pi,ws=0.1*pi,0.5*pi
ASSIGN w=0:0.01:pi
STOP
77
Output:
-100 -100
Gain in db
Gain in db
-200 -200
-300 -300
-400 -400
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
IIR Band pass filter IIR Band stop filter
0 0
-50
-50
Gain in db
Gain in db
-100
-100
-150
-200 -150
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
79
CHEBYSHEV1-IIR FILTER
Program:
plot(om/pi,20*log(m));grid on;
title('iir high pass filter');
ylabel('gain in db');
xlabel('normalised frequency');
%chebyshev1 band pass filter
wp=[0.2*pi,0.4*pi];
ws=[0.1*pi,0.5*pi];
[n,wn]=cheb1ord(wp/pi,ws/pi,alpha,alphas);
[b,a]=cheby1(n,alpha,wn);
w=0:0.001:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,2,3);
plot(ph/pi,m);grid on;
title('iir band pass filter');
ylabel('gain in db');
xlabel('normalised frequency');
%chebyshev1 band stop filter
wp=[0.2*pi,0.4*pi];
ws=[0.1*pi,0.5*pi];
[n,wn]=cheb1ord(wp/pi,ws/pi,alpha,alphas);
[b,a]=cheby1(n,alphas,wn,'stop');
w=0:0.001:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,2,4);
plot(ph/pi,m);grid on;
title('iir band stop filter');
ylabel('gain in db');
xlabel('normalised frequency');
81
RESULT:
The program to design chebyshev1 IIR low pass, high pass, band pass and band reject
filter is executed and output is verified successfully.
82
Aim:
To write a MATLAB program to design chebyshev-2 IIR low pass, high pass, band pass and
band reject filter.
START
ASSIGN α1 and α2
CALCULATE wp=0.2*pi,ws=0.3*pi
ASSIGN w=0:0.01:pi
STOP
84
START
CALCULATE wp=0.2*pi,ws=0.3*pi
ASSIGN w=0:0.01:pi
STOP
85
(4) Calculate cut off frequency and order of filter.(v)Assign w=0:0.01: pi.
START
CALCULATE wp=0.2*pi,0.4*pi,ws=0.1*pi,0.5*pi
ASSIGN w=0:0.01:pi
STOP
87
START
CALCULATE wp=0.2*pi,0.4*pi,ws=0.1*pi,0.5*pi
ASSIGN w=0:0.01:pi
STOP
89
Output:
0 -50
Gain in db
Gain in db
-50 -100
-100 -150
-150 -200
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
IIR Band pass filter IIR Band stop filter
0 50
-20 0
Gain in db
Gain in db
-40 -50
-60 -100
0 0.5 1 0 0.5 1
Normalised frequency Normalised frequency
91
plot(om/pi,20*log(m));grid on;
title('IIR High pass filter');
ylabel('Gain in db');
xlabel('Normalised frequency');
%Chebyshev2 band pass filter
wp=[0.2*pi,0.4*pi];
ws=[0.1*pi,0.5*pi];
[n,wn]=cheb2ord(wp/pi,ws/pi,alpha,alphas);
[b,a]=cheby2(n,alpha,wn);
w=0:0.001:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,2,3);
plot(ph/pi,m);grid on;
title('IIR Band pass filter');
ylabel('Gain in db');
xlabel('Normalised frequency');
%Chebyshev2 band stop filter
wp=[0.2*pi,0.4*pi];
ws=[0.1*pi,0.5*pi];
[n,wn]=cheb2ord(wp/pi,ws/pi,alpha,alphas);
[b,a]=cheby2(n,alphas,wn,'stop');
w=0:0.001:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,2,4);
plot(ph/pi,m);grid on;
title('IIR Band stop filter');
ylabel('Gain in db');
xlabel('Normalised frequency');
93
RESULT:
The program to design chebyshev-2 IIR low pass, high pass, band pass filter is executed
and output is verified successfully.
94
Aim:
UP SAMPLING:
clear all;
close all;
clc;
f1=100;
k=1:10;
fs=1000;
L=4; %Up sample by a value
x=sin(2*pi*f1/fs*k); %Input signal
subplot(2,1,1);
stem(x);
title('Input sequence ');
xlabel(' Samples(n) ');
ylabel('Amplitude');
y=Upsample(x,L); %TO DO UP SAMPLE
subplot(2,1,2);
stem(y); %Draw the graph
xlabel(' Samples(n) ');
ylabel('Amplitude');
title('Input sequence Upsampled by a factor L');
Output:
96
Down sampling:
Up Sampling:
97
START
downsample(x,M)
STOP
Flowchart: Up Sampling
START
Upsample(x,L)
STOP
98
Result:
The program for decimation and interpolation is executed and its output is verified
successfully using MATLAB.
99
100
Aim:
Introduction:
Peripherals:
The DSP includes the following peripherals:
• Four direct memory access (DMA) controllers, each with four independent channels.
• One external memory interface (EMIF) with 21-bit address and 16-bit data. The EMIF has
support for mobile SDRAM and non-mobile SDRAM single-level cell (SCL) NAND with 1-bit ECC,
and multi-level cell (MLC) NAND with 4-bit ECC. Two serial busses each configurable to support
one Multimedia Card (MMC) / Secure Digital (SD/SDIO) controller, one inter-IC sound bus (I2S)
interface with GPIO, or a full GPIO interface.
• One parallel bus configurable to support a 16-bit LCD bridge or a combination of an 8-bit LCD
bridge, a serial peripheral interface (SPI), an I2S, a universal asynchronous receiver/transmitter
(UART), and GPIO.
• One inter-integrated circuit (I2C) multi-master and slave interface with 7-bit and 10-bit
addressing modes.
• Three 32-bit timers with 16-bit prescaler; one timer supports watchdog functionality.
• A USB 2.0 slave.
102
3. The indirect addressing mode allows you to reference a location using a pointer. Each
addressing mode provides one or more types of operands.
Absolute Addressing Modes:
1. k16 Absolute Addressing Mode
The k16 absolute addressing mode uses the operand *abs16 (#k16), where k16 is a 16-bit
unsigned constant. DPH (the high part of the extended data page register) and k16 are
concatenated to form a 23-bit data-space address. An instruction using this addressing mode
encodes the constant as a 2-byte extension to the instruction. Because of the extension, an
instruction using this mode cannot be executed in parallel with another instruction.
2. k23 Absolute Addressing Mode
The k23 absolute addressing mode uses the *(#k23) operand, where k23 is
a 23-bit unsigned constant. An instruction using this addressing mode encodes the constant as a
3-byte extension to the instruction. . Because of the extension, an instruction using this mode
cannot be executed in parallel with another instruction.
3. I/O Absolute Addressing Mode
The I/O absolute addressing mode uses the *port (#k16) operand, where k16
is a 16-bit unsigned constant. An instruction using this addressing mode encodes the constant as
a 2-byte extension to the instruction. Because of the extension, an instruction using this mode
cannot be executed in parallel with another instruction.
Direct Addressing Modes:
1. DP direct
This mode uses the main data page specified by DPH (high part of the extended data page
register) in conjunction with the data page register (DP). This mode is used to access a memory
location or a memory-mapped register.
2. SP direct
This mode uses the main data page specified by SPH (high part of the extended stack
pointers) in conjunction with the data stack pointer (SP). This mode is used to access stack values
in data memory.
3. Register-bit direct
This mode uses an offset to specify a bit address. This mode is used to access one
register bit or two adjacent register bits.
4. PDP direct
104
This mode uses the peripheral data page register (PDP) and an offset to specify an I/O
address. This mode is used to access a location in I/O space.
Indirect Addressing Modes:
1. AR indirect
This mode uses one of eight auxiliary registers (AR0–AR7) to point to data. The way the
CPU uses the auxiliary register to generate an address depends on whether you are accessing
data space (memory or memory-mapped registers), individual register bits, or I/O space.
2. Dual AR indirect
This mode uses the same address-generation process as the AR indirect addressing
mode. This mode is used with instructions that access two or more data-memory locations.
3. CDP indirect
This mode uses the coefficient data pointer (CDP) to point to data. The way the CPU uses
CDP to generate an address depends on whether you are accessing data space (memory or
memory-mapped registers), individual register bits, or I/O space.
4. Coefficient indirect
This mode uses the same address-generation process as the CDP indirect addressing
mode. This mode is available to support instructions that can access a coefficient in data memory
at the same time they access two other data-memory values using the dual AR indirect
addressing mode.
Circular Addressing:
Circular addressing can be used with any of the indirect addressing modes. Each of the
eight auxiliary registers (AR0–AR7) and the coefficient data pointer can be independently
configured to be linearly or circularly modified as they act as pointers to data or to register bits.
This configuration is done with a bit (ARnLC) in status register ST2_55.
105
Result:
The Block diagram and addressing modes of TMS320C5515 processor is studied.
106
Aim
To Study the various addressing mode of TMS320C6745 DSP processor.
Addressing Modes The TMS320C55x DSP supports three types of addressing modes that
enable flexible access to data memory, to memory-mapped registers, to register bits, and to I/O
space:
The absolute addressing mode allows you to reference a location by supplying all or part of an
address as a constant in an instruction.
The direct addressing mode allows you to reference a location using an address offset.
The indirect addressing mode allows you to reference a location using a pointer.
Each addressing mode provides one or more types of operands. An instruction that supports an
addressing-mode operand has one of the following syntax elements listed below.
Baddr - When an instruction contains Baddr, that instruction can access one or two bits in an
accumulator (AC0–AC3), an auxiliary register (AR0–AR7), or a temporary register (T0–T3). Only
the register bit test/set/clear/complement instructions support Baddr. As you write one of these
instructions, replace Baddr with a compatible operand.
Cmem - When an instruction contains Cmem, that instruction can access a single word (16 bits)
of data from data memory. As you write the instruction, replace Cmem with a compatible operand.
Lmem - When an instruction contains Lmem, that instruction can access a long word (32 bits) of
data from data memory or from a memory-mapped registers. As you write the instruction, replace
Lmem with a compatible operand.
Smem - When an instruction contains Smem, that instruction can access a single word (16 bits) of
data from data memory, from I/O space, or from a memory-mapped register. As you write the
instruction, replace Smem with a compatible operand.
Xmem and Ymem - When an instruction contains Xmem and Ymem, that instruction can perform
two simultaneous 16-bit accesses to data memory. As you write the instruction, replace Xmem
and Ymem with compatible operands.
107
Absolute Addressing Modes k16 absolute - This mode uses the 7-bit register called DPH (high
part of the extended data page register) and a 16-bit unsigned constant to form a 23-bit data-
space address. This mode is used to access a memory location or a memory-mapped register.
k23 absolute - This mode enables you to specify a full address as a 23-bit unsigned constant.
This mode is used to access a memory location or a memory-mapped register.
I/O absolute - This mode enables you to specify an I/O address as a 16-bit unsigned constant.
This mode is used to access a location in I/O space.
Direct Addressing Modes DP direct - This mode uses the main data page specified by DPH
(high part of the extended data page register) in conjunction with the data page register (DP). This
mode is used to access a memory location or a memory-mapped register.
SP direct - This mode uses the main data page specified by SPH (high part of the extended stack
pointers) in conjunction with the data stack pointer (SP). This mode is used to access stack values
in data memory.
Register-bit direct - This mode uses an offset to specify a bit address. This mode is used to
access one register bit or two adjacent register bits.
PDP direct - This mode uses the peripheral data page register (PDP) and an offset to specify an
I/O address. This mode is used to access a location in I/O space. The DP direct and SP direct
addressing modes are mutually exclusive. The mode selected depends on the CPL bit in status
register ST1_55: 0 DP direct addressing mode 1 SP direct addressing mode The register-bit and
PDP direct addressing modes are independent of the CPL bit.
Indirect Addressing Modes You may use these modes for linear addressing or circular
addressing.
AR indirect - This mode uses one of eight auxiliary registers (AR0–AR7) to point to data. The way
the CPU uses the auxiliary register to generate an address depends on whether you are
accessing data space (memory or memory-mapped registers), individual register bits,or I/O space.
Dual AR indirect - This mode uses the same address-generation process as the AR indirect
addressing mode. This mode is used with instructions that access two or more data-memory
locations.
CDP indirect - This mode uses the coefficient data pointer (CDP) to point to data. The way the
CPU uses CDP to generate an address depends on whether you are accessing data space
(memory or memory-mapped registers), individual register bits, or I/O space.
108
Coefficient indirect - This mode uses the same address-generation process as the CDP indirect
addressing mode. This mode is available to support instructions that can access a coefficient in
data memory at the same time they access two other data-memory values using the dual AR
indirect addressing mode.
Circular Addressing Circular addressing can be used with any of the indirect addressing modes.
Each of the eight auxiliary registers (AR0–AR7) and the coefficient data pointer (CDP) can be
independently configured to be linearly or circularly modified as they act as pointers to data or to
register bits, see Table 3−10. This configuration is done with a bit (ARnLC) in status register
ST2_55. To choose circular modification, set the bit. Each auxiliary register ARn has its own
linear/circular configuration bit in ST2_55: 0 Linear addressing 1 Circular addressing The CDPLC
bit in status register ST2_55 configures the DSP to use CDP for linear addressing or circular
addressing: 0 Linear addressing 1 Circular addressing You can use the circular addressing
instruction qualifier, .CR, if you want every pointer used by the instruction to be modified circularly,
just add .CR to the end of the instruction mnemonic (for example, ADD.CR). The circular
addressing instruction qualifier overrides the linear/circular configuration in ST2_55.
ADDITION
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H
.mmregs
.text Input: Output:
START: Data Memory: Data Memory:
LD #140H,DP A000h 0004h A002h 0008h
RSBX CPL A001h 0004h
NOP
NOP
NOP
NOP
LD INP1,A
ADD INP2,A
STL A,OUT
HLT: B HLT
109
SUBTRACTION
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H
.mmregs
.text
START:
LD #140H,DP
RSBX CPL
NOP
NOP
NOP
NOP
LD INP1,A
SUB INP2,A
STL A,OUT
HLT: B HLT
Input: Output:
Data Memory: Data Memory:
A000h 0004h A002h 0002h
A001h 0002h
Result
Thus, the various addressing mode of DSP processor TMS320C5505 was studied.
110
Aim:
To generate sine wave and square wave using TMS320C5515 FIXED POINT DSP KIT.
Procedure:
j=0;
}
aic3204_disable();
printf( "\n***Program has Terminated***\n" );
SW_BREAKPOINT;
}
Result:
The sine wave and square waves are generated using TMS320C5515 DSP kit and the
output waveforms are obtained in CRO.
114
Aim:
To design and plot the FIR filter using TMS320C5515 FIXED POINT DSP KIT.
Procedure:
Result:
The FIR filter is implemented using TMS320C5515 DSP kit and the output waveforms are
obtained in CRO.
117
Aim:
To design and plot the IIR filter using TMS320C5515 FIXED POINT DSP KIT.
Procedure:
#include "stdio.h"
#include "usbstk5515.h"
#include "aic3204.h"
#include "PLL.h"
#include "stereo.h"
#include "IIR_band_pass_filters.h"
#include "IIR_band_stop_filters.h"
#include "IIR_filters_fourth_order.h"
#include "IIR_low_pass_filters.h"
#include "IIR_high_pass_filters.h"
#include "SweepGenerator.h"
Int16 left_input;
Int16 right_input;
Int16 left_output;
Int16 right_output;
Int16 mono_input;
aic3204_codec_write(left_output, right_output);
}
SW_BREAKPOINT;
Result:
The IIR and FIR filter is implemented using TMS320C5515 DSP kit and the output
waveforms are obtained in CRO.
120
Aim:
To sample and display the input signals using TMS320C5515 FIXED POINT DSP KIT.
Procedure:
Result:
The Input signals are sampled, reconstructed and displayed in CRO using TMS320C5515
DSP kit .
123
Additional Experiments
Aim:
To implement the linear convolution using TMS320C5515 FIXED POINT DSP KIT.
Hardware and software required:
1. TMS320C5515 DSP KIT
2. PC with code composer studio v4
3. CRO
Procedure:
1. Start the code composer IDE.
2. Open new CCS Project and add the necessary library files.
3. Select a new source and type the program
4. Save the source file with a file extension .c
5. Go to project menu select the properties option and apply the necessary settings.
6. Apply Build active project in project menu.
7. Go to Launch TI option in target menu and set the general configuration settings about the
target.
8. Connect the TMS320C5515 kit with the PC through USB port and connect the LINEIN and
LINEOUT pins with function generator and CRO respectively.
9. In target menu click RUN icon and observe the output in CRO.
#include "stdio.h"
#include "usbstk5505.h"
#include "PLL.h"
int x[15],h[15],y[15];
main()
{
int i,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\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf ("Enter Values for n \n");
for(i=0;i<n;i++)
scanf("%d",&h[i]);
for(i=m;i<=m+n-1;i++)
124
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
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]);
}}
for(i=0;i<m+n-1;i++)
printf("\n The Value of output y[%d]=%d",i,y[i]);
}
Result:
The Linear convolution is implemented and output is verified using TMS320C5515 DSP kit.
125
Aim:
To implement the circular convolution using TMS320C5515 FIXED POINT DSP KIT.
Hardware and software required:
1. TMS320C5515 DSP KIT
2. PC with code composer studio v4
3. CRO
Procedure:
1. Start the code composer IDE.
2. Open new CCS Project and add the necessary library files.
3. Select a new source and type the program
4. Save the source file with a file extension .c
5. Go to project menu select the properties option and apply the necessary settings.
6. Apply Build active project in project menu.
7. Go to Launch TI option in target menu and set the general configuration settings about the
target.
8. Connect the TMS320C5515 kit with the PC through USB port and connect the LINEIN and
LINEOUT pins with function generator and CRO respectively.
9. In target menu click RUN icon and observe the output in CRO.
{
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];
}
}
printf("%d \t",y[i]);
Result:
The circular convolution is implemented and output is verified using TMS320C5515 DSP
kit.
127
Aim:
UP SAMPLING:
clear all;
close all;
clc;
f1=100;
k=1:10;
fs=1000;
L=4; %Up sample by a value
x=sin(2*pi*f1/fs*k); %Input signal
subplot(2,1,1);
stem(x);
title('Input sequence ');
xlabel(' Samples(n) ');
ylabel('Amplitude');
y=Upsample(x,L); %TO DO UP SAMPLE
subplot(2,1,2);
stem(y); %Draw the graph
xlabel(' Samples(n) ');
ylabel('Amplitude');
title('Input sequence Upsampled by a factor L');
Output:
129
Down sampling:
Up Sampling:
130
START
downsample(x,M)
STOP
Flowchart: Up Sampling
START
Upsample(x,L)
STOP
131
Result:
The program for decimation and interpolation is executed and its output is verified
successfully using MATLAB.
132
Aim:
Procedure:
Block Diagram:
133
int A[10],i;
float B[10],a=0;
void main(void)
{
for(i=0;i<10;i++)
scanf("%d",&A[i]);
for(i=0;i<10;i++)
{
a=a+(A[i]*B[i]);
}
printf("mac result is %f",a);
}
Result:
The MAC operation is implemented using TMS320C5515 DSP kit and the output is obtained
in console window.
134