Sie sind auf Seite 1von 84

VICKRAM

COLLEGE OF ENGINEERING,ENATHI-630561
Affiliated to Anna University,Trichy

2011-2012
EC1359-DIGITAL SIGNAL PROCESSING LABORATORY VI SEMESTER

B.Tech-INFORMATION TECHNOLOGY

PREPARED BY: Mr.Prithivirajan (SR.LECTURER/ECE) Mr.Antony Joe Christo (LECTURER/ECE)

APPROVED BY: Dr.VenkataKrishanan

(HOD/ECE)

LIST OF EXPERIMENTS S.No 1 2 3 4(A) 4(B) 4(C) 4(D) 4(E) 4(F) 5(A) 5(B) 5(C) 5(D) 5(E) 6 7 8 9 10 11 Name of the Experiments Generation of Signals using MATLAB Linear Convolution of Two Sequences using MATLAB Circular Convolution of Two Sequences using MATLAB Design of IIR Filters using MATLAB Butterworth Lowpass Filter Butterworth Highpass filter Butterworth Bandpass filter Butterworth Bandstop filter Chebyshev type-I filter Chebyshev Type II filter Design of FIR Filters using MATLAB Blackman Window Rectangular Window Hamming window Hanning window Kaiser window Calculation of FFT using MATLAB Sampling and effect of aliasing USING TMS320C5416 PROCESSOR: Study of various Addressing Modes of DSP using Simple Programming Examples Calculation of FFT Implementation of FIR Filter Sampling of Input Signal and Display Page Number 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 34 Signature

37 41 43

12

IIR Filter Implementation

45

GENERATION OF BASIC SEQUENCES AIM: To write a program for generation of sine wave, Cosine wave, Unit impulse, Unit step, Unit ramp and Exponential sequence. ALGORTHIM: 1. 2. 3. 4. 5. Clear Clear all Close all Initialize the values of n. Apply the inputs to the following sequences. i) Sine wave signal = sin ( 0.2* pi* n) ii) Cosine wave signal iii) Unit impulse iv) Unit step v) Unit ramp vi) Exponential sequence 6. Plot the graphs 7. Label the graphs 8. Stop = cos (0.2* pi* n) = 1 for n=0 0, otherwise = 1 for n0 0, otherwise = n , for n0 0, otherwise = an

%%%%%%%%%GENERATION OF SIGNALS%%%%%%%%%% %CLEAR THE SCREEN clc; clear all; close all; %INITIALIZATION n=0:15; pi=3.14; %SINE WAVE SIGNAL x=sin(0.2*pi*n); %PLOT THE SINE WAVE subplot(2,3,1); stem(x); %LABEL THE SINEWAVE title('SINE WAVE SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->'); %COSINE WAVE SIGNAL x=cos(0.2*pi*n); %PLOT THE COSINE WAVE subplot(2,3,2); stem(x); %LABEL THE COSINEWAVE title('COSINE WAVE SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->'); %EXPONENTIAL SIGNAL x=0.8.^(-n); %PLOT EXPONENTIAL SIGNAL subplot(2,3,3); stem(x); %LABEL EXPONENTIAL SEQUENCE title('EXPONENTIAL SEQUENCE'); xlabel('time-->');

ylabel('amplitude-->'); %RAMP SEQUENCE x=n; %PLOT RAMP SEQUENCE subplot(2,3,4); stem(x); %LABEL RAMP SEQUENCE title('RAMP SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->'); %STEP SEQUENCE a=length(n); x=ones(a); %PLOT STEP SEQUENCE subplot(2,3,5); stem(x); %LABEL STEP SEQUENCE title('STEP SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->'); %IMPULSE SEQUENCE x=1; %PLOT IMPULSE SEQUENCE subplot(2,3,6); stem(0,x); %LABEL IMPULSE SEQUENCE title('IMPULSE SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->');

RESULT:

Thus the program for generation of basic sequences have been done and verified.

LINEAR CONVOLUTION AIM: To write a program to convolute the two input sequences using linear convolution. 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] ENTER THE SECOND SEQUENCE[3 4 5] OUTPUT IS: z= 3 10 22 34 31 20

