DSP Lab Manual 2020
DSP Lab Manual 2020
(Regulation 2017)
LAB MANUAL
Date : 12.08.2020
Prepared by Approved by
1
V.R.S COLLEGE OF ENGINEERING AND TECHNOLOGY
(Accredited by & NAAC and An ISO 9001: 2008 Recertified Institution)
OUTCOMES:
At the end of the course, the student should be able to:
Carryout basic signal processing operations
Demonstrate their abilities towards MATLAB based implementation of various DSP systems
Analyze the architecture of a DSP Processor
Design and Implement the FIR and IIR Filters in DSP Processor for performing filtering operation over
real-time signals
Design a DSP system for various applications of DSP
TOTAL= 60 PERIODS
2
List of Experiments
14. To find the Linear convolution of two sequences using DSP processor 111
3
MATLAB EXPERIMENTS
4
INTRODUCTION
5
6
Ex. No: 1 Generation of elementary Discrete-Time sequences
AIM:
To generate basic sequences such as Unit impulse, Unit step, Ramp, Exponential, Sine
sequence & Cosine Sequence using MATLAB Programs.
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
THEORY:
The Unit Step Sequence is designed as unit step means that the amplitude of U(t) = 1
U(n) = 1 ; n 0
=0;n<0
ii. Ramp Sequence:
g(n) = an ;n0
0 ;n<0
7
When the values of a > 1 the sequence grows exponentially and when the value is 0 < a < 1
the sequence decay’s exponentially. Note also that a < 0 the discrete time exponential signal takes
attenuating signal.
we can write Acos (on + ) = A/2 ej ejon + A/2 e-j e –jon .Since ejon2 = 1st the energy
signal is infinite and the average power of the signal is 1
v. Sinusoidal signal:
x(t) = A sin ( rt + )
Where ‘A’ is amplitude & r is the frequency in rad/sec and are the phase angle radians. The
analog sinusoidal signal has the following properties
i) The signal is periodic satisfy the condition
x(t+T) = x(t)
ii) For different value of frequencies the continuous time sinusoidal signals are themselves
different.
PROCEDURE:
8
PROGRAM:
Discrete Time Signals:
%Unit step sequence:
n=input ('Enter the n value');
t=0:1: n-1;
y=ones (1,n);
subplot (2,2,1);
stem (t,y);
xlabel ('n-->');
ylabel ('Amplitude');
title ('Unit step signal');
%Generation of sine sequence:
n=0:0.01:pi;
y=sin (2*pi*n);
subplot (2,2,2)
stem (n,y);
xlabel ('n->');
ylabel ('Amplitude');
title ('Sine sequence');
%Generation of cosine sequence:
n=0:0.01: pi;
y=cos (2*pi*n);
subplot (2,2,3);
stem (n,y);
xlabel ('x(n)');
ylabel ('Amplitude');
title ('Cosine sequence');
%Exponential sequence:
n=input ('Enter the length');
t=0: n;
a=input ('Enter the a value');
y=exp (a*t);
subplot (2,2,4);
stem (t,y);
xlabel ('Time');
ylabel('Amplitude');
title('Exponential sequence');
%Ramp signal:
clc;
l=input('Enter the length of the sequence');
n=0:l;
r=n;
stem(n,r);
disp(r);
title('Ramp sequence');
xlabel('Time');
ylabel('Amplitude');
9
%Impulse signal:
n=input ('Enter the n value');
t=0:1: n-1;
y= (1, zeros(1,n-1));
subplot (2,2,5);
stem (t,y);
xlabel ('n-->');
ylabel ('Amplitude');
title ('Impulse signal');
Continuous Time Signals:
10
OUTPUT:
Amplitude
0.5
0
0 1 2 3 4
n-->
Cosine sequence
1
0.5
Amplitude
-0.5
-1
0 1 2 3 4
x(n)
Sine sequence
1
0.5
Amplitude
-0.5
-1
0 1 2 3 4
n->
11
OUTPUT:
Enter the length 5
Enter the a value 5
Exponential sequence
6
Amplitude
0
0 2 4 6
time
OUTPUT:
Enter the length of the sequence 6
ramp sequence
6
4
amplitude
0
0 1 2 3 4 5 6
time
RESULT:
Thus the basic sequences of Unit impulse, Unit step, Ramp, Exponential and Sine Sequence &
Cosine Sequence are generated using MATLAB Programs.
12
Ex. No: 2a
LINEAR CONVOLUTION OF TWO SEQUENCES
AIM:
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
THEORY:
The linear convolution of two sequence x(n) of L no of samples and h(n) of M no of
samples produce a result y(n) which contains N= L + M – 1 . If is a sequence which is periodic with
N samples. Linear convolution can be used to find the response of a filter.
PROCEDURE:
13
PROGRAM:
%Linear convolution:
clc;
x=input ('Enter the input sequence');
n1=length(x);
subplot (2,2,1);
Stem(x);
title ( ' Input sequence');
xlabel ('n->');
ylabel ('Amplitude');
h=input ('Enter the impulse sequence');
n2=length (h);
subplot (2,2,2);
stem (h);
title (' Impulse sequence');
xlabel ('n->');
ylabel ('Amplitude');
y=conv(x, h);
n=1:n1+n2-1;
subplot (2,2,3);
stem (n,y);
Disp(y);
title ('Convoluted sequence');
xlabel ('n->');
ylabel ('Amplitude');
14
OUTPUT:
Output is 20 31 34 50 32 19 10
4 4
amplitude
amplitude
2 2
0 0
1 2 3 4 1 2 3 4
n-> n->
convoluted sequence
60
40
amplitude
20
0
0 2 4 6 8
n->
RESULT:
Thus the linear convolution program using MATLAB on the given sequence was performed
and verified.
15
16
Ex. No: 2b
AIM:
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
THEORY:
In the case of circular convolution if x(n) contains L no of samples and h(n) has N no of samples
and that L > M, then we perform circular convolution between the two using N = Max ( L, M) by
adding L, M no of zero samples to the sequence h(n) . So that both sequence are periodic with N.
Circular cannot be used to find the response of a linear filter without zero padding.
PROCEDURE:
17
PROGRAM:
%Circular convolution
clc;
X1=input ('Enter the first sample');
X2=input ('Enter the second sample');
l1=length(x1);
l2=length(x2);
x1s=fft(x1);
Disp (x1s);
x2s=fft(x2);
Disp (x2s);
x3s=x1s.*x2s;
y=ifft (x3s);
Disp(y);
Subplot (3, 1, 1);
n=0:1:l1-1;
Stem (n, x1);
Title ('First input sample');
Xlabel ('Time');
Ylabel ('Amplitude');
Subplot (3, 1, 2);
n=0:1:l2-1;
Stem (n, x2);
Title (Second input sample');
Xlabel ('Time');
Ylabel ('Amplitude');
Subplot (3, 1, 3);
Stem (n, y);
Title ('Circular convolution');
Xlabel ('Time');
Ylabel ('Amplitude');
18
OUTPUT:
0
0 0.5 1 1.5 2 2.5 3
time
second input sample
10
amplitude
0
0 0.5 1 1.5 2 2.5 3
time
circular convolution
100
amplitude
50
0
0 0.5 1 1.5 2 2.5 3
time
RESULT:
Thus the Circular convolution program using MATLAB on the given sequence is performed
and verified.
19
20
Ex.No:3 a AUTO CORRELATION
AIM:
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
THEORY:
Auto-correlation is the comparison of a time series with itself at a different time. It aims, for
example, to detect repeating patterns or seasonality. For example: “Is there weekly seasonality on a
server website?” “Does the current week’s data highly correlate with that of the previous week?”
PROCEDURE:
21
PROGRAM:
%Auto correlation
clc;
clear all; close all;
x=input ('Enter the t sequence');
y=xcorr(x,x);
subplot(2,1,1);
stem(x);
xlabel('x');
ylabel('Amplitude');
title('x sequence');
subplot(2,1,2);
stem(y);
xlabel('y');
ylabel('Amplitude');
title(' y sequence');
disp('The resultant signal is');
RESULT:
22
Ex.No:3 b CROSS CORRELATION
AIM:
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
THEORY:
Cross-correlation is the comparison of two different time series to detect if there is a
correlation between metrics with the same maximum and minimum values. For example: “Are two
audio signals in phase?”
PROCEDURE:
23
PROGRAM:
% Cross correlation
clc;
clear all; close all;
x=input ('Enter the first sequence');
h=input('Enter the second sequence');
y=xcorr(x,h);
subplot(3,1,1);
stem(x);
xlabel('x');
ylabel('Amplitude');
title('x sequence');
subplot(3,1,2);
stem(h);
xlabel('h');
ylabel('Amplitude');
title('h sequence');
subplot(3,1,3);
stem(y);
xlabel('y');
ylabel('amplitude');
title(' y sequence');
24
OUTPUT(Cross Correlation):
RESULT:
25
26
Ex. No: 4
SPECTRUM ANALYSIS USING DFT
AIM:
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
THEORY:
DFT is used for analyzing discrete-time finite-duration signals in the frequency domain
1 N 1
X [k ]
N
x ( n) W
n 0
kn
N , 0 k N 1
1 N 1
X [k ]
N
x ( n) W
n 0
kn
N , 0 k N 1
27
PROGRAM:
N=input('type length of DFT= ');
T=input('type sampling period= ');
freq=input('type the sinusoidal freq= ');
k=0:N-1;
f=sin(2*pi*freq*1/T*k);
F=fft(f);
stem(k,abs(F));
grid on;
xlabel('k');
ylabel('X(k)');
INPUT:
type length of DFT=32
type sampling period=64
type the sinusoidal freq=11
OUTPUT:
Result:
Thus the Spectrum Analysis of the signal using DFT is obtained using MATLAB.
28
Ex.No: 5 a. DESIGN OF FIR FILTER USING RECTANGULAR WINDOW
AIM:
To design the FIR low pass, High pass, Band pass and Band stop filters using rectangular
window and find out the response of the filter by using MATLAB.
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
1. Start the program.
2. Get pass band ripple and stop band ripple.
3. Get Pass band and stop band frequency.
4. Get sampling frequency.
5. Calculate the order of the filter.
6. Find the window Coefficient.
7. Plot the magnitude and phase response.
THEORY:
The rectangular window (sometimes known as the boxcar or Dirichlet window) is the
simplest window, equivalent to replacing all but N values of a data sequence by zeros, making it
appear as though the waveform suddenly turns on and off:
W(n)= 1.
Other windows are designed to moderate these sudden changes because discontinuities have
undesirable effects on the discrete-time Fourier transform (DTFT) and/or the algorithms that produce
samples of the DTFT.
The rectangular window is the 1st order B-spline window as well as the 0th power cosine
window.
PROCEDURE:
29
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,'low',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
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);
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
b=fir1(n,wp,'band',y);
[h,o]=freqz(b,1,256);
subplot(2,2,3);
plot(o/pi,m);
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
30
%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);
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')
OUTPUT:
Pass band ripple=0.03
Stop band ripple=0.04
Stop band frequency in rad/sec=1200
Pass band frequency in rad/sec=600
Sampling frequency in rad/sec=4000
RESULT:
Thus the program to design FIR low pass, high pass, band pass and band stop Filters
using Rectangular Window was written and response of the filter using MATLAB was executed.
31
32
Ex.No: 5 b. DESIGN OF FIR FILTER USING HAMMING WINDOW
AIM:
To design the FIR low pass, High pass, Band pass and Band stop filters using Hamming
window and find out the response of the filter by using MATLAB.
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
1. Start the program.
2. Get pass band ripple and stop band ripple.
3. Get Pass band and stop band frequency.
4. Get sampling frequency.
5. Calculate the order of the filter.
6. Find the window Coefficient.
7. Plot the magnitude and phase response.
THEORY:
HAMMING WINDOW:
The filters response can be obtained by
WH (n) = 0.54+0.46cos2n/N-1 ; –(N-1)/2 n N -1/2
=0 ; 0
The frequency response is
WH (ejw) = 0.54sinwn/2/sinw/2+0.23sin (wn/2-n/n-1)/sin (w/2-/n-1) +0.23sin (wn/2+n/n-1)/sin
(w/2-/n-1)
PROCEDURE:
33
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,'low',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m);
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);
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')
%BAND PASS FILTER
wn=[wp,ws];
b=fir1(n,wp,'band',y);
[h,o]=freqz(b,1,256);
subplot(2,2,3);
plot(o/pi,m);
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND PASS FILTER')
34
%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);
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('BAND STOP FILTER')
OUTPUT:
Pass band ripple =0.03
Stop band ripple =0.04
Stop band frequency in rad/sec =1200
Pass band frequency in rad/sec =600
Sampling frequency in rad/sec =4000
RESULT:
Thus the design of FIR low pass, high pass, bands pass and band stop filters using Hamming
Window was executed using MATLAB.
35
36
Ex. No: 6 a. IIR FILTER USING BUTTERWORTH FILTER APPROXIMATION
AIM:
To design the IIR low pass, High pass, Band pass and Band stop filters using Butterworth
approximation and find out the response of the filter by using MATLAB.
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
THEORY:
Butterworth Filter:
The magnitude response of butter worth filter decreases maintain as the frequency increases 0
to .
The filter transition band is more in butter worth filter.
The poles on the butter worth filter are lie on a circle.
For the same specification the no. of files create disadvantage.
PROCEDURE:
37
PROGRAM:
clear all;
clc;
close all;
format long
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp=input('enter the pass band frequency ');
ws=input('enter the stop band frequency ');
[n1,w1]=buttord(wp,ws,rp,rs);
[num,den]=butter(n1,w1);
[num1,den1]=butter(n,w1,'stop');
[g,w]=freqz(num,den);
[g1,w1]=freqz(num1,den1);
m=20*log10(abs(g));
m1=20*log10(abs(g1));
title('Gain response of Butterworth filter');
Subplot(2,1,1);
Plot(w/pi,m);
Ylabel('gain in db?>');
Xlabel('omega/pi');
title('Bandpass filter');
Subplot(2,1,2);
Plot(w/pi,m1);
Ylabel('gain in db?>');
Xlabel('omega/pi');
title('Bandreject filter');
38
OUTPUT:
enter the pass band ripple 10
enter the stop band ripple 30
enter the pass band frequency [0.2 0.8]
enter the stop band frequency [0.4 0.7]
RESULT:
Thus the design of IIR band pass and band stop filters using Butterworth method was
executed using MATLAB.
39
40
Ex. No: 6 b. IIR FILTER USING CHEBYSHEV FILTER APPROXIMATION
AIM:
To design the IIR Band pass and Band stop filters using Chebyshev approximation and find
out the response of the filter by using MATLAB.
APPARATUS REQUIRED:
Personal Computer
MATLAB Software
ALGORITHM:
1. Start the program.
2. Get pass band ripple and stop band ripple.
3. Get Pass band and stop band frequency.
4. Calculate the order of the filter.
5. Plot the band pass and band stop filter.
THEORY:
Chebyshev Filter:
The magnitude response of the chebyshev filter exhibits ripple in the pass band or stop band
according to the type.
The transition band is less as compare to butter worth filter.
The poles on a chebyshev filter are lie on ellipse.
The order of chebyshev filter is less than that of butter worth.
PROCEDURE:
Start the MATLAB software and create new M-file.
Type the program in the file.
Save & compile the program.
Give the input data.
Observe the output waveform.
Thus the graph is to be plotted.
41
PROGRAM:
clear all;
clc;
close all;
format long
rp=input('enter the pass band ripple');
rs=input('enter the stop band ripple');
wp=input('enter the pass band frequency ');
ws=input('enter the stop band frequency ');
[n1,w1]=cheb1ord(wp,ws,rp,rs);
[num,den]=cheby1(n1,rp,w1);
[num1,den1]=cheby1(n1,rs,w1,'stop');
[g,w]=freqz(num,den);
[g1,w1]=freqz(num1,den1);
m=20*log10(abs(g));
m1=20*log10(abs(g1));
title('Gain response of chebyshev filter');
Subplot(2,1,1);
plot(w/pi,m);
Ylabel('gain in db?>');
Xlabel('omega/pi');
title('Bandpass filter');
Subplot(2,1,2);
plot(w/pi,m1);
Ylabel('gain in db?>');
Xlabel('omega/pi');
title('Bandreject filter');
42
OUTPUT:
enter the pass band ripple 1
enter the stop band ripple 2
enter the pass band frequency [0.3 0.8]
enter the stop band frequency [0.2 0.9]
RESULT:
Thus the MATLAB program for IIR filter using Chebyshev approximation for the sequence
was performed.
43
44
DSP PROCESSOR
BASED
IMPLEMENTATION
45
46
Ex. No: 7 STUDY OF ARCHITECTURE OF DIGITAL SIGNAL PROCESSOR
AIM:
To study the various architecture of digital signal processor TMS320C50 Kit.
Introduction:
The hardware experiments in the DSP lab are carried out on the Texas Instruments
TMS320C6713 DSP Starter Kit (DSK), based on the TMS320C6713 floating point DSP running at
225 MHz The basic clock cycle instruction time is 1/(225 MHz)= 4.44 nanoseconds. During each
clock cycle, up to eight instructions can be carried out in parallel, achieving up to 8×225 = 1800
million instructions per second (MIPS).
The DSK board includes a 16MB SDRAM memory and a 512KB Flash ROM. It has an on-
board 16-bit audio stereo codec (the Texas Instruments AIC23B) that serves both as an A/D and a
D/A converter. There are four 3.5 mm audio jacks for microphone and stereo line input, and speaker
and head-phone outputs. The AIC23 codec can be programmed to sample audio inputs at the
following sampling rates: fs = 8, 16, 24, 32, 44.1, 48, 96 kHz
The ADC part of the codec is implemented as a multi-bit third-order noise-shaping delta-
sigma converter that allows a variety of oversampling ratios that can realize the above choices of fs.
The corresponding oversampling decimation filters act as anti-aliasing pre-filters that limit the
spectrum of the input analog signals effectively to the Nyquist interval [−fs/2, fs/2]. The DAC part is
similarly implemented as a multi-bit second-order noise-shaping delta-sigma converter whose
oversampling interpolation filters act as almost ideal reconstruction filters with the Nyquist interval as
their pass band.
The DSK also has four user-programmable DIP switches and four LEDs that can be used to
control and monitor programs running on the DSP. All features of the DSK are managed by the Code
Composer Studio (CCS). The CCS is a complete integrated development environment (IDE) that
includes an optimizing C/C++ compiler, assembler, linker, debugger, and program loader.
The CCS communicates with the DSK via a USB connection to a PC. In addition to
facilitating all programming aspects of the C6713 DSP, the CCS can also read signals stored On the
47
DSP memory, or the SDRAM, and plot them the following block diagram depicts the overall
operations involved in all of the hardware experiments in the DSP lab. Processing is interrupt-driven
at the sampling rate fs, as explained below.
Architecture
The ‟54x DSPs use an advanced, modified Harvard architecture that maximizes processing
power by maintaining one program memory bus and three data memory buses. These processors also
provide an arithmetic logic unit (ALU) that has a high degree of parallelism, application-specific
hardware logic, on-chip memory, and additional on-chip peripherals.
These DSP families also provide a highly specialized instruction set, which is the basis of the
operational flexibility and speed of these DSPs. Separate program and data spaces allow simultaneous
access to program instructions and data, providing the high degree of parallelism. Two reads and one
write operation can be performed in a single cycle.
Instructions with parallel store and application-specific instructions can fully utilize this
architecture. In addition, data can be transferred between data and program spaces. Such parallelism
supports a powerful set of arithmetic, logic, and bit-manipulation operations that can all be performed
in a single machine cycle. Also included are the control mechanisms to manage interrupts, repeated
operations, and function calls.
48
1.Central Processing Unit (CPU)
The CPU of the ‟54x devices contains:
A 40-bit arithmetic logic unit (ALU)
Two 40-bit accumulators
A barrel shifter
A 17-bit multiplier/adder
A compare, select, and store unit (CSSU)
49
2 Arithmetic Logic Unit (ALU)
The ‟54x devices perform 2s-complement arithmetic using a 40-bit ALU and two 40-bit
accumulators (ACCA and ACCB). The ALU also can perform Boolean operations. The ALU can
function as two 16-bit ALUs and perform two 16-bit operations simultaneously when the C16 bit in
status register 1 (ST1) is set.
3 Accumulators
The accumulators, ACCA and ACCB, store the output from the ALU or the multiplier / adder block;
the accumulators can also provide a second input to the ALU or the multiplier / adder. The bits in
each accumulator are grouped as follows:
Guard bits (bits 32–39)
A high-order word (bits 16–31)
A low-order word (bits 0–15)
Instructions are provided for storing the guard bits, the high-order and the low-order accumulator
words in data memory, and for manipulating 32-bit accumulator words in or out of data memory.
Also, any of the accumulators can be used as temporary storage for the other.
4 Barrel Shifter
The ‟54x‟s barrel shifter has a 40-bit input connected to the accumulator or data memory
(CB, DB) and a 40-bit output connected to the ALU or data memory (EB). The barrel shifter
produces a left shift of 0 to 31 bits and a right shift of 0 to 16 bits on the input data. The shift
requirements are defined in the shift-count field (ASM) of ST1 or defined in the temporary register
(TREG), which is designated as a shift-count register.
This shifter and the exponent detector normalize the values in an accumulator in a single
cycle. The least significant bits (LSBs) of the output are filled with 0s and the most significant bits
(MSBs) can be either zero-filled or sign-extended, depending on the state of the sign-extended mode
bit (SXM) of ST1. Additional shift capabilities enable the processor to perform numerical scaling, bit
extraction, extended arithmetic, and overflow prevention operations
5 Multiplier/Adder
-bit 2s-complement multiplication with a 40-bit
accumulation in a single instruction cycle. The multiplier / adder block consists of several elements: a
multiplier, adder, signed/unsigned input control, fractional control, a zero detector, a rounder (2s-
complement), overflow/saturation logic, and TREG. The multiplier has two inputs: one input is
50
selected from the TREG, a data-memory operand, or an accumulator; the other is selected from the
program memory, the data memory, an accumulator, or an immediate value.
The fast on-chip multiplier allows the ‟54x to perform operations such as convolution,
correlation, and filtering efficiently. In addition, the multiplier and ALU together execute
multiply/accumulate (MAC) computations and ALU operations in parallel in a single instruction
cycle. This function is used in determining the Euclid distance, and in implementing symmetrical and
least mean square (LMS) filters, which are required for complex DSP algorithms.
7 Program Control
Program control is provided by several hardware and software mechanisms: The program
controller decodes instructions, manages the pipeline, stores the status of operations, and decodes
conditional operations. Some of the hardware elements included in the program controller are the
program counter, the status and control register, the stack, and the address-generation logic. Some of
the software mechanisms used for program control include branches, calls, conditional instructions, a
repeat instruction, reset, and interrupts.
The ‟54x supports both the use of hardware and software interrupts for program control.
Interrupt service routines are vectored through a reloadable interrupt vector table. Interrupts can be
globally enabled/disabled and can be individually masked through the interrupt mask register (IMR).
Pending interrupts are indicated in the interrupt flag register (IFR). For detailed information on the
structure of the interrupt vector table, the IMR and the IFR, see the device-specific data sheets.
51
9 Auxiliary Registers (AR0–AR7)
The eight 16-bit auxiliary registers (AR0–AR7) can be accessed by the central arithmetic
logic unit (CALU) and modified by the auxiliary register arithmetic units (ARAUs). The primary
function of the auxiliary registers is generating 16-bit addresses for data space. However, these
registers also can act as general-purpose registers or counters.
52
when operating in the repeat mode. The 16-bit block-repeat end address (REA) contains the ending
address if the block of program memory is to be repeated when operating in the repeat mode.
17 Power-Down Modes
There are three power-down modes, activated by the IDLE1, IDLE2, and IDLE3 instructions.
In these modes, the ‟54x devices enter a dormant state and dissipate considerably less power than in
normal operation. The IDLE1 instruction is used to shut down the CPU.
The IDLE2 instruction is used to shut down the CPU and on-chip peripherals. The IDLE3
instruction is used to shut down the ‟54x processor completely. This instruction stops the PLL
circuitry as well as the CPU and peripherals.
RESULT:
Thus, the architecture of DSP processor TMS320C50 was studied.
53
54
Ex. No: 8
AIM:
To write an assembly language program for MAC operation using various addressing modes
of Processor.
TOOLS REQURIED:
DSP hardware.
TMS320C5X-starter kit.
RS232 cable.
PROCEDURE:
Start the Process.
In the C50 debugger software.
Project-> New project Save project (.dbj)
File New file
Type the program Save file (.asm)
Project add file to project (asm file)
Project add file to project (micro 50)
Project build
Serial Port settings Auto detect
Serial Load program filename.asc
SerialCommunication window
Reset kit.
SD input addressender
Give the input data
Reset kit
Go C000 enter
Reset kit
SD output address enter
Stop the Process.
55
PROGRAM:
ADDITION:
.MMREGS
.TEXT
START:
LDP #100H
LACC 00H
ADD 01h
SACL 02h
H: B H
.END
INPUT:
1000H 0004
1001H 0004
OUTPUT:
1002H 0008
SUBTRACTION:
.MMREGS
.TEXT
START:
LDP #100H
LACC 00H
SUB 01h
SACL 02h
H: B H
.END
INPUT:
1000H 0002
1001H 0004
OUTPUT:
1002H 0002
RESULT
Thus, the various addressing mode of DSP processor TMS320C50 was studied.
56
Ex. No: 9 GENERATION OF VARIOUS SIGNALS AND RANDOM NOISE
AIM:
To generate the triangle and square waveform using TMS320C50 processor.
TOOLS REQURIED:
DSP hardware.
TMS320C5X-starter kit.
RS232 cable.
THEORY:
The simplest method to generate Sine wave is to use Trigonometric Sine function. The Sin
function will generate the samples from our specific parameter like sampling frequency, number of
samples, input frequency.
The basic form as a function of time (t) is:
y(t) = A Sin(t+)
where:
A, the amplitude, is the peak deviation of the function from its center position.
ω, the angular frequency, specifies how many oscillations occur in a unit time interval,
in radians per second
, the phase, specifies where in its cycle the oscillation begins at t = 0.
PROCEDURE:
57
In serial select the load program, download file will open and browse it. Click ok to
continue.
In serial communication window type ‘sd’ space starting address, enter the input value.
After entering the data execute the program.
Click enter to verify the output.
PROGRAM:
AMPLITUDE .SET 5
Freq .SET 175
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
58
%Square waveform generation
.mmregs
.text
Start:
Ldp #100h
Lacc #0fffh
Loop: sacl 0
Rpt #offh
Out 0,04
Cmpl
B loop
.end
.MMREGS
.TEXT
START:
LDP #120H
LACC #0H ; change lower amplitude
SACL 0
LOOP: LACC 0
OUT 0,04H
ADD #05h ; change frequency
SACL 0
SUB #0FFFh ; change upper amplitude
BCND LOOP, LEQ
B START
.END
TEMP .set 0
TEMP1 .set 1
59
.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
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
.end
60
OUTPUT:
Model Graph:
RESULT:
Thus the triangle, Sine , square and saw tooth waveform using DSP processor was
successfully generated.
61
62
Ex. No: 10
FIR FILTER IMPLEMENTATION
AIM:
To design and demonstration of FIR filter for Low Pass, High Pass, Band Pass and Band Stop
Filtering.
TOOLS REQURIED:
DSP hardware.
TMS320C5X-starter kit.
RS232 cable.
ALGORITHM:
Get the sum of terms to design the filter.
Specify the value of angular frequency from 0 to and plots divided into 0.01 division.
Using FIR function get the design of filter.
Finally adjust the value and execute the program.
THEORY:
In signal processing, a finite impulse response (FIR) filter is a filter whose impulse
response (or response to any finite length input) is of finite duration, because it settles to zero
in finite time.
Infinite impulse response (IIR) filters, which may have internal feedback and may continue to
respond indefinitely (usually decaying).
The impulse response of Nth-order discrete-time FIR filter (i.e., with a Kronecker
delta impulse input) lasts for N + 1 samples, and then settles to zero.
o FIR is non recursive structure without response of FIR filter depends only on present
and past input samples
63
PROCEDURE:
Start the program by clicking view click the workspace.
Click the serial go to the port settings.
Before auto detect reset the kit& click ok to continue.
Click project new. Save the file &all files will be DSP project.
Click assembly file & save the file as “.asm”.
In left hand side, right click project & add file to project.
In left hand side, right click command file & add file to project.
Click built in project for the compile of program. Click ok to continue.
In serial select the load program, download file will open and browse it. Click ok to
continue.
In serial communication window type ‘sd’ space starting address, enter the input
value.
After entering the data execute the program.
Click enter to verify the output.
64
.word 0ACBH
.word 0100CH
.word 0142FH
.word 01675H
.word 01675H
.word 0142FH
.word 0100CH
.word 0ACBH
.word 0552H
.word 084H
.word 0FD0FH
.word 0FB4CH
.word 0FB36H
.word 0FC72H
.word 0FE6CH
.word 07EH
.word 0218H
.word 02DEH
.word 02B9H
.word 01D3H
.word 083H
.word 0FF35H
.word 0FE44H
.word 0FDEDH
.word 0FE37H
.word 0FEFFH
.word 00H
.word 0EBH
.word 017EH
.word 0196H
START:
LAR AR0,#0200H
MAR *,AR0
RPT #33H
BLKP CTABLE,*+
SETC CNF
65
NOP
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
MAR *,AR1
SACL *
LAR AR1,#333H
ZAP
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SFR ;remove if o/p is less amplitude
SACL *
OUT *,4
NOP
B ISR
.end
66
.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
.word 0FCB9H
.word 05H
.word 0FCD3H
* Move the Filter coefficients
* from program memory to data memory
START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
* Input data and perform convolution
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
IN 0,06H
LAR AR7,#0 ;change value to modify sampling freq.
MAR *,AR7
BACK: BANZ BACK,*-
67
IN 0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SACL *
OUT *,4
LACC #0FFH
SACL 0
OUT 0,05
NOP
B ISR
.end
.word 02D3H
.word 012FH
68
.word 0FEBDH
.word 0FC97H
.word 0FBCBH
.word 0FCB0H
.word 0FE9EH
.word 029H
.word 0FFDCH
.word 0FD11H
.word 0F884H
.word 0F436H
.word 0F2A0H
.word 0F58AH
.word 0FD12H
.word 075FH
.word 01135H
.word 01732H
.word 01732H
.word 01135H
.word 075FH
.word 0FD12H
.word 0F58AH
.word 0F2A0H
.word 0F436H
.word 0F884H
.word 0FD11H
.word 0FFDCH
.word 029H
.word 0FE9EH
.word 0FCB0H
.word 0FBCBH
.word 0FC97H
.word 0FEBDH
.word 012FH
.word 02D3H
.word 0312H
.word 0220H
.word 0C6H
.word 0FFECH
.word 0FH
.word 010FH
.word 024AH
* Move the Filter coefficients
* from program memory to data memory
START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
69
BLKP CTABLE,*+
SETC CNF
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
IN 0,06H
LAR AR7,#0 ;change value to modify sampling freq.
MAR *,AR7
BACK: BANZ BACK,*-
IN 0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SACL *
OUT *,4
LACC #0FFH
SACL 0
OUT 0,05
NOP
B ISR
.end
% FIR BAND REJECT FILTER:
* Filter Order: 52
* lower Cutoff frequency in KHz = .000000Hz
* upper Cutoff frequency in KHz = .000000Hz
.mmregs
.text
B START
CTABLE:
.word 0FEB9H
.word 14EH
.word 0FDA1H
70
.word 155H
.word 0FE1BH
.word 282H
.word 0FEAFH
.word 2ACH
.word 0FD35H
.word 8DH
.word 0F9D9H
.word 0FE07H
.word 0F7CCH
.word 0FEE2H
.word 0FA2FH
.word 4BAH
.word 1AH
.word 25CH
.word 420H
.word 1008H
.word 89H
.word 0D61H
.word 0F3F2H
.word 0AF9H
.word 0DB7EH
.word 045DFH
.word 045DFH
.word 0DB7EH
.word 0AF9H
.word 0F3F2H
.word 0D61H
.word 89H
.word 1008H
.word 420H
.word 25CH
.word 1AH
.word 4BAH
.word 0FA2FH
.word 0FEE2H
.word 0F7CCH
.word 0FE07H
.word 0F9D9H
.word 8DH
.word 0FD35H
.word 2ACH
.word 0FEAFH
.word 282H
.word 0FE1BH
.word 155H
.word 0FDA1H
.word 14EH
.word 0FEB9H
71
START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
IN 0,06H
LAR AR7,#0 ;change value to modify sampling freq.
MAR *,AR7
BACK: BANZ BACK,*-
IN 0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SACL *
OUT *,4
LACC #0FFH
SACL 0
OUT 0,05
NOP
B ISR
.end
72
OUTPUT:
Frequency Response
RESULT:
Thus the Filter was implemented using DSP Processor.
73
74
Ex. No: 11
IIR FILTER IMPLEMENTATION
AIM:
To design and demonstrate Butterworth and Chebyshev IIR Filters using DSP Processor.
TOOLS REQURIED:
DSP hardware.
TMS320C5X-starter kit.
RS232 cable.
ALGORITHM:
Get the sum of terms to design the filter.
Specify the value of angular frequency from 0 to and plots divided into 0.01 division.
Using FIR function get the design of filter.
Finally adjust the value and execute the program.
THEORY:
In signal processing, a finite impulse response (FIR) filter is a filter whose impulse
response (or response to any finite length input) is of finite duration, because it settles to zero
in finite time.
Infinite impulse response (IIR) filters, which may have internal feedback and may continue to
respond indefinitely (usually decaying).
The impulse response of Nth-order discrete-time FIR filter (i.e., with a Kronecker
delta impulse input) lasts for N + 1 samples, and then settles to zero.
o FIR is non recursive structure without response of FIR filter depends only on present
and past input samples
75
PROCEDURE:
Start the program by clicking view click the workspace.
Click the serial go to the port settings.
Before auto detect reset the kit& click ok to continue.
Click project new. Save the file &all files will be DSP project.
Click assembly file & save the file as “.asm”.
In left hand side, right click project & add file to project.
In left hand side, right click command file & add file to project.
Click built in project for the compile of program. Click ok to continue.
In serial select the load program, download file will open and browse it. Click ok to
continue.
In serial communication window type ‘sd’ space starting address, enter the input
value.
After entering the data execute the program.
Click enter to verify the output.
76
SACL T1
SACL T2
SACL TEMP
OUT TEMP,4 ;CLEAR DAC BEFORE START TO WORK
LOOP:
LACC #0
SACL TEMP
OUT TEMP,5 ;OUTPUT LOW TO DAC2 TO CALCULATE TIMING;
IN TEMP,06 ;SOC;
LAR AR7,#30h ;CHANGE VALUE TO MODIFY SAMPLING FREQ
;sampling rate 100ms.
MAR *,AR7
BACK: BANZ BACK,*-
;
IN INPUT,4 ;INPUT DATA FROM ADC1
NOP
NOP
;
LACC INPUT
AND #0FFFH
SUB #800h
SACL INPUT
;
LT INPUT
MPY #K
PAC
SACH T1,1
;;;CALL MULT ----MULTIPLICATION TO BE DONE WITH K
;;RESULT OF MULT IN T1
;
LT T2 ;PREVIOUS RESULT IN T2
MPY #M
PAC
SACH T3 ,1
;;;CALL MULT ----MULTIPLICATION TO BE DONE WITH M
;;RESULT OF MULT IN T3+
;
LACC T1
ADD T3
SACL T2
ADD #800h
SACL TEMP
OUT TEMP,4 ;OUTPUT FILTER DATA TO DAC1
;
LACC #0FFH
SACL TEMP
OUT TEMP,5 ;OUTPUT HIGH TO DAC2 TO CALCULATE TIMING
;
B LOOP
77
%High Pass Filter:
.MMREGS
.TEXT
START:
LDP #100H
LACC #00H
SACL 00H
SACL 01H
SACL 02H
SACL 03H
SACL 04H
SACL 05H
LOOP:
LACC #00H
SACL 00H
IN 0,06H
LAR AR7,#30H
MAR *,AR7
BACK: BANZ BACK,*-
; LT 01H
; MPY #0FFFFB5DEH
; PAC
; SACH 05H,1
IN 0,04H
NOPS
NOP
NOP
NOP
LT 01H
; MPY #0FFFFB5DEH
MPY #4A22H
; MPY #315EH
PAC
SACH 05H,1
LACC 00H
AND #0FFFH
XOR #800H
SUB #800H
SACL 00H
SACL 01H
ZAP
LT 00H
; DMOV 00H
; LTD 00H
MPY #4A22H
78
; MPY #315EH
PAC
SACH 02H,1
LT 03H
MPY #1446H
; MPY #4E9FH
PAC
SACH 04H,1
LACC 02H
ADD 04H
SUB 05H
SACL 03H
ADD #800H
SACL 00H
; OUT 00H,1AH
OUT 0,04H
B LOOP
NOP
NOP
H: BH
LOOP1:
LACC #00H
SACL 00H
IN 0,06H
LAR AR7,#30H
MAR *,AR7
BACK: BANZ BACK,*-
IN 0,04H
NOP
NOP
NOP
NOP
79
LT 04H
MPY #2FC4H
; MPY #05F8H
PAC
SACH 24H,0
; SACH 24H,4
LT 03H
MPY #99B2H
; MPY #1336H
PAC
SACH 23H,0
; SACH 23H,4
LT 02H
MPY #0DB29H
; MPY #1B65H
PAC
SACH 22H,0
; SACH 22H,4
LT 01H
MPY #99B2H
; MPY #1336H
PAC
SACH 21H,0
; SACH 21H,4
LACC 03H
SACL 04H
LACC 02H
SACL 03H
LACC 01H
LACC 02H
LACC 00H
AND #0FFFH
XOR #800H
SUB #800H
SACL 00H
SACL 01H
ZAP
; DMOV 03H
80
; DMOV 02H
; DMOV 01H
LT 00H
MPY #2FC4H
; MPY #05F8H
PAC
SACH 20H,0
; SACH 20H,4
;
;
;
LT 73H
MPY #2A22H
; MPY #0544H
PAC
SACH 63H,0
; SACH 63H,4
LT 72H
MPY #6761H
; MPY #0CECH
PAC
SACH 62H,0
; SACH 62H,4
LT 71H
MPY #0B6E8H
; MPY #16DDH
PAC
SACH 61H,0
; SACH 61H,4
LACC 72H
SACL 73H
LACC 71H
SACL 72H
LACC 70H
SACL 71H
;
; DMOV 72H
; DMOV 71H
; LTD 70H
LT 70H
MPY #0F184H
; MPY #1E30H
81
PAC
SACH 60H,0
; SACH 60H,4
LACC 20H
SUB 21H
ADD 22H
SUB 23H
ADD 24H
ADD 60H
SUB 61H
ADD 62H
SUB 63H
SACL 70H
ADD #800H
SACL 00H
; OUT 00H,1AH
IN 0,04H
B LOOP1
NOP
NOP
H: B H
LOOP1:
LACC #00H
SACL 00H
IN 0,06H
LAR AR7,#30H
MAR *,AR7
BACK: BANZ BACK,*-
IN 0,04H
NOP
NOP
NOP
NOP
82
LT 04H
MPY #003BH
PAC
; SACH 24H,0
; RPT #0BH
; SFR
SACH 24H,4
LT 03H
MPY #0000H
PAC
; RPT #0BH
; SFR
; SACH 23H,0
SACH 23H,4
LT 02H
MPY #0077H
PAC
; RPT #0BH
; SFR
; SACH 22H,0
SACH 22H,4
LT 01H
MPY #0000H
PAC
; RPT #0BH
; SFR
; SACH 21H,0
SACH 21H,4
LACC 03H
SACL 04H
LACC 02H
SACL 03H
LACC 01H
LACC 02H
LACC 00H
AND #0FFFH
XOR #800H
SUB #800H
SACL 00H
SACL 01H
ZAP
LT 00H
MPY #003BH
PAC
83
; RPT #0BH
; SFR
; SACH 20H,0
SACH 20H,4
LT 73H
MPY #0B04H
PAC
; RPT #0BH
; SFR
; SACH 63H,0
SACH 63H,4
LT 72H
MPY #1226H
PAC
; RPT #0BH
; SFR
; SACH 62H,0
SACH 62H,4
LT 71H
MPY #21A3H
PAC
; RPT #0BH
; SFR
; SACH 61H,0
SACH 61H,4
LACC 72H
SACL 73H
LACC 71H
SACL 72H
LACC 70H
SACL 71H
LT 70H
MPY #15E9H
PAC
; RPT #0BH
; SFR
; SACH 60H,0
SACH 60H,4
LACC 20H
ADD 21H
SUB 22H
ADD 23H
ADD 24H
84
ADD 60H
SUB 61H
ADD 62H
SUB 63H
SACL 70H
ADD #800H
SACL 00H
; OUT 00H,1AH
OUT 0,04H
B LOOP1
NOP
NOP
H: B H
OUTPUT:
Frequency Response
85
RESULT:
Thus the IIR Filter was implemented using DSP Processor.
86
Ex. No: 12 UP SAMPLING AND DOWN SAMPLING
AIM:
To write a program to implement Up sampling and Down-sampling operation using DSP Processor.
TOOLS REQURIED:
DSP hardware.
TMS320C5X-starter kit.
RS232 cable.
ALGORITHM:
THEORY:
Interpolation is the process of increasing the sampling rate. In practice, this usually implies
lowpass-filtering a signal, then throwing away some of its samples.
"Upsampling" is a more specific term which refers to just the process of throwing away
samples, without the low pass filtering operation.
The interpolation factor is simply the ratio of the input rate to the output rate. It is
usually symbolized by "M", so input rate / output rate=M.
o A signal can be up sampled (without doing any filtering) whenever it is "under
sampled", that is, when a sampling rate was used that was greater than the Nyquist
criteria required. Specifically, the signal's highest frequency must be double the post-
interpolation sampling rate.
Decimation is the process of reducing the sampling rate. In practice, this usually implies
lowpass-filtering a signal, then throwing away some of its samples.
"Downsampling" is a more specific term which refers to just the process of throwing away
samples, without the lowpass filtering operation.
87
The decimation factor is simply the ratio of the input rate to the output rate. It is
usually symbolized by "D", so input rate / output rate D.
A signal can be downsampled (without doing any filtering) whenever it is "oversampled", that
is, when a sampling rate was used that was greater than the Nyquist criteria required.
Specifically, the signal's highest frequency must be less than half the post-
decimation sampling rate.
PROCEDURE:
88
PROGRAM:
%down sampler
B3 .SET 0F000H
B2 .SET 0F00H
B1 .SET 00F0H
B0 .SET 000FH
.mmregs
.text
B START
CTABLE:
.word 0FF82H
.word 0083H
.word 0166H
.word 01CFH
.word 0288H
.word 009DH
.word 0FF5BH
.word 0FE38H
.word 0FDACH
.word 0FE01H
.word 0FF31H
89
.word 00DEH
.word 0271H
.word 0342H
.word 02DDH
.word 0132H
.word 0FEADH
.word 0FC20H
.word 0FA92H
.word 0FAEEH
.word 0FDB6H
.word 02CCH
.word 096AH
.word 0104CH
.word 015F9H
.word 0192EH
.word 0192EH
.word 015F9H
.word 0104CH
.word 096AH
.word 02CCH
.word 0FDB6H
.word 0FAEEH
.word 0FA92H
.word 0FC20H
.word 0FEADH
90
.word 0132H
.word 02DDH
.word 0342H
.word 0271H
.word 00DEH
.word 0FF31H
.word 0FE01H
.word 0FDACH
.word 0FE38H
.word 0FF5BH
.word 009DH
.word 0288H
.word 01CFH
.word 0166H
.word 0083H
.word 0FF82H
*
* Move the Filter coefficients
* from program memory to data memory
*
START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
91
REPDECI:
LAR AR0,#4H
LAR AR2,#9000H
LAR AR3,#359
ISR:
LDP #0AH
LACC #0
SACL 0
IN 0,06H
MAR *,AR7
IN 0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
XOR #800H
SUB #800H
92
SACL *
SETC CNF
NOP
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
LACC *
; ADD #800H
; SACL *
MAR *,AR0
BANZ NO_OUT,*-
MAR *,AR2
SACL *+
; MAR *,AR1
; OUT *,4
CLRC CNF
LAR AR0,#4H
B REPISR
NO_OUT:
93
RPT #3H
NOP
B ISR
REPISR:
MAR *,AR3
BANZ ISR,*-
REP:
LDP #100H
LAR AR2,#9000H
LAR AR3,#359
REPXN:
MAR *,AR2
LACC *+
; SUB #1000
MAR *,AR3
BANZ REPXN,*- ;repeat this for all the 360 output samples
B REPDECI
SERIAL
94
SPLK #25H,TXD ;start of character "%"
CALL TXDATA
RPT #0FFFH
NOP
LACC DATA
BSAR 12
SACL TXD
CALL HEXASC
CALL TXDATA
RPT #0FFFH
NOP
LACC DATA
BSAR 8
SACL TXD
CALL HEXASC
CALL TXDATA
RPT #0FFFH
NOP
LACC DATA
BSAR 4
SACL TXD
CALL HEXASC
95
CALL TXDATA
RPT #0FFFH
NOP
LACC DATA
SACL TXD
CALL HEXASC
CALL TXDATA
RPT #0FFFH
NOP
CALL TXDATA
RPT #0FFFH
NOP
RET
HEXASC:
LACC TXD
SUB #9H
BCND GRT9,GT
96
LACC TXD
ADD #30H
SACL TXD
RET
ADD #37H
SACL TXD
RET
TXDATA:
REPCHK:
IN STS,9
LACC STS
AND #04H
BCND REPCHK,EQ
OUT TXD,8
RET
HLT: B HLT
.end
97
%Up sampler
.mmregs
.text
B START
CTABLE:
.word 0FF82H
.word 083H
.word 0167H
.word 01CFH
.word 0188H
.word 09DH
.word 0FF5BH
.word 0FE38H
.word 0FDACH
.word 0FE01H
.word 0FF31H
.word 0DEH
.word 0271H
.word 0342H
.word 02DDH
.word 0132H
.word 0FEADH
.word 0FC20H
.word 0FA92H
.word 0FAEEH
.word 0FDB6H
.word 02CCH
.word 096AH
.word 0104CH
.word 015F9H
.word 0192EH
.word 0192EH
.word 015F9H
98
.word 0104CH
.word 096AH
.word 02CCH
.word 0FDB6H
.word 0FAEEH
.word 0FA92H
.word 0FC20H
.word 0FEADH
.word 0132H
.word 02DDH
.word 0342H
.word 0271H
.word 0DEH
.word 0FF31H
.word 0FE01H
.word 0FDACH
.word 0FE38H
.word 0FF5BH
.word 09DH
.word 0188H
.word 01CFH
.word 0167H
.word 083H
.word 0FF82H
*
* Move the Filter coefficients
* from program memory to data memory
*
START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
*
* Input data and perform convolution
*
LAR AR0,#0H
REPINT:
LAR AR2,#9000H
LAR AR3,#359
ISR:
SETC CNF
LDP #0AH
99
LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
MAR *,AR0
BANZ INC0,*-
IN 0,06H
; LAR AR7,#0 ;change value to modify sampling freq.
; MAR *,AR7
;BACK: BANZ BACK,*-
RPT #10H
IN 0,4
LAR AR0,#0H
B STORE
INC0: SPLK #0H,0H
RPT #15H
NOP
STORE: NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
XOR #800H
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
; ADD #800H
SFR ;remove if o/p is less amplitude
; SACL *
; OUT *,4
MAR *,AR2
SACL *+
100
LACC #0FFFH
SACL 0
OUT 0,05
NOP
MAR *,AR3
BANZ ISR,*-
REP:
LDP #100H
LAR AR2,#9000H
LAR AR3,#359
REPXN:
MAR *,AR2
LACC *+
; SUB #1000
SACL DATA ;store the samples in DATA
CALL SERIAL ;subroutine to send DATA
MAR *,AR3
BANZ REPXN,*- ;repeat this for all the 360 output samples
B REPINT
LACC DATA
AND #B3 ;1st digit (from msb)
BSAR 12
SACL TXD
CALL HEXASC
CALL TXDATA
RPT #0FFFH
NOP
LACC DATA
AND #B2 ;second digit
BSAR 8
SACL TXD
101
CALL HEXASC
CALL TXDATA
RPT #0FFFH
NOP
LACC DATA
AND #B1 ;3rd digit
BSAR 4
SACL TXD
CALL HEXASC
CALL TXDATA
RPT #0FFFH
NOP
LACC DATA
AND #B0 ;4th digit
SACL TXD
CALL HEXASC
CALL TXDATA
RPT #0FFFH
NOP
102
SACL TXD
RET
103
OUTPUT:
Down sampling:
Up sampling:
RESULT:
Thus the Up and Down sampling operation was implemented using DSP Processor.
104
ADDITIONAL EXPERIMENTS
105
106
Ex. No: 13
AIM:
To compute Discrete Fourier Transform of the input sequence using FFT Function.
APPARATUS REQUIRED:
1. Personal Computer
2. MATLAB Software
ALGORITHM:
1. Start the program.
2. Get the N point values from the user.
3. Assign the range of the time axis.
4. Give the title for the x axis and y axis for the program.
5. Plot the data sequence as a discrete values or continuous as per our requirements.
PROCEDURE:
Start the MATLAB software and create new M-file.
Type the program in the file.
Save & compile the program.
Give the input data.
Observe the output waveform.
Thus the graph is to be plotted.
THEORY:
A fast Fourier transform is an algorithm that samples a signal over a period of time and
divides it into its frequency components. These components are single sinusoidal oscillations at
distinct frequencies each with their own amplitude and phase.
107
PROGRAM:
108
OUTPUT:
RESULT:
Thus the Discrete Fourier Transform of the input Sequence is computed using FFT function.
109
110
Ex. No: 14
LINEAR CONVOLUTION
AIM:
THEORY:
Linear convolution is function of the most important operation in signal processing. It
relates the input & output and unit sample response of the system.
Click project new. Save the file &all files will be DSP project.
In left hand side, right click project & add file to project.
In left hand side, right click command file & add file to project.
In serial select the load program, download file will open and browse it. Click ok to
continue.
In serial communication window type ‘sd’ space starting address, enter the input
value.
After entering the data execute the program.
111
PROGRAM:
.mmregs
.text
START:
LDP #02H
LAR AR1,#8100H ; x(n) datas
lar ar0,#08200H ;h(n) datas
LAR AR3,#8300H ;y(n) starting
LAR AR4,#0007 ;N1+N2-1
;to fold the h(n) values
lar ar0,#8203H ; data mem 8200 to program mem c100(tblw)
lacc #0c100h
mar *,ar0
rpt #3
tblw *- ;to move 8203- 8200 to c100- c103
;padding of zerros for x(n) values
lar ar6,#8104h
mar *,ar6
lacc #0h
rpt #3h
sacl *+
;convalution operation starts
LOP: MAR *,AR1
LACC *+
SACL 050H ;starting of the scope of multiplication
LAR AR2,#0153H ; end of the array, to be multiplied with h(n) {150+N1-1}
MAR *,AR2
ZAP
RPT #03H ;N1-1 times so that N1 times
MACD 0C100H,*-
APAC ;to accmulate the final product sample
MAR *,AR3
SACL *+
MAR *,AR4
BANZ LOP,*-
H: B H
112
OUTPUT:
;INPUT ( x(n) )
;8100 - 1
;8101 - 3
;8102 - 1
;8103 - 3
;INPUT ( h(n) )
; 8200 - 0
; 8201 - 1
; 8202 - 2
; 8203 - 1
;OUTPUT ( y(n) )
; 8300 - 1
; 8301 - 5
; 8302 - 8
; 8303 - 8
; 8304 - 7
; 8305 - 3
; 8306 - 0
RESULT:
Thus the program was written in TMS320C50 perform linear convolution.
113
114
LABORATORY CALIBRATION REPORT
115
116
July 2019 to December 2019
117
V.R.S COLLEGE OF ENGINEERING AND TECHNOLOGY
ARASUR- 607107
(Accredited by & NAAC and An ISO 9001: 2008 Recertified Institution)
Department of Electronics and Communication Engineering
(Regulation 2017)
LAB REPORT
The simulation of the following experiments were verified using MATLAB with simulink
1. Generation of elementary Discrete-Time sequences
OUTPUT:
0.5
0
0 1 2 3 4
n-->
Cosine sequence
1
0.5
Amplitude
-0.5
-1
0 1 2 3 4
x(n)
118
Sine sequence
1
0.5
Amplitude
0
-0.5
-1
0 1 2 3 4
n->
OUTPUT:
Enter the length 5
Enter the a value 5
Exponential sequence
6
Amplitude
0
0 2 4 6
time
OUTPUT:
Enter the length of the sequence 6
ramp sequence
6
4
amplitude
0
0 1 2 3 4 5 6
time
119
2. a. To find the Linear convolution of two sequences
OUTPUT:
Output is 20 31 34 50 32 19 10
4 4
amplitude
amplitude
2 2
0 0
1 2 3 4 1 2 3 4
n-> n->
convoluted sequence
60
40
amplitude
20
0
0 2 4 6 8
n->
120
first input sample
4
amplitude
2
0
0 0.5 1 1.5 2 2.5 3
time
second input sample
10
amplitude
0
0 0.5 1 1.5 2 2.5 3
time
circular convolution
100
amplitude
50
0
0 0.5 1 1.5 2 2.5 3
time
121
Y= 1.0 4.0 10.0 20.0 25.0 24.00 16.00
OUTPUT:
122
5. a. To design FIR filters using Rectangular Window
OUTPUT:
Pass band ripple=0.03
Stop band ripple=0.04
Stop band frequency in rad/sec=1200
Pass band frequency in rad/sec=600
Sampling frequency in rad/sec=4000
123
6. a. To design IIR filters using Butterworth approximation
OUTPUT:
enter the pass band ripple 10
enter the stop band ripple 30
enter the pass band frequency [0.2 0.8]
enter the stop band frequency [0.4 0.7]
124
b. To design IIR filters using Chebyshev approximation
OUTPUT:
enter the pass band ripple 1
enter the stop band ripple 2
enter the pass band frequency [0.3 0.8]
enter the stop band frequency [0.2 0.9]
1000H 0004
1001H 0004
OUTPUT:
1002H 0008
SUBTRACTION:
INPUT:
1000H 0002
1001H 0004
OUTPUT:
1002H 0002
125
6. Generation of various signals and random noise
Design and demonstration of FIR Filter for Low pass, High pass, Band pass and Band stop
7.
filtering
Design and demonstration of Butter worth & Chebyshev IIR Filters for Low pass, High pass,
8.
Band pass and Band stop filtering
9. Implement an Up-sampling and Down-sampling operation in DSP Processor
Note:
The implementations of above following experiments were verified using MATLAB with
Simulink and DSP Processor kit.
126