Post on 28-Nov-2014
DIGITAL SIGNAL PROCESSING LAB MANUAL
ECE: V SEMESTER
LIST OF EXPERIMENTS
MATLAB :-
INTRODUCTION TO MATLAB. GENERATION OF SIGNALS. LINEAR AND CIRCULAR CONVOLUTION OF TWO SEQUENCES. SAMPLING AND EFFECT OF ALIASING. DESIGN OF FIR FILTERS. CALCULATION OF FFT OF A SIGNAL. DESIGN OF IIR FILTERS.
PROCESSOR:-
STUDY OF TMS320C50 PROCESSOR. 16 BIT ARITHMETIC OPERATION USING TMS320C50. STUDY OF VARIOUS ADDRESSING MODES OF DSP USING SIMPLE
PROGRAMMING EXAMPLES. SAMPLING OF INPUT SIGNAL AND DISPLAY. IMPLEMENTATION OF FIR FILTER. CALCULATION OF FFT.
1. STUDY OF MATLAB
AIM:
To study the MATLAB and its operations.
APPARATUS REQUIRED:
PC with software MATLAB
THEORY:
MATLAB is a high performance language for technical computing. It integrates computing, visualization and programming in an easy way to be used by the environment where problems and solutions are expressed in familiar mathematical notation.
Typical uses include
1. Math and Computation
2. Algorithm development
3. Data acquisition
4. Modeling, simulation and proto-typing
5. Scientific and engineering graphics
6. Application development including graphical user interface building
7. Data analysis, exploration, visualization.
MATLAB SYSTEM:
The MATLAB consists of three main parts
1. Desktop and Development Environment
This is the set of tools and facilities that help you use MATLAB function and files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop and command window, command history and editor and debugger, a code analyzer and other reports, and browser for viewing help, the workspace, files and the search path.
2. The MATLAB Mathematical Function Library
This is a vast collection of computational algorithm ranging from elementary function like sum, sine, cosine and complex arithmetic to more sophisticated functions like matrix inverse, matrix Eigen values, Bessel functions and fast Fourier transform.
3. The MATLAB Language
This is a high level matrix/array language with control flow statements, functions, data structures, input and output and object oriented programming features. It allows both programming in the small to rapidly create quick and dirty throw –away program and programming in the large to create large and complex application programmer.
4. Graphics
MATLB has extensive facilities for displaying vectors and matrices as graphs as well as annotating and printing these graphs. It includes high-level functions for two and three dimensional data visualization, image processing animation and presentation graphics.
5. MATLAB External Interfaces
This is a library that allows you to write a C program and function FORTRAN programmer that interacts with MATLAB. It includes facilities for calling routines from MATLAB (dynamic range), calling MATLAB as a computational engine, and for reading and writing MATLAB files.
EXAMPLES:
1. Mathematics-Mathematical operation functions and data analysis.
2. Programming-Programming features and techniques.
RESULT:
Thus the functions and operations of MATLAB was studied.
2.GENERATION OF SIGNALS
AIM:
To draw the waveform for unit step, unit ramp, unit impulse, exponential, sine and cosine wave using MATLAB program.
APPARATUS REQUIRED:
PC with MATLAB
ALGORITHM:
STEP1: Clear output screen by using clc command in editor window.
STEP2: Divide output screen into number of portions by using sub-plot command.
STEP3: Then the function for unit step, ramp, impulse and exponential, sine and cosine waves are
declared.
STEP4: Give the title for each output.
STEP5: End the program.
PROCEDURE:
1. Click MATLAB icon and open a new file.
2. Type the program and save the project.
3. Run the program by clicking on debug.
4. Note the output and plot the graph for the output.
PROGRAM:
clc;
clear all;
figure(1);
subplot(3,2,1);
a=5;
t=-a ; a;
i =[zeros(1,a),1,ones(1,a)];
stem (t, i);
x label (‘time’);
y label (‘amplitude’);
title (‘unit step’);
subplot (3,2,2);
figure (1);
a=5;
t=-a;a;
x=t.i;
stem(t,x);
x label (‘time’);
y label (‘amplitude’);
title (‘unit ramp’);
subplot (3,2,3);
figure (1);
a=5;
t=-a:a;
j=[zeros(1,a),1,zeros(1,a)];
stem (t,j);
x label (‘time’);
y label (‘amplitude’);
title (‘unit impulse’);
subplot (3,2,4);
figure (1);
a=5;
t=-a:a;
x=exp(t);
stem (t,x);
x label (‘time’);
y label (‘amplitude’);
title (‘unit exponential’);
subplot (3,2,5);
t=0:.01:2;
x=sin(2*pi*t);
plot (t,x);
line ([0,2],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title (‘sine wave’);
subplot (3,2,6);
t=0:.01:2;
x=cos(2*pi*t);
plot(t,x);
line([0,2],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title(‘cosine wave’);
RESULT:
Thus the waveform for unit step, unit ramp, unit impulse, unit exponential, and sine and cosine wave obtained using MATLAB program.
3. LINEAR AND CIRCULAR CONVOLUTION OF TWO SEQUENCES
AIM:
To perform linear and Circular convolution.
APPARATUS REQUIRED:
PC with MATLAB
ALGORITHM:
STEP1: Get the input sequence.
STEP2: Plot them using subplots in figure window.
STEP3: Calculate output using convolution command.
STEP4: Plot sequences using subplot command.
STEP5: Stop the program.
THEORY:
LINEAR CONVOLUTION:
Any linear system is implemented by means of linear convolution defined as,
Y (n) =∑x (k) h (n-k)
If the two inputs are each of length n1 and n2 the output is of length n1+n2-1.the linear convolution between the two inputs is equivalent to flipping one input and running it through the other like a train.
CIRCULAR CONVOLUTION:
We know that linear convolution of two finite length data sequence is done by assuming that the data is zero outside the length in which it is defined[recall that linear convolution runs from –α to α].this need not be the only valid assumption. For e.g. one can assume that the data is periodic outside the sequence length in which it is defined. This is consistent with the definition of DFT.DFT is equivalent to discrete time Fourier series and that all Fourier series assume periodicity. So this definition of convolution would be more practical use since it implies with DFT definition. Therefore circular
Convolution is defined
n-1
X (n) +y (n) =∑ x (m) y [(n-m) mod n)]
m=0
PROCEDURE:
1. Click on MATLAB icon and open new file.
2. Type program and save it.
3. Run program by clicking on debug.
4. Note output and plots the graph.
PROGRAM:
%linear convolution
clear all;
clc;
close all;
a=input(‘enter the value of a’);
b= input(‘enter the value of b’);
subplot (3,1,1);
stem (a);
subplot (3,1,2);
stem(b);
c=conv(a,b);
subplot (3,1,3);
stem (c);
%circular convolution
clear all;
clc;
close all;
x= input(‘enter the value of x’);
y= input(‘enter the value of y’);
a=length(x);
b=length(y);
n=a+b/2
%zero padding
if a~=b
if a<b
n=b;
x=[x,zeros(1,b-1)];
else
n=a;
y=[y,zeros(1,a-1)];
end
else
n=a;
end
%circular convolution
for i=1:n
z(i)=0;
for j=1:n
k=mod(i-j(n))+1;
z(i)=z(i)+[x(j)*y(k)];
end
end
subplot (3,1,1);
stem (x);
x label (‘n’);
y label (‘x(n)’);
title (‘sequence 1’);
disp(‘sequence 1 :’);x
subplot (3,1,2);
stem (y);
x label (‘n’);
ylabel (‘y(n)’);
title(‘sequence 2’);
disp(‘sequence 2 :’);y
subplot(3,1,3);
stem (z);
x label (‘n’);
y label (‘z(n)’);
title (‘output’);
disp(‘output :’);z
g.text(‘circular convolution’);
RESULT:
Thus program to perform linear and circular convolution in MATLAB has been verified and processed.
4.SAMPLING AND EFFECT OF ALIASING
AIM:
The sample sine wave and plot it on the screen and study the effect of aliasing using MATLAB.
APPARATUS REQUIRED:
PC with MATLAB.
ALGORITHM:
STEP1: Start the program.
STEP2: Design the value of the signal frequency of sine wave and the sampling frequency.
STEP3: Define the number of samples required and the time of simulation.
STEP4: Calculate the values of sine wave at each time using the appropriate formula.
STEP5: Plot the graph using the stem command.
STEP6: Increase the frequency of sine wave when fo > fs/2 so that aliasing takes place.
STEP7: End the program.
THEORY:
According to sampling theorem a band limited signal with highest frequency component of Wm must be sampled (i.e.) Ws=2Wm is not satisfied, and then the signal will be aliased to another signal of linear frequency this is known as aliasing.
PROCEDURE:
1. Click on MATLAB icon and open a new file.
2. Type the program & save the project.
3. Run the program by clicking on debug.
4. Note the output and plot the graph for the output.
PROGRAM:
%SAMPLING AND EFFECT OF ALIASING
clc;
clear all;
close all;
disp(‘aliasing’);
fc1=50;
fc2=10;
t=0:(1/10)e2:0.1;
x1=sin(2*pi*fc1*t);
x2= sin(2*pi*fc2*t);
subplot (2,3,1);
plot(x1);
line ([0,200],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title (‘sinusoidal signal f=50 hz’);
subplot (2,3,4);
plot (x2);
line([0,100],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title (‘sinusoidal signal f=50 hz’);
fs=40;
n=0:1:15;
x3=sin(2*pi*fc1*n/fs);
x4=sin(2*pi*fc2*n/fs);
subplot (2,3,2);
stem(x3);
line ([0,15],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title (‘sampled signal (alias fs=40hz)’);
subplot (2,3,5);
stem (x4);
line ([0,15],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title(‘sampled signal fs=40 hz’);
fs1=150
n=0:1:10
x5=sin (2*pi*fc1*n/fs1);
x6=sin(2*pi*fc2*n/fs1);
subplot (2,3,3);
stem (x5);
line([0,10],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title(‘sampled signal fs1=150hz’);
subplot(2,3,6);
stem (x6);
line ([0,10],[0,0]);
x label (‘time’);
y label (‘amplitude’);
title(‘sampled signal fs1=150hz’);
g text(‘sampling and aliasing’);
RESULT :
Thus a sine wave is sampled and the effects of aliasing are studied.
5. DESIGN OF FIR FILTERS
AIM:
To write a MATLAB program for FIR filter using different window techniques for the given order and sampling frequency.
APPARATUS REQUIRED:
PC with MATLAB
ALGORITHM:
STEP1: Clear the screen.
STEP2: Sampling frequency & cut off frequency are specified.
STEP3: FIR filter coefficient is determined by using FIR 1 command.
STEP4: Input to the FIR filter is given as a sequence square wave & the output is computed using filter
command.
STEP5: Frequency response of the filter with various windows functions calculated using frequency.
STEP6: From the frequency response various functions are studied.
THEORY:
FIR is the non-recursive filter that has the impulse response for finite number of n, n1 ≤ n≤ n2 with n1 and n2 being finite. This filter is also known as convolution filter b0 and is all non-zero system.
In general, the unit sample response is of finite duration and must be truncated at some point to yield FIR filter of finite length. This method is called as WINDOWING. Thus multiplying a window function in time domain results in the convolution of Fourier transform of window with that of unit sample response, which will be a sine function .In most of times, two criteria that has satisfied by the window functions are-
(i) The width of the main lobe should be small for the ripples to be small.(ii) The height of the side lobe should be small for the ripples to be small.
Thus we will study various windows based on the above criteria.
PROCEDURE:
1. Click on MATLAB icon and open a new file.
2. Type the program & save the project.
3. Run the program by clicking on debug.
4. Note the output and plot the graph for the output.
PROGRAM:
% KAISER WINDOW
clc;
clear all;
close all;
n=input (‘enter the order of the filter’); %order of the filter
wc=input (‘enter cut off frequency’); % cut off frequency
beta=input(‘enter the beta value’); % kaiser window parameter
w=kaiser(n+1,beta); %fir filter using Kaiser window fn
b=fir1(n,wc,w); % fir filter coefficient
[h,omega]=freqz(b,1,256); %frequency response
m=20*log(abs(h)); %magnitude response
ph=angle(h*(180/pi)); %phase response
subplot (2,2,1);
plot (b);
title (‘filter response’);
subplot (2,2,2);
plot (omega/pi,h);
title (‘frequency response’);
subplot (2,2,3);
plot(m);
title(‘magnitude response’);
subplot(2,2,4);
plot(ph);
title(‘phase response’);
%RECTANGULAR WINDOW
clc;
clear all;
close all;
n=input(‘enter the value’)
wc=input(‘enter the cut-off frequency’)
w=boxcar(n+1);
b=fir1(n,wc,w);
[h,omega]=freqz(b,1,256);
m=20*log(abs(h));
ph=angle(h*180/pi));
subplot(2,2,1);
plot(b);
title(‘filter response’);
subplot(2,2,2);
plot(omega/pi,h);
title(‘frequency response’);
subplot(2,2,3);
plot(m);
title(‘magnitude response’);
subplot(2,2,4);
plot(ph);
title(‘phase response’);
%BARLETT WINDOW
clc;
clear all;
close all;
n=input(‘enter the value’);
wc=input(‘enter cut off frequency’);
w=barlett(n+1);
b=fir1(n,wc,w);
[h,omega]=freqz(b,1,256);
m=20*log(abs(h));
ph=angle(h*(180/pi));
subplot(2,2,1);
plot(b);
title(‘h(n)’);
subplot(2,2,2);
plot(omega/pi,h);
title(‘frequency response’);
subplot(2,2,3);
plot(m);
title(‘magnitude response’);
subplot(2,2,4);
plot(ph);
title(‘phase response’);
%BLACKMAN WINDOW
clc;
clear all;
close all;
n=input(‘enter the value’);
wc=input(‘enter the cut off frequency’);
w=blackman(n+1);
b=fir1(n,wc,w);
[h,omega]=freqz(b,1,256);
m=20*log(abs(n));
ph=angle(h*(180/pi));
subplot(2,2,1);
plot(b);
title(‘h(n)’);
subplot(2,2,2);
plot(omega/pi,h);
title(‘frequency response’);
subplot(2,2,3);
plot(m);
title(‘magnitude response’);
subplot(2,2,4);
plot(ph);
title(‘phase response’);
RESULT:
Thus the FIR filter was designed using window technique using MATLAB program for the given order and cut –off frequency.
6. CALCULATION OF FFT OF A SIGNAL
AIM:
To perform fast Fourier transforms using DFT using MATLAB program.
APPARATUS REQUIRED:
PC with MATLAB
ALGORITHM:
STEP1: Get the input sequence.
STEP2: Plot them using subplots in the figure window.
STEP3: Find the result using FFT commands.
STEP4: Plot the sequences using subplot command.
STEP5: Stop the program.
THEORY:
The FFT is the faster version of the discrete Fourier transform (FFT).The FFT utilizes same algorithm to do the same thing as DFT, but in much less time. The DFT is extremely imp in the area of frequency analytic because it takes a discrete signal in time domain and transform that signal into it discrete frequency domain representation. Without the discrete time, to discrete time freq transform, we could not be able to compute FFT in DFT based system. It is the speed and discrete nature of the FFT that allows us to analyze the signal spectrum with MATLAB.
PROCEDURE:
1. Click on MATLAB icon and open a new file
2. Type the program and save the project
3. Run the program by clicking debug.
4. Note the output and plot the graph.
PROGRAM:
%N POINT FFT USING DFT:
clc;
clear all;
close all;
x=input(‘enter the sequence’);
N=length(x);
z= fft(x,n);
display(‘input’);x
display(‘output’);z
n=1:N;
subplot(3,2,1);
stem(n,x);
xlabel(‘sequence number’);
ylabel(‘amplitude’);
title(‘input sequence’);
subplot(3,2,2);
stem(n,abs(z));
xlabel(‘sequence number’);
ylabel(‘amplitude’);
title(‘output amplitude’);
subplot(3,2,3);
stem(b,real(z));
xlabel(‘sequence number’);
ylabel(‘real’);
title(‘output real part’);
subplot(3,2,4);
stem(n,imag(z));
xlabel(‘sequence number’);
ylabel(‘imaginary’);
title(‘output imaginary part’);
subplot(3,2,5);
stem(n,(z));
xlabel(‘sequence number’);
ylabel(‘phase’);
title(‘output phase’);
%N-POINT INVERSE FFT USING IDFT:
clc;
clear all;
close all;
x=input(‘enter the number’);
N=length(x);
z= ifft(x,n);
display(‘input’);x
display(‘output’);z
n=1:N;
subplot(2,2,1);
stem(n,x);
xlabel(‘sequence number’);
ylabel(‘amplitude’);
title(‘input sequence’);
subplot(2,2,2);
stem(n,z);
xlabel(‘sequence number’);
ylabel(‘amplitude’);
title(‘output sequence’);
subplot(2,2,3);
stem(n,floor(real(acos(z))));
xlabel(‘sequence number’);
ylabel(‘amp’);
title(‘output sequence’);
gtext(‘mnmjec’);
RESULT:
Thus the program to perform linear combination and circular convolution using FFT has been processed and verified successfully.
7. DESIGN OF IIR FILTERS
AIM:
To write MATLAB program for IIR filter for the given order and cut off frequency and stop band frequency.
APPARATUS REQUIRED:
PC with MATLAB
ALGORITHM:
STEP1: Get the required filter parameters.
STEP2: Calculate filter co-efficient.
STEP3: Butterworth filter can be designed using butter command
[b a]=butter (n, w0), n=order of filter and w0=normalized cut off frequency.
STEP4: Chebyshev filter can be designed using cheby1 and cheby2 command.
[b a]=cheby1(n,r,w0)
n=order of filter, r=pass band ripple and w0=normalized cut off frequency.
STEP5: plot the frequency, magnitude and phase response.
STEP6: End the program.
THEORY:
BUTTERWORTH FILTER:
Butterworth filter approximation concentrates on w=0 (i.e.) maximally flat response at origin.
Hn(w)=wn
|π(jw)|2 =1/(1+c2w2n)
As the order of filter is increased the sharpness of cut off increase. The attenuation in pass band is xp(w) =10log (1+c2).butter worth filter gives a fairly linear response. As order of chebyshev response becomes higher, phase response become non-linear.
CHEBYSHEV FILTER:
Concentrates over range 0<w<1 rather than w=0.the same characteristics of Butterworth filter can be achieved using a filter of lesser order. It has ripples in pass band and stop band.
Tn (w) =cos (n cos-1w), |w|<1 =cosh (ncosh-1w), |w|≥1
Tn+1(w)=2w Tn(w)-Tn-1(w)
PROCEDURE:
1. Click on MATLAB icon and open a new file.
2. Type the program and save the project.
3. Run the program by clicking on debug.
4. Note the output and plot the graph for the output.
PROGRAM:
%CHEBYSHEV 1 FILTER
clc;
close all;
clear all;
n=input(‘enter the order value’); %order of the filter
wc=input(‘enter the cut off frequency’); %cut off frequency
r=input(‘enter stop band ripple’); %stop band frequency
[b, a]=cheby1(n,r,wc,’s’); %chebyshev function
[h,omega]=freqz(b,a,256); %frequency response
m=20&log(abs(h)); %magnitude response
subplot(2,2,2);
plot(m);grid
title(‘magnitude response’);
subplot(2,2,1);
plot(omega/pi,h);grid
title(‘frequency response’);
ph=angle(h*(180/pi)); %phase response
subplot(2,2,3);
plot(ph);grid
title(‘phase response’);
gtext(‘chebychev1=IIR filter’);
%CHEBYSHEV 2 FILTER
clc;
close all;
n=input(‘enter the order value’); %order of the filter
wc=input(‘enter the cut off frequency’); %cut off frequency
r=input(‘enter passband ripple’); %pass band frequency
[b, a]=cheby2(n,r,wc,’s’); %chebyshev function
[h,omega]=freqz(b,a,256); %frequency response
m=20*log(abs(h)); %magnitude response
ph=angle(h*(180/pi)); %phase response
subplot(2,2,1); %plot response
plot(omega/pi,h);grid
title(‘frequency response’);
subplot(2,2,2);
plot(m);grid
title(‘magnitude response’);
subplot(2,2,3);
plot(ph);grid
title(‘phase response’);
%BUTTERWORTH FILTER
clc;
close all;
clear all; %clear the screen
n=input(‘enter the value’); %order of the filter
wc=input(‘enter the cut off frequency’); %cut off frequency
[b,a]=butter(n,wc); %butterworth function
[h.omega]=freqz(b,a,256); %frequency response
m=20*log((abs(h)); %magnitude response
ph=angle(h*(180/pi)) %phase response
subplot(2,2,1);
plot(omega/pi,h);grid %plot the response
title(‘frequency response’);
subplot(2,2,2);
plot(m);grid
title(‘magnitude response’);
subplot(2,2,3);
plot(ph);grid
title(‘phase response’);
gtext(‘BUTTERWORTH IIR FILTER’);
RESULT:
Thus the programs for IIR filter are designed successfully using MATLAB programs for the given order, cut off frequency and stop band frequency.
8.STUDY OF TMS320C50 PROCESSOR
ARCHITECTURE:
In a strict Harvard architecture, program and data memory are in two separate spaces, permitting a full overlap of instruction fetch end execution. The TMS320 family’s modification of the Harvard architecture allows transfer between program and data spaces, thereby increasing the flexibility of the device. The modification permits coefficients stored in program memory to be read into data RAM, eliminating the need for a separate coefficient ROM. It also makes available immediate instructions and subroutines based on computed values.
32- BIT ACCUMULATOR:
The TMS320C50 contains a 32 bit ALU and accumulator for support of double- precision, two’s complements arithmetic. The ALU is a general purpose arithmetic unit that operates on 16 bit words taken from the data RAM or derived from immediate instructions. The accumulator stores the output from the ALU and is often an input to the ALU. Its word length is 32- bit. The accumulator is divided into a high order word (bits 31 through 16) and a low order word (bits 15 through 0). Instructions are provided for storing and loading the high and low order accumulator words to memory.
16x16 BIT PARALLEL MULTIPLIER:
The multiplier performs a 16x16 bit two’s complement multiplication with a 32-bit result in a single instruction cycle .The multiplier consists of three units: theT-Register, P-Register, and multiplier array. Multiplier values either come from the data memory or are derived immediately from the MPY (multiply immediate) instruction word. The fast on-chip multiplier allows the device to perform fundamental operation such as convolution, correlation and filtering. Two multiply /accumulator instructions in the instruction set fully utilize the computational bandwidth of the multiplier, allowing both operands to be processed simultaneously.
SHIFTERS:
A 16-bit scaling shifter is available at the accumulator input. This shifter produces a left shift of 0 to 16 bits on the input data to accumulator .in addition one shifter at the output of P-register, can shift the product by 1or 4-bits left or 6-bits right, before transferring the product to accumulator.
DATA AND PROGRAM MEMORY:
Since the TMS320C50 use Harvard architecture, data and program memory reside in two separate spacers. Additionally TMS320C50 has one more memory space called I/O memory space. The total memory capacity of TMS320C50 is 64KW each of Program, Data and I/O memory. The 64KW of data memory is divided into 512 pages with each page containing 128 words. Only one page can be active at a time .TMS320C50 has 1056 words of dual access on chip data memory is divided as three blocks B0, B1,& B2 of which B0 can be configured as program or data RAM.
INTERRUPTS AND SUBROUNTINE:
The TMS320C50 has three external makeable user interrupts available for external devices that interrupt the processor .the TMS320C50 contains an eight-level hardware stack for saving the contents of the program counter during interrupts and subroutine calls.
SERIAL PORT:
A full-duplex on-chip serial port provides direct communication with serial devices such as codec’s, serial A/D converters and other serial systems. The interface signals are compatible with codec’s and many others serial devices with a minimum of external hardware.
INPUT AND OUTPUT:
The 16-bit parallel data bus can be utilized to perform I/O functions in two cycles. The I/O ports are addressed by four LSBs on the address lines, allowing 16 input and 16 output ports. In addition, a polling input for bit test and jump operation (BIO) and three interrupt pins (INT0-INT2) have been incorporated for multitasking.
EXAMPLES OF ARITHMETIC OPERATIONS USING TMS320C50
PROGRAM:
ADDITION:
.MMREGS
.TEXT
START: LDP #1004
LACC #1111H
ADD #2222H
SACL 0H
HLT: B HLT
SUBTRACTION:
.MMREGS
.TEXT
START: LDP #100H
LACC #2222H
SUB #1111H
SACL 0H
HLT: B HLT
MULTIPLICATION:
.MMREGS
.TEXT
START: LDP #100H
LACC #037AH,0
SACL 0000,0
LACC # 012EH,0
SACL 0001,0
LT 0000
MPY 0001
PAC
SACL 0002,0
SACH 0003,0
HLT: B HLT
RESULT:
Thus the architecture of TMS320C50 was studied with the simple programming examples
9. STUDY OF VARIOUS ADDRESSING MODES OF DSP USING SIMPLE PROGRAMMING EXAMPLES
AIM:
To study the various addressing modes of DSP processor using simple programming examples.
APPARATUS REQUIRED:
1. TMS320C5X
2. PC
3. RS232 CABLE
TYPES OF ADDRESSING MODES:
1. Direct addressing
2. Memory map register addressing
3. Indirect addressing
4. Immediate addressing
5. Dedicated register addressing
6. Circular addressing
PROCEDURE:
1. Click on C50 debugger icon and start a new project.
2. Type the program and save it as an assembly file.
3. Program is executed by giving G0C000 in communication window.
4. The output is obtained.
5. Values are obtained by giving various input values.
PROGRAM:
IMMEDIATE ADDRESSING MODE:
.MMREGS
ENTRY
.LACC #1000H
.LACC #1111H,3
LAR AR0,#1000H
LAR AR1,#1100H
ADD #00FFH
ADD #0011H,2
SPLK #10H,0
MPY #0010H
SUB #0022H
SUB #0011H,3
.END
DIRECT ADDRESSING MODE:
.MMREGS
.ENTRY
LDP #20H
LACC 10H
LACC 5H,2
LDP #22H
LAR AR0,15H
SACL 15H
SACL 20H,3
SAMM AR7
LDP # 12H
ADD 25H
ADD 7H,2
SUB 10H
SUB 12H,2
SPLK #10H,0
MPY 15H
.END
INDIRECT ADDRESSING MODE:
.MMREGS
.PS0A00H
.ENTRY
LAR AR0,#1000H
LACC*
LACC*,4,AR1
LAR AR1,#1010H
SACL*,
SACL*+,2,AR0
LACC*-,2,AR1
LACC*0+
LACC*BR0+
ADD*+,0,AR0
SUB*-,2
SPLK #10H,0
MPY*
.END
CIRCULAR ADDRESSING MODE:
.MMREGS
.PS0A00H
.ENTRY
SPLK #1000H,0
SPLK #1003H,1
SPLK #08H,2
LACC*+
LACC*+
LACC*+
LACC*+
.END
RESULT:
Thus the various addressing modes of DSP processor using simple programming examples are studied and verified.
10. SAMPLING OF INPUT SIGNAL AND DISPLAY
AIM:
To write a program to sample and display an analog signal using TMS320C50 KIT.
APPARATUS REQUIRED:
1. TMS320C5X
2. PC
3. RS232 CABLE
PROCEDURE:
1. Click on C50 debugger icon and start a new project.
2. Type the program and save it as an assembly file.
3. The input signal is given to the DSP kit.
4. Program is executed by giving G0C000 in communication window.
5. The sampled output can be viewed in CRO.
PROGRAM:
DATA .SET 2H
DELAY .SET3H
.MMREGS
.TEXT
START: LDP#100H
LAR AR0,#9000H
LAR AR1,#719H
REP: IN 0,06
RPT #OFH
NOP
IN 0,04
SPLK #00FFH,DELAY
RPT DELAY
NOP
LACC 0
AND #0FFFH
MAR*,AR0
SACL*+,0,AR1
BANZ REP,*-
CONT1: LAR AR0,#9000H
LAR AR1,#719H
LOOP:MAR*,AR0
RPT #1FFH
NOP
OUT*+,04,AR1
BANZ LOOP,*-
B CONT1
RESULT:
Thus the input signal was sampled and displayed.
11.IMPLEMENTATION OF FIR FILTER
AIM:
To implement a low pass FIR filter using rectangular window using TMS320C50.
APPARATUS REQUIRED:
1. TMS320C5X
2. PC
3. RS232 CABLE
PROCEDURE:
1. Click on C50 debugger icon and start a new project.
2. Type the program and save it as an assembly file.
3. Program is executed by giving G0C000 in communication window.
4. The output is obtained
5. Values are obtained by giving various input values.
PROGRAM:
.MMREGS
.TEXT
B START
CTABLE:
.WORD 0FFF4H
.WORD 0FFE3H
.WORD 0FFCFH
. WORD 0FEBBH
. WORD 0FFA7H
. WORD 0FF97H
.WORD 0FF8EH
. WORD 0FF8FH
. WORD 0FF9BH
. WORD 0FFB7H
. WORD 0FFE3H
. WORD 022H
. WORD 075H
. WORD 0DCH
. WORD 0157H
. WORD 01E5H
. WORD 0283H
. WORD 032FH
. WORD 03E5H
. WORD 04A0H
. WORD 055CH
. WORD 0614H
. WORD 06C2H
.WORD 0761H
. WORD 076BH
.WORD 085BH
.WORD 085BH
. WORD 07EBH
. WORD 07E1H
. WORD 06C2H
. WORD 0614H
. WORD 055CH
. WORD 04A0H
. WORD 03E5H
. WORD 032FH
. WORD 0283H
. WORD 01E5H
. WORD 0157H
. WORD 0DCH
. WORD 075H
. WORD 022H
. WORD 0FFE3H
. WORD 0FFB7H
. WORD 0FF9BH
. WORD 0FF8FH
. WORD 0FF8EH
. WORD 0FF97H
. WORD 0FFA7H
. WORD 0FFBBH
. WORD 0FFCFH
. WORD 0FFE3H
. WORD 0FFF4H
START: MAR*,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05
IN 0,06H
LAR AR7,#0
MAR*,AR7
BACK:
BANZ BACK,*-
IN 0,4
NOP
NOP
NOP
NOP
MAR*,AR1
LAR AR1,#0300H
LACC0
AND #0FFFH
SUB #800H
SACL*
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH*
LACC*
ADD #800H
SFR
SACL*
OUT*,4
LACC #0FFH
SACL 0
OUT0,05
NOP
B ISR
HLT: B HLT
RESULT :
Thus the FIR filter was designed using TMS320C50 DSP Kit.
12. CALCULATION OF FFT
AIM:
To perform DIT fast Fourier transform for 4 point sequence using TMS320C50 processor.
APPARATUS REQUIRED:
1. TMS320C50
2. PC
3. RS232 CABLE
ALGORITHM:
STEP1: processor initialization.
STEP2: Get the 4 input samples from data memory.
STEP3: Apply bit reversal to these samples.
STEP4: multiply the bit –reversed samples with twiddle factors.
STEP5: Store the real part of output and imaginary part of output.
STEP6: End of program.
PROCEDURE:
11. Click on C50 debugger icon and start a new project.
2. Type the program and save it as an assembly file.
3. Program is executed by giving G0C000 in communication window.
4. The output is obtained and verified.
5. Build the program and load it into the processor.
6. The inputs can be given by SD command in communication window.
7. Values are obtained by giving various input values.
PROGRAM:
IN.SET 8010H
BITREV .SET 8020H
REA L.SET 8040H
IMG: SET 8050H
.MMREGS
.TEXT
START: LDP # 100H
LAR AR1 ,#IN
LAR AR2,#BITREV
SPLR #2H,05H
LMMR INDX,#8005H
MAR*,AR2
RPT #3H
BLDD #IN,*BR0+
LAR AR2 ,#BITREV
LAR AR3 ,#8030H
LAR AR0 ,#1H
FFT1: MAR*,AR2
LACC*+
SACB
LT*+
MPY #1H
APAC
MAR*,AR3
SACL*+
LACB
SPAC
SACL*+,AR0
BANZ FFT1,*-
LAR AR3,#8030H
LAR AR4,#REAL
LAR AR5,#IMG
MAR*,AR3
LACC*
SACB
ADRK#2H
LT*-
MPY #1H
APAC
MAR*,AR4
SACL*
ADRK #2H
LACC #0H
MAR*,AR5
SACL*
ADRK #2H
LACB
SPAC
MAR*,AR4
SACL*-
LACC #0H
MAR*,AR5
SACL*-,AR3
LACL*,AR4
SACL*,AR3
ADRK #2H
LT*
MPY #0FFFFH
MAR*,AR5
SPL8,AR3
LT*
MPY #1H
MAR*,AR5
ADRK #2H
SPL*
HLT: B HLT
INPUTS: OUTPUTS:
(BIT REVERSED OUTPUT)
8010 :0000 8020 :0000
8010 :0000 8020 :0002
8010 :0000 8020 :0001
8010 :0000 8020 :0003
(REAL PART) (IMAGINARY PART)
8040 :0006 8050 :0000
8041 :FFFE 8051 :0002
8042 :FFFE 8052 :0000
8043 :FFFE 8053 :FFFE
RESULT:
Thus the FFT of the inputs were performed successfully using DSP processor.