%%%%%%%%LINEAR CONVOLUTION%%%%%%%%% %CLEAR THE SCREEN clc; clear all; x=input('ENTER THE FIRST SEQUENCE'); y=input('ENTER THE SECOND SEQUENCE'); z=conv(x,y); %PLOT THE FIRST SEQUENCE subplot(3,1,1); stem(x); %LABEL THE FIRST SEQUENCE title('FIRST SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->'); %PLOT THE SECOND SEQUENCE subplot(3,1,2); stem(y); %LABEL THE SECOND SEQUENCE title('SECOND SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->'); %PLOT THE OUTPUT SEQUENCE subplot(3,1,3); stem(z); %LABEL THE OUTPUT SEQUENCE title('OUTPUT SEQUENCE'); xlabel('time-->'); ylabel('amplitude-->'); %DISPLAY THE OUTPUT disp('THE OUTPUT IS:');z

RESULT: Thus the program for linear convolution was verified and the output was obtained. CIRCULAR CONVOLUTION AIM: To write a program to convolute the two input sequences using circular convolution. ALGORTHIM: 1. 2. 3. 4. 5. 6. Clear Clear all Close all Get the two input sequences g(n) and h(n) Find the length of two input sequences. Determine their value of K by using the formula K = mod( n-m , 1 ) +1

7. Find the value of y by using the formula Y= y+ g(m) * h(k) 8. Plot the graphs 9. Label the graphs 10. Stop

1 z= 1 z= 1 z= 1 n= 0 1 2 3 4 8 8 4 8 4

THE RESULTANT OUTPUT IS: z= 1 4 8 8

%%%%%%%%%CIRCULAR CONVOLUTION%%%%%% %CLEAR THE SCREEN clc; clear all; close all; %INPUT g=[1 2 4 0] h=[1 2] %LENGTH OF THE INPUT L=length(g); M=length(h); %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 %PLOT THE INPUT n=0:L-1 figure(1); subplot(3,1,1); stem(n,g,'.'); %TITLE title('CIRCULAR CONVOLUTION'); %PLOT THE INPUT subplot(3,1,2); stem(n,h,'*'); %LABEL ylabel('amplitude-->');

%PLOT THE OUTPUT subplot(3,1,3); stem(n,z,'r.'); %LABEL xlabel('time-->') %DISPLAY THE OUTPUT disp('THE RESULTANT OUTPUT IS:');z

RESULT: Thus the program for circular convolution was verified and the output was obtained.

BUTTERWORTH LOWPASS FILTER AIM: To write a program to design a Butterworth lowpass filter ALGORTHIM: 1. 2. 3. 4. 5. 6. 7. Clear Clear all Close all Get the pass band and stop band ripples Get the pass band and stop band frequencies. Get the sampling frequency. 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%%%%%%%% %CLEAR THE SCREEN clc; clear all; close all; format long; %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); %PLOT THE GAIN subplot(2,1,1); plot(om/pi,m); %TITLE title('BUTTER WORTH LOW PASS FILTER'); %LABEL THE OUTPUT ylabel('gain in db-->'); xlabel('(a)normalized frequency-->'); %PLOT THE PHASE subplot(2,1,2); plot(om/pi,an); %LABEL THE OUTPUT xlabel('(b)normalized frequency-->'); ylabel('phase in radians-->');

RESULT: Thus the design of Butterworth lowpass filter has been done and verified. BUTTERWORTH HIGHPASS FILTER AIM: To write a program to design a Butterworth highpass filter ALGORTHIM: 1. 2. 3. 4. 5. Clear Clear all Close all Get the pass band and stop band ripples 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 frequency2500 Enter the sampling frequency10000

