Lab Manual
Lab Manual
Lab Manual
USING MATLAB
1.
2.
Generation of Signals
Linear and circular
convolution
of
sequences
3.
4.
5.
6.
7.
two
1. MATLAB PROGRAMS
1. LINEAR CONVOLUTION
clc;clear all;close all;
x=input('ENTER THE FIRST SEQUENCE ');
h=input('ENTER THE SECOND SEQUENCE ');
y=conv(x,h);
stem(y);
xlabel('Amplitude---->');
ylabel('time----->');
title('LINEAR CONVOLUTION');
2. Program illustrates the design of a Butterworth bandstop filter.
% Program P7_1
% Design of a Butterworth Bandstop Digital Filter
Ws = [0.4 0.6]; Wp = [0.3 0.7]; Rp = 0.4; Rs = 50;
% Estimate the Filter Order
[N1, Wn1] = buttord(Wp, Ws, Rp, Rs);
% Design the Filter
[num,den] = butter(N1,Wn1,stop);
% Display the transfer function
disp(Numerator coefficients are );disp(num);
disp(Denominator coefficients are );disp(den);
% Compute the gain response
[g,w] = gain(num,den);
% Plot the gain response
plot(w/pi,g);grid
axis([0 1 -60 5]);
xlabel(\omega /\pi); ylabel(Gain, dB);
title(Gain Response of a Butterworth Bandstop Filter);
4. Program illustrates the design of a causal IIR filter, its simulation in transposed
Direct Form II, and its application in filtering a signal.
% Program P8_3
% Illustration of Filtering by an IIR Filter
%
clf;
% Generate the input sequence
k = 0:50;
w2 = 0.7*pi;w1 = 0.2*pi;
x1 = 1.5*cos(w1*k); x2 = 2*cos(w2*k);
x = x1+x2;
% Determine the filter transfer function
[N, Wn] = ellipord(0.25, 0.55, 0.5, 50);
[num, den] = ellip(N,0.5, 50,Wn);
% Generate the output sequence
y = filter(num,den,x);
5. Program up-sampler.
% Illustration of Up-Sampling by an Integer Factor
%
clf;
n = 0:50;
x = sin(2*pi*0.12*n);
y = zeros(1, 3*length(x));
y([1: 3: length(y)]) = x;
subplot(2,1,1)
stem(n,x);
title(Input Sequence);
xlabel(Time index n);ylabel(Amplitude);
subplot(2,1,2)
stem(n,y(1:length(x)));
title(Output Sequence);
xlabel(Time index n);ylabel(Amplitude);
subplot(2,1,2)
stem(n, y); axis([0 50 -1.2 1.2]);
title(Output Sequence);
xlabel(Time index n);
ylabel(Amplitude);
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gain in db....>');
xlabel('(a) normalised frequency>');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b) normalised frequency');
ylabel('phase in radian');
DSP PROGRAMS
1.
con1
con2
con3
con4
con5
con6
fs
fm
pi
ms
mx
CNT
start
.include "5416_iv.asm"
.def start
.data
.word 0555h ;1/3!
.word 0044h ;1/5!
.word 0001h ;1/7!
.word 0fffh ;1/2!
.word 0155h ;1/4!
.word 000bh ;1/6!
.word 7d00h
.word 07cfh
.word 0c8ch
.word 0
.word 0
.word 256
.text
LD #con1,DP
RSBX INTM
LD
#022Bh,0,A
STLM A,PMST
;SPCR1 reset
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#0020h,McBSP0_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP0_SPSA
;PCR
#0A00h,McBSP0_SPSD
STM
STM
RCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;RCR1
;32 BITS WORDSIZE
STM RCR2,McBSP0_SPSA
;RCR2
STM #0001h,McBSP0_SPSD
STM
STM
XCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCR2
STM SRGR1,McBSP0_SPSA
;SRGR1
STM #000Bh,McBSP0_SPSD
;--17
STM
STM
SRGR2,McBSP0_SPSA
#303Fh,McBSP0_SPSD
;SRGR2
STM
STM
MCR1,McBSP0_SPSA
#0001h,McBSP0_SPSD
;MCR1
STM
STM
MCR2,McBSP0_SPSA
#0000h,McBSP0_SPSD
;MCR2
STM
STM
RCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERB
STM
STM
RCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERA
STM
STM
XCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCERB
STM
STM
XCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCERA
STM
STM
SPCR1,McBSP0_SPSA
#0091h,McBSP0_SPSD
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#00A1h,McBSP0_SPSD
;--------------------------McBSP1 Initializations-----------------------------STM
STM
SPCR1,McBSP1_SPSA
#0090h,McBSP1_SPSD
;SPCR1 reset
STM
STM
SPCR2,McBSP1_SPSA
#0020h,McBSP1_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP1_SPSA
;PCR
#0A00h,McBSP1_SPSD
STM
STM
RCR1,McBSP1_SPSA
#00A0h,McBSP1_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP1_SPSA
#0000h,McBSP1_SPSD
;RCR2
STM
STM
XCR1,McBSP1_SPSA
#00A0h,McBSP1_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP1_SPSA
#0000h,McBSP1_SPSD
;XCR2
STM
STM
SRGR1,McBSP1_SPSA
#0002h,McBSP1_SPSD
;SRGR1
;--5
STM
SRGR2,McBSP1_SPSA
;SRGR2
NOP
NOP
STM
#303Bh,McBSP1_SPSD
STM
STM
MCR1,McBSP1_SPSA
#0001h,McBSP1_SPSD
;MCR1
STM
STM
MCR2,McBSP1_SPSA
#0000h,McBSP1_SPSD
;MCR2
STM
STM
RCERB,McBSP1_SPSA
#0001h,McBSP1_SPSD
;RCERB
STM RCERA,McBSP1_SPSA
STM #0001h,McBSP1_SPSD
;RCERA
STM
STM
XCERB,McBSP1_SPSA
#0001h,McBSP1_SPSD
;XCERB
STM
STM
XCERA,McBSP1_SPSA
#0001h,McBSP1_SPSD
;XCERA
STM
STM
SPCR1,McBSP1_SPSA
#0091h,McBSP1_SPSD
NOP
NOP
STM
STM
SPCR2,McBSP1_SPSA
#00A1h,McBSP1_SPSD
INTM
LD
#02Fh,0,A
STLM A,IMR
STM
STM
#0h,McBSP0_DXR1
#0h,McBSP0_DXR2
STM
STM
#0007h,GPIOCR
#0003h,GPIOSR
STM
STM
#SPCR2,McBSP1_SPSA
#00E1h,McBSP1_SPSD
NOP
;Mclk
STM
#0007h,GPIOSR
STM #SPCR2,McBSP0_SPSA
STM #00E1h,McBSP0_SPSD
;Sclk & Fs
;---------------------------------------------------------------------------STM #256,BK
STM #2000h,AR5
SSBX SXM
WAIT
NOP
NOP
LD CNT,A
BC WAVE,AEQ
NOP
B
WAIT
_XINT0_ISR
LD
STLM
STLM
*AR5+%,A
A,McBSP0_DXR1
A,McBSP0_DXR2
LD CNT,A
SUB #1,A
STL A,CNT
RETE
WAVE
LD #0,A
STLM A,IMR
LD #con1,DP
STM #1508h,AR2
LD fm,T
MPY *AR2,A
STM #1506h,AR2
RPT #15
SUBC *AR2,A
STL A,ms
;COSINE APPROX
LD ms,T ;X
STM #1509h,AR2
MPY *AR2+,A
SFTA A,-5
STL A,*AR2 ;X^2
STM #150Ah,AR2
MPY *AR2+,A ;X^3
SFTA A,-9
STL A,*AR2
STM #150Bh,AR2
MPY *AR2+,A ;X^4
SFTA A,-9
STL A,*AR2
STM #150Ch,AR2
MPY *AR2+,A ;X^5
SFTA A,-9
STL A,*AR2
STM #150Dh,AR2
MPY *AR2+,A ;X^6
SFTA A,-9
STL A,*AR2
STM #150Eh,AR2
MPY *AR2+,A ;X^7
SFTA A,-9
STL A,*AR2
;cos x = 1 - x ^2 / 2! + x^4 / 4! - x^6 / 6! + ....
STM #150Ah,AR2
LD con4,T
MPY *AR2,A
SFTA A,-13
LD #1FFFh,B
SUB A,B
STM #150ch,AR2
LD con5,T
MPY *AR2,A
SFTA A,-13
ADD A,B
STM #150eh,AR2
LD con6,T
MPY *AR2,A
SFTA A,-13
SUB A,B
STM #1600h,AR1
STL B,*AR1+
LD #0,A
RPT #1
STL A,*AR1+
;sin x = x - x ^3 / 3! + x^5 / 5! - x^7 / 7! + ....
STM #150Bh,AR2
LD con1,T
MPY *AR2,A
SFTA A,-13
STM #1509h,AR2
LD *AR2,4,B
SUB A,B
STM #150Dh,AR2
LD con2,T
MPY *AR2,A
SFTA A,-13
ADD A,B
STM #150Fh,AR2
LD con3,T
MPY *AR2,A
SFTA A,-13
SUB A,B
STL B,*AR1
;WAVE GENERATION
STM #2000h,AR7
STM #256,BRC
RPTB wave1
STM #1602h,AR2
STM #1600h,AR3
MPY *AR2,*AR3,A
SFTA A,-12
STM #1602h,AR4
STM #1601h,AR5
MVDD *AR4,*AR5
STM #1603h,AR6
LD *AR6,B
SUB B,A
STL A,*AR7+
STM #1602h,AR6
STL A,*AR6
STM #1601h,AR4
STM #1603h,AR5
MVDD *AR4,*AR5
wave1
NOP
NOP
STM #2000h,AR5
NOP
NOP
LD #256,A
STL A,CNT
NOP
NOP
LD
#02Fh,0,A
STLM A,IMR
NOP
NOP
B WAIT
POS
NEG
P
N
CNT
E
start
LD
;
#POS,DP
Data Page Pointer
RSBX INTM
LD
#022Bh,0,A
STLM A,PMST
;SPCR1 reset
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#0020h,McBSP0_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP0_SPSA
;PCR
#0A00h,McBSP0_SPSD
STM
STM
RCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCR2
STM
STM
XCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;XCR1
;32 BITS WORDSIZE
STM XCR2,McBSP0_SPSA
;XCR2
STM #0001h,McBSP0_SPSD
STM SRGR1,McBSP0_SPSA
;SRGR1
STM #0017h,McBSP0_SPSD
;--17
STM
STM
SRGR2,McBSP0_SPSA
#303Fh,McBSP0_SPSD
;SRGR2
STM
STM
MCR1,McBSP0_SPSA
#0001h,McBSP0_SPSD
;MCR1
STM
STM
MCR2,McBSP0_SPSA
#0000h,McBSP0_SPSD
;MCR2
STM
STM
RCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERB
STM
STM
RCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERA
STM XCERB,McBSP0_SPSA
STM #0001h,McBSP0_SPSD
STM
STM
XCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
STM
STM
SPCR1,McBSP0_SPSA
#0091h,McBSP0_SPSD
;XCERB
;XCERA
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#00A1h,McBSP0_SPSD
;--------------------------McBSP2 Initializations-----------------------------STM
STM
NOP
SPCR1,McBSP2_SPSA
#0090h,McBSP2_SPSD
;SPCR1 reset
NOP
STM
STM
SPCR2,McBSP2_SPSA
#0020h,McBSP2_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP2_SPSA
;PCR
#0A00h,McBSP2_SPSD
STM
STM
RCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;RCR2
STM
STM
XCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;XCR2
STM
STM
SRGR1,McBSP2_SPSA
#0005h,McBSP2_SPSD
;SRGR1
;--5
STM
STM
SRGR2,McBSP2_SPSA
#303Bh,McBSP2_SPSD
;SRGR2
STM
STM
MCR1,McBSP2_SPSA
#0001h,McBSP2_SPSD
;MCR1
STM
STM
MCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;MCR2
STM
STM
RCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERB
STM
STM
RCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERA
STM
STM
XCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERB
STM
STM
XCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERA
STM
STM
SPCR1,McBSP2_SPSA
#0091h,McBSP2_SPSD
NOP
NOP
STM
STM
SPCR2,McBSP2_SPSA
#00A1h,McBSP2_SPSD
INTM
LD
#027h,0,A
STLM A,IMR
STM #0h,McBSP0_DXR1
STM #0h,McBSP0_DXR2
STM
STM
#0007h,GPIOCR
#0003h,GPIOSR
STM
STM
#SPCR2,McBSP2_SPSA
#00E1h,McBSP2_SPSD
NOP
STM
#0007h,GPIOSR
STM
STM
#SPCR2,McBSP0_SPSA
#00E1h,McBSP0_SPSD
;Mclk
;Sclk & Fs
WAIT
NOP
NOP
LD CNT,B
BC WAVE,BEQ
NOP
B
WAIT
_XINT0_ISR
NOP
NOP
LD
*AR4+%,A
CODEC
STLM A,McBSP0_DXR1
STLM A,McBSP0_DXR2
LD CNT,B
SUB #1h,B
STL B,CNT
;Count=Count-1
RETE
WAVE
LD #128,A
STL A,CNT
NOP
NOP
PORTW E,0
LD #0h,A
STLM A,IMR
STM #1504h,AR2
STM #1505h,AR3
STM #2000h,AR4
STM #6,BRC
RPTB L1
LD POS,A
STL A,P
LD NEG,B
STL B,N
L2
LD *AR2,A
STL A,*AR4+
LD P,B
SUB #1h,B
STL B,P
BC L2,BNEQ
L3
LD *AR3,A
STL A,*AR4+
LD N,B
SUB #1,B
STL B,N
BC L3,BNEQ
L1
NOP
NOP
LD #027h,A
STLM A,IMR
STM #2000h,AR4
;Initialization of Interrupts
;Interrupt Mask Register
;Output Memory
WAIT
COEFF
.word 086eh,0b9eh,0e5fh,1064h,1176h,1064h,0e5fh,0b9eh,086eh
;Filter Co-efficients in data ;
memory
.text
start
LD
#COEFF,DP
RSBX INTM
LD
#022Bh,0,A
STLM A,PMST
;Variable Declaration
;SPCR1 reset
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#0020h,McBSP0_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP0_SPSA
;PCR
#0A00h,McBSP0_SPSD
STM
STM
RCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCR2
STM
STM
XCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCR2
STM
STM
SRGR1,McBSP0_SPSA
#000Bh,McBSP0_SPSD
;SRGR1
;--17
STM
STM
SRGR2,McBSP0_SPSA
#303Fh,McBSP0_SPSD
;SRGR2
STM
MCR1,McBSP0_SPSA
;MCR1
STM
#0001h,McBSP0_SPSD
STM
STM
MCR2,McBSP0_SPSA
#0000h,McBSP0_SPSD
STM
STM
RCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERB
STM
STM
RCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERA
STM
STM
XCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCERB
STM
STM
XCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCERA
STM
STM
SPCR1,McBSP0_SPSA
#0091h,McBSP0_SPSD
;MCR2
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#00A1h,McBSP0_SPSD
;--------------------------McBSP2 Initializations-----------------------------STM
STM
SPCR1,McBSP2_SPSA
#0090h,McBSP2_SPSD
;SPCR1 reset
STM
STM
SPCR2,McBSP2_SPSA
#0020h,McBSP2_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP2_SPSA
;PCR
#0A00h,McBSP2_SPSD
STM
STM
RCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;RCR2
NOP
NOP
STM
STM
XCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;XCR2
STM
STM
SRGR1,McBSP2_SPSA
#0002h,McBSP2_SPSD
;SRGR1
;--5
STM
STM
SRGR2,McBSP2_SPSA
#303Bh,McBSP2_SPSD
;SRGR2
STM
STM
MCR1,McBSP2_SPSA
#0001h,McBSP2_SPSD
;MCR1
STM
STM
MCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;MCR2
STM
STM
RCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERB
STM
STM
RCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERA
STM
STM
XCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERB
STM
STM
XCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERA
STM
STM
SPCR1,McBSP2_SPSA
#0091h,McBSP2_SPSD
NOP
NOP
STM
STM
SPCR2,McBSP2_SPSA
#00A1h,McBSP2_SPSD
INTM
LD
#02Fh,0,A
STLM A,IMR
STM
STM
#0h,McBSP0_DXR1
#0h,McBSP0_DXR2
STM
STM
#0007h,GPIOCR
#0003h,GPIOSR
STM
STM
#SPCR2,McBSP2_SPSA
#00E1h,McBSP2_SPSD
NOP
STM
#0007h,GPIOSR
STM
STM
#SPCR2,McBSP0_SPSA
#00E1h,McBSP0_SPSD
;Mclk
;Sclk & Fs
SSBX SXM
RSBX FRCT
RSBX OVM
STM #150,BK
STM #1600h,AR5
STM #1700h,AR6
LD
STM
RPT
STL
STM
WAIT
#0h,A
#1900h,AR3
#10
A,*AR3+
#1900h,AR3
NOP
NOP
B
WAIT
_XINT0_ISR
LDM
McBSP0_DRR1,A
CODEC)
STL
A,0,*AR5
(1600h)
STM #1900h,AR3
MVDD *AR5,*AR3
to Temporary Buffer
RPT #7
MAR *AR3+
RPT #8
y(n)=x(k)*h(n-k)
MACD *AR3-,COEFF,A
SFTA A,-15
STLM A,McBSP0_DXR1
STLM A,McBSP0_DXR2
STL
MAR
RETE
A,0,*AR6+%
*AR5+%
bpole
azero
xin
xout
yin
S1
E
.include "5416_IV.asm"
.def start
.data
.word 97e3h,154fh
.word 0b4ch,1698h,0b4ch
.word 0,0
.word 0
.word 0
.word 00
.word 45h
.text
start
LD
#bpole,DP
RSBX INTM
LD
#022Bh,0,A
STLM A,PMST
;Variable Declaration
;SPCR1 reset
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#0020h,McBSP0_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP0_SPSA
;PCR
#0A00h,McBSP0_SPSD
STM
STM
RCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCR2
STM
STM
XCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCR2
STM
STM
SRGR1,McBSP0_SPSA
#000Bh,McBSP0_SPSD
;SRGR1
;--17
STM
STM
SRGR2,McBSP0_SPSA
#303Fh,McBSP0_SPSD
;SRGR2
STM
STM
MCR1,McBSP0_SPSA
#0001h,McBSP0_SPSD
;MCR1
STM
STM
MCR2,McBSP0_SPSA
#0000h,McBSP0_SPSD
;MCR2
STM
STM
RCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERB
STM
STM
RCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERA
STM
STM
XCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCERB
STM
STM
XCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;XCERA
STM
STM
SPCR1,McBSP0_SPSA
#0091h,McBSP0_SPSD
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#00A1h,McBSP0_SPSD
;--------------------------McBSP2 Initializations-----------------------------STM
STM
SPCR1,McBSP2_SPSA
#0090h,McBSP2_SPSD
;SPCR1 reset
SPCR2,McBSP2_SPSA
;SPCR2 reset
NOP
NOP
STM
STM
#0020h,McBSP2_SPSD
STM
STM
PCR,McBSP2_SPSA
;PCR
#0A00h,McBSP2_SPSD
STM
STM
RCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;RCR2
STM
STM
XCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;XCR2
STM
STM
SRGR1,McBSP2_SPSA
#0002h,McBSP2_SPSD
;SRGR1
;--5
STM
STM
SRGR2,McBSP2_SPSA
#303Bh,McBSP2_SPSD
;SRGR2
STM
STM
MCR1,McBSP2_SPSA
#0001h,McBSP2_SPSD
;MCR1
STM
STM
MCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;MCR2
STM
STM
RCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERB
STM
STM
RCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERA
STM
STM
XCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERB
STM
STM
XCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERA
STM
STM
SPCR1,McBSP2_SPSA
#0091h,McBSP2_SPSD
NOP
NOP
STM
STM
SPCR2,McBSP2_SPSA
#00A1h,McBSP2_SPSD
INTM
LD
#02Fh,0,A
STLM A,IMR
STM
STM
#0h,McBSP0_DXR1
#0h,McBSP0_DXR2
STM
STM
#0007h,GPIOCR
#0003h,GPIOSR
STM
STM
#SPCR2,McBSP2_SPSA
#00E1h,McBSP2_SPSD
NOP
STM
#0007h,GPIOSR
STM
STM
#SPCR2,McBSP0_SPSA
#00E1h,McBSP0_SPSD
;Mclk
;Sclk & Fs
SSBX SXM
RSBX FRCT
RSBX OVM
STM
STM
STM
STM
STM
WAIT
NOP
NOP
NOP
NOP
NOP
#128,BK
#1600h,AR4
#1700h,AR1
#1400h,AR5
#1500h,AR6
WAIT
_XINT0_ISR
LDM
LDM
McBSP0_DRR1,A
McBSP0_DRR2,A
STM
STM
#1800h,AR3
#1300h,AR7
STL
NOP
NOP
LD
STL
A,0,xin
NOP
NOP
STM
xin,A
A,0,*AR4+%
xout,AR2
RPT #02h
MACD *AR2-,azero,A
SFTA A,-15
STL
A,0,*AR6
MVDD *AR5,*AR3+
LD
#bpole,DP
RPT
#01h
MACD *AR3-,bpole,A
SFTA
STL
NOP
NOP
LD
LD
SUB
STL
A,-15
A,0,*AR7
*AR6,A
*AR7,B
B,0,A
A,0,*AR5
;Zero Output
;Transfer IIR Output to Temp Buffer
;Pole Output
STL
A,0,*AR1+%
STLM A,McBSP0_DXR1
STLM A,McBSP0_DXR2
RETE
5. FFT DESIGN
R1
I1
stages
grp
grp1
but
but1
R
I
A1
sizetw
sizein
bitr
shi
CNT
E
start
.include "twi.asm"
.include "twr.asm"
.include "cos.asm"
.include "5416_iv.asm"
.def start
.data
.word 0h
;Variables
.word 0h
.word 7h
.word 64
.word 0h
.word 1h
.word 0h
.word 0h
.word 0h
.word 0h
.word 40h
.word 80h
.word 40h
.word 7Fh
.word 128
.word 45h
.text
LD
#R1,DP
RSBX INTM
LD
#022Bh,0,A
STLM A,PMST
INTM
STM
STM
SPCR1,McBSP0_SPSA
#0090h,McBSP0_SPSD
;SPCR1 reset
STM
STM
SPCR2,McBSP0_SPSA
#0020h,McBSP0_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP0_SPSA
;PCR
#0A00h,McBSP0_SPSD
STM
STM
RCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCR2
STM
STM
XCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;XCR1
;32 BITS WORDSIZE
NOP
NOP
STM XCR2,McBSP0_SPSA
;XCR2
STM #0001h,McBSP0_SPSD
STM SRGR1,McBSP0_SPSA
;SRGR1
STM #0017h,McBSP0_SPSD
;--17
STM
STM
SRGR2,McBSP0_SPSA
#303Fh,McBSP0_SPSD
;SRGR2
STM
STM
MCR1,McBSP0_SPSA
#0001h,McBSP0_SPSD
;MCR1
STM
STM
MCR2,McBSP0_SPSA
#0000h,McBSP0_SPSD
;MCR2
STM
STM
RCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERB
STM
STM
RCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERA
STM XCERB,McBSP0_SPSA
STM #0001h,McBSP0_SPSD
;XCERB
STM
STM
XCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
STM
STM
SPCR1,McBSP0_SPSA
#0091h,McBSP0_SPSD
;XCERA
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#00A1h,McBSP0_SPSD
;--------------------------McBSP2 Initializations-----------------------------STM
STM
SPCR1,McBSP2_SPSA
#0090h,McBSP2_SPSD
;SPCR1 reset
STM
STM
SPCR2,McBSP2_SPSA
#0020h,McBSP2_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP2_SPSA
;PCR
#0A00h,McBSP2_SPSD
STM
STM
RCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;RCR2
STM
STM
XCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;XCR2
STM
STM
SRGR1,McBSP2_SPSA
#0005h,McBSP2_SPSD
;SRGR1
;--5
STM
STM
SRGR2,McBSP2_SPSA
#303Bh,McBSP2_SPSD
;SRGR2
STM
STM
MCR1,McBSP2_SPSA
#0001h,McBSP2_SPSD
;MCR1
NOP
NOP
STM
STM
MCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;MCR2
STM
STM
RCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERB
STM
STM
RCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERA
STM
STM
XCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERB
STM
STM
XCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERA
STM
STM
SPCR1,McBSP2_SPSA
#0091h,McBSP2_SPSD
STM
STM
SPCR2,McBSP2_SPSA
#00A1h,McBSP2_SPSD
NOP
NOP
INTM
LD
#017h,0,A
STLM A,IMR
STM #0h,McBSP0_DXR1
STM #0h,McBSP0_DXR2
STM
STM
#0007h,GPIOCR
#0003h,GPIOSR
STM
STM
#SPCR2,McBSP2_SPSA
#00E1h,McBSP2_SPSD
NOP
STM
#0007h,GPIOSR
STM
STM
#SPCR2,McBSP0_SPSA
#00E1h,McBSP0_SPSD
;Mclk
;Sclk & Fs
;---------------------------------------------------------------------------;-----------------------------Program Starts---------------------STM
STM
SSBX SXM
RSBX OVM
LD
#0h,0,A
RPT #127
STL A,*AR1+
STM #1800h,AR1
STM
WAIT
#3500h,AR7
NOP
NOP
LD CNT,B
BC FFT,BEQ
NOP
NOP
B
WAIT
_RINT0_ISR
PSHM AL
PSHM AH
PSHM AG
PSHM BL
PSHM BH
PSHM BG
LD
*AR6+,0,A
STLM A,McBSP0_DXR1
STLM A,McBSP0_DXR2
LD
CNT,B
SUB #1h,0,B
STL
B,0,CNT
POPM BG
POPM BH
POPM BL
POPM AG
POPM AH
POPM AL
RETE
FFT
NOP
NOP
LD
#0,A
STLM A,IMR
STM
STM
#1000h,AR6
#1800h,AR1
STM
STM
#2000h,AR4
#1000h,AR3
RPT #127
MVDD *AR4+,*AR3+
LD
#R1,DP
NOP
LD
STL
NOP
#80h,A
A,CNT
PORTW E,0
;------------Bit Reversal----------------------;------------For 128 pt FFT The Index value is
128/2=64(40H)------------------STM
STM
#0040h,AR0 ;Index
#2400h,AR4 ;Bit reversed o/p
NOP
NOP
RPT #127
MVPD #2000h,*AR4+0B
;Bit Reversal
NOP
NOP
STM #2400h,AR5
LD #0h,0,A
STM #2800h,AR3
RPT #127
STL A,0,*AR3+
STM #3000h,AR3
STM #3400h,AR4
STM #40h,BK
;TWIDDLE REAL
;TWIDDLE IMAG
LD stages,0,A
LD grp,0,B
STL B,grp1
LD but,0,A
STM #2400h,AR5
STM #2800h,AR2
GU
LD #40h,B
STLM B,BK
LD but,0,A
STL A,but1
LD #0h,0,B
SUB A,0,B
STL B,A1
STM #3000h,AR3
STM #3400h,AR4
BU
LD #80h,B
STLM B,BK
LD
LD
STL
STL
*AR5,0,A
*AR2,0,B
A,0,R
B,0,I
LD but,0,A
STLM A,AR0
NOP
NOP
MAR *AR5+0%
MAR *AR2+0%
MPY
MPY
SUB
STH
*AR3,*AR5,A
*AR4,*AR2,B
B,0,A
A,R1
MPY
MPY
ADD
STH
*AR3,*AR2,A
*AR4,*AR5,B
A,0,B
B,I1
LD
LD
SUB
STL
R,-1,A
R1,0,B
B,0,A
A,*AR5
LD I,-1,A
LD I1,0,B
SUB B,0,A
STL A,*AR2
NOP
NOP
NOP
LD A1,0,B
STLM B,AR0
NOP
NOP
MAR *AR5+0%
MAR *AR2+0%
LD R,-1,A
LD R1,0,B
ADD B,0,A
STL A,*AR5+
LD I,-1,A
LD I1,0,B
ADD B,0,A
STL A,*AR2+ ;BUT
NOP
LD #40h,0,B
STLM B,BK
LD grp,0,A
STLM A,AR0
NOP
NOP
NOP
NOP
MAR *AR3+0%
MAR *AR4+0%
LD
SUB
STL
BC
but1,0,B
#1h,0,B
B,0,but1
BU,BNEQ
;;;;;Butterfly End
LD #80h,B
STLM B,BK
NOP
NOP
NOP
LD but,0,B
STLM B,AR0
NOP
NOP
MAR *AR5+0%
MAR *AR2+0%
LD
SUB
STL
BC
grp1,0,B
#1h,0,B
B,grp1
GU,BNEQ
;;;;;;;;Group End
NOP
LD but,0,B
SFTA B,1
STL B,but
STL B,but1
LD grp,0,B
SFTA B,-1
STL B,grp
STL B,grp1
LD stages,0,A
SUB #1h,0,A
STL A,stages
BC SU,ANEQ
LD
LD
;;;;;;;;;STAGES
#0h,0,A
#0h,0,B
VE
STM #2400h,AR3
STM #1800h,AR6
STM #7Fh,BRC
RPTB VE
LD *AR3+,A
ABS A
STL A,*AR6+
NOP
NOP
NOP
STM #1800h,AR6
LD
#0017h,A
STLM A,IMR
NOP
NOP
B
WAIT
6. FSK DESIGN
;PROGRAM STARTING ADDRESS
001000
;GRAPH STARTING ADDRESS
001700
;This program is to generate a sine wave from a look-up-table
;There are 16 sine wave samples that represent the 360 degrees of the sine wave starting
from S1
.include "5416_IV.asm"
.data
.word 40h
.word 0h
.word 0h
CNT
VAR
VAR2
.include "1000.asm"
.include "2000.asm"
.text
start
RSBX INTM
LD
#022Bh,0,A
STLM A,PMST
;------------------------Serial Port Initializations------------------------;--------------------------McBSP0 Initializations---------------------------SSBX INTM
STM SPCR1,McBSP0_SPSA
STM #0090h,McBSP0_SPSD
;SPCR1 reset
NOP
NOP
STM
STM
SPCR2,McBSP0_SPSA
#0020h,McBSP0_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP0_SPSA
;PCR
#0A00h,McBSP0_SPSD
STM
STM
RCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCR2
STM
STM
XCR1,McBSP0_SPSA
#00A0h,McBSP0_SPSD
;XCR1
;32 BITS WORDSIZE
STM XCR2,McBSP0_SPSA
;XCR2
STM #0001h,McBSP0_SPSD
STM SRGR1,McBSP0_SPSA
;SRGR1
STM #0017h,McBSP0_SPSD
;--17
STM
STM
SRGR2,McBSP0_SPSA
#303Fh,McBSP0_SPSD
;SRGR2
STM
STM
MCR1,McBSP0_SPSA
#0001h,McBSP0_SPSD
;MCR1
STM
STM
MCR2,McBSP0_SPSA
#0000h,McBSP0_SPSD
;MCR2
STM
STM
RCERB,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERB
STM
STM
RCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
;RCERA
STM XCERB,McBSP0_SPSA
STM #0001h,McBSP0_SPSD
STM
STM
XCERA,McBSP0_SPSA
#0001h,McBSP0_SPSD
STM
STM
SPCR1,McBSP0_SPSA
#0091h,McBSP0_SPSD
NOP
NOP
;XCERB
;XCERA
STM
STM
SPCR2,McBSP0_SPSA
#00A1h,McBSP0_SPSD
;--------------------------McBSP2 Initializations-----------------------------STM
STM
SPCR1,McBSP2_SPSA
#0090h,McBSP2_SPSD
;SPCR1 reset
STM
STM
SPCR2,McBSP2_SPSA
#0020h,McBSP2_SPSD
;SPCR2 reset
STM
STM
PCR,McBSP2_SPSA
;PCR
#0A00h,McBSP2_SPSD
STM
STM
RCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;RCR1
;32 BITS WORDSIZE
STM
STM
RCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;RCR2
STM
STM
XCR1,McBSP2_SPSA
#00A0h,McBSP2_SPSD
;XCR1
;32 BITS WORDSIZE
STM
STM
XCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;XCR2
STM
STM
SRGR1,McBSP2_SPSA
#0005h,McBSP2_SPSD
;SRGR1
;--5
STM
STM
SRGR2,McBSP2_SPSA
#303Bh,McBSP2_SPSD
;SRGR2
STM
STM
MCR1,McBSP2_SPSA
#0001h,McBSP2_SPSD
;MCR1
STM
STM
MCR2,McBSP2_SPSA
#0000h,McBSP2_SPSD
;MCR2
STM
STM
RCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;RCERB
STM
RCERA,McBSP2_SPSA
;RCERA
NOP
NOP
STM
#0001h,McBSP2_SPSD
STM
STM
XCERB,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERB
STM
STM
XCERA,McBSP2_SPSA
#0001h,McBSP2_SPSD
;XCERA
STM
STM
SPCR1,McBSP2_SPSA
#0091h,McBSP2_SPSD
STM
STM
SPCR2,McBSP2_SPSA
#00A1h,McBSP2_SPSD
NOP
NOP
INTM
LD
#02Fh,0,A
STLM A,IMR
STM #0h,McBSP0_DXR1
STM #0h,McBSP0_DXR2
STM
STM
#0007h,GPIOCR
#0003h,GPIOSR
STM
STM
#SPCR2,McBSP2_SPSA
#00E1h,McBSP2_SPSD
NOP
STM
#0007h,GPIOSR
STM
STM
#SPCR2,McBSP0_SPSA
#00E1h,McBSP0_SPSD
;Mclk
;Sclk & Fs
;---------------------------------------------------------------------------STM #64,BK
STM #1700h,AR6
STM #1650h,AR7
LD #0h,A
RPT #1000h
STL A,*AR7+
STM #1650h,AR7
WAIT
NOP
NOP
NOP
LD CNT,A
BC FSK,AEQ
NOP
NOP
B
WAIT
_XINT0_ISR
LDM
LDM
McBSP0_DRR1,A
McBSP0_DRR2,A
;R Channel
;L Channel
PORTR
0h,VAR
LD *AR6+%,A
STLM
STLM
A,McBSP0_DXR1
A,McBSP0_DXR2
LD
SUB
STL
CNT,A
#1h,A
A,CNT
RETE
FSK
LD
STL
#40h,A
A,CNT
STM
STM
STM
STM
#1650h,AR1
#1700h,AR2 ;OUTPUT
#1600h,AR3 ;1000Hz
#1610h,AR4 ;2000Hz
LD VAR,A
AND #00FFh,A
NOP
NOP
STL A,VAR
STL A,VAR2
HAI
LD
SUB
#8h,B;
#1h,B;
LD VAR2,A
AND #0001h,A
STL A,*AR1+
LD VAR2,B
SFTA B,-1
STL B,VAR2
BC
HAI,BNEQ;
;-------------------------------------------------------------------------------------------------------STM #1650h,AR1
STM #1700h,AR2
;OUTPUT
STM #1658h,AR5
LD #8h,B
L5
LD *AR1+,A
BC ZERO,AEQ
ONE
STM #1600h,AR3
RPT #7
MVDD *AR3+,*AR2+
B
STAT
ZERO
STM #1610h,AR4
RPT #7
MVDD *AR4+,*AR2+
STAT
SUB #1h,B
BC L5,BGT
PORTW
VAR,0h
WAIT