DSP LAB Manual - ECE -KNCET (2)
DSP LAB Manual - ECE -KNCET (2)
DSP LAB Manual - ECE -KNCET (2)
MATLAB is a high-level technical computing language and interactive environment for algorithm
development, data visualization, data analysis, and numeric computation.
Strengths of MATLAB:
Other Features:
Functions for integrating MATLAB based algorithms with external applicationsand languages, such
as C, C++, Fortran, Java, COM, and Microsoft Excel.
Weaknesses of MATLAB:
MATLAB is an interpreted language (making it for the most part slower than a compiled language
such as C++).
MATLAB is designed for scientific computation and is not suitable for some things (such as parsing
text).
1. The MATLAB language, this is a high level matrix/array language with control flow statements,
functions data structure input/output, and object oriented programming features. It allows both
“programming in the large” to create complete large and complex application programs.
3. Handle Graphics, this is the MATLAB graphics system. It includes high level commands for two
dimensional data visualization, image processing , and animation and presentation graphics .It also
includes low level commands that allows the user to fully customize the appearance of graphics as well
as to build complete Graphical User Interface on your MATLAB applications
4. The MATLAB mathematical function library. This is a vast collection of computational and complex
arithmetic ranging from elementary functions like sum, sine, cosine and complex arithmetic to more
sophisticated function like matrix inverse, matrix eigen values ,Bessel functions and fast Fourier
Transforms.
5. The MATLAB Application program Interface (API). This is a library that allows the user to write C
and FORTRAN programs that interact with MATLAB. It includes facilities for calling routines from
MATLAB(dynamic linking),calling MATLAB as a computational engine, and for reading and writing
MAT-files.
Simulink:
Block sets are add ins to simulink that provide additional libraries of blocks for specializing
applications like communications signals processing and power systems.
Real-time workshop is a program that allows the user to generate C code from block diagrams and to
run it on a variety of real time systems.
M-files:
Like most other programming language, MATLAB provides mathematical expressions, but unlike
most programming language, these expressions involve entire matrices. Files that contain code in the
MATLAB language are called M-files .M-files can be creating using a text editor, and can be used as any
other MATLAB function or command.
1. Scripts which do not accept input arguments or return output arguments. They operate on data in
the workspace.
2. Functions, which can accept input arguments or return output arguments. Internal variables are
local to the function.
Toolboxes:
MATLAB features a family of application –specific solution called toolboxes. Toolboxes are
comprehensive collations of MATLAB functions (M-files) that extend the MATLAB environment to solve
particular classes of problems. Areas in which toolboxes are available include signal processing, control
systems neural networks, fuzzy logic wavelets, Simulation and, many others.
The signal processing toolbox in MATLAB facilities in analysis of signals and design of systems. This
contains a list of functions pertaining to the various areas of signal processing.
Exp.No: 1
GENERATION OF INPUT SIGNALS
Digital Signal Processing Lab Manual Page 3
Date:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
2. Assign the signals unit impulse, unit step, unit ramp, exponential, sine and cosine signals.
GENERATION OF SIGNALS
Amplitude-->
0.5 0.5
0 0
-5 0 5 0 5 10
time--> time-->
unit ramp signal unit exponentail signal
6 15
Amplitude-->
Amplitude-->
4 10
2 5
0 0
0 2 4 6 -5 0 5
time--> time-->
0.5
Amplitude-->
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
time-->
cosine signal
1
0.5
Amplitude-->
-0.5
-1
0 1 2 3 4 5 6 7 8 9 10
time-->
Unit Impulse:
u(n) = 1 for n ≥ 0
= 0 for n < 0
Unit Ramp:
ur(n) )= 1 for n ≥ 0
= 0 for n < 0
Exponential Sequence:
Sine Sequence:
Cosine Sequence:
RESULT:
Thus the above standard signals have been generated by using the MATLAB.
AIM:
APPARATUS REQUIRED:
Hard ware: IBM PC or compatible
ALGORITHM:
clc;
clear all;
close all;
N=input('Enter the number of samples N= ');
fm=input('Enter the frequency');
t=0:0.01:N;
x=cos(2*pi*fm*t);
subplot(3,2,1);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Input Signal');
fs1=fm;
fs2=2*fm;
fs3=5*fm;
n=0:0.08:N;
y=cos(2*pi*fm*n);
subplot(3,2,2);
stem(n,y,'r');
xlabel('Time');
ylabel('Amplitude');
title('Sampling Signal');
y1=cos(2*pi*n*fm/fs1);
subplot(3,2,3);
stem(n,y1,'g');
xlabel('Time');
ylabel('Amplitude');
title('Sampling Signal with fs<2fm');
y2=cos(2*pi*n*fm/fs2);
subplot(3,2,4);
stem(n,y2);
xlabel('Time');
ylabel('Amplitude');
title('Sampling Signal with fs=2fm');
y3=cos(2*pi*n*fm/fs3);
subplot(3,2,5);
stem(n,y3);
OUTPUT
Amplitude
0 0
-1 -1
0 5 10 0 5 10
Time Time
Sampling Signal with fs<2fm Sampling Signal with fs=2fm
1 1
Amplitude
Amplitude
0 0
-1 -1
0 5 10 0 5 10
Time Time
Sampling Signal with fs>2fm
1
Amplitude
-1
0 5 10
Time
RESULT:
Thus the MATLAB program for Sampling and aliasing has been successfully executed.
Exp.No: 3
CALCULATION OF FFT
Date:
AIM:
APPARATUS REQUIRED:
Hard ware: IBM PC or compatible
ALGORITHM:
3
Amplitude
Amplitude
0.5 2
0 0
0 2 4 6 8 0 2 4 6 8
Time Time
Phase Response IFFT Response
4 1
Amplitude
Amplitude
2
0.5
0
-2 0
0 2 4 6 8 0 2 4 6 8
Time Time
RESULT:
Thus the Matlab program for the N-point FFT and IFFT of given input sequence was calculated.
To write the program for finding the linear and circular convolution of two signals using MATLAB 7.0
APPARATUS REQUIRED:
Hard ware: IBM PC or compatible
LINEAR CONVOLUTION:
ALGORITHM:
1. Get the number of samples.
2. Generate the output sequence of the given two input signals using‘conv’ command.
3. Plot the graph.
clc;
clear all;
close all;
x=input('Enter the first sample');
N1=length(x);
h=input('Enter the second sample');
N2=length(h);
n=0:1:N1-1;
subplot(2,2,1);
stem(n,x);
xlabel('Time');
ylabel('Amplitude');
title('X Sequence Response');
n=0:1:N2-1;
subplot(2,2,2);
stem(n,h);
xlabel('Time');
ylabel('Amplitude');
title('H Sequence Response');
y=conv(x,h);
N=N1+N2-1;
n=0:1:N-1;
subplot(2,2,3);
stem(n,y);
xlabel('Time');
ylabel('Amplitude');
title('Convolution of X&H Response');
CIRCULAR CONVOLUTION:
ALGORITHM:
1. Get the number of samples.
2. Generate the sequence for the given two input signals using ‘zeros’ and ‘ones’ matrix command.
3. Generate the convoluted output sequence of the given two input signals using ‘conv’ command.
4. Plot the graph.
1.5 3
Amplitude
1 Amplitude 2
0.5 1
0 0
0 0.5 1 0 0.5 1 1.5 2
Time Time
Convolution of X&H Response
8
6
Amplitude
0
0 1 2 3
Time
clc;
clear all;
close all;
x=input('enter the input signal');
h=input('enter the impulse signal');
n2=length(x);
n3=length(h);
if(n2==n3)
n=max(n2,n3)
x1=[x,zeros(1,n-n2)];
h1=[h,zeros(1,n-n3)];
3 1.5
Amplitude
Amplitude
2 1
1 0.5
0 0
0 0.5 1 1.5 2 0 0.5 1
Time Time
Convolution of X&H Response
10
Amplitude
0
1 1.5 2 2.5 3
Time
RESULT
Thus theMatlab program for Linear and Circular Convolution of the two sequences through
Fast Fourier Transformation was successfully executed.
Exp.No: 5.a
DESIGN OF FIR FILTER USING RECTANGULAR WINDOW
Date:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter ‘N’.
4. Design the low pass, high pass, band pass and band stop filter.
5. Plot the magnitude response of all filters.
PROGRAM:
clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem)
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=boxcar(n1);
%LOW PASS FILTER
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%HIGH PASS FILTER
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
x=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
n=
18
Gain in db---->
Gain in db---->
0 0
-50 -50
-100 -100
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 10
Gain in db---->
Gain in db---->
0 0
-50 -10
-100 -20
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
RESULT:
Exp.No: 5.b
DESIGN OF FIR FILTER USING HAMMING WINDOW
Date:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter N.
4. Design the lowpass, High pass, Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.
PROGRAM:
clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem)
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=hamming(n1);
%LOW PASS FILTER
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%HIGH PASS FILTER
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
n = 30
Gain in db---->
Gain in db---->
0
-50
-50
-100
-150 -100
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 5
0
Gain in db---->
Gain in db---->
0
-5
-50
-10
-100 -15
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
RESULT:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter N.
4. Design the lowpass,Highpass,Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.
clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem)
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=hanning(n1);
%LOW PASS FILTER
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
Digital Signal Processing Lab Manual Page 23
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%HIGH PASS FILTER
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
x=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
subplot(2,2,3);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
%BAND STOP FILTER
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')
n= 21
Gain in db---->
Gain in db---->
0
-50
-50
-100
-150 -100
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 5
0
Gain in db---->
Gain in db---->
0
-5
-50
-10
-100 -15
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
RESULT:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter N.
4. Design the lowpass,Highpass,Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.
clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in rad/sec=');
fp=input('Pass band frequency in rad/sec=');
f=input('Sampling frequency in rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem)
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=blackman(n1);
%LOW PASS FILTER
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
Digital Signal Processing Lab Manual Page 26
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%HIGH PASS FILTER
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
x=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
subplot(2,2,3);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
%BAND STOP FILTER
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')
n = 22
0 0
Gain in db---->
Gain in db---->
-50 -50
-100 -100
-150 -150
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
BAND PASS FILTER BAND STOP FILTER
50 5
0
Gain in db---->
Gain in db---->
0
-50
-5
-100
-150 -10
0 0.5 1 0 0.5 1
Normalized frequency----> Normalized frequency---->
RESULT:
Date:
AIM:
APPARATUS REQUIRED:
ALGORITHM:
1. Start the program and specify the input datas for each type of filters.
2.Find the order of the filter using built function.
3.Find the number and denominator polynomials for calculation of transfer function.
4.Plot the frequency response and gain for low pass,high pass, band pass and band stop IIR butterworth
filter.
5.Stop the program
PROGRAM:
clc;
clear all;
close all;
N=8;
wn=0.4;
[num,den]=butter(N,wn,'s');
w=(0:0.01:2);
h=freqs(num,den,w);
subplot(2,2,1);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth low pass filter');
grid on;
xlabel('frequency in hz');
ylabel('gain in db');
[num,den]=butter(N,wn,'high','s');
h=freqs(num,den,w);
subplot(2,2,2);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth high pass filter');
grid on;
xlabel('frequency in hz');
ylabel('gain in db');
Digital Signal Processing Lab Manual Page 29
N=8;
wp=0.4;
ws=0.6;
wn=[wp ws];
[num,den]=butter(N,wn,'s');
h=freqs(num,den,w);
subplot(2,2,3);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth band pass filter');
grid on;
xlabel('frequency in hz');
ylabel('gain in db');
N=8;
wp=0.4;
ws=0.6;
wn=[wp ws];
[num,den]=butter(N,wn,'stop','s');
h=freqs(num,den,w);
subplot(2,2,4);
plot(w/2*pi,(abs(h)),'linewidth',2.5);
title('butterworth band stop filter');
grid on;
ylabel('gain in db');
xlabel('frequency in hz');
gain in db
0.5 0.5
0 0
0 1 2 3 4 0 1 2 3 4
frequency in hz frequency in hz
butterworth band pass filter butterworth band stop filter
1.5 1.5
gain in db
gain in db
1 1
0.5 0.5
0 0
0 1 2 3 4 0 1 2 3 4
frequency in hz frequency in hz
RESULT:
Thus the digital butterworth IIR Filteris designed by using Matlab program.
AIM:
To write a program to compute Convolution and m-fold decimation by poly phase decomposition
APPARATUS REQUIRED:
Hard ware: IBM PC or compatible
ALGORITHM:
1. Get the input sequence.
2. Get the filter coefficients and also the decimation factor.
3. Find the response by using convolution.
4. Plot the graph.
PROGRAM
Clear all;
clc;
close all;
x=input('enter the input sequence');
h=input('enter the FIR filter coefficients');
M=input('enter the decimation factor');
N1=length(x);
n=0:1:N1-1;
subplot(2,1,1);
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('X sequence response');
N2=length(h);
n=0:1:N2-1;
subplot(2,1,2);
stem(n,h);
xlabel('time');
ylabel('amplitude');
title('H sequence response');
H=length(h);
P=floor((H-1)/M)+1;
r=reshape([reshape(h,1,H),zeros(1,P*M-H)],M,P);
X=length(x);
Y=floor((X+H-2)/M)+1;
U=floor((X+M-2)/M)+1;
R=zeros(1,X+P-1);
X sequence response
4
3
amplitude
0
0 0.5 1 1.5 2 2.5 3
time
H sequence response
1
amplitude
0.5
0
0 0.5 1 1.5 2 2.5 3
time
10
amplitude
0
0 0.5 1 1.5 2 2.5 3 3.5 4
time
RESULT:
Thus a program for Convolution and m-fold decimation by poly phase decomposition is computed
using MATLAB.
AIM:
To study about direct, indirect and immediate addressing modes in TMS320C50 debugger.
APPARATUS REQUIRED:
ALGORITHM:
IMMEDIATE ADDRESSING MODE:
AIM:
To write a program to find the Convolution of two sequences X(n) and H(n) using TMS320C50 debugger.
APPARATUS REQUIRED:
LINEAR CONVOLUTION
ALGORITHM:
1. Start the program.
2. LPD will load the 9LSB’s of address data memory.Location or immediate value into the data pointer (DP)
register.
3. Load auxiliary register (LAR) loads the content of the address data memory location into the designated
auxilary register.
4. Then ZC clears the content of accumulator too.
5. MAR modify current AR and ARP as specified.
6. The RPT load the 8 bit LSBs of the addressed value of the RPT.
7. The SACL store the 16 LSBs of the accumulator into the addressed data memory.
8. MUL is used to multiply the content of T register.
9. The LTP would load the contents of the addressed data memory location into T register.
10. ADD will add the content of the memory.
11. LACC is used to load the content of the addressed data memory into accumulator.
LDP #02H
LAR AR1,#8100H ; x(n) datas
lar ar0,#08200H ;h(n) datas
LAR AR3,#8300H ;y(n) starting
LAR AR4,#0006 ;N1+N2-1;
to fold the h(n) values
************************
lar ar0,#8203H ; data mem 8200 to program mem c100(tblw)
lacc #0c100h ; Iniltialize Program Memory
mar *,ar0 ; Auxilary Register Pointer for AR0 Reg to the 8203 address
rpt #3 ; Repeat the Next instruction 3 times
tblw *- ; to move 8203- 8200 to c100- c103;
padding of zerros for x(n) values
;**********************************
lar ar6,#8104h ;padding N1 - 1 zeros for first input Sequence.8100 to 8103 for input datas.8104 to 8106
are padding zero datas.
mar *,ar6 ; AuxilaryReg Pointer for AR6 point to the 8104 address
lacc #0h ; Load ACC to Zero
rpt #2h ; Repeat the next instruction to 2 times
sacl *+ ; Load ACC value to data memory location(8104 to 8106) and inc the
dma ;convalution operation starts
;******************************
LOP: MAR *,AR1 ; Point to the first input seq data memory address location
LACC *+ ; load data memory value to ACC
SACL 050H ; Load ACC value to 150th Program memory location(LDP is 2, memory
location start from 100 to 17F)
LAR AR2,#0153H ; Load data to AR2 reg
MAR *,AR2 ; point to the program memory location
ZAP ; ACC = 0,Preg0 = 0
RPT #03H ;N1-1 times so that N1 times
MACD 0C100H,*- ;convolution Multiplication
APAC ;toaccmulate the final product sample
MAR *,AR3 ; Point to the output data memory Location
SACL *+ ; Store ACC value to data memory location and inc the data memory address
MAR *,AR4 ; Load data value to AR reg
BANZ LOP,*- ; Continue the loop operation when N = 0
H: B H ; Halt the Program
CIRCULAR CONVOLUTION
ALGORITHM:
1. Start the Program.
2. Load the LSB’s of the address data memory location.
3. Load the contents of the address data memory location into auxiliaryregister.
4. Modify the current AR as specified.
5. Load the content of addressed data memory location.
6. Store the 16 LSBs of the accumulator into the address data memorylocation.
7. Load the content in ARL Z.0
8. Branch the contents of entire auxiliary register.
9. Load the content AR.1,AR.2,AR.0
10. Store the content of the accumulator’
11. Modify the current AR as specified.
12. Stop the program.
;----------------------------------------------------------------------------
.mmregs
.text
START:
LDP #100H ; Data page
LAR AR2,#8200H ; X2(n)
LAR AR1,#8400H ; Re_arange X2(n)
LAR AR4,#8300H ; Output Memory
LAR AR3,#03H ; Count; Re_Arrange the Data of X2(n):
;------------------------------
MAR *,AR2; Modify aux Reg as data memory
LACC*,AR1 ; load data mem value acc& change Aux Reg
SACL *+,AR2 ; store acc data to data memory location
LAR AR2,#(8200h+3h) ; X2(N) End of location Rearranged input seq
LAR AR0,#2H ; load data to AR regRe_arange:
LACC *-,AR1 ;load (AR2 -> 8203) data memory value to acc & change Aux reg
SACL *+,AR0 ;store acc data to data memory location(AR1 -> 8401) BANZ
Re_arange,*-,AR2 ; Repeat the instruction when AR0 is reach zero\;Multiply &Accumulate:
;----------------------
Next_YN:
LAR AR1,#8100H ; Load data to aux regits for 1st i/p seq data
LAR AR2,#8400H ; Load data to aux regits for 2st i/p seq data
LAR AR0,#3H ;Load data to aux regits for output length
ZAC
SACL 0H ; load acc data to data mem location of 0H
MAR *,AR1 ; point to data memory location
LT *+,AR2 ; load data to TREG0 & change aux Reg
Loop_MAC:
MPY *+,AR1 ;multiply data(X2(n)) memory value to TREG0 value and store output to preg
LTP *+,AR0 ;load data memory value to treg0 and store preg value to acc
ADD 0H ; add data its for continues addition
SACL 0H ; store acc data to 0h location
BANZ Loop_MAC,*-,AR2 ; repeat the AR0 when reach zero
LACC 0H ; load 0h location value into acc
MAR *,AR4 ; modify aux reg for output data store
SACL *+ ;store acc data to output data memory location; Shift X2(n) Values:
;--------------------
LAR AR1,#(8400h+3h) ;load data value to arregits for rearrange the second i/p seq
LAR AR2,#2H ; load data to ar reg.
LAR AR0,#2H ; Index Value 2H
MAR *,AR1 ;modify AR reg value as data memory
LACC *- ;load data mem value to acc&dec
Digital Signal Processing Lab Manual Page 38
SACL 1H ; load acc data to 1H location
Shift_X2N:
LACC *+ ;load data memory value to acc
SACL *0-,AR2 ; dec the mem location & change arreg
BANZ Shift_X2N,*-,AR1 ; Repeat the loop
MAR *+ ;inc the arreg
LACC 1H ; load 1H data memvakue to acc
SACL *,AR3 ; store acc data to data mem location
BANZ Next_YN,*- ; Branch Loop
NOP
H: B H
;OUTPUT:
; 8300 - 000E
; 8301 - 0010
; 8302 - 000E
; 8303 - 0010
RESULT:
AIM:
To write a program to convert analog signals into digital signals using TMS320C50 debugger.
APPARATUS REQUIRED:
1. System with TMS 320C50 debugger software
2. TMS 320C50 Kit.
3. CR0
4. Function Generator
ALGORITHM:
1. Initialize data pointer with 100H data
2. give the analog signal as input
3. Introduce the time delay as per required.
4. Observe the discrete signal as output
5. Plot the graph.
PROGRAM:
.MMREGS
.TEXT
START:
LDP #0100H ; Load Data Page Pointer
NOP
ADC_Start:
IN 0,06H ; ADC Start of Conversion
NOP
NOP
NOP
IN 0,04H ; ADC Data Read
RPT #0FH ; Delay
NOP
LACC 0H
AND #0FFFH ; 12 Bit ADC
SACL 0H
OUT 0,04H ; DAC Data Write
B ADC_Start
NOP
NOP
.END
RESULT:
Thus the analog signal was converted into digital signal using TMS320C50 debugger.
AIM:
To write a program to generate Triangle Wave,SineWave,Square Wave and SawTooth Wave
using TMS320C50 debugger.
APPARATUS REQUIRED:
1.System with TMS 320C50 debugger software
2.TMS 320C50 Kit.
3.CR0
4.Function Generator.
ALGORITHM:
TRIANGLE WAVE GENERATION:
1. Start the program.
2. Load the LSBs of the address data memory location.
3. Write full 16 bit pattern into address data memory location.
4. Load the content of address data memory location.
5. Add the content of address data memory location.
6. Store the data of accumulator into address data memory location.
7. Modify the current AR as specified.
8. Repeat the step 2,3.
9. Subtract the contents of address data memory location.
10. Repeat the steps 5,6,7.
11. Stop the program.
AMPLITUDE .SET 4
FREQ .SET 350
TEMP .SET 0
;
.mmregs
.text
START:
LDP #100H
splk #0,TEMP
CONT1:
lar AR2,#FREQ
CONT:
out TEMP,4
LACC TEMP
ADD #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONT,*-
LAR AR2,#FREQ
CONTx:
OUT TEMP,4
LACC TEMP
SUB #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONTx
B CONT1
.end
TEMP .set 0
TEMP1 .set 1
.mmregs
.text
START:
LDP #100H
SPLK #TABLE,TEMP ;load start address of table
lar AR2,#( (LENGTH/INCFREQ)+(LENGTH*DECFREQ) )-1
lar ar3,#DECFREQ ;repeat counter for reducing frequency
CONT:
CALL DELAY
LACC TEMP ;load address of sine value
TBLR TEMP1 ;read sine data to TEMP1
LT TEMP1
MPY #AMPLITUDE
PAC
SACL TEMP1
Digital Signal Processing Lab Manual Page 44
mar *,ar3
banz repeat,*-
lar ar3,#DECFREQ ;repeat counter for reducing frequency
LACC TEMP
ADD #INCFREQ ;increase table value
repeat:
SACL TEMP ;store it
OUT TEMP1,4 ;send sine data to DAC
MAR *,AR2
BANZ CONT,*-
b START
DELAY:
lar ar7,#delay
mar *,ar7
back: banz back,*-
ret
;
TABLE
.word 100
.word 101
.word 103
.word 105
.word 106
.word 108
.word 110
.word 112
.word 113
.word 115
.word 117
.word 119
.word 120
.word 122
.word 124
.word 125
.word 127
.word 129
.word 130
.word 132
.word 134
.word 135
.word 137
.word 139
.word 140
.word 142
.word 143
.word 145
.word 146
.word 148
.word 150
Digital Signal Processing Lab Manual Page 45
.word 151
.word 152
.word 154
.word 155
.word 157
.word 158
.word 160
.word 161
.word 162
.word 164
.word 165
.word 166
.word 168
.word 169
.word 170
.word 171
.word 173
.word 174
.word 175
.word 176
.word 177
.word 178
.word 179
.word 180
.word 181
.word 182
.word 183
.word 184
.word 185
.word 186
.word 187
.word 188
.word 189
.word 189
.word 190
.word 191
.word 192
.word 192
.word 193
.word 193
.word 194
.word 195
.word 195
.word 196
.word 196
.word 197
.word 197
.word 197
.word 198
.word 198
.word 198
.word 199
Digital Signal Processing Lab Manual Page 46
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 200
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 198
.word 198
.word 198
.word 197
.word 197
.word 197
.word 196
.word 196
.word 195
.word 195
.word 194
.word 193
.word 193
.word 192
.word 192
.word 191
.word 190
.word 189
.word 189
.word 188
.word 187
.word 186
.word 185
.word 184
.word 183
.word 182
.word 181
.word 180
.word 179
.word 178
.word 177
.word 176
.word 175
.word 174
.word 173
.word 171
Digital Signal Processing Lab Manual Page 47
.word 170
.word 169
.word 168
.word 166
.word 165
.word 164
.word 162
.word 161
.word 160
.word 158
.word 157
.word 155
.word 154
.word 152
.word 151
.word 149
.word 148
.word 146
.word 145
.word 143
.word 142
.word 140
.word 139
.word 137
.word 135
.word 134
.word 132
.word 130
.word 129
.word 127
.word 125
.word 124
.word 122
.word 120
.word 119
.word 117
.word 115
.word 113
.word 112
.word 110
.word 108
.word 106
.word 105
.word 103
.word 101
.word 99
.word 98
.word 96
.word 94
.word 93
.word 91
.word 89
Digital Signal Processing Lab Manual Page 48
.word 87
.word 86
.word 84
.word 82
.word 80
.word 79
.word 77
.word 75
.word 74
.word 72
.word 70
.word 69
.word 67
.word 65
.word 64
.word 62
.word 60
.word 59
.word 57
.word 56
.word 54
.word 53
.word 51
.word 49
.word 48
.word 47
.word 45
.word 44
.word 42
.word 41
.word 39
.word 38
.word 37
.word 35
.word 34
.word 33
.word 31
.word 30
.word 29
.word 28
.word 26
.word 25
.word 24
.word 23
.word 22
.word 21
.word 20
.word 19
.word 18
.word 17
.word 16
.word 15
Digital Signal Processing Lab Manual Page 49
.word 14
.word 13
.word 12
.word 11
.word 10
.word 10
.word 9
.word 8
.word 7
.word 7
.word 6
.word 6
.word 5
.word 4
.word 4
.word 3
.word 3
.word 2
.word 2
.word 2
.word 1
.word 1
.word 1
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 1
.word 1
.word 1
.word 2
.word 2
.word 2
.word 3
.word 3
.word 4
.word 4
.word 5
.word 6
Digital Signal Processing Lab Manual Page 50
.word 6
.word 7
.word 7
.word 8
.word 9
.word 10
.word 10
.word 11
.word 12
.word 13
.word 14
.word 15
.word 16
.word 17
.word 18
.word 19
.word 20
.word 21
.word 22
.word 23
.word 24
.word 25
.word 26
.word 28
.word 29
.word 30
.word 31
.word 33
.word 34
.word 35
.word 37
.word 38
.word 39
.word 41
.word 42
.word 44
.word 45
.word 47
.word 48
.word 50
.word 51
.word 53
.word 54
.word 56
.word 57
.word 59
.word 60
.word 62
.word 64
.word 65
.word 67
.word 69
Digital Signal Processing Lab Manual Page 51
.word 70
.word 72
.word 74
.word 75
.word 77
.word 79
.word 80
.word 82
.word 84
.word 86
.word 87
.word 89
.word 91
.word 93
.word 94
.word 96
.word 98
.word 100
.end
RESULT:
AIM:
To design a FIR low pass filter in serial mode.
APPARATUS REQUIRED:
1.System with VI debugger software
2.TMS 320C50 Kit.
3.CR0
ALGORITHM:
1. Start the program.
2. Initialize the C table value.
3. Load the auxillary register with 0200H.
4. Modify the auxillary register zero.
5. Block the C table to the program.
6. Set configuration control bit.
7. Load the data pointer with 0AH.
8. Initialize the analog to digital conversion.
9. Load the auxillary register 1 with 0300 content.
10. Load the accumulator in 8000H.
11. AND the accumulator with 0FFFH.
12. Subtract the accumulator content with data 800H.
13. Modify the auxillary register 1.
14. Store the accumulator data in 8000H.
15. Load the auxillary register 1 with content 0333H.
16. Zero the accumulator register.
17. Multiply the accumulator with data.
18. Load the program register, with PM bits to accumulator.
19. Load the auxillary register 1 with content 0300H.
20. Add accumulator content with 800H.
21. Shift the accumulator right 1 bit.
22. Store the accumulator content in 8200 location.
23. Branch the program to step 7.
SACL 0H
IN 0,06H ;soc
NOP ;delay
NOP ;delay
LAR AR1,#0300H ;move 300h to auxilary register
RESULT:
Thus the program for designing a FIR low pass filter in serial mode was
Performed
AIM:
To design a FIR high pass filter in serial mode.
APPARATUS REQUIRED:
1.System with VI debugger software
2.TMS 320C50 Kit.
3.CR0
ALGORITHM:
1. Start the program.
2. Initialize the C table value.
3. Load the auxillary register with 0200H.
4. Modify the auxillary register zero.
5. Block the C table to the program.
6. Set configuration control bit.
7. Load the data pointer with 0AH.
8. Initialize the analog to digital conversion.
9. Load the auxillary register 1 with 0300 content.
10. Load the accumulator in 8000H.
11. AND the accumulator with 0FFFH.
12. Subtract the accumulator content with data 800H.
13. Modify the auxillary register 1.
14. Store the accumulator data in 8000H.
15. Load the auxillary register 1 with content 0333H.
16. Zero the accumulator register.
17. Multiply the accumulator with data.
18. Load the program register, with PM bits to accumulator.
19. Load the auxillary register 1 with content 0300H.
20. Add accumulator content with 800H.
21. Shift the accumulator right 1 bit.
22. Store the accumulator content in 8200 location.
23. Branch the program to step 7.
* Filter Order: 52
* Cutoff frequency in KHz = 3.000000
.mmregs
.text
B START
CTABLE:
.word 0FCD3H
.word 05H
.word 0FCB9H
.word 087H
.word 0FD3FH
.word 01ADH
.word 0FE3DH
.word 0333H
.word 0FF52H
.word 04ABH
.word 0FFF8H
.word 0595H
.word 0FFACH
.word 0590H
.word 0FE11H
.word 047CH
.word 0FB0BH
.word 029DH
.word 0F6BAH
.word 0AEH
.word 0F147H
.word 01CH
.word 0E9FDH
.word 04C5H
.word 0D882H
.word 044BCH
.word 044BCH
.word 0D882H
.word 04C5H
.word 0E9FDH
.word 01CH
.word 0F147H
.word 0AEH
.word 0F6BAH
.word 029DH
.word 0FB0BH
.word 047CH
.word 0FE11H
.word 0590H
.word 0FFACH
.word 0595H
.word 0FFF8H
.word 04ABH
.word 0FF52H
.word 0333H
.word 0FE3DH
.word 01ADH
.word 0FD3FH
.word 087H
RESULT:
Thus the program for designing a FIR high pass filter in serial mode was performed.