%%%%%%%%BUTTER WORTH HIGH PASS FILTER%%%%%% %CLEAR THE SCREEN clc; clear all; close all; format long; %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); %PLOT THE GAIN subplot(2,1,1); plot(om/pi,m); %TITLE title('BUTTER WORTH HIGH PASS FILTER'); %LABEL THE OUTPUT ylabel('gain in db-->'); xlabel('(a)normalized frequency-->'); %PLOT THE PHASE subplot(2,1,2); plot(om/pi,an); %LABEL THE OUTPUT xlabel('(b)normalized frequency-->'); ylabel('phase in radians-->'); RESULT: Thus the design of Butterworth highpass filter has been done and verified. BUTTERWORTH BANDPASS FILTER AIM: To write a program to design a Butterworth bandpass filter ALGORTHIM: 1. Clear 2. Clear all

3. 4. 5. 6. 7.

Close all Get the pass band and stop band ripple Get the pass band and stop band frequency Get the sampling frequency 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

Enter the passband ripple0.5 Enter the stopband ripple40 Enter the passband frequency1200 Enter the stopband frequency2400 Enter the sampling frequency10000 wn = 0.24000000000000 0.48000000000000

>>

%%%%%%BUTTER WORTH BAND PASS FILTER%%%%%% %CLEAR THE SCREEN clc; clear all; close all; format long; %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); %PLOT THE GAIN subplot(2,1,1); plot(om/pi,m); %TITLE title('BUTTER WORTH BAND PASS FILTER'); %LABEL THE OUTPUT ylabel('gain in db-->'); xlabel('(a)normalized frequency-->'); %PLOT THE PHASE subplot(2,1,2); plot(om/pi,an); %LABEL THE OUTPUT xlabel('(b)normalized frequency-->'); ylabel('phase in radians-->'); RESULT: Thus the design of Butterworth bandpass filter has been done and verified. BUTTERWORTH BANDSTOP FILTER AIM: To write a program to design a Butterworth bandstop filter ALGORTHIM: 1. Clear 2. Clear all

3. 4. 5. 6. 7.

Close all Get the pass band and stop band ripples Get the pass band and stop band frequencies. Get the sampling frequency. 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 wn =

0.24000000000000 0.48000000000000

%%%%%%%BUTTER WORTH BAND STOP FILTER%%%%%%%% %CLEAR THE SCREEN clc; clear all; close all; format long; %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); %PLOT THE GAIN subplot(2,1,1); plot(om/pi,m); %TITLE title('BUTTER WORTH BAND STOP FILTER'); %LABEL THE OUTPUT ylabel('gain in db-->'); xlabel('(a)normalized frequency-->'); %PLOT THE PHASE subplot(2,1,2); plot(om/pi,an); %LABEL THE OUTPUT xlabel('(b)normalized frequency-->'); ylabel('phase in radians-->'); RESULT: Thus the design of Butterworth bandstop filter has been done and verified. CHEBYSHEV TYPE-I FILTER AIM: To write a program to design a chebyshev type-I filter ALGORTHIM: 1. Clear 2. Clear all 3. Close all

4. 5. 6. 7. 8. 9.

Initialize the pass band, stop band attenuation and frequency. Find the order and cut off frequency. Find the filter co- efficient. Plot the phase and magnitude responses. Label the graphs Stop

>> astop = 15

chebyshev type 1 filter 0 -50 gain--> -100 -150 -200

0.1

0.2

0.3

0.4 0.5 0.6 frequency-->

0.7

0.8

0.9

4 2 gain--> 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 frequency-->

0.7

0.8

0.9

%%%%%%%%%%CHEBYSHEV TYPE-I FILTER%%%%%%%% %CLEAR THE SCREEN clc; clear all; close all; %PASS BAND AND STOP BAND ATTENUATION AND FREQUENCY

apass=1; astop=15 wp=2*pi; ws=3*pi; %ORDER AND CUTOFF FREQUENCY [n,wn]=cheb1ord(wp\pi,ws\pi,apass,astop); %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); %PLOT THE GAIN subplot(2,1,1); plot(ph/pi,m); grid; title('chebyshev type 1 filter'); %LABEL THE GRAPH ylabel('gain-->'); xlabel('frequency-->'); %PLOT THE PHASE subplot(2,1,2); plot(ph/pi,an); grid; %LABEL THE GRAPH ylabel('gain-->'); xlabel('frequency-->'); [b,a]=cheby1(n,apass,wn);

