Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
COLLEGE OF ENGINEERING,ENATHI-630561
Affiliated to Anna University,Trichy
2011-2012
VI SEMESTER
B.Tech-INFORMATION TECHNOLOGY
Rectangular Window 21
5(B)
Hamming window 23
5(C)
Hanning window 25
5(D)
Kaiser window 27
5(E)
Calculation of FFT using MATLAB 29
6
Sampling and effect of aliasing 31
7
USING TMS320C5416 PROCESSOR: 34
Study of various Addressing Modes of DSP
8
using Simple Programming Examples
Calculation of FFT 37
9
Implementation of FIR Filter 41
10
Sampling of Input Signal and Display 43
11
IIR Filter Implementation 45
12
AIM:
To write a program for generation of sine wave, Cosine wave, Unit impulse,
Unit step, Unit ramp and Exponential sequence.
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Initialize the values of n.
5. Apply the inputs to the following sequences.
i) Sine wave signal = sin ( 0.2* pi* n)
%INITIALIZATION
n=0:15;
pi=3.14;
%EXPONENTIAL SIGNAL
x=0.8.^(-n);
%RAMP SEQUENCE
x=n;
%STEP SEQUENCE
a=length(n);
x=ones(a);
%IMPULSE SEQUENCE
x=1;
RESULT:
Thus the program for generation of basic sequences have been done and
verified.
LINEAR CONVOLUTION
AIM:
ALGORTHIM:
9. Clear
10. Clear all
11. Close all
12. Enter the first sequence x(n)
13. Enter the second sequence h(n)
14. The convoluted signal is denoted as
y(n) = Σ x(m) h(n-m)
15. Plot the graphs
16. Label the graphs
17. Stop
ENTER THE FIRST SEQUENCE[1 2 3 4]
OUTPUT IS:
z=
3 10 22 34 31 20
%%%%%%%%LINEAR CONVOLUTION%%%%%%%%%
Thus the program for linear convolution was verified and the output was
obtained.
CIRCULAR CONVOLUTION
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the two input sequences g(n) and h(n)
5. Find the length of two input sequences.
6. Determine their value of K by using the formula
K = mod( n-m , 1 ) +1
z=
1 4
z=
1 4 8
z=
1 4 8 8
n=
0 1 2 3
z=
1 4 8 8
%%%%%%%%%CIRCULAR CONVOLUTION%%%%%%
%INPUT
g=[1 2 4 0]
h=[1 2]
%ZERO PADDING
if L>M
h=[h zeros(1,L-M)];
else
g=[g zeros(1,M-L)];
L=M;
end;
%OUTPUT
for n=1:L
y=0;
for M=1:L
k=mod(n-M,L)+1;
y=y+g(M)*h(k);
end
z(n)=y
end
%TITLE
title('CIRCULAR CONVOLUTION');
%PLOT THE INPUT
subplot(3,1,2);
stem(n,h,'*');
%LABEL
ylabel('amplitude-->');
%LABEL
xlabel('time-->')
Thus the program for circular convolution was verified and the output was
obtained.
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Calculate the order of the filter
i. N ≥ log( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficient.
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop
Enter the passband ripple0.5
Enter the stopband ripple40
Enter the passband frequency1200
Enter the stopband frequency2400
Enter the sampling frequency10000
>> 1 4 8 8
%%%%%%%%%BUTTER WORTH LOW PASS FILTER%%%%%%%%
%INPUT
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');
%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
%TITLE
title('BUTTER WORTH LOW PASS FILTER');
RESULT:
Thus the design of Butterworth lowpass filter has been done and verified.
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Calculate the order of the filter
i. N ≥ log( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficient.
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop
%INPUT
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');
%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
%TITLE
title('BUTTER WORTH HIGH PASS FILTER');
RESULT:
Thus the design of Butterworth highpass filter has been done and verified.
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripple
5. Get the pass band and stop band frequency
6. Get the sampling frequency
7. Calculate the order of the filter
i. N ≥ log ( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficients
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop
wn =
0.24000000000000 0.48000000000000
>>
%INPUT
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');
%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);wn=[w1,w2]
[b,a]=butter(n,wn,'bandpass');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
%TITLE
title('BUTTER WORTH BAND PASS FILTER');
RESULT:
Thus the design of Butterworth bandpass filter has been done and verified.
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Calculate the order of the filter
i. N ≥ log ( λ/ ξ ) / log (1/ k)
8. Find the filter co- efficient.
9. Plot the phase and magnitude responses.
10. Label the graphs
11. Stop
wn =
0.24000000000000 0.48000000000000
%INPUT
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');
%OUTPUT
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
wn=[w1,w2]
[b,a]=butter(n,wn,'stop');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
%TITLE
title('BUTTER WORTH BAND STOP FILTER');
RESULT:
Thus the design of Butterworth bandstop filter has been done and verified.
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Initialize the pass band, stop band attenuation and frequency.
5. Find the order and cut off frequency.
6. Find the filter co- efficient.
7. Plot the phase and magnitude responses.
8. Label the graphs
9. Stop
>>
astop =
15
chebyshev type 1 filter
0
-50
gain-->
-100
-150
-200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->
4
2
gain-->
-2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->
%OUTPUT
[b,a]=cheby1(n,apass,wn);
w=0:.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
[b,a]=cheby1(n,apass,wn);
RESULT:
Thus the design of chebyshev type- I filter has been done and verified.
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Initialize the pass band, stop band attenuation and frequency.
5. Find the order and cut off frequency.
6. Find the filter co- efficient.
7. Plot the phase and magnitude responses.
8. Label the graphs
9. Stop
>>
astop =
15
chebyshev type 2 filter
20
0
gain-->
-20
-40
-60
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->
2
1
gain-->
-1
-2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency-->
%OUTPUT
[b,a]=cheby2(n,apass,wn);
w=0:.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
[b,a]=cheby2(n,apass,wn);
RESULT:
Thus the design of chebyshev type- II filter has been done and verified.
BLACKMAN WINDOW
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the Blackman window sequence for each low
pass, high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.
%input
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=blackman(n1);
RESULT:
Thus the design of Blackman window has been done and verified.
RECTANGULAR WINDOW
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the rectangular window sequence for each low
pass, high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.
%input
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband frequency');
fs=input('enter the stopband frequency');
f=input('enter the sampling frequency');
%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(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);
RESULT:
Thus the design of rectangular window has been done and verified.
HAMMING WINDOW
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the hamming window sequence for each low
pass, high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.
gain in db---> 0
gain in db--->
0
-20
-40
-50
-60
-80 -100
0 0.5 1 0 0.5 1
(a) normalized frequency---> (b) normalized frequency--->
band pass filter band stop filter
0 20
-20
0
gain in db--->
gain in db--->
-40
-20
-60
-40
-80
-100 -60
0 0.5 1 0 0.5 1
(c) normalized frequency---> (d) normalized frequency--->
%%%%%%%%%%HAMMING WINDOW%%%%%%%%%
%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(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);
RESULT:
Thus the design of hamming window has been done and verified.
HANNING WINDOW
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the hanning window sequence for each low pass,
high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.
0
gain in db--->
gain in db--->
0
-50
-50
-100
-150 -100
0 0.5 1 0 0.5 1
(a) normalized frequency---> (b) normalized frequency--->
band pass filter band stop filter
0 20
0
gain in db--->
gain in db--->
-50
-20
-40
-100
-60
-150 -80
0 0.5 1 0 0.5 1
(c) normalized frequency---> (d) normalized frequency--->
%%%%%%%%%HANNING WINDOW%%%%%%%%%%%
%input
rp=input('Enter the passband ripple');
rs=input('Enter the stopband ripple');
fp=input('Enter the passband frequency');
fs=input('Enter the stopband frequency');
f=input('Enter the sampling frequency');
%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=hanning(n1);
RESULT:
Thus the design of hanning window has been done and verified.
KAISER WINDOW
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the pass band and stop band ripples.
5. Get the pass band and stop band frequencies.
6. Get the sampling frequency.
7. Find the filter co – efficient.
8. Calculate the values of the Kaiser window sequence for each low pass,
high pass, band pass and band stop filter.
9. Plot the graphs.
10. Label the graphs.
11. Stop.
0
gain in db--->
gain in db--->
0
-50
-50
-100
-150 -100
0 0.5 1 0 0.5 1
(a) normalized frequency---> (b) normalized frequency--->
band pass filter band stop filter
0 10
0
gain in db--->
gain in db--->
-50
-10
-20
-100
-30
-150 -40
0 0.5 1 0 0.5 1
(c) normalized frequency---> (d) normalized frequency--->
%%%%%%%%%%%%KAISER WINDOW%%%%%%%%%%
%input
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband frequency');
fs=input('enter the stopband frequency');
f=input('enter the sampling frequency');
beta=input('enter the beta value');
%output
wp=2*fp/f;
ws=2*fs/f;
num=-20*log(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=kaiser(n1,beta);
RESULT:
Thus the design of Kaiser window has been done and verified.
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Get the input sequences in matrix form.
5. Calculate the length.
6. Apply the inputs in the given formula
1. X(k) = Σ x(n) e –jл2nk / N
7. Plot the graphs.
8. Label the graphs.
9. Stop.
y=
>>
6
2
Imaginary axis-->
-2
-4
-6
-5 0 5 10 15 20 25
Real axis-->
clc;
close all;
clear all;
%INPUT
x=input('enter the sequence');
n=input('enter the length of fft');
%OUTPUT
y=fft(x,n);
RESULT:
Thus the program for fast fourier transform has been done and verified.
SAMPLING OF SIGNALS
AIM:
ALGORTHIM:
1. Clear
2. Clear all
3. Close all
4. Compute the signal modulated, carrier, and amplitude modulated signal.
5. Compute the 128 point DFT computation of the signal.
6. Plot the signals
7. Label the signals.
8. Stop
Modulated Signal x(n) Carrier Signal xa(n)
2 1
1 0.5
amplitude
amplitude
0 0
-1 -0.5
-2 -1
0 100 200 300 0 100 200 300
n--> n-->
Amplitude modulated Signal xam(n)
2
1
amplitude
-1
-2
0 100 200 300
n-->
128 point DFT of the signal for 0 ? n ? 127 xamp(n)
35
30
25
20
amplitude
15
10
-5
0 20 40 60 80 100 120 140
n-->
25
20
15
amplitude
10
-5
-10
-15
0 20 40 60 80 100 120 140
n-->
%%%%%%%%%%SAMPLING OF SIGNALS%%%%%%%%
clc;
close all;
clear all;
f1=1/128;
f2=5/128;
n=0:255;
fc=50/128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xa=cos(2*pi*fc*n);
xamp=x.*xa;
subplot(2,2,1);
plot(n,x);
title('Modulated Signal x(n)');
xlabel('n-->');
ylabel('amplitude');
subplot(2,2,2);
plot(n,xa);
title('Carrier Signal xa(n)');
xlabel('n-->');
ylabel('amplitude');
subplot(2,2,3);
plot(n,xamp);
title('Amplitude modulated Signal xam(n)')
xlabel('n-->');
ylabel('amplitude');
RESULT:
Thus the program for sampling of signals has been done and verified.
STUDY OF VARIOUS ADDRESSING MODES OF DSP USING SIMPLE
PROGRAMMING EXAMPLES
AIM:
1.ADDITION
ALGORTHIM:
OUTPUT:
SD A000
Substitute Data A000:05C0-0003
Substitute Data A001:0003-0003
Substitute Data A002:1000-.
#GO 0000
Executing....
Vi Microsystems Pvt. Ltd.
Chennai - 96
Micro5416 Serial Monitor
#SD A002
PROGRAM:
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
OUTPUT:
SD A000
#SD A002
3. MULTIPLICATION
ALGORTHIM:
PROGRAM:
.mmregs
.text
START:
STM #140H,ST0
STM #40H, PMST
STM #0A000H,AR0
ST #2H,*AR0
LD *AR0+,T
ST #4H,*AR0
MPY *AR0+,A
STL A,*AR0
HLT: B HLT
OUTPUT:
GO 0000
Executing....
#SD A002
4.DIVISION
ALGORTHIM:
1. Initialize the memory for input & output.
2. Load the memory with data pointer.
3. Perform the division operation.
4. Store the result.
5. End.
PROGRAM:
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
RPT #0FH
SUBC DIVIS,A
STL A, OUT
HLT: B HLT
OUTPUT:
SD A000
RESULT:
ALGORTHIM:
PROGRAM:
DATA .SET 0H
.mmREGS
.text
START:
STM #140H,ST0
RSBX CPL
NOP
NOP
NOP
NOP
NOP
REP:
ST #0H,DATA
INC:
LD DATA,A
ADD #1H,A
STL A, DATA
PORTW DATA, #04H
CMPM DATA, #0FFFFH
BC INC,NTC
DEC:
LD DATA,A
SUB #1H,A
STL A,DATA
PORTW DATA, #04H
CMPM DATA,#00H
BC DEC,NTC
B REP
RESULT:
Thus the program for triangular wave generation was executed successfully.
ALGORTHIM:
PROGRAM:
.mmregs
.text
START:
STM #40H,PMST
RSBX CPL
STM #120H,ST0
RSBX FRCT
NOP
NOP
CALL BIT_REV
CALL INCLUDE
ST #1H,BFY
ST #4H,GRP
ST #2H,DNS
ST #3H,STG
LD STG,A
SUB #1H,A
STL A,STGC
STM #TWIDC,AR0
RPT #3H
MVPD TABCOS,*AR0+
STM #TWIDS,AR0
RPT #3H
MVPD TABSIN,*AR0+
STM #2H,AR5 ;AR5 = STAGE LOOP
STGLOP:
ST #0H,K
LD BFY,A
SUB #1H,A
STL A,BFYC
LD GRP,A
SUB #1H,A
STL A,GRPC
LD DNS,A
STLM A,AR0
SUB #1H,A
STL A,DNSC
LD DNSC,A
LD GRP,A
CMPM GRP,#4H ;N/2=8/2=4H
BC NO_CHG,NTC
LD #0H,A
NO_CHG:
STL A,INCTF
LD GRPC,A
STLM A,AR3 ;AR3 = GROUP LOOP
STM #INC,AR1
GRPLOP:
ST #0H,K ;k is initially 0 in all groups
LD BFYC,A
STLM A,AR4 ;AR4 = BFLY LOOP
BFYLOP:
LD *AR1+0,A
CALL MUL
LD DNS,A
STLM A,AR0
LD *AR1-0,A
CALL ADDSUB
LD K,A
ADD INCTF,A
STL A,K
BANZ BFYLOP,*AR4-
LD DNS,A
STLM A,AR0
LD *AR1+0,A
BANZ GRPLOP,*AR3-
MPY BFY,#2,A ;BFY * 2 = BFY
STL A,BFY
MPY DNS,#2,A ;DNS * 2 = DNS
STL A,DNS
STLM A,AR0
LD GRP,A
STL A,-1,GRP ;GRP / 2 = GRP
BANZ STGLOP,*AR5-
HLT: B HLT
MUL:
STM #TWIDC,AR2
LD K,A
STLM A,AR0
NOP
NOP
LD *AR2+0,A
LD *AR2,A
STL A,CX
STM #TWIDS,AR2
LD K,A
STLM A,AR0
LD *AR2+0,A
LD *AR2,A
STL A,DX
LD *AR1+,A
STL A,AX
LD *AR1-,A
STL A,BX
LD AX,A
STLM A,T
MPY CX,A ;A*C
LD BX,B
STLM B,T
MPY DX,B ;B*D
SUB B,A ;AC-BD -> A
STL A,-8,ACMBD
LD AX,A
STLM A,T
MPY DX,A ;A*D
LD BX,B
STLM B,T
MPY CX,B ;B*C
ADD A,B ;AD+BC -> B
STL B,-8,ADPBC
LD ACMBD,A
STL A,*AR1+
LD ADPBC,A
STL A,*AR1-
LD DNS,A
STLM A,AR0
RET
ADDSUB:
LD *AR1+0,A
STL A,ATEMP
LD *AR1-0,B
STL B,BTEMP
ADD A,B
STL B,*AR1
LD ATEMP,A
SUB BTEMP,A
LD *AR1+0,B
STL A,*AR1-0
LD *AR1+,A
LD *AR1+0,A
STL A,ATEMP
LD *AR1-0,B
STL B,BTEMP
ADD A,B
STL B,*AR1
LD ATEMP,A
SUB BTEMP,A
LD *AR1+0,B
STL A,*AR1-0
LD *AR1-,A
LD *+AR1(2),A
LDM AR1,A
STL A,AR10
RET
BIT_REV:
STM #INPUT,AR4
STM #REV,AR5
STM #4H,AR0 ;N/2
STM #7H,BRC ;N-1
RPTB REPREV
LD *AR4+0B,A
TABCOS:
.word 00100H
.word 000B5H
.word 00000H
.word 0FF4BH
TABSIN:
.word 00000H
.word 0FF4BH
.word 0FF00H
.word 0FF4BH
RESULT:
SD 0A200
#SD A400
ALGORTHIM:
PROGRAM:
.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
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
RESULT:
Thus the program for FIR high pass filter was executed successfully.
SAMPLING OF SIGNALS
AIM:
PROGRAM:
B3 .SET 0F000H
B2 .SET 0F00H
B1 .SET 00F0H
B0 .SET 000FH
DATA .SET 0H
TXD .SET 1H
FS .SET 2H
.mmregs
.text
START:
STM #0140h,ST0
RSBX CPL
RSBX FRCT
NOP
NOP
NOP
NOP
STM #9200H,AR1
STM #360,AR2
ST #01H,10H
PORTW 10H,0AH
LOOP:
PORTR 06,0
CHK_BUSY:
ST #02H,10H
PORTW 10H,0AH
PORTR 07,0
BITF 0,#20H
BC CHK_BUSY,TC
ST #04H,10H
PORTW 10H,0AH
PORTR 04,0
LD 0,A
AND #0FFFH,A
XOR #0800H,A
STL A,*AR1+
ST #1000H,FS
RPT FS
NOP
BANZ LOOP,*AR2-
REPSER:
LD #25H,A
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
LD FS,A
STL A,DATA
CALL SERIAL
STM #259,AR7
STM #9200H,AR6
REPYN:
ST #55H,10H
PORTW 10H,0AH
LD *AR6+,A
STL A,DATA
CALL SERIAL
BANZ REPYN,*AR7-
LD #40H,A
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
B REPSER
SERIAL:
LD DATA,A
AND #B3,A ;1st digit (from msb)
SFTL A,-12
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
LD DATA,A
AND #B2,A ;1st digit (from msb)
SFTL A,-8
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
LD DATA,A
AND #B1,A ;1st digit (from msb)
SFTL A,-4
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
LD DATA,A
AND #B0,A ;1st digit (from msb)
CALL HEXASC
CALL TXDATA
STM #0140h,ST0
RSBX CPL
NOP
NOP
NOP
NOP
; CALL DELAY
RET
HEXASC:
ADD #30H,A
LD A,B
SUB #3AH,B
BC LESS9,BLT
ADD #7H,A
LESS9:
RET
TXDATA:
CALL 8C41H ; 8C38H for 5416 mode 1
SSBX INTM
rpt #2ffh ;delay
nop
RET
DELAY:
STM #0H,AR3
DEL1: STM #02FFFH,AR2
DEL: LD #0H,A
ADD #1H,A
BANZ DEL,*AR2-
BANZ DEL1,*AR3-
RET
RESULT:
ALGORTHIM:
PROGRAM:
XN .SET 0H
XNM1 .SET 1H
XNM2 .SET 2H
YN .SET 3H
YNM1 .SET 4H
YNM2 .SET 5H
XN1 .SET 6H
XN1M1 .SET 7H
XN1M2 .SET 8H
YN1 .SET 9H
YN1M1 .SET 0AH
YN1M2 .SET 0BH
TEMP .SET 0CH
A10 .SET 0100H
A11 .SET 0FFEDH
A12 .SET 002CH
B10 .SET 0100H
B11 .SET 0FE00H
B12 .SET 0100H
.mmregs
.text
START:
STM #40H,PMST
RSBX CPL
STM #01H,ST0
RSBX FRCT
NOP
NOP
NOP
;initialize xn,x(n-1),x(n-2),yn,y(n-1),y(n-2)
ST #0H,XN
ST #0H,XNM1
ST #0H,XNM2
ST #0H,YN
ST #0H,YNM1
ST #0H,YNM2
ST #0H,XN1
ST #0H,XN1M1
ST #0H,XN1M2
ST #0H,YN1
ST #0H,YN1M1
ST #0H,YN1M2
REPEAT:
;to read data from ADC
PORTR 06,20 ;start of conversion
CHK_BUSY: ;check status
PORTR 07,20
BITF 20,#20H
BC CHK_BUSY,TC
PORTR 04,20 ;read ADC data
LD 20,A
AND #0FFFH,A
XOR #0800H,A ;to correct 2's complement
SUB #800H,A
STL A,XN ;xn
STL A,TEMP
;
LD #0H,B ;sum = B = 0
LD #B10,A ;b0 = T
STLM A,T
MPY XN,A ;b0*xn = A
SFTL A,-8
ADD A,B ;b0*xn =B
LD #B11,A ;b0 = T
STLM A,T
MPY XNM1,A ;b0*xn = A
SFTL A,-8
ADD A,B ;b0*xn =B
LD #B12,A ;b0 = T
STLM A,T
MPY XNM2,A ;b0*xn = A
SFTL A,-8
ADD A,B ;b0*xn =B
LD #A11,A ;b0 = T
STLM A,T
MPY YNM1,A ;b0*xn = A
SFTL A,-8
SUB A,B ;b0*xn =B
LD #A12,A ;b0 = T
STLM A,T
MPY YNM2,A ;b0*xn = A
SFTL A,-8
SUB A,B ;b0*xn =B
STL B,YN
STL B,XN1
LD YNM1,A
STL A,YNM2
LD YN,A
STL A,YNM1
LD XNM1,A
STL A,XNM2
LD XN,A
STL A,XNM1
LD YN,A
ADD #800H,A
STL A,YN
PORTW YN,04H
B REPEAT
RESULT:
Thus the program for IIR butterworth filter was executed successfully.