Ec8562-Digital Signal Processing Laboratory-1953309632-Ec8562-Digital-Signal-Processing-Lab
Ec8562-Digital Signal Processing Laboratory-1953309632-Ec8562-Digital-Signal-Processing-Lab
Ec8562-Digital Signal Processing Laboratory-1953309632-Ec8562-Digital-Signal-Processing-Lab
Regulation : 2017
Branch : B.E. – ECE
Year & Semester : III Year / V Semester
Regulation 2017
LIST OF EXPERIMENTS:
TOTAL: 60 PERIODS
INDEX
LIST OF EXPERIMENTS
2 Correlation of Sequences
12a Up-sampling
12b Down-sampling
INTRODUCTION
It also allows you to put a list of your processing requests together in a file and save
that combined list with a name so that you can run all of those commands in the same
order at some later time. Furthermore, it allows you to run such lists of commands such
that you pass in data. and/or get data back out (i.e. the list of commands is like a
function in most programming languages). Once you save a function, it becomes part of
your toolbox. For those with computer programming backgrounds: Note that MATLAB
runs as an interpretive language (like the old BASIC). That is, it does not need to be
compiled. It simply reads through each line of the function, executes it, and then goes
on to the next line.
DSP Development System
• Testing the software and hardware tools with Code Composer Studio
• Use of the TMS320C6713 DSK
• Programming examples to test the tools
Digital signal processors such as the TMS320C6x (C6x) family of processors are like
fast special-purpose microprocessors with a specialized type of architecture and an
instruction set appropriate for signal processing. The C6x notation is used to designate a
member of Texas Instruments’ (TI) TMS320C6000 family of digital signal processors. The
architecture of the C6x digital signal processor is very well suited for numerically intensive
calculations. Based on a very-long-instruction-word (VLIW) architecture, the C6x is
considered to be TI’s most powerful processor. Digital signal processors are used for a wide
range of applications, from communications and controls to speech and image processing.
The general-purpose digital signal processor is dominated by applications in communications
(cellular). Applications embedded digital signal processors are dominated by consumer
products. They are found in cellular phones, fax/modems, disk drives, radio, printers, hearing
aids, MP3 players, high-definition television (HDTV), digital cameras, and so on. These
processors have become the products of choice for a number of consumer applications, since
they have become very cost-effective. They can handle different tasks, since they can be
reprogrammed readily for a different application.
DSP techniques have been very successful because of the development of low-cost
software and hardware support. For example, modems and speech recognition can be less
expensive using DSP techniques.DSP processors are concerned primarily with real-time
signal processing. Real-time processing requires the processing to keep pace with some
external event, whereas non-real-time processing has no such timing constraint. The external
event to keep pace with is usually the analog input. Whereas analog-based systems with
discrete electronic components such as resistors can be more sensitive to temperature
changes, DSP-based systems are less affected by environmental conditions.
DSP processors enjoy the advantages of microprocessors. They are easy to use,
flexible, and economical. A number of books and articles address the importance of digital
signal processors for a number of applications .Various technologies have been used for real-
time processing, from fiber optics for very high frequency to DSPs very suitable for the audio-
frequency range. Common applications using these processors have been for frequencies from
0 to 96kHz. Speech can be sampled at 8 kHz (the rate at which samples are acquired), which
implies that each value sampled is acquired at a rate of 1/(8 kHz) or 0.125ms. A commonly
used sample rate of a compact disk is 44.1 kHz. Analog/digital (A/D)- based boards in the
megahertz sampling rate range are currently available.
Ex. No: 1
Date :
GENERATION OF DISCRETE TIME SIGNALS
AIM:
To generate a discrete time signal sequence (Unit step, Unit ramp, Sine, Cosine,
Exponential, Unit impulse) using MATLAB function.
APPARATUS REQUIRED:
HARDWARE : Personal
PROCEDURE:
amplitude
0.5 0.5
0 0
-4 -2 0 2 4 0 2 4 6 8
time period sequence
17
unit ramp x 10 exponential sequence
6 3
amplitude
amplitude
4 2
2 1
0 0
0 2 4 6 0 2 4 6 8
sequence time period
OUTPUT: (CONTINUOUS SIGNALS)
17
x 10 continuous exponential sequence
3
amplitude
0
0 1 2 3 4 5 6 7 8
time period
sine wave
1
amplitude
-1
0 0.5 1 1.5 2 2.5 3 3.5
time period
cosine wave
1
amplitude
-1
0 0.5 1 1.5 2 2.5 3 3.5
time period
RESULT:
Thus the MATLAB programs for discrete time signal sequence (Unit step,
Unit ramp, Sine, Cosine, Exponential, Unit impulse) using MATLAB function written
and the results were plotted.
Ex. No: 2
Date:
CORRELATION OF SEQUENCES
AIM:
APPARATUS REQUIRED:
PROCEDURE:
6. If any error occurs in the program correct the error and run it again
RESULT:
Thus the MATLAB programs for auto correlation and cross correlation
written and the results were plotted.
Ex. No: 3
Date:
LINEAR AND CIRCULAR CONVOLUTIONS
AIM:
To write MATLAB programs to find out the linear convolution and Circular
convolution of two sequences.
APPARATUS REQUIRED:
PROCEDURE:
6. If any error occurs in the program correct the error and run it again
%convolution operation
y=conv(x,h);
%to plot the signal
subplot(3,1,1);
stem(x);
ylabel('amplitude');
xlabel('n1....>');
title('input sequence')
subplot(3,1,2);
stem(h);
ylabel('amplitude');
xlabel('n2....>');
title('impulse signal')
subplot(3,1,3);
stem(y);
ylabel('amplitude');
xlabel('n3');
disp('the resultant signal is');y
%circular convolution
clc;
clear all;
close all;
%to get the input sequence
g=input('enter the input sequence');
h=input('enter the impulse sequence');
N1=length(g);
N2=length(h);
N=max(N1,N2);
N3=N1-N2
%loop for getting equal length sequence
if(N3>=0)
h=[h,zeros(1,N3)];
else
g=[g,zeros(1,-N3)];
end
%computation of circular convoluted sequence
for n=1:N;
y(n)=0;
for i=1:N;
j=n-i+1;
if(j<=0)
j=N+j;
end
y(n)=y(n)+g(i)*h(j);
end
end
figure;
subplot(3,1,1);
stem(g);
ylabel('amplitude');
xlabel('n1..>');
title('input sequence')
subplot(3,1,2);
stem(h);
ylabel('amplitude');
xlabel('n2');
title('impulse sequence')
subplot(3,1,3);
stem(y);
ylabel('amplitude');
xlabel('n3');
disp('the resultant signal is');
OUTPUT : LINEAR CONVOLUTION
Enter the length of input sequence 4
Enter the length of impulse sequence 4
Enter the input sequence [1 2 3 4]
Enter the impulse sequence [4 3 2 1]
input sequence
4
amlitude
0
1 1.5 2 2.5 3 3.5 4
n1....>
impulse signal
4
amlitude
0
1 1.5 2 2.5 3 3.5 4
n2....>
40
amlitude
20
0
1 2 3 4 5 6 7
n3
OUTPUT : CIRCULAR CONVOLUTION
Enter the input sequence [1 2 2 1]
Enter the impulse sequence [4 3 2 1]
input sequence
2
amplitude
0
1 1.5 2 2.5 3 3.5 4
n1..>
impulse sequence
4
amplitude
0
1 1.5 2 2.5 3 3.5 4
n2
20
amplitude
10
0
1 1.5 2 2.5 3 3.5 4
n3
RESULT:
Thus the MATLAB programs for linear convolution and circular convolution
written and the results were plotted.
Ex. No: 4
Date:
FREQUENCY ANALYSIS USING DFT
AIM:
APPARATUS REQUIRED:
SOFTWARE : MATLAB
PROCEDURE:
14. If any error occurs in the program correct the error and run it again
fft
12
10
8
imaginary axis
0
1 2 3 4 5 6 7 8
real axis
PROGRAM: (Spectrum Analysis Using DFT)
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
RESULT:
Thus the Spectrum Analysis of the signal using DFT is obtained using MATLAB.
Ex. No: 5a
Date:
DESIGN OF FIR FILTERS
(RECTANGULAR WINDOW DESIGN)
AIM:
To write a program 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:
PROCEDURE:
1. Start the MATLAB program.
6. If any error occurs in the program correct the error and run it again
%highpass 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('(b)normalized frequency......>');
%bandpass filter
wn=[wp ws];0
b=fir1(n,wn,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('gain in db....>');
xlabel('(c)normalized frequency....>');
%bandstop 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('(d)normalized frequency.....>');
G a in in d b--------.
0 0
-50 -50
-100 -100
0 0.5 1 0 0.5 1
Normalized freqency------> Normalized freqency------>
MAGNITUDE RESPONSE OF BPF MAGNITUDE RESPONSE OF BSF
50 20
G a in in d b--------.
G a in in d b--------.
0
0
-20
-50
-40
-100 -60
0 0.5 1 0 0.5 1
Normalized freqency------> Normalized freqency------>
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.
Ex. No: 5b
Date:
DESIGN OF FIR FILTERS
(HANNING WINDOW DESIGN)
AIM:
To write a program to design the FIR low pass, High pass, Band pass and
Band stop filters using HANNING window and find out the response of the filter by
using MATLAB.
APPARATUS REQUIRED:
PROCEDURE:
1. Start the MATLAB program.
6. If any error occurs in the program correct the error and run it again
%lowpass 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);
ylabel('gain in db....>');
xlabel('(a)normalized frequency');
%highpass 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('(b)normalized frequency...>');
%bandpass filter
wn=[wp ws];
b=fir1(n,wn,Y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(o/pi,m);
ylabel('gain in db.....>');
xlabel('(c)normalized frequency....>');
%bandstop 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('(d)normalized frequency....>')
Gain in db--------.
0
0
-50
-50
-100
-150 -100
0 0.5 1 0 0.5 1
Normalized freqency------> Normalized freqency------>
MAGNITUDE RESPONSE OF BPF MAGNITUDE RESPONSE OF BSF
0 5
Gain in db--------.
Gain in db--------.
0
-50
-5
-100 -10
0 0.5 1 0 0.5 1
Normalized freqency------> Normalized freqency------>
RESULT:
Thus the program to design FIR low pass, high pass, band pass and
band stop Filters using HANNING Window was written and response of the
filter using MATLAB was executed.
Ex. No: 6
Date:
DESIGN OF IIR FILTERS
AIM:
To write a program to design the IIR Butterworth & Chebyshew Filter (LPF/HPF/BPF/BSF) by
using MATLAB.
APPARATUS REQUIRED:
PROCEDURE:
1. Start the MATLAB program.
6. If any error occurs in the program correct the error and run it again
lpf hpf
1 1
abs(h)
abs(h)
0.5 0.5
0 0
0 1 2 3 4 0 1 2 3 4
normalized frequency normalised frquency
bpf bsf
1 1
abs(h)
abs(h)
0.5 0.5
0 0
0 1 2 3 4 0 1 2 3 4
normalised frequency normalised frequency
PROGRAMS: IIR (CHEBYSHEW FILTER)
% chebyshew filter
% get the input values
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
%filter order
[n,wn]=cheb1ord(w1,w2,rp,rs);
%lowpass filter
%either coefficient
[b,a]=cheby1(n,rp,wn);
%frequency response
[H,w]=freqz(b,a,512);
subplot(2,2,1);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('LPF')
%high pass filter
%filter coefficient
[b,a]=cheby1(n,rp,wn,'High');
%frequency response
[H,w]=freqz(b,a,512);
subplot(2,2,2);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('HPF')
%band pass filter
%filter coefficient
wn1=[w1,w2];
[b,a]=cheby1(n,rp,wn1);
%frequency response
[H,w]=freqz(b,a,512);
subplot(2,2,3);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('BPF')
%band stop filter
%filter coefficient
wn2= [w1, w2];
%frequency response
[b,a]=cheby1(n,rp,wn2,'stop');
[H,w]=freqz(b,a,512);
subplot(2,2,4);
plot(w,abs(H));
xlabel('normalised frequency');
ylabel('abs(H)');
title('BSF')
LPF HPF
1 1
abs(H)
abs(H)
0.5 0.5
0 0
0 1 2 3 4 0 1 2 3 4
normalised frequency normalised frequency
BPF BSF
1 1
abs(H)
abs(H)
0.5 0.5
0 0
0 1 2 3 4 0 1 2 3 4
normalised frequency normalised frequency
RESULT:
Thus the program to design IIR Butterworth & Chebyshew Filter (LPF/HPF/BPF/BSF) by
using MATLAB was executed.
DSP PROCESSOR EXPERIMENTS
PROCEDURE TO WORK ON CODE COMPOSER STUDIO
1. To create a New Project
Project →New (SUM.pjt)
Type the code (Save & give a name to file, Eg: sum.c).
3. To Add Source files to Project
Project → Add files to Project → sum.c
4. To Add rts6700.lib file & hello.cmd:
AIM:
To study the Architecture of TMS320VC67XX DSP processor.
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 225MHz. 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 headphone 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 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 DSP s memory, or the SDRAM, and plot them in the
‟
time or frequency domains. 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.
TMS320C6713 floating point DSP
The AIC23 codec is configured (through CCS) to operate at one of the above
sampling rates fs. Each collected sample is converted to a 16-bit two’s complement
integer (a short data type in C). The codec actually samples the audio input in stereo,
that is, it collects two samples for the left and right channels
ARCHITECTURE
The 67XX 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.
1. Central Processing Unit (CPU)
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 67XX 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
The multiplier / adder perform 17-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 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 C67XX 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.
6. Compare, Select, and Store Unit (CSSU)
The compare, select, and store unit (CSSU) performs maximum comparisons
between the accumulator’s high and low words, allows the test/control (TC) flag bit of
status register 0 (ST0) and the transition (TRN) register to keep their transition
histories, and selects the larger word in the accumulator to be stored in data memory.
The CSSU also accelerates Viterbi-type butterfly computation with optimized on-chip
hardware.
7. Program Control
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 includes branches,
calls, and conditional instructions, are peat instruction, reset, and interrupt.
The C67XX supports both the use of hardware and software interrupts for
program control. Interrupt service routines are vectored through a re-locatable
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.
8. Status Registers (ST0, ST1)
The status registers, ST0 and ST1, contain the status of the various conditions
and modes for the 67XX devices. ST0 contains the flags (OV, C, and TC) produced
‟
by arithmetic operations and bit manipulations in addition to the data page pointer
(DP) and the auxiliary register pointer (ARP) fields. ST1 contains the various modes
and instructions that the processor operates on and executes.
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.
10. Temporary Register (TREG)
The TREG is used to hold one of the multiplicands for multiply and
multiply/accumulate instructions. It can hold a dynamic (execution-time
programmable) shift count for instructions with a shift operation such as ADD, LD,
and SUB. It also can hold a dynamic bit address for the BITT instruction. The EXP
instruction stores the exponent value computed into the TREG, while the NORM
instruction uses the TREG value to normalize the number. For ACS operation of
Viterbi decoding, TREG holds branch metrics used by the DADST and DSADT
instructions.
11. Transition Register (TRN)
The TRN is a 16-bit register that is used to hold the transition decision for the
path to new metrics to perform the Viterbi algorithm. The CMPS (compare, select,
max, and store) instruction updates the contents of the TRN based on the comparison
between the accumulator high word and the accumulator low word.
12. Stack-Pointer Register (SP)
The SP is a 16-bit register that contains the address at the top of the system
stack. The SP always points to the last element pushed onto the stack. The stack is
manipulated by interrupts, traps, calls, returns, and the PUSHD, PSHM, POPD, and
POPM instructions. Pushes and pops of the stack pre decrement and post increment,
respectively, all 16 bits of the SP.
13. Circular-Buffer-Size Register (BK)
The 16-bit BK is used by the ARAUs in circular addressing to specify the data
block size.
14. Block-Repeat Registers (BRC, RSA, REA)
The block-repeat counter (BRC) is a 16-bit register used to specify the number
of times a block of code is to be repeated when performing a block repeat. The block-
repeat start address (RSA) is a 16-bit register containing the starting address of the
block of program memory to be repeated 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.
15. Interrupt Registers (IMR, IFR)
The interrupt-mask register (IMR) is used to mask off specific interrupts
individually at required times. The interrupt-flag register (IFR) indicates the current
status of the interrupts.
16. Processor-Mode Status Register (PMST)
The processor-mode status registers (PMST) controls memory configurations
of the 67XX devices.
17. Power-Down Modes
There are three power-down modes, activated by the IDLE1, IDLE2, and
IDLE3 instructions. In these modes, the 67XX devices enter a dormant state and
‟
completely. This instruction stops the PLL circuitry as well as the CPU and
peripherals.
RESULT
Thus the study of architecture TMS320VC67XX and its functionalities has been
identified.
Ex. No: 8
Date:
MAC OPERATION USING VARIOUS ADDRESSING MODES
AIM:
THEORY:
SUBTRACTION:
INP1 .SET 0H
INP2 .SET 1H
OUT .SET 2H
.mmregs
.text
START:
LD #140H,DP
RSBX CPL
NOP
NOP
NOP
NOP
LD INP1,A
SUB INP2,A
STL A,OUT
HLT: B HLT
INPUT:
Data Memory:
A000h 0004h
A001h 0002h
OUTPUT:
Data Memory:
A002h 0002h
MULTIPLICATION
.mmregs
.text
START:
STM #0140H,ST0
STM #40H,PMST
STM #0A000H,AR0
ST #1H,*AR0
LD *AR0+,T
ST #2H,*AR0
MPY *AR0+,A
STL A,*AR0
HLT: B HLT
.END
OUTPUT
A002H 2H
DIVISION
DIVID .SET 0H
DIVIS .SET 1H
OUT .SET 2H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
NOP
NOP
LD DIVID,A ;dividend to acc
RPT #0FH
SUBC DIVIS,A ;A / DIVIS -> A
STL A,OUT ;result in 9002h
HLT: B HLT
.END
INPUT
DATA MEMORY
A000H 000AH
A001H 0002H
OUTPUT
A002H 0005H
RESULT:
Thus, the various addressing mode of DSP processor TMS320C5416XX was studied
Ex. No: 9
Date:
WAVEFORM GENERATION
AIM:
To generate a sine wave ,square wave ,Triangular wave and Saw tooth wave using
TMS320C5416XX DSP KIT.
APPARATUS REQUIRED:
SOFTWARE : Vi Debugger
PROCEDURE:
COMPILE:
mmreg
.text
START:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
REP:
LD #TABLE,A
STM #372,AR1
LOOP:
READA DATA
PORTW DATA,04H
ADD #1H,A
B REP
}
}
DATA .SET 0H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL ; NOP
NOP
NOP
NOP
REP:
ST #0H,DATA
CALL DELAY
ST #0FFFH,DATA
CALL DELAY
B REP
DELAY:
STM #0FFFH,AR1
DEL1:
PORTW DATA,04H
BANZ DEL1,*AR1-
RET
Output
TRIANGULAR WAVE GENERATION
DATA .SET 0H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
REP:
ST #0H,DATA
INC:
LD DATA,A
ADD #1H,A
STL A,DATA
PORTW DATA,04H
CMPM DATA,#0FFFH
BC INC,NTC
DEC:
LD DATA,A
SUB #1H,A
STL A,DATA
PORTW DATA,04H
CMPM DATA,#0H
BC DEC,NTC
B REP
SAWTOOTH WAVE GENERATION
DATA .SET 0H
.mmregs
.text
START:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
REP:
ST #0H,DATA
INC:
LD DATA,A
ADD #1H,A
STL A,DATA
PORTW DATA,04H
CMPM DATA,#0FFFH
BC INC,NTC
B REP
RESULT:
Thus, the sine wave ,square ,triangular and saw tooth waveform was generated
displayed at graph.
Ex. No: 10
Date:
DESIGN OF FIR FILTERS
AIM:
To write a ASM program for the design of FIR Filter, also plots the magnitude
responses for the same.
APPARATUS REQUIRED:
PROCEDURE:
1. Open Code Composer Studio v4.
2. To create the New Project
Project→ New (File Name.)
3. To create a Source file
File →New→ Type the code (Save & give file name, Eg: sum.asm).
4. To Add Source files to Project
Project→ Add files to
Projectsum.asm
COMPILE:
B3 .SET 0F000H
B2 .SET 0F00H
B1 .SET 00F0H
B0 .SET 000FH
DATA .SET 50H
TXD .SET 51H
.mmregs
.text
START:
STM #01h,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
STM #150H,AR1
LD #0H,A
RPT #34H
STL A,*AR1+
REPFIRL:
STM #0A200H,AR4
STM #359,AR5
LOOP:
PORTR 06,0
CHK_BUSY:
PORTR 07,0
BITF 0,#20H
BC CHK_BUSY,TC
PORTR 04,0
LD 0,A
AND #0FFFH,A
XOR #0800H,A
SUB #800H,A
STM #150H,AR1
STL A,*AR1
STM #183H,AR2
LD #0H,A
RPT #33H
MACD *AR2-,TABLE,A
STH A,1,0H
LD 0H,A
ADD #800H,A
STL A,1H
PORTW 1H,04H
STL A,*AR4+
BANZ LOOP,*AR5-
STM #0A200H,AR2
STM #359,AR3
REPSER:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD *AR2+,A
SUB #7FFH,A
STL A,DATA
CALL SERIAL
BANZ REPSER,*AR3-
STM #01h,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
B REPFIRL
SERIAL:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD #25H,A
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B3,A ;1st digit (from msb)
SFTL A,-12
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B2,A ;1st digit (from msb)
SFTL A,-8
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B1,A ;1st digit (from msb)
SFTL A,-4
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B0,A ;1st digit (from msb)
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD #24H,A
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
RET
HEXASC:
ADD #30H,A
LD A,B
SUB #3AH,B
BC LESS9,BLT
ADD #7H,A
LESS9:
RET
TXDATA:
CALL 8C69H ;8C38H for 5416 mode 1
SSBX INTM
rpt #2ffh ;delay
nop
RET
fs = 41khz ; fc = 4khz ; N = 52
TABLE:
.word 01FH
.word 010EH
.word 01ABH
.word 01B4H
.word 0117H
.word 0H
.word 0FECDH
.word 0FDEEH
.word 0FDC2H
.word 0FE6EH
.word 0FFCDH
.word 016FH
.word 02C0H
.word 0333H
.word 0274H
.word 097H
.word 0FE19H
.word 0FBCBH
.word 0FA9BH
.word 0FB53H
.word 0FE50H
.word 0362H
.word 09C5H
.word 01048H
.word 01599H
.word 01895H
.word 01895H
.word 01599H
.word 01048H
.word 09C5H
.word 0362H
.word 0FE50H
.word 0FB53H
.word 0FA9BH
.word 0FBCBH
.word 0FE19H
.word 097H
.word 0274H
.word 0333H
.word 02C0H
.word 016FH
.word 0FFCDH
.word 0FE6EH
.word 0FDC2H
.word 0FDEEH
.word 0FECDH
.word 0H
.word 0117H
.word 01B4H
.word 01ABH
.word 010EH
.word 01FH
Program Description:
1. Make all the x(n) zero initially
2. Read the data from the adc.
3. Store the adc data in x(0)
4. Make the pointer to point the x(n_end)
5. Perform the convolution of x(n) and the coefficients h(n) using
MACD instruction.
6. Send the convolution output to the dac
7. Repeat from step 2.
.mmregs
.text
START:
STM #01h,ST0 ;intialize the data page pointer
RSBX CPL ;Make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
*****loop to make all x(n) zero initially*****
STM #150H,AR1 ;initialize ar1 to point to x(n)
LD #0H,A ;make acc zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero
*****to read the adc data and store it in x(0)*****
LOOP:
PORTR 06,0 ;start of conversion
CHK_BUSY:
; PORTR 07,0 ;check for busy
; BITF 0,#20H
; BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc
XOR #0800H,A ;recorrect the 2's complement adc data
SUB #800H,A ;remove the dc shift
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n_end)
*****start of convolution*****
LD #0H,A ;sum is 0 initially
RPT #33H
MACD *AR2-,TABLE,A ;convolution process
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift to the convolution output
STL A,1H
PORTW 1H,04H ;send the output to the dac
B LOOP
TABLE:
.word 0FCEFH
.word 62H
.word 0FD50H
.word 14AH
.word 0FE1BH
.word 28FH
.word 0FF11H
.word 3E5H
.word 0FFD1H
.word 4ECH
.word 0FFF5H
.word 54FH
.word 0FF28H
.word 4DAH
.word 0FD38H
.word 398H
.word 0FA2EH
.word 1DDH
.word 0F627H
.word 55H
.word 0F131H
.word 4BH
.word 0EA6DH
.word 568H
.word 0D950H
.word 459EH
.word 459EH
.word 0D950H
.word 568H
.word 0EA6DH
.word 4BH
.word 0F131H
.word 55H
.word 0F627H
.word 1DDH
.word 0FA2EH
.word 398H
.word 0FD38H
.word 4DAH
.word 0FF28H
.word 54FH
.word 0FFF5H
.word 4ECH
.word 0FFD1H
.word 3E5H
.word 0FF11H
.word 28FH
.word 0FE1BH
.word 14AH
.word 0FD50H
.word 62H
.word 0FCEFH
Program Description:
1. Make all the x(n) zero initially
2. Read the data from the adc.
3. Store the adc data in x(0)
4. Make the pointer to point the x(n_end)
5. Perform the convolution of x(n) and the coefficients h(n) using
MACD instruction.
6. Send the convolution output to the dac
7. Repeat from step 2.
.mmregs
.text
START:
STM #01h,ST0 ;intialize the data page pointer
RSBX CPL ;Make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
*****loop to make all x(n) zero initially*****
STM #150H,AR1 ;initialize ar1 to point to x(n)
LD #0H,A ;make acc zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero
*****to read the adc data and store it in x(0)*****
LOOP:
PORTR 06,0 ;start of conversion
CHK_BUSY:
PORTR 07,0 ;check for busy
BITF 0,#20H
BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc
XOR #0800H,A ;recorrect the 2's complement adc data
SUB #800H,A ;remove the dc shift
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n_end)
;*****start of convolution*****
LD #0H,A ;sum is 0 initially
RPT #33H
MACD *AR2-,TABLE,A ;convolution process
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift to the convolution output
STL A,1H
PORTW 1H,04H ;send the output to the dac
B LOOP
TABLE:
.word 208H
.word 257H
.word 218H
.word 143H
.word 0H
.word 0FE9EH
.word 0FD7AH
.word 0FCE7H
.word 0FD08H
.word 0FDD1H
.word 0FEECH
.word 0FFE4H
.word 3DH
.word 0FFA1H
.word 0FDFCH
.word 0FB8FH
.word 0F8ECH
.word 0F6D4H
.word 0F608H
.word 0F713H
.word 0FA21H
.word 0FEE6H
.word 4A7H
.word 0A60H
.word 0EF8H
.word 1187H
.word 1187H
.word 0EF8H
.word 0A60H
.word 4A7H
.word 0FEE6H
.word 0FA21H
.word 0F713H
.word 0F608H
.word 0F6D4H
.word 0F8ECH
.word 0FB8FH
.word 0FDFCH
.word 0FFA1H
.word 3DH
.word 0FFE4H
.word 0FEECH
.word 0FDD1H
.word 0FD08H
.word 0FCE7H
.word 0FD7AH
.word 0FE9EH
.word 0H
.word 143H
.word 218H
.word 257H
.word 208H
Program Description:
1. Make all the x(n) zero initially
2. Read the data from the adc.
3. Store the adc data in x(0)
4. Make the pointer to point the x(n_end)
5. Perform the convolution of x(n) and the coefficients h(n) using
MACD instruction.
6. Send the convolution output to the dac
7. Repeat from step 2.
.mmregs
.text
START:
STM #01h,ST0 ;intialize the data page pointer
RSBX CPL ;Make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
;*****loop to make all x(n) zero initially*****
STM #150H,AR1 ;initialize ar1 to point to x(n)
LD #0H,A ;make acc zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero
;*****to read the adc data and store it in x(0)*****
LOOP:
PORTR 06,0 ;start of conversion
CHK_BUSY:
PORTR 07,0 ;check for busy
BITF 0,#20H
BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc
XOR #0800H,A ;recorrect the 2's complement adc data
SUB #800H,A ;remove the dc shift
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n_end)
;*****start of convolution*****
LD #0H,A ;sum is 0 initially
RPT #33H
MACD *AR2-,TABLE,A ;convolution process
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift to the convolution output
STL A,1H
PORTW 1H,04H ;send the output to the dac
B LOOP
TABLE:
.word 0FEB9H
.word 14EH
.word 0FDA1H
.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
RESULT:
Thus the asm program for the design of FIR filter was plotted successfully.
Ex. No: 11
Date:
DESIGN OF IIR FILTER
AIM:
To write a ASM program for the design of IIR Filter, also plots the magnitude
responses for the same.
APPARATUS REQUIRED:
RESULT:
Thus the asm program for the design of IIR filter were plotted successfully.
Ex No: 12
Date :
DECIMATION
PROGRAM DESCRIPTION:
In this program the sampling rate at the input is 40Khz. This input sampling rate is reduced by a
factor of 2 at the output. For this, the auxillary register AR3 is loaded with the value of 2 initially. Then
the output of the FIR filter is sent out to the dac only once out of 2 outputs.
i.e whenever the register AR3 becomes 0, the filter output is sent to the dac and reloaded with 2. where
2 is the decimation factor of this decimator.
B3 .SET 0F000H
B2 .SET 0F00H
B1 .SET 00F0H
B0 .SET 000FH
DATA .SET 50H
TXD .SET 51H
.mmregs
.text
START:
STM #01h,ST0 ;initialize the data page pointer
RSBX CPL ;make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
NOP
NOP
STM #150H,AR1 ;initialize AR1 with x(n)
LD #0H,A ;make acc. zero
RPT #34H
STL A,*AR1+ ;make all x(n) zero
STM #2H,AR3 ;load the decimation factor
REPDECI:
STM #0A200H,AR4
STM #2159,AR5
CHK_BUSY:
PORTR 07,0 ; check for busy
BITF 0,#20H
BC CHK_BUSY,TC
PORTR 04,0 ;read the adc data
LD 0,A
AND #0FFFH,A ;AND adc data with 0fffh for 12 bit adc.
XOR #0800H,A ;recorrect the 2's complement adc output.
SUB #800H,A ;remove the dc shift.
STM #150H,AR1 ;initialize ar1 with x(0)
STL A,*AR1 ;store the adc data in x(0)
STM #183H,AR2 ;initialize ar2 with x(n)
*****start of convolution*****
LD #0H,A ;initialize the sum as zero
RPT #33H
MACD *AR2-,TABLE,A ;convolution operation
STH A,1,0H
LD 0H,A
ADD #800H,A ;add the dc shift
STL A,1H
BANZ NO_OUT,*AR3- ;send the filter output only if ar3 is 0.
PORTW 1H,04H
STL A,*AR4+
STM #2H,AR3 ;reinitialize ar3 with decimation factor.
B DECI_END
B LOOP
NO_OUT:
NOP
NOP
NOP
B LOOP ;repeat the above.
DECI_END:
BANZ LOOP,*AR5
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
STM #0A200H,AR4
STM #359,AR5
REPSER:
LD *AR4+,A
SUB #2048,A
STL A,DATA
CALL SERIAL
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
BANZ REPSER,*AR5-
STM #01h,ST0 ;initialize the data page pointer
RSBX CPL ;make the processor to work using DP
RSBX FRCT ;reset the fractional mode bit
NOP
NOP
NOP
NOP
B REPDECI
HLT: B HLT
SERIAL:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD #25H,A
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B3,A ;1st digit (from msb)
SFTL A,-12
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B2,A ;1st digit (from msb)
SFTL A,-8
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B1,A ;1st digit (from msb)
SFTL A,-4
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD DATA,A
AND #B0,A ;1st digit (from msb)
CALL HEXASC
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD #24H,A
CALL TXDATA
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
RET
HEXASC:
ADD #30H,A
LD A,B
SUB #3AH,B
BC LESS9,BLT
ADD #7H,A
LESS9:
RET
TXDATA:
CALL 8C69H ;8C38H for 5416 mode 1
SSBX INTM
rpt #2ffh ;delay
nop
RET
TABLE:
.word 01FH
.word 010EH
.word 01ABH
.word 01B4H
.word 0117H
.word 0H
.word 0FECDH
.word 0FDEEH
.word 0FDC2H
.word 0FE6EH
.word 0FFCDH
.word 016FH
.word 02C0H
.word 0333H
.word 0274H
.word 097H
.word 0FE19H
.word 0FBCBH
.word 0FA9BH
.word 0FB53H
.word 0FE50H
.word 0362H
.word 09C5H
.word 01048H
.word 01599H
.word 01895H
.word 01895H
.word 01599H
.word 01048H
.word 09C5H
.word 0362H
.word 0FE50H
.word 0FB53H
.word 0FA9BH
.word 0FBCBH
.word 0FE19H
.word 097H
.word 0274H
.word 0333H
.word 02C0H
.word 016FH
.word 0FFCDH
.word 0FE6EH
.word 0FDC2H
.word 0FDEEH
.word 0FECDH
.word 0H
.word 0117H
.word 01B4H
.word 01ABH
.word 010EH
.word 01FH
RESULT:
Thus the asm program for the design of decimated were successfully.
VIVA QUESTIONS
1. What is MATLAB?
2. What are the applications of MATLAB?
3. State sampling theorem.
4. What is energy signal? How to calculate energy of a signal?
5.What is power signal? How to calculate power of a signal?
6.Explain linear convolution and circular convolution.
7.What are Fourier series and Fourier transform?
8.Differentiate between DTFT and DFT. Why it is advantageous to use DFT in computers rather than
DTFT?
9.What is meant by correlation?
10.Differentiate between IIR filters and FIR filters.
11.What is the procedure to design a digital Butterworth filter?
12.What is the difference between Butterworth, Chebyshev I and Chebyshev II filters?
13.What is a Digital Signal Processor (DSP)?
14.Differentiate between floating point DSP and fixed point DSP.