RESULT: Thus the design of chebyshev type- I filter has been done and verified. CHEBYSHEV TYPE-II FILTER AIM: To write a program to design a chebyshev type-II filter ALGORTHIM:

1. 2. 3. 4. 5. 6. 7. 8. 9.

Clear Clear all Close all Initialize the pass band, stop band attenuation and frequency. Find the order and cut off frequency. Find the filter co- efficient. Plot the phase and magnitude responses. Label the graphs Stop

>> astop = 15

chebyshev type 2 filter 20 0 gain--> -20 -40 -60

0.1

0.2

0.3

0.4 0.5 0.6 frequency-->

0.7

0.8

0.9

2 1 gain--> 0 -1 -2

0.1

0.2

0.3

0.4 0.5 0.6 frequency-->

0.7

0.8

0.9

%%%%%%%%%CHEBYSHEV TYPE-II FILTER%%%%%%%%% %CLEAR THE SCREEN clc; clear all; close all; %PASS BAND AND STOP BAND ATTENUATION AND FREQUENCY apass=1;

astop=15 wp=2*pi; ws=3*pi; %ORDER AND CUTOFF FREQUENCY [n,wn]=cheb1ord(wp\pi,ws\pi,apass,astop); %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); %PLOT THE GAIN subplot(2,1,1); plot(ph/pi,m); grid; title('chebyshev type 2 filter'); %LABEL THE GRAPH ylabel('gain-->'); xlabel('frequency-->'); %PLOT THE PHASE subplot(2,1,2); plot(ph/pi,an); grid; %LABEL THE GRAPH ylabel('gain-->'); xlabel('frequency-->'); [b,a]=cheby2(n,apass,wn);

RESULT: Thus the design of chebyshev type- II filter has been done and verified. BLACKMAN WINDOW AIM: To write a program to design a Blackman window sequence. ALGORTHIM: 1. Clear

2. 3. 4. 5. 6. 7. 8.

Clear all Close all Get the pass band and stop band ripples. Get the pass band and stop band frequencies. Get the sampling frequency. Find the filter co efficient. 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.

Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1500 Enter the stopband frequency2000 Enter the sampling frequency9000 >>

%%%%%%%%%BLACKMAN WINDOW%%%%%%% %CLEAR THE SCREEN clc clear all; close all; %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); %Low pass 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); title('low pass filter'); ylabel('gain in db--->'); xlabel('(a) normalized frequency--->'); %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); title('high pass filter'); ylabel('gain in db--->'); xlabel('(b) normalized frequency--->');

%Band pass 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); title('band pass filter'); ylabel('gain in db--->'); xlabel('(c) normalized frequency--->');

%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); title('band stop filter'); ylabel('gain in db--->'); xlabel('(d) normalized frequency--->');

RESULT: Thus the design of Blackman window has been done and verified.

RECTANGULAR WINDOW AIM: To write a program to design a Rectangular window sequence. ALGORTHIM: 1. Clear 2. Clear all

3. 4. 5. 6. 7. 8.

Close all Get the pass band and stop band ripples. Get the pass band and stop band frequencies. Get the sampling frequency. Find the filter co efficient. 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.

Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1400 Enter the stopband frequency2500 Enter the sampling frequency9000

%%%%%%%%%RECTANGULAR WINDOW%%%%%%%%%% %CLEAR THE SCREEN clc clear all; close all; %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); %Low pass 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); title('low pass filter'); ylabel('gain in db--->'); xlabel('(a) normalized frequency--->'); %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); title('high pass filter'); ylabel('gain in db--->'); xlabel('(b) normalized frequency--->');

%Band pass 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); title('band pass filter'); ylabel('gain in db--->');

xlabel('(c) normalized frequency--->'); %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); title('band stop filter'); ylabel('gain in db--->'); xlabel('(d) normalized frequency--->');

RESULT: Thus the design of rectangular window has been done and verified.

HAMMING WINDOW AIM: To write a program to design a Hamming window sequence. ALGORTHIM: 1. 2. 3. 4. Clear Clear all Close all Get the pass band and stop band ripples.

5. 6. 7. 8.

Get the pass band and stop band frequencies. Get the sampling frequency. Find the filter co efficient. 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.

Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1200 Enter the stopband frequency2400 Enter the sampling frequency9000 >>

low pass filter 20 0 gain in db---> gain in db---> -20 -40 -60 -80 0 0.5 1 (a) normalized frequency---> band pass filter 0 50

high pass filter

-50

-100

0.5 1 (b) normalized frequency---> band stop filter

0 -20 gain in db---> -40 -60 -80 -100 0 0.5 1 (c) normalized frequency---> gain in db--->

20 0 -20 -40 -60

0.5 1 (d) normalized frequency--->

%%%%%%%%%%HAMMING WINDOW%%%%%%%%% %CLEAR THE SCREEN clc; clear all; close all;

%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=hamming(n1); %low pass 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); title('low pass filter'); ylabel('gain in db--->'); xlabel('(a) normalized frequency--->'); %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); title('high pass filter'); ylabel('gain in db--->'); xlabel('(b) normalized frequency--->');

%band pass 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); title('band pass filter'); ylabel('gain in db--->'); xlabel('(c) normalized frequency--->'); %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); title('band stop filter'); ylabel('gain in db--->'); xlabel('(d) normalized frequency--->');

RESULT: Thus the design of hamming window has been done and verified.

HANNING WINDOW AIM: To write a program to design a Hanning window sequence. ALGORTHIM: 1. Clear 2. Clear all 3. Close all

4. 5. 6. 7. 8.

Get the pass band and stop band ripples. Get the pass band and stop band frequencies. Get the sampling frequency. Find the filter co efficient. 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.

Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1200 Enter the stopband frequency2400 Enter the sampling frequency9000 >>

low pass filter 50 gain in db---> gain in db---> 0 -50 -100 -150 50

high pass filter

-50

0.5 1 (a) normalized frequency---> band pass filter

-100

0.5 1 (b) normalized frequency---> band stop filter

0 gain in db---> gain in db---> 0 0.5 1 (c) normalized frequency--->

20 0

-50

-20 -40 -60 -80 0 0.5 1 (d) normalized frequency--->

-100

-150

%%%%%%%%%HANNING WINDOW%%%%%%%%%%% %CLEAR THE SCREEN clc clear all; close all; %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); %low pass 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); title('low pass filter'); ylabel('gain in db--->'); xlabel('(a) normalized frequency--->'); %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); title('high pass filter'); ylabel('gain in db--->'); xlabel('(b) normalized frequency--->');

%band pass 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); title('band pass filter'); ylabel('gain in db--->'); xlabel('(c) normalized frequency--->');

%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); title('band stop filter'); ylabel('gain in db--->'); xlabel('(d) normalized frequency--->');

RESULT: Thus the design of hanning window has been done and verified.

KAISER WINDOW AIM: To write a program to design a Kaiser window sequence. ALGORTHIM: 1. Clear 2. Clear all 3. Close all

4. 5. 6. 7. 8.

Get the pass band and stop band ripples. Get the pass band and stop band frequencies. Get the sampling frequency. Find the filter co efficient. 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.

Enter the passband ripple0.05 Enter the stopband ripple0.04 Enter the passband frequency1200 Enter the stopband frequency2400 Enter the sampling frequency9000 Enter the beta value6

low pass filter 50 gain in db---> gain in db---> 0 -50 -100 -150 50

high pass filter

-50

0.5 1 (a) normalized frequency---> band pass filter

-100

0.5 1 (b) normalized frequency---> band stop filter

0 gain in db---> gain in db---> 0 0.5 1 (c) normalized frequency--->

10 0

-50

-10 -20 -30 -40 0 0.5 1 (d) normalized frequency--->

-100

-150

%%%%%%%%%%%%KAISER WINDOW%%%%%%%%%% %CLEAR THE SCREEN clc; clear all; close all; %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); %low pass 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); title('low pass filter'); ylabel('gain in db--->'); xlabel('(a) normalized frequency--->'); %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); title('high pass filter'); ylabel('gain in db--->'); xlabel('(b) normalized frequency--->');

%band pass 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); title('band pass filter'); ylabel('gain in db--->'); xlabel('(c) normalized frequency--->');

%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); title('band stop filter'); ylabel('gain in db--->'); xlabel('(d) normalized frequency--->');

RESULT: Thus the design of Kaiser window has been done and verified.

FAST FOURIER TRANSFORM AIM: To write a program for finding fast fourier transform. ALGORTHIM: 1. 2. 3. 4. Clear Clear all Close all 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 j2nk / N 7. Plot the graphs. 8. Label the graphs. 9. Stop.

Enter the sequence[1 2 3 4 5 6] enter the length of fft 6 the resultant output is y= 21.0000 -3.0000 + 5.1962i -3.0000 + 1.7321i -3.0000 -3.0000 - 5.1962i >> -3.0000 - 1.7321i

2 Imaginary axis-->

-2

-4

-6 -5

10 Real axis-->

15

20

25

%%%%%%%%%FAST FOURIER TRANSFORM%%%%%%%%%% %CLEAR THE SCREEN clc; close all; clear all; %INPUT x=input('enter the sequence'); n=input('enter the length of fft');

%OUTPUT y=fft(x,n); %PLOT THE GRAPH stem(y); %LABEL THE GRAPH ylabel('Imaginary axis-->'); xlabel('Real axis-->'); disp('the resultant output is');y

RESULT: Thus the program for fast fourier transform has been done and verified.

SAMPLING OF SIGNALS AIM: To write a program for sampling of signals. ALGORTHIM: 1. 2. 3. 4. 5. Clear Clear all Close all Compute the signal modulated, carrier, and amplitude modulated signal. Compute the 128 point DFT computation of the signal.

6. Plot the signals 7. Label the signals. 8. Stop

Modulated Signal x(n) 2 1 amplitude 0 -1 -2 amplitude 1 0.5 0 -0.5 -1

Carrier Signal xa(n)

100

200

300

100 n-->

200

300

n--> Amplitude modulated Signal xam(n) 2 1 amplitude 0 -1 -2

100 n-->

200

300

128 point DFT of the signal for 0 ? n ? 127 xamp(n) 35 30 25 20 amplitude 15 10 5 0 -5

20

40

60 n-->

80

100

120

140

128 point DFT of the signal for 0 ? n ? 99 xam(n) 30 25 20 15 amplitude 10 5 0 -5 -10 -15

20

40

60 n-->

80

100

120

140

%%%%%%%%%%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'); %128 point DFT of the signal for 0 n 127 n=0:127; figure; n1=128; f1=1/128; f2=5/128; fc=50/128; x=cos(2*pi*f1*n)+cos(2*pi*f2*n); xc=cos(2*pi*fc*n); xa=cos(2*pi*fc*n); xamp=x.*xa; xam=fft(xamp,n1); stem(n,xam); title('128 point DFT of the signal for 0 n 127 xamp(n)'); xlabel('n-->'); ylabel('amplitude'); %128 point DFT of the signal for 0 n 99 n=0:99; figure; n2=0:n1-1;

f1=1/128; f2=5/128; fc=50/128; x=cos(2*pi*f1*n)+cos(2*pi*f2*n); xc=cos(2*pi*fc*n); xa=cos(2*pi*fc*n); xamp=x.*xa; for i=1:100; xamp1(i)=xamp(i); end xam=fft(xamp1,n1); stem(n2,xam); title('128 point DFT of the signal for 0 n 99 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: To write a program to perform addition, Subtraction, Multiplication and division operations using TMS320c5416 Processor. 1.ADDITION ALGORTHIM: 1. Initialize the memory for input & output. 2. Load the memory with data pointer. 3. Perform the addition operation. 4. Store the result. 5. End. 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 ADD INP2,A STL A,OUT HLT: B HLT 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 Substitute Data A002:00062.SUBTRACTION

ALGORTHIM: 1. 2. 3. 4. 5. Initialize the memory for input & output. Load the memory with data pointer. Perform the Subtraction operation. Store the result. End.

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 Substitute Data A000:0003-0006 Substitute Data A001:0003-0002 Substitute Data A002:0006-. #GO 0000 Executing.... Vi Microsystems Pvt. Ltd. Chennai - 96 Micro5416 Serial Monitor #SD A002 Substitute Data A002:00043. MULTIPLICATION

ALGORTHIM: 1. 2. 3. 4. 5. Initialize the memory for input & output. Load the memory with data pointer. Perform the multiplication operation. Store the result. End.

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.... Vi Microsystems Pvt. Ltd. Chennai - 96 Micro5416 Serial Monitor #SD A002 Substitute Data A002:0008-

4.DIVISION ALGORTHIM:

1. 2. 3. 4. 5.

Initialize the memory for input & output. Load the memory with data pointer. Perform the division operation. Store the result. 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 Substitute Data A000:0002-0004 Substitute Data A001:0004-0002 Substitute Data A002:0008-. #GO 0000 Executing.... Vi Microsystems Pvt. Ltd. Chennai - 96 Micro5416 Serial Monitor #SD A002 Substitute Data A002:0002RESULT: Thus the programs for addition, subtraction, multiplication and division operations are executed successfully using DSP processor TRIANGULAR WAVE GENERATION AIM:

To write a program for triangular wave generation using TMs320C5416 processor. ALGORTHIM: 1. 2. 3. 4. 5. Initialize the value. Generate the loop to increment the value. Generate the loop to decrement the value. Store the data in the required memory place. End

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. 8-POINT FAST FOURIER TRANSFORM

AIM: To write a program for 8-point FFT using TMS320C5416 processor. ALGORTHIM: 1. 2. 3. 4. 5. Initialize the memory for input and output. Get the inputs in the memory location A200. Perform FFT operation. Store the results in A400 memory location. End

PROGRAM: INPUT REV INC TWIDC TWIDS BFY BFYC DNS DNSC GRP GRPC STG STGC K INCTF AX BX CX DX ACMBD ADPBC AR10 AR11 AR12 AR13 AR14 ATEMP BTEMP .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .SET .mmregs .text START: STM RSBX STM RSBX NOP #40H,PMST CPL #120H,ST0 FRCT 9200H 9300H 9400H 9500H 9550H 0H 1H 2H 3H 4H 5H 6H 7H 8H 9H 0AH 0BH 0CH 0DH 0EH 0FH 10H 11H 12H 13H 14H 15H 16H

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,*AR4LD DNS,A STLM A,AR0 LD *AR1+0,A BANZ GRPLOP,*AR3MPY 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,*AR5HLT: 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,*AR1LD DNS,A STLM A,AR0 RET ADDSUB: LD STL LD STL ADD STL LD SUB LD STL LD LD STL LD STL ADD STL LD SUB LD STL LD LD LDM STL RET BIT_REV: STM STM STM STM RPTB LD *AR1+0,A A,ATEMP *AR1-0,B B,BTEMP A,B B,*AR1 ATEMP,A BTEMP,A *AR1+0,B A,*AR1-0 *AR1+,A *AR1+0,A A,ATEMP *AR1-0,B B,BTEMP A,B B,*AR1 ATEMP,A BTEMP,A *AR1+0,B A,*AR1-0 *AR1-,A *+AR1(2),A AR1,A A,AR10 #INPUT,AR4 #REV,AR5 #4H,AR0 ;N/2 #7H,BRC ;N-1 REPREV *AR4+0B,A A,*AR5+

REPREV: STL RET

INCLUDE: STM #REV,AR1 STM #INC,AR2 STM #7H,BRC RPTB REPINC LD *AR1+,A STL A,*AR2+ LD #0H,A REPINC: STL A,*AR2+ RET TABCOS: .word .word .word .word TABSIN: .word .word .word .word 00100H 000B5H 00000H 0FF4BH 00000H 0FF4BH 0FF00H 0FF4BH

RESULT: Thus the program for 8-point FFT was executed successfully.

OUTPUT: SD 0A200 Substitute Data A200:E055-0700 Substitute Data A201:EBAA-0B00 Substitute Data A202:B055-0F00 Substitute Data A203:F7AA-0B00 Substitute Data A204:8055-0700 Substitute Data A205:FBAA-0300 Substitute Data A206:9255-0000 Substitute Data A207:AFAA-0300 Substitute Data A208:DFAA-. #GO 0000 Executing.... Vi Microsystems Pvt. Ltd. Chennai - 96 Micro5416 Serial Monitor #SD A400 Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data Substitute Data A400:3900A401:0000A402:0000A403:E5B0A404:FF00A405:0000A406:0000A407:03B0A408:0100A409:0000A40A:0000A40B:FC50A40C:FF00A40D:0000A40E:0000-.

FIR FILTER DESIGN(HIGH PASS FIR FILTER)

AIM: To write a program to design a FIR high pass filter using TMS320C5416 processor with the following specifications. Sampling freq Cut-off freq N Filter type Window type ALGORTHIM: 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. 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 ;*****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 : 43khz : 2khz : 52 : High pass filter : Rectangular

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 .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word 0FCEFH 62H 0FD50H 14AH 0FE1BH 28FH 0FF11H 3E5H 0FFD1H 4ECH 0FFF5H 54FH 0FF28H 4DAH 0FD38H 398H 0FA2EH 1DDH 0F627H 55H 0F131H 4BH 0EA6DH 568H 0D950H 459EH 459EH 0D950H 568H 0EA6DH 4BH 0F131H 55H 0F627H

.word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word

1DDH 0FA2EH 398H 0FD38H 4DAH 0FF28H 54FH 0FFF5H 4ECH 0FFD1H 3E5H 0FF11H 28FH 0FE1BH 14AH 0FD50H 62H 0FCEFH

RESULT: Thus the program for FIR high pass filter was executed successfully.

SAMPLING OF SIGNALS AIM: To write a program for sampling of signals using TMS320C5416 processor. PROGRAM: B3 B2 B1 B0 DATA TXD FS .SET .SET .SET .SET .SET .SET .SET 0F000H 0F00H 00F0H 000FH 0H 1H 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,*AR7LD #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,*AR3RET RESULT: Thus the program for Sampling of signals was executed successfully.

IIR FILTER DESIGN(HIGH PASS FIR FILTER)

AIM: To write a program to design an IIR butterworth filter using TMS320C5416 processor with the following specifications. Filter type : High pass filter Filter order :2 Filter design type : Butterworth Pass band attenuation : 3db First corner freq : 0.2 Second corner freq : 0.24 Sampling freq : 50Khz Cut-off freq : 10Khz ALGORTHIM: 1. Make all the x(n) zero initially 2. Read the data from the adc. 3. Store the adc data. 4. Make the pointer to point the x(n_end) 5. Perform the convolution of x(n) and the coefficients h(n) 6. Send the convolution output to the dac 7. End PROGRAM: ;FROM PCDSP COEFFICIENTS XN .SET XNM1 .SET XNM2 .SET YN .SET YNM1 .SET YNM2 .SET XN1 .SET XN1M1 .SET XN1M2 .SET YN1 .SET YN1M1 .SET YN1M2 .SET TEMP .SET A10 .SET A11 .SET A12 .SET B10 .SET B11 .SET B12 .SET .mmregs 0H 1H 2H 3H 4H 5H 6H 7H 8H 9H 0AH 0BH 0CH 0100H 0FFEDH 002CH 0100H 0FE00H 0100H

.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 STLM A,T MPY XNM1,A SFTL A,-8 ADD A,B ;b0 = T ;b0*xn = A ;b0*xn =B

LD #B12,A STLM A,T MPY XNM2,A SFTL A,-8 ADD A,B LD #A11,A STLM A,T MPY YNM1,A SFTL A,-8 SUB A,B LD #A12,A STLM A,T MPY YNM2,A SFTL A,-8 SUB A,B STL B,YN STL B,XN1 LD STL LD STL LD STL LD STL YNM1,A A,YNM2 YN,A A,YNM1 XNM1,A A,XNM2 XN,A A,XNM1

;b0 = T ;b0*xn = A ;b0*xn =B ;b0 = T ;b0*xn = A ;b0*xn =B ;b0 = T ;b0*xn = A ;b0*xn =B

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.

Das könnte Ihnen auch gefallen