# 1.

OPERATIONS ON MATRICES

AIM : To Perform Different Operations on Matrices SOFTWARE : PC Equipped with MATLAB 7.0 PROGRAM :
%CREATING A MATRIX a=[1 10 0; 5 15 8; 3 5 9] a= 1 5 3 10 15 5 0 8 9

% TRANSPOSE OF A MATRIX b=a' b= 1 5 3 10 15 5 0 8 9 % MULTIPLICATION OF A MATRIX c=a*b c= 101 155 53 155 314 162 53 162 115 %ROW BY ROW MULTIPLICATION d=a.*b d= 1 50 0 50 225 40 0 40 81 %TRANSPOSE OF A MATRIX e=inv(a) e= -0.8261 0.7826 -0.6957 0.1826 -0.0783 0.0696 0.1739 -0.2174 0.3043 % CREATING A MATRIX inv(a)*a ans = 1

1 0 0

0 1 0

0 0 1

%EIGEN VALUE OF THE MATRIX f=eig(a) f= 21.5506 -1.1582 4.6075 %SINGULAR VALUE DECOMPOSITION g=svd(a) g= 21.7831 7.4155 0.7119 %COEFFICIENTS OF CHARACTERISTIC POLYNOMIAL h=poly(a) h= 1.0000 -25.0000 69.0000 115.0000 %TO ROUND THE RESULT i=round(poly(a)) i= 1 -25 69 115 %ROOTS OF CHARACTERISTIC POLYNOMIAL l=roots(h) l= 21.5506 4.6075 -1.1582 %RANK OF A MATRIX m=rank(a) m= 3 %ACCESING A SPECIFIC OR PARTICULAR ELEMENT OF THE MATRIX a(3,2) ans = 5

2

%READING A SPECIFIC ROW IN THE MATRIX a(3,:) ans = 3 5 9

%READING A SPECIFIC COLUMN IN THE MATRIX a(:,1) ans = 1 5 3 %ACCESSING SUBMATRICES n=a(1:2,1:2) n= 1 5 10 15

%CREATING A COLUMN o=[2 ; 5 ; 10] o= 2 5 10 %CONCATINATING WITH A COLUMN P=[a o] P= 1 5 3 10 15 5 0 2 8 5 9 10

%GENERATING SERIES OF NUMBERS R=1:10 R= 1 2 3 4 5 6 7 8 9 10

3

%GENERATING SERIES OF NUMBERS WITH SPECIFIED STEP S=1:9:100 S= 1 10 19 28 37 46 55 64 73 82 91 100 %ADDING A SCALAR TO EVERY ELEMENT OF THE MATRIX t=a+2 t= 3 7 5 12 2 17 10 7 11 %DETERMINATION OF A MATRIX u=det(a) u= -115 %SIZE OF THE MATRIX v=size(a) v= 3 3 4 .

SIGNAL GENERATIONS 5 .2.

50) 1 zeros(1. ylabel('Amplitude'). b=k*a. stem(t.b). ylabel('Amplitude').50)]. title('Sample Sequence').2.b).1 IMPULSE SEQUENCE AIM : To Generate Impulse Sequence SOFTWARE : PC Equipped with MATLAB 7. subplot(211). subplot(212). xlabel('Time Axis'). t=-50:1:50. O/P Wave Forms : 6 . plot(t. k=input('Enter the Amplitude').0 PROGRAM : a=[zeros(1.

xlabel('time sequence') ylabel('amplitude').101).2. Output Waveform: 7 .a).2 STEP SEQUENCE AIM : To Generate Step Sequence SOFTWARE : PC Equipped with MATLAB 7. stem(t.0 PROGRAM: t=-50:1:50. title('step response'). a=4*ones(1.

plot(t.3 RAMP WAVEFORM AIM : To Generate Ramp Wave SOFTWARE : PC Equipped with MATLAB 7. ylabel('x').x). xlabel('time sequence'). title('ramp sequence'). for n=1:50 x(n)=n end.2. Output Waveform: 8 .0 PROGRAM : t=1:1:50.

ylabel('amplitude').1 SAWTOOTH WAVEFORM AIM : To Generate Saw tooth Waveform SOFTWARE : PC Equipped with MATLAB 7. axis([-100 1000 -100 100]). for n=1:(P/2) a(n)=n. end a1=a. end plot(a1).4.0 PROGRAM : P=100. for i=1:9 a1=[a1 a]. t=1:1:P*10. title('sawtooth sequence'). xlabel('time sequence').2. end for n=(P/2)+1:P a(n)=n-P. Output Waveform: 9 .

ylabel('amplitude'). end plot(x).4.2 SAWTOOTH WAVEFORM AIM : To Generate Sawtooth Waveform SOFTWARE : PC Equipped with MATLAB 7. if(l==6) l=0. xlabel('time sequence').0 PROGRAM : clear all.2. l=0. title('sawtooth sequence'). end Output Waveform: 10 . for n=1:30 x(n)=l. else l=l+1.

2. ylabel('Amplitude').T/4) -1*ones(1. T=(1/fs). xlabel('time sequence'). %a1=a. axis([1 100 -3 2]) Output waveform: 11 .T/4) -1*ones(1.1 SQUARE WAVEFORM AIM : To Generate Square Wave SOFTWARE : PC Equipped with MATLAB 7.0125.T/4) ones(1. %end plot(a).T/4) ].5. title('square wave'). %for n=1:9 % a1=[a1 a]. a=[ones(1.0 PROGRAM : fs=0. t=1:1:T*10.T/4) -2*ones(1.

ylabel('Amplitude').T/2)] a1=a for n=1:9 a1=[a1 a] end plot(t.0125 T=1/fs t=1:1:T*10 a=[ones(1. axis([0 1000 0 2]) Output Waveform: 12 .0 PROGRAM : fs=.2.T/2) -1*ones(1. xlabel('time sequence').a1) title('square wave').2 SQUARE WAVEFORM AIM : To Generate Square Wave SOFTWARE : PC Equipped with MATLAB 7.5.

for a=1:5. x(n*8+a)=5-i. x(n*8+a)=a. ylabel('Amplitude').6.0 PROGRAM : for n=0:6.2. a=a+1. SOFTWARE : PC Equipped with MATLAB 7.1 TRIANGULAR WAVEFORM AIM : To Generate Triangular Wave. end for i=1:5. end end plot(x) title('triangular waveform'). xlabel('time sequence'). axis([1 20 1 10]) Output waveform: 13 .

2.6.2 TRIANGULAR WAVEFORM
AIM : To Generate Triangular Wave SOFTWARE : PC Equipped with MATLAB 7.0 PROGRAM : P=20; t=1:1:P*10; for n=1:(P/4) a(n)=n; end for n=(P/4)+1:(3*P/4) a(n)=(P/2)-n; end for n=(3*P/4)+1:P a(n)=n-P; end a1=a; for i=1:9 a1=[a1 a]; end plot(t,a1); title('triangular waveform'); xlabel('time sequence'); ylabel('Amplitude'); axis([0 200 -10 10]); Output Waveform:

14

2.7.1 SINEWAVE
AIM : To Generate Sinewave SOFTWARE : PC Equipped with MATLAB 7.0 PROGRAM : f=1000; T=1/f; t=0:T:50*T; y=sin(2*pi*50*t); plot(t,y); title('sinewave'); xlabel('time sequence'); ylabel('Amplitude'); %stem(y); Output Waveform:

15

2.7.2 SINUSOIDAL SEQUENCE
AIM : To Generate Sinusoidal Sequence for the given Specifications SOFTWARE: PC Equipped with MATLAB 7.0 PROGRAM: %Generation of sinusoidal sequence Clear; A=input('enter the value of gain constant'); N=input('enter the number of samples'); w=input('enter the radian frequency'); phy=input('enter the initial phase in rad'); for n=0:N-1 x(n+1)=A*cos(w*n+phy); t(n+1)=n; end stem(t,x); title('sinusoidal sequence'); xlabel('time index'); ylabel('amplitude'); pause;

16

Simulation Results: Type in the Gain constant : 5 Enter the number of samples : 40 Enter the radian frequency : 0 Enter the initial Phase in rad : 0 Output Waveforms: 17 .

Simulation Results: Type in the Gain constant : 5 Enter the number of samples : 40 Enter the radian frequency : pi/8 Enter the initial Phase in rad : 0 Output Waveforms: 18 .

Simulation Results: Type in the Gain constant : 5 Enter the number of samples : 40 Enter the radian frequency : pi/4 Enter the initial Phase in rad : 0 Output Waveforms: 19 .

Simulation Results: Type in the Gain constant : 5 Enter the number of samples : 40 Enter the radian frequency : pi Enter the initial Phase in rad : 0 Output Waveforms: 20 .

k1=input('enter the gain of first sinusoidal').S1). t(n+1)=n end subplot(311) stem(t. k2=input('enter the gain of second sinusoidal'). title('sum of two sinusoidals').3. title('second sinusoidal'). S3(n+1)=S1(n+1)+S2(n+1). stem(t. 21 . SUM OF SINUSOIDAL SEQUENCES AIM : To Generate Sum of Two Sinusoidal Sequences SOFTWARE : PC Equipped with MATLAB 7.S3). subplot(312) stem(t. subplot(313). title('first sinusoidal'). S2(n+1)=k2*sin(b*n).0 PROGRAM: % sum of sinusoidal a=input('enter the frequency of first sinusoidal').S2). N=input('enter the number of samples'). b=input('enter the frequency of second sinusoidal' ). for n=0:N-1 S1(n+1)=k1*sin(a*n).

2 enter the number of samples 50 Output Waveform: 22 .Simulation Results: enter the frequency of first sinusoidal 50 enter the gain of first sinusoidal 0.2 enter the frequency of second sinusoidal 50 enter the gain of second sinusoidal 0.

areal=input('enter the real part of a').4. j=sqrt(-1). ylabel('amplitude'). title(‘Complex exponential’) xlabel('time index').^n). for n=1:N-1 x(n)=k*(a. title(‘Complex exponential’) xlabel('time index'). stem(t. 23 . kreal=input('enter the real part of gain constant'). t(n)=n.real(x)). a=areal+j*aimag.imag(x)). aimag=input('enter the imaginary part of a'). k=kreal+j*kimag. pause. kimag=input('enter the imaginary part of gain constant'). ylabel('amplitude'). N=input('enter the number of samples').0 PROGRAM : %Generation of complex exponential sequence clear.1 COMPLEX EXPONENTIAL SEQUENCE AIM : To Generate the Complex Exponential Sequence for the given Specifications SOFTWARE : PC Equipped with MATLAB 7. end stem(t.

45 Enter the number of samples : 40 Output Waveform: 24 .Simulation Results: Enter the Real Part of Gain constant : 5 Enter the Image Part of Gain constant : 0 Enter the Real Part of a : 0.8 Enter the Imaginary Part of a : 0.

Simulation Results: Enter the Real Part of Gain constant : 5 Enter the Image Part of Gain constant : 0 Enter the Real Part of a : 0.85 Enter the Imaginary Part of a : 0.65 Enter the number of samples : 40 Output Waveform: 25 .

K=input('type the value of gain constant'). title('real exponential sequence').2 REAL EXPONENTIAL SEQUENCE AIM : To Generate the Real Exponential Sequence for the given Specifications SOFTWARE: PC Equipped with MATLAB 7.8 Output Waveform: 26 . for n=0:N-1 x(n+1)=K. ylabel('amplitude'). Simulation Results: Type in the Gain Constant : 5 Enter the Number of Samples : 20 Enter the Value of a : 0. a=input('enter the value of a'). N=input('enter the number of samples').*(a. xlabel('discrete time variable').0 PROGRAM: clear.x).4.^n). end stem(t. t(n+1)=n.

Simulation Results: Type in the Gain Constant : 5 Enter the Number of Samples : 20 Enter the Value of a : 1.2 Output Waveform: 27 .

28 .

Simulation Results: Type in the Gain Constant : 5 Enter the Number of Samples : 20 Enter the Value of a : -0.8 Output Waveform: 29 .

Simulation Results:

Type in the Gain Constant : 5 Enter the Number of Samples : 20 Enter the Value of a : -1.2 Output Waveform:

30

5.1.1 LINEAR CONVOLUTION
AIM : To Perform Convolution of Two Sequences SOFTWARE : PC Equipped with MATLAB 7.0 PROGRAM : a=[1,1,1,1]; b=[2,2,2,2]; t=1:8; a1=[a zeros(1,(length(b)-1))]; b1=[b zeros(1,(length(a)-1))]; b2=fliplr(b1); for n=1:7 b2=[b2(end) b2(1:end-1)]; c(n)=a1*b2'; end subplot(311); stem(a1); title('first sequence'); subplot(312); stem(b2); title('second sequence'); ylabel('amplituide'); subplot(313); stem(c) title('convolution of two discrete sequences '); xlabel('discrete time index');

31

Output Waveform:

32

N=length(b). b1=b. else for j=1:i-1 a=[a(M+N-1) a(1:(M+N-2))]. stem(a1). title('first sequence').M-1) b].1. M=length(a). a=[a zeros(1. a=I. for i=1:M+N-1 if i==1 c(i)=a*b'.0 33 .N-1)]. title('second sequence').5. ylabel('amplituide'). subplot(313). xlabel('discrete time index'). stem(b1). stem(c) title('convolution of two discrete sequences '). I=a. b=input('enter the samples of second sequence').2 LINEAR CONVOLUTION AIM : To Perform Convolution on given Two Sequences SOFTWARE : PROGRAM: a=input('enter the samples of first sequence'). a=fliplr(a). PC Equipped with MATLAB 7. end end subplot(311). a1=a. b=[zeros(1. end c(i)=a*b'. subplot(312).

Output Waveform: 34 .

3. title('second sequence').0 PROGRAM : a=[1. b1=fliplr(b). stem(a1).2. t=1:1:4. end subplot(311). for n=1:4 b1=[b1(end) b1(1:end-1)].5. title('first sequence'). ylabel('amplituide').7.4].1 CIRCULAR CONVOLUTION AIM : To Perform Circular Convolution of Two Sequences SOFTWARE : PC Equipped with MATLAB 7. stem(c) title('convolution of two discrete sequences '). xlabel('discrete time index') 35 .6.8]. stem(b2). subplot(313).2. b=[5. subplot(312). x(n)=a*b1'.

Output Waveforms: 36 .

end subplot(211). xlabel('time index'). z(n)=a1*b1'.1 AUTO CORRELATION AIM : To Perform Auto Correlation of Two Sequences SOFTWARE : PC Equipped with MATLAB 7. ylabel('amplitude')- 37 . title('Auto Correlation'). subplot(212). a1=[a zeros(1. b1=[zeros(1.6. title('input sequence').(length(a)-1)) a].1. stem(a1).1].0 PROGRAM : a=[1. for n=1:7 b1=[b1(end) b1(1:end-1)]. t=1:7.(length(a)-1))]. ylabel('amplitude').1. stem(z).

Output Waveform : 38 .

end for n=1:4 b1=[b1(end) b1(1:end-1)].(length(b)-1))]. t=1:8. b=input('b is '). title('First sequence') subplot(312). title(‘Cross correlation’) xlabel(‘Tme index’) SIMULATION RESULTS : a is [1 2 3] b is [3 4 5] c = 14 26 18 9 18 9 5 39 .2 CROSS CORRELATION AIM : To Perform Cross Correlation of Two Sequences SOFTWARE : PC Equipped with MATLAB 7.(length(a)-1))]. c(n)=a1*b1'. for n=5:7 b1=[b1(end) b1(1:end-1)]. c(n)=a1*b1'.6.0 PROGRAM : a=input('a is '). end c subplot(311). stem(c). stem(a1). b1=[b zeros(1. title(‘second sequence’) ylabel(‘Amplitude’) subplot(313). a1=[a zeros(1. stem(b1).

Output Waveform: 40 .

1.N)]. U=fft(u. N=input('enter the length of the sequence'). subplot(2.M).1). xlabel('frequency index').angle(U)). xlabel('time index'). ylabel('magnitude'). pause. title('phase of DFT samples'). stem(k. pause. u=[ones(1.u). ylabel('amplitude'). title('original time domain sequence'). xlabel('frequncy index k').1 DISCRETE FOURIER TRANSFORM AIM: To determine the Discrete Fourier Transform Coefficients of the given Input Sequence SOFTWARE : PC Equipped with MATLAB 7. M=input('type the length of dft'). title('magnitude of the DFT samples'). stem(t. k=0:1:M-1.abs(U)). stem(k.1. subplot(2.7. t=0:N-1.2).0 PROGRAM: %discrete fourier transform clear. 41 . ylabel('phase').

SIMULATION RESULTS: enter the length of the sequence 10 type the length of dft 20 Output Waveform: 42 .

subplot(212). title('Input sequence') ylabel('amplitude'). xlabel('Samples') 43 . title('Discrete Fourier transform'). z(k)=g. of points'). p=exp(-y).7. end. z subplot(211). stem(abs(z)). ylabel('amplitude'). z=[zeros(N)] for k=1:1:N for n1=1:1:N y=i*2*pi*k*n1/N. g=z(k)+(x(n1)*p). end.0 PROGRAM : x=[1 2 3 4] N=input('enter no.2 DISCRETE FOURIER TRANSFORM AIM : To Perform Discrete Fourier Transform of the given Sequence SOFTWARE : PC Equipped with MATLAB 7. stem(x).

Output Waveform 44 .

t=0:1/fs:10/fs.8. subplot(212). ylabel('amplitude') xlabel('time index') a1=xcorr(s. ylabel('Normalized magnitude') xlabel('Frequency') f=1:1024 45 .1 POWER DENSITY SPECTRUM AIM : To Compute and Plot Power Density Spectrum of the given Signals SOFTWARE : PC Equipped with MATLAB 7. %figure. f1=400.s). plot(t. s=sin(2*pi*f1*t)+sin(2*pi*f2*t).*conj(psd1)/1024.1024). subplot(211). %title('psd1').0 PROGRAM : Clear . psd1=fft(a1. title('input signal'). %plot(psd1). psd2=psd1. title('psd2'). plot(psd2). f2=200. fs=1000.s).

Output Waveform: : 46 .

000001. Pyy = Y.8. subplot(311) plot(y) title('Noisy time domain signal') Y = fft(y.0 PROGRAM : t = 0: .Pyy(1:50)) title('Power density spectrum') xlabel('Frequency (Hz)') ylabel(‘Amplitude’) Output Waveforms: 47 . x = sin(2*pi*50*t) + sin(2*pi*120*t).0000001: . y = x + 2*randn(size(t)).*conj(Y)/256.2 POWER DENSITY SPECTRUM AIM : To Compute and Plot Power Density Spectrum of the given Signals SOFTWARE : PC Equipped with MATLAB 7. Pyy(1:128)) title('Power density spectrum') xlabel('Frequency (Hz)') ylabel(‘Amplitude’) subplot(313) plot(f(1:50). subplot(312) plot(f. f = 1000/256*(0:127).256).

48 .

rs).9. title('Analog LPF Butterworth').w]=freqs(b.a. w=w/(2*pi).wn]=buttord(wp. ws=input('Enter value of stopband edge'). [h.1.512). [b. [n.1 ANALOG LOWPASS FILTER (BUTTERWORTH) AIM : To Design an Analog Lowpass Butterworth Filter for the given Specifications SOFTWARE : PC Equipped with MATLAB 7. fs=input('Enter value of sampling freq'). rs=input('Enter value of stopband attenuation'). rp=input('Enter value of passband attenuation').0 PROGRAM: wp=input('Enter value of passband edge').a]=butter(n.20*log10(y)).ws. ws=ws/fs/2.rp.'s'). plot(w. xlabel('frequency') SIMULATION RESULTS : Enter value of passband edge 5000 Enter value of stopband edge 8000 Enter value of passband attenuation 0. y=abs(h). ylabel('magnitude'). wp=wp/fs/2.1 Enter value of stopband attenuation 30 Enter value of sampling freq8000 OUTPUT WAVEFORM : 49 .wn.

9. ylabel('Magnitude in db').wn.0 PROGRAM: N=input('enter the order of filter'). omega=0:200:12000*pi.'s'). 50 . title('Butterworth LPF'). [num.20*log10(abs(h))).den]=butter(N.den. xlabel('Normalized Frequency'). wn=input('enter the value of cutoff frequency in Hz'). 1.2 ANALOG LOWPASS FILTER (BUTTERWORTH) AIM : To Design an Analog Lowpass Butterworth Filter for the given Specifications SOFTWARE : PC Equipped with MATLAB 7. plot(omega/2*pi.omega). h=freqs(num.

SIMULATION RESULTS : Enter the order of filter6 Enter the value of cutoff frequency in Hz 10000 OUTPUT WAVEFORM : 51 .

den.9.'s').den]=butter(N.wn.'high'. ylabel('Magnitude'). 52 .omega).20*log10(abs(h))). xlabel('Normalized Frequency').2 ANALOG HIGH PASS FILTER (BUTTERWORTH) AIM : To Design an Analog High pass Butterworth Filter for the given Specifications SOFTWARE: PC Equipped with MATLAB 7. h=freqs(num.0 PROGRAM: N=input('enter the order of filter'). plot(omega/2*pi. wn=input('enter the value of cutoff frequency in Hz'). title('Butterworth HPF'). omega=0:200:12000*pi. [num.

SIMULATION RESULTS : Enter the order of filter6 Enter the value of cutoff frequency in Hz 10000 OUTPUT WAVEFORM : 53 .

mag). b=fir1(N. plot(omega/pi. Fs=input('enter the value of sampling frequency'). SIMULATION RESULTS : enter the order of filter 6 enter the value of sampling frequency 10000 enter the value of cutoff frequency 1000 OUTPUT WAVEFORM : 54 .omega]=freqz(b. mag=20*log10(abs(h)). Fc=input('enter the value of cutoff frequency').10. Hw=rectwin (N+1). [h. title('FIR LPF using Rectangular Window'). xlabel('normalized frequency').Wn.1. Wn=2*Fc/Fs.512). ylabel('magnitude').1 FIR LOWPASS FILTER USING RECTANGULAR WINDOW AIM : To Design a FIR LowPass Filter using Rectangular Window for the given Specifications SOFTWARE: PC Equipped with MATLAB 7.Hw). grid.0 PROGRAM: N=input('enter the order of filter').

b=fir1(N.mag). plot(omega/pi. Fc=input('enter the value of cutoff frequency'). [h.Hw.1. ylabel(' Magnitude’) 55 .2 AIM : FIR LOWPASS FILTER USING TRIANGULAR WINDOW To Design a FIR LowPass Filter using Triangular Window for the given Specifications SOFTWARE: PC Equipped with MATLAB 7. grid. Hw=triang(N+1).Wn.omega]=freqz(b. xlabel('normalized frequency'). Fs=input('enter the value of sampling frequency'). title('FIR LPF using Triangular window'). N=input('enter the order of filter').512).10. Wn=2*Fc/Fs.0 PROGRAM: clear. mag=20*log10(abs(h)).).

SIMULATION RESULTS : Enter the order of filter6 Enter the value of sampling frequency10000 Enter the value of cutoff frequency1000 OUTPUT WAVEFORM : 56 .

mag=20*log10(abs(h)). grid.512). Hw=kaiser(N+1.Wn.Hw). xlabel('normalized frequency'). 57 . [h. Wn=2*Fc/Fs.10.mag).1. title('FIR LPF using kaiser Window').0 PROGRAM: N=input('enter the order of filter'). Fc=input('enter the value of cutoff frequency').omega]=freqz(b. Fs=input('enter the value of sampling frequency'). plot(omega/pi. AIM : FIR LOWPASS FILTER USING KAISER WINDOW To Design a FIR LowPass Filter using Kaiser Window for the given Specifications SOFTWARE: PC Equipped with MATLAB 7. b=fir1(N.2). ylabel('magnitude').3.

SIMULATION RESULTS : Enter the order of filter6 Enter the value of sampling frequency10000 Enter the value of cutoff frequency1000 OUTPUT WAVEFORM 58 .

512).Wn. mag=20*log10(abs(h)). title('FIR HPF using Rectangular Window'). b=fir1(N.0 PROGRAM: N=input('enter the order of filter'). Fc=input('enter the value of cutoff frequency'). grid.1.omega]=freqz(b. plot(omega/pi. Fs=input('enter the value of sampling frequency'). Hw=rectwin(N+1).4 FIR HIGHPASS FILTER USING RECTANGULAR WINDOW AIM : To Design a FIR HighPass Filter using Rectangular Window for the given Specifications SOFTWARE: PC Equipped with MATLAB 7.'high'. ylabel('magnitude').Hw). Wn=2*Fc/Fs.10. 59 . xlabel('normalized frequency').mag). [h.

SIMULATION RESULTS : Enter the order of filter22 Enter the value of sampling frequency100000 Enter the value of cutoff frequency5000 OUTPUT WAVEFORM 60 .

61 . b=fir1(N.0 PROGRAM: N=input('enter the order of filter'). Hw=hamming(N+1). wn2=wn2/(fs/2).10. ylabel('magnitude').mag). plot(omega/pi. mag=20*log10(abs(h)). fs=input('enter the value of sampling frequency').Wn.omega]=freqz(b. Wn1=wn1/(fs/2).4 FIR BANDPASS FILTER USING HAMMING WINDOW AIM : To Design a FIR BandPass Filter using Hamming Window for the given Specifications SOFTWARE: PC Equipped with MATLAB 7.1. grid.'bandpass'.Hw).512). [h. wn1=input('enter the value of Lower cutoff frequency'). title('FIR Bandpass filter using hamming Window'). xlabel('normalized frequency'). wn=[wn1 wn2]. wn2=input('enter the value of Upper cutoff frequency').

SIMULATION RESULTS : enter the order of filter6 enter the value of Lower cutoff frequency500 enter the value of Upper cutoff frequency700 enter the value of sampling frequency10000 OUTPUT WAVEFORM 62 .

[B. mag=20*log10(abs(H)). Fc1=input('Enter the value of Lower cutoff frequncy'). ylabel('Gain in db'). title('IIR BANDSTOP FILTER').A]=cheby1(N.'stop').A. pause. xlabel('Normalized frequency').omega]=freqz(B.Wn. SIMULATION RESULTS: Enter the value of order : 20 Enter the value Sampling Frequency : 10000 Enter the value of Lower Cutoff Frequency : 1000 Enter the value of Upper Cutoff Frequency : 2000 Enter the value of passband Ripple in dB : 1 63 . grid.0 PROGRAM: %IIR bandstop filter using Chebyshev Approximation clear. Fc2=input('Enter the value of HIGHER cutoff frequncy').IIR BSF USING CHEBYSHEV APPROXIMATION AIM : To design a infinite impulse response band stop filter using chebyshev approximation SOFTWARE: PC Equipped with MATLAB 7.r. plot(omega/pi. r=input('enter the value of allowable ripple'). [H.N). Fs=input('entrer the value of sampling frequency'). Wn(2)=2*Fc2/Fs.mag). N=input('enter the value of order '). Wn(1)=2*Fc1/Fs.

64 .

DSP PROCESSORS 65 .

ARCHITECTURE OF TMS320C67XX AND INSTRUCTION SET CONTENTS TMS320C6000 CPU Architecture Addressing Modes Instruction Set Overview 66 . 1.1.

67 .

TMS320C67x Block Diagram 68 .

TMS320C6713 ARCHITECTURE 69 .

Optimized for Audio Highly Optimized C/C++ Compiler Functional Units and Operations Performed: 70 . 6.Highest-Performance Floating-Point Digital Signal Processor TMS320C6713 • • • • • • Eight 32-Bit Instructions/Cycle 32/64-Bit Data Word 4.7-ns Instruction Cycle Time 1800 MIPS/1350 MFLOPS Rich Peripheral Set.4-.

Addressing Modes: • Immediate Addressing Mode • Register Direct Addressing Mode • Register Indirect Addressing Mode • Register relative Addressing mode Circular Addressing Mode Instructions Set: • • • • • • • • • • • • Absolute Value Instructions Addition/Subtraction Instructions Load/Store/Move Instructions Multiplication Instructions Compare Instructions Bit Manipulation Instructions Shift Instructions Logical Operation Instructions Program Control Instructions Conversion Instructions Special Instructions Miscellaneous Instructions 71 .

C67x Instruction Set 72 .

AMR Register: CMPEQ (Integer Compare for Equality): 74 .

B1 MPY(U/US/SU): 75 .LDB(U)/LDH(U)/LDW : LDB .D2 *+B14[36].

MVKH/MVKLH (Move 16-Bit Constant Into the Upper Bits of a Register): SHL (Arithmetic Shift Left): 76 .

77 .

S1 A1:A0.SUB(U) (Signed or Unsigned Integer Subtraction Without Saturation): Floating-Point Instruction Set ABSDP (Double-Precision Floating-Point Absolute Value): ABSDP .A3:A2 78 .

S1 A1:A0.unit) src1. src2.A5:A4 79 .M1 A1:A0. dst CMPGTDP .A4 MPYDP (Double-Precision Floating-Point Multiply): MPYDP .A3:A2.A3:A2.CMPGTDP (Double-Precision Floating-Point Compare for Greater Than): CMPGTDP (.

up to one crosspath per execute packet per side – ‘C64x .same side as unit – Source register .1 cycle delay slot • Address – Pointer must be on same side as unit – Data can be transferred to/from either side – Parallel accesses: both cross or neither cross • Conditional – Unlimited 81 .A4 [A1] LDW .D2 *B0.A5 – • Data – Destination register .B0.Conditionals Cross Paths: If conditional register comes from the opposite side.L1x A2. it does NOT use a data or address cross-path • Examples: [B2] ADD .

Click the File and Save . From the Project menu. Exit →YES 4. Click the clear button in the import configuration dialog box to remove any previously defined configuration [My System (Uninstall all) ] 3.dvr) and open → OK 6.dvr (For dsktixds6000. Pjt) 1. Add Source file to the Project Project → add files to project → select your .CODE COMPOSER STUDIO STEPS 1. little endian Click the import button → close Click on Install device driver → Select Tisim C6XXX . Start CCS setup by double clicking on the setup CCS desktop icon 2. File → NEW → Source file 3. Creating a New Project The information for a project is stored in a single project file ( * . Select the standard configuration Family → Platform → Endianness → C67XX Simulator Little C6711 device simulation. choose NEW The Project creation Wizard window displays Project Name : Enter the Project name Location: D:\ti\myprojects ↓ Finish 2. Type your source code in that file. The CCS Setup closes and the CCS IDE automatically opens using the configuration you just created.lib → OPEN 82 .asm file → click open To add Library Files Project → add files to project D:\ti → C6000→ Cgtools → Lib(Object & Library files) rst6700. 5. After writing the source file save that file as . In File Option select NEW source file.asm file 4.

out file ↓ OPEN Debug → RUN View → Registers → Core Registers According to the Program select the core Register and load the address of the Core Register as Memory address For ex : A5 → 8000 0000 View → Memory Address → 8000 0000 Select → Format type as 16 – bit Signed int → OK 83 .cmd) ↓ OPEN TO Compile Project → Compile File Project → Build If there are any errors it will specify If building is successful it creates .out file.To add Command Files Project → Add files to project D:\ti → Tutorial → (dsk6711 / sim62XX) ↓ hello1 (linker command file) ↓ hello . cmd (for real time lnk. Loading the Program File → Load Program → Debug → Select .

&b). printf("THE VALUE OF A+B IS %d".2.&a.a+b).b. printf("ENTER THE VALUES OF A AND B"). scanf("%d %d".Code SOFTWARE: PC and Code Composer Studio PROGRAM : # include <stdio.h> void main() { int a.1 ADDITION AIM: To Perform Addition of two numbers using C. } SIMULATED RESULTS: Enter the values of a and b 2 3 The value of a+b is 5 84 .

2 SUBTRACTION AIM: To Perform Subtraction of two numbers using C.&b).2.&a. } SIMULATED RESULTS: Enter the values of a and b 3 2 The value of a-b is 1 85 . printf("THE VALUE OF A-B IS %d".b. printf("ENTER THE VALUES OF A AND B").h> void main() { int a.a-b). scanf("%d %d".Code SOFTWARE: PC and Code Composer Studio PROGRAM : # include <stdio.

} SIMULATED RESULTS: Enter the values of a and b 2 3 The value of a * b is 6 86 .a*b).&b).&a.b.2.3 MULTIPLICATION AIM: To Perform Multiplication of two numbers using C.h> void main() { int a. printf("THE VALUE OF A * B IS %d". printf("ENTER THE VALUES OF A AND B"). scanf("%d %d".Code SOFTWARE: PC and Code Composer Studio PROGRAM : # include <stdio.

3.j. int b[9]={1. int m=5.h> void main() { int a[9]={1.1 LINEAR CONVOLUTION AIM : To Perform Linear Convolution of two sequences using C-Code SOFTWARE: PC and Code Composer Studio PROGRAM: #include<stdio.j++) c[i]=c[i]+(a[j]*b[i-j]). int c[10]. for(j=0.j<=i.1. c[i]).n=5.2. for(i=0.i<m+n-1.i.1}.1.5}.4.i<m+n-1.3.i++) { c[i]=0.i++) printf ("%d". } OUTPUT : 1 3 6 10 15 14 12 9 5 87 . } for(i=0.1.

&b[i]).N. for(i=0. for(j=0.i.h> #define MAX1 10 #define MAX2 10 void main() { int a[MAX1].3. for(i=0.2 LINEAR CONVOLUTION AIM : To Perform Linear Convolution of two sequences using C-Code SOFTWARE: PC and Code Composer Studio PROGRAM: #include<stdio.b[MAX2]. scanf("%d". scanf("%d".M.temp).&N).i<(M+N-1).j<=i.temp.&M). printf("ENTER THE ELEMENTS OF THE ARRAY A:\n").i++) scanf("%d".j++) { if((j<M)&&((i-j)<N)) temp+=a[j]*b[i-j].&a[i]). printf("ENTER THE RANGE OF THE ARRAY A:(MAX1=10)\n"). printf("ENTER THE RANGE OF THE ARRAY B:(MAX2=10)\n").i++) { temp=0. printf("THE VALUES OF THE ARRAY (A CONV B):\n").i<N.i++) scanf("%d".j. printf("ENTER THE ELEMENTS OF THE ARRAY B:\n"). } printf("%d ". } } 88 .i<M. for(i=0.

SIMULATION RESULTS : ENTER THE RANGE OF THE ARRAY A:(MAX1=10) 4 ENTER THE RANGE OF THE ARRAY B:(MAX2=10) 3 ENTER THE ELEMENTS OF THE ARRAY A: 1 2 3 4 ENTER THE ELEMENTS OF THE ARRAY B: 1 2 3 THE VALUES OF THE ARRAY (A CONV B): 1 4 10 16 17 12 89 .

D1 A2.2.0.0 .A6 .3.2 [B0] B [A2] B B STH .0.0.y[i]+=x[j]*h[i-j].A7.I=0 .POINTER TO X .0 . .j<=i.3.S1 X.S2 H.i<m+n-1. .A5 MVKH .POINTER TO H .A3.B5.2.3.L1 A7 ZERO . for(i=0.L2 A3.bss Y.i++) .0.6.1.RETURN BACK TO C PROGRAM NOP 5 90 .3 LINEAR CONVOLUTION AIM: To perform Linear Convolution of two sequences using Assembly Code SOFTWARE: PC and Code Composer Studio PROGRAM : .B4 MVKL .L1 A3 LL2: ZERO .B5 .4.half 1.S1 Y.B2 ZERO .B2.0.global _main X H _main: MVKL .S2 11.0.A5 MVK .*A5[A3] ADD .half 1.5.S1 Y.B6 .4.D1 *A4[A8].L1 A2 ZERO .S2 NOP 5 .J=0.0.A4 MVKH .A2 .S2X A8.30.B4 MVKH .A7 .L1 A3.L1 A8 LL1: LDH MV SUB LDH NOP 4 MPY ADD ADD CMPLT .L1 A8.A4 MVKL .D2 *B4[B7].6.B7 .M1X A6.S1 LL2 NOP 5 B3 .B0 LL1 .0.M+N-1 .L1 A2.POINTER TO Y .A2 .A3 CMPLT .S1 X.5.0.j++) .B6.L1X A3. for(j=0.A8 .L2X B5.0.1.S2 H.

To View Output Graphically Select View → Graph → Time and Frequency 91 . To view Output Numerically Select view → Registers → Core Registers → A5 Select view → Memory → Address → Type value of A5 → Format → 16 – bit Unsigned Int Click OK 80000000 : 1 4 10 20 35 56 70 76 73 60 36 2.OUTPUT: 1.

i<M.4. 92 .i++) a[i]=0. for(i=0. for(i=0.h> #define MAX 10 void main( ) { int a[MAX].z. } else { for(i=M.c[MAX].i++) scanf("%d".&N). } c[1]=temp.i++) { temp=c[0]. scanf("%d".i<N. for(i=0.N).i<N.x. k=max(M. if(k==M) { for(i=N. printf("ENTER THE RANGE OF THE ARRAY B:(MAX=10)\n").i.j.int ).z>=2.&a[i]). for(i=0.i<M.b[MAX].1 CIRCULAR CONVOLUTION AIM : To Perform Circular Convolution of two sequences using C-Code SOFTWARE: PC and Code Composer Studio PROGRAM: #include<stdio.&M).temp.N. } printf("THE VALUES OF THE ARRAY (A CIRCULAR CONV B):\n"). scanf("%d".i++) c[i]=b[M-1-i].i++) c[i]=a[N-i-1]. printf("ENTER THE RANGE OF THE ARRAY A:(MAX=10)\n"). int max(int .k.i<k. for(i=0. printf("ENTER THE ELEMENTS OF THE ARRAY B:\n").i<M.M. c[0]=c[k-1]. for(z=k-1.&b[i]). printf("ENTER THE ELEMENTS OF THE ARRAY A:\n").i<N.i++) scanf("%d".z--) { c[z]=c[z-1].i++) b[i]=0.

} } int max(int l. else x=x+b[j]*c[j].j++) { if(k==M) x=x+a[j]*c[j]. for(j=0. else return(p).x).int p) { if(l>p) return(l).j<k.x=0. } SIMULATED RESULTS : ENTER THE RANGE OF THE ARRAY A:(MAX=10) 4 ENTER THE RANGE OF THE ARRAY B:(MAX=10) 3 ENTER THE ELEMENTS OF THE ARRAY A: 1 2 3 4 ENTER THE ELEMENTS OF THE ARRAY B: 1 2 3 THE VALUES OF THE ARRAY (A CIRCULAR CONV B): 18 16 10 16 93 . } printf("%d ".

k. for(i=0.i<k.&b[i]). } else { for(i=M.h> #define MAX 10 void main( ) { int a[MAX]. for(i=0.z.&N).z--) { c[z]=c[z-1].i++) { temp=c[0].i<M.i++) a[i]=0.int ). if(k==M) { for(i=N.i++) c[i]=a[N-i-1]. printf("ENTER THE ELEMENTS OF THE ARRAY A:\n").M.&M).i<N. } printf("THE VALUES OF THE ARRAY (A CIRCULAR CONV B):\n").x.j. scanf("%d". for(i=0. printf("ENTER THE RANGE OF THE ARRAY B:(MAX=10)\n"). c[0]=c[k-1]. k=max(M. for(i=0.i++) b[i]=0. printf("ENTER THE RANGE OF THE ARRAY A:(MAX=10)\n").i<M. } c[1]=temp.i++) scanf("%d". printf("ENTER THE ELEMENTS OF THE ARRAY B:\n").i++) c[i]=b[M-1-i].c[MAX].i++) scanf("%d".i<M.4. int max(int .i. for(z=k-1. scanf("%d".N). for(i=0.i<N.&a[i]).b[MAX].z>=2.temp.2 CIRCULAR CONVOLUTION AIM : To Perform Circular Convolution of two sequences using C-Code SOFTWARE: PC and Code Composer Studio PROGRAM: #include<stdio. 94 .N.i<N.

x). } SIMULATED RESULTS : ENTER THE RANGE OF THE ARRAY A:(MAX=10) 4 ENTER THE RANGE OF THE ARRAY B:(MAX=10) 3 ENTER THE ELEMENTS OF THE ARRAY A: 1 2 3 4 ENTER THE ELEMENTS OF THE ARRAY B: 1 2 3 THE VALUES OF THE ARRAY (A CIRCULAR CONV B): 18 16 10 16 95 . else x=x+b[j]*c[j]. else return(p).int p) { if(l>p) return(l).x=0. } } int max(int l.j<k. for(j=0.j++) { if(k==M) x=x+a[j]*c[j]. } printf("%d ".

} COMPLEX.c FFT implementation calling a C-coded FFT function #include <math. } for (i = 0 .0.14159265358979 typedef struct {float real.imag=0. FAST FOURIER TRANSFORM(FFT) AIM : C-Program to implement FFT SOFTWARE: PC and Code Composer Studio PROGRAM 1 : /* Number of points for FFT (PTS) 256 iobuffer → input signal sample → output of FFT function (don't use on graph window) x1→ use in graph window */ ============================================================ // FFT256c. //intermediate buffer short i. //general purpose index variable short buffercount = 0.real = cos(2*PI*i/(PTS*2. //set to 1 by ISR when iobuffer full COMPLEX w[PTS].> freq.5.real=0. i++) //swap buffers { samples[i]. //Im component of twiddle constants } for (i = 0 . void FFT(COMPLEX *Y. i++) // set up twiddle constants in w { w[i].0)). i<PTS . i < PTS ./*10. //Re component of twiddle constants w[i]. imag. //primary working buffer main() { for (i = 0 . samples[i].0. //buffer with new data 96 . //as input and output buffer float x1[PTS]. //twiddle constants stored in w COMPLEX samples[PTS].100 -> sampling freq*/ samples[i]. i < PTS .imag =-sin(2*PI*i/(PTS*2.h> #define PTS 64 //# of points for FFT #define PI 3. //FFT prototype float iobuffer[PTS]. i++) //swap buffers { iobuffer[i] = sin(2*PI*1*i/PTS). int n). //number of new samples in iobuffer short flag = 0.real=iobuffer[i].0)).

(Y[lower_leg]).imag*samples[i].real = (Y[upper_leg]). //index of upper/lower butterfly leg int leg_diff. imag} COMPLEX. } for (i = 0 . //index/step through twiddle constant i = 1.imag = (Y[upper_leg]). i++) //for N-point FFT { index = 0. 97 //end of main .i < num_stages.temp2.real + samples[i].c for (i = 0 .imag. j++) { for (upper_leg = j. leg_diff = N/2. //step between values in twiddle. //number of FFT stages (iterations) int index. temp1.imag = 0. for (j = 0. temp2. } } PROGRAM 2 ( FFT.imag + (Y[lower_leg]). //difference between upper&lower legs step = (PTS*2)/N. upper_leg < N.real. int N) //input sample array. extern COMPLEX w[PTS]./* iobuffer[i] = x1[i]. temp1.j.real = (Y[upper_leg]).h // 512 for (i = 0. step.C) #define PTS 256 //# of points for FFT typedef struct {float real.real .real*samples[i].PTS). //temporary storage variables int i. }while (i!=N). //loop counter variables int upper_leg. //difference between upper/lower leg int num_stages = 0.imag). FFT(samples. # of points { COMPLEX temp1. i = i*2. //processed frame to iobuffer*/ //imag components = 0 //call function FFT. i++) samples[i].real. upper_leg += (2*leg_diff)) { lower_leg = upper_leg+leg_diff. i < PTS .0.k. i++) //compute magnitude { x1[i] = sqrt(samples[i]. //twiddle constants stored in w void FFT(COMPLEX *Y. lower_leg.real + (Y[lower_leg]). i < PTS .///32. //log(base2) of N points= # of stages do { num_stages +=1. j < leg_diff.

imag = temp1.real.real -temp2.real. k = k/2.real = (Y[i]). (Y[i]).real = temp2. } } return.imag = temp1. i++) //bit reversal for resequencing data { k = N/2. i < (N-1).real = temp1.imag = (Y[j]).cmd Add Library file Compile the program using project → compile Project → build Load the program using file → load Run the program and observe output using Graph 98 .temp2. for (i = 1.imag.real = temp1.real = (Y[j]). while (k <= j) { j = j .imag.imag*(w[index]). } j = j + k.imag. (Y[i]).imag = (Y[upper_leg]). (Y[upper_leg]). } leg_diff = leg_diff/2. } index += step. (Y[j]).real*(w[index]).imag .imag.imag = (Y[i]). (Y[lower_leg]).imag. (Y[upper_leg]). } Procedure :        Add the source files program1 and program2 in the project using project → add files to project Add the Linker command file lnk.imag*(w[index]). } j = 0.k. temp1.(Y[lower_leg]).imag +temp2. (Y[j]). (Y[lower_leg]).imag.real. if (i<j) { temp1. step *= 2.real.imag = temp2.real*(w[index]).real.

Output Waveform: 99 .

//FFT prototype float iobuffer[PTS].h> #define PTS 128 //# of points for FFT #define PI 3. //intermediate buffer short i. for (i = 0 .a. //number of new samples in iobuffer short flag = 0. //primary working buffer main() { float j. /*Im component of twiddle constants*/ } /****************Input Signal X(n) ************************/ for(i=0. //Re component of twiddle constants w[i]. } 100 . //as input and output buffer float x1[PTS].k. samples[i].14159265358979 typedef struct {float real.imag =-sin(2*PI*i/(PTS*2.0.} COMPLEX.i++) { x[i] = sin(2*PI*5*i/PTS).0)). samples[i]. // Signal x(Fs)=sin(2*pi*f*i/Fs).j=0.real=0.real = cos(2*PI*i/(PTS*2.sum=0.0)).imag. int n). //set to 1 by ISR when iobuffer full float y[128].imag=0. COMPLEX w[PTS]. void FFT(COMPLEX *Y.0. sample --> output of FFT function (don't use on graph window) x1 --> use in graph window to view PSD */ #include <math. i<PTS .0 . i++) // set up twiddle constants in w { w[i].i. //general purpose index variable short buffercount = 0.i<PTS. int n. //twiddle constants stored in w COMPLEX samples[PTS].x[PTS].POWER DENSITY SPECTRUM (PSD) AIM : C-Program to implement PSD SOFTWARE: PC and Code Composer Studio PROGRAM 1 : /*Number of points for FFT (PTS) x --> Sine Wave Co-Efficients iobuffer --> Out put of Auto Correlation.

imag*samples[i].imag = 0.real + samples[i]./********************Auto Correlation of X(n)=R(t) ********/ for(n=0. FFT(samples. //buffer with new data } for (i = 0 . i < PTS . } iobuffer[n] = sum. } } //end of main 101 .real*samples[i].c /******************** PSD ***************/ for (i = 0 . for(k=0.imag).PTS). } // Auto Correlation R(t) /********************** FFT of R(t) *****************************/ for (i = 0 .0. i < PTS .real=iobuffer[i]. i < PTS . i++) samples[i].n++) { sum=0.k++) { sum=sum+(x[k]*x[n+k]).n<PTS. //imag components = 0 //call function FFT.k<PTS-n. i++) //swap buffers { samples[i]. i++) //compute magnitude { x1[i] = sqrt(samples[i].

temp2. i++) //for N-point FFT { index = 0. //index/step through twiddle constant i = 1.imag. j < leg_diff. (Y[lower_leg]). extern COMPLEX w[PTS]. (Y[upper_leg]).imag +temp2. //twiddle constants stored in w void FFT(COMPLEX *Y.j.imag + (Y[lower_leg]).real = temp1. temp1. //difference between upper/lower leg int num_stages = 0.temp2.} COMPLEX.real.imag.imag*(w[index]).imag = temp1. } leg_diff = leg_diff/2.imag = temp2.real.imag. upper_leg += (2*leg_diff)) { lower_leg = upper_leg+leg_diff. //number of FFT stages (iterations) int index. i = i*2. for (j = 0.h // 512 for (i = 0.real = (Y[upper_leg]).imag = (Y[upper_leg]). leg_diff = N/2.imag .PROGRAM 2 : Number of points for FFT (PTS) ============================================================ #define PTS 128 //# of points for FFT typedef struct {float real. upper_leg < N.real = (Y[upper_leg]). # of points { COMPLEX temp1. //loop counter variables int upper_leg. i < (N-1).real*(w[index]).real. int N) //input sample array. //step between values in twiddle. i++) //bit reversal for resequencing data 102 .imag = (Y[upper_leg]).real = temp2. temp2. (Y[upper_leg]).imag. temp1.real. //index of upper/lower butterfly leg int leg_diff. step.(Y[lower_leg]). //log(base2) of N points= # of stages do { num_stages +=1. j++) { for (upper_leg = j. //temporary storage variables int i.imag.real -temp2.i < num_stages. } index += step.(Y[lower_leg]).real . //difference between upper&lower legs step = (PTS*2)/N. step *= 2.real*(w[index]). (Y[lower_leg]). }while (i!=N).k. lower_leg.imag*(w[index]). for (i = 1. } j = 0.real + (Y[lower_leg]).

(Y[j]). (Y[i]).imag.real = (Y[i]).imag.imag = (Y[j]). } } return.cmd  Add Library file  Compile the program using project → compile  Project → build  Load the program using file → load  Run the program and observe output using Graph 103 .imag = (Y[i]).real. temp1.real = temp1. k = k/2.real = (Y[j]).imag.k. if (i<j) { temp1. (Y[i]).real.real. } Procedure :  Add the source files program1 and program2 in the project using project → add files to project  Add the Linker command file lnk.{ k = N/2. (Y[j]).imag = temp1. while (k <= j) { j = j . } j = j + k.

Output Waveforms: 104 .

/* EMIF SDRAM extension */ mcbsp0_init().027335.016567.023194.020203.0.041842.-0.-0.303048. -0.115971.041842. /* EMIF global control */ *(unsigned volatile int *)EMIF_CE0 = 0x30.303048.h" double h[31] = {-0. /* clear all pending interrupts */ *(unsigned volatile int *)EMIF_GCR = 0x3300.0. return(0).-0. /* EMIF SDRM refresh period */ *(unsigned volatile int *)EMIF_SDEXT = 0x54519.0. /* disable all interrupts */ IER=1.7.043293. */ *(unsigned volatile int *)McBSP0_RCR = 0x10040.025105.038657.-0. } void mcbsp0_init() { /* set up McBSP0 */ *(unsigned volatile int *)McBSP0_SPCR = 0.386435. int main() { /* dsp and periphiral initialization */ CSR=0x100.0.025105.0. /* EMIF CE0control */ *(unsigned volatile int *)EMIF_CE1 = 0xffffff03. /* reset serial port */ *(unsigned volatile int *)McBSP0_PCR = 0.0.-0. 8bit async */ *(unsigned volatile int *)EMIF_SDCTRL = 0x07117000.-0.h" #include "codec_poll. /* EMIF SDRAM control *(unsigned volatile int *)EMIF_SDRP = 0x61a. /* set pin control reg.0.038657.0.011411. /* EMIF CE1 control.-0.000000.c) #include <stdio.-0. 0.033672.027335.0.-0.082004.011411.-0.023194.009656..h> #include <c6x.082004. codec_playback().h> #include "c6211dsk. one 16 bit data/frame */ 105 */ .0.115971.033672. /* set rx control reg.009656.0.043293.0.0.020203 }. 0.-0.1 FINITE IMPULSE RESPONSE FILTER AIM : C-Program to implement FIR filter SOFTWARE: PC and Code Composer Studio PROGRAM 1: (filter.016567.000000. /* disable all interrupts except NMI */ ICR=0xffff.-0.0.0.

mcbsp0_read(). } *(unsigned volatile int *)McBSP0_DXR = out_data. mcbsp0_read(). /* setup SP control reg. mcbsp0_write(0). 106 */ . mcbsp0_read(). mcbsp0_write(0). while ( temp == 0) { temp = *(unsigned volatile int *)McBSP0_SPCR & 0x2.. /* set tx control reg. mcbsp0_read(). } int mcbsp0_read() { int temp. mcbsp0_write(0x0386). one 16 bit data/frame */ *(unsigned volatile int *)McBSP0_DXR = 0. temp = *(unsigned volatile int *)McBSP0_SPCR & 0x2. return temp. mcbsp0_read(). temp = *(unsigned volatile int *)McBSP0_SPCR & 0x20000. i.*(unsigned volatile int *)McBSP0_XCR = 0x10040. x[31]. mcbsp0_write(1). *(unsigned volatile int *)McBSP0_SPCR = 0x12001. z. } temp = *(unsigned volatile int *)McBSP0_DRR. mcbsp0_write(0). mcbsp0_write(0). while ( temp == 0) { temp = *(unsigned volatile int *)McBSP0_SPCR & 0x20000. // set up control register 3 for S/W reset mcbsp0_read(). } void codec_playback() { int temp. } void mcbsp0_write(int out_data) { int temp. double y. mcbsp0_read().

S2 B0 NOP NOP NOP NOP NOP NMI_RST: NOP NOP NOP NOP NOP NOP NOP NOP RESV1: NOP NOP NOP NOP NOP NOP NOP NOP RESV2: NOP NOP NOP NOP 109 . B0 B .S2 _c_int00.sect "vectors" RESET_RST: MVKL .S2 _c_int00.{ x[i+1] = x[i].ref _c_int00 .asm) * * * TI Proprietary Information Internal Data . } } } PROGRAM 2: (vectors. B0 MVKH .

NOP NOP NOP NOP INT4: NOP NOP NOP NOP NOP NOP NOP NOP INT5: NOP NOP NOP NOP NOP NOP NOP NOP INT6: NOP NOP NOP NOP NOP NOP NOP NOP INT7: NOP NOP NOP NOP NOP NOP NOP NOP INT8: NOP NOP NOP NOP NOP NOP NOP NOP 110 .

INT9: NOP NOP NOP NOP NOP NOP NOP NOP INT10: NOP NOP NOP NOP NOP NOP NOP NOP INT11: NOP NOP NOP NOP NOP NOP NOP NOP INT12: NOP NOP NOP NOP NOP NOP NOP NOP INT13: NOP NOP NOP NOP NOP NOP NOP NOP INT14: NOP NOP NOP NOP NOP 111 .

#define ALL_5 #define CE1_8 #define CE1_32

0x55555555 0xffffff03 /* reg to set CE1 as 8bit async */ 0xffffff23 /* reg to set CE1 as 32bit async */

PROGRAM 4 : (codec_poll.h)
#define PRINT 1 void codec_playback(); void mcbsp0_init(); int mcbsp0_read(); void mcbsp0_write(int out_data);

PROGRAM 5 : (lnk.cmd) -c -heap 0x400 -stack 0x400 -lrts6201.lib

/* very large stack for DSP Programs*/

MEMORY { vecs : o = 00000000h I = 00000200h IRAM : o = 00000200h I = 0000fe00h CEO : o = 80000000h I = 01000000h } SECTIONS { "vectors" > vecs .cinit > IRAM .text > IRAM .stack > IRAM .bss > IRAM .cinit > IRAM .const > IRAM .data > IRAM .far > IRAM .switch > IRAM .sysmem > IRAM .tables > IRAM .cio > IRAM }

115

Procedure :  Open Code Composer studio, make sure the DSP kit is turned on.  Make sure to connect the signal generator to Audio Jack named ‘IN’  Make sure Sinusoidal Input frequency = 1 KHz and i/p voltage Vp-p = 1-2 V  Connect a CRO to audio jack named ‘OUT’  Add the source files program1 and program2 in the project using project → add files to project  Copy Program3 and Program 4 header files and paste it in project folder.  Add the Linker command file program5.  Add Library file “rts6700.lib”(c:\ti\c6000\cgtools\lib\rts6700.lib)  Compile the program using project → compile  Project → build  Load the program using file → load  Run the program and observe output at the Oscilloscope.

116

7.2 INFINITE IMPULSE RESPONSE FILTER
AIM : C-Program to implement IIR filter SOFTWARE: PC and Code Composer Studio PROGRAM 1: (filter1.c) #include <stdio.h> #include <c6x.h> #include "c6211dsk.h" #include "codec_poll.h" #define order 8 float num_bw1[9]={0.001953,-0.015621,0.054672,-0.109345,0.136681, -0.109345,0.054672,-0.015621,0.001953}; float den_bw1[9]={1.000000,1.991584,3.926426,5.038243,5.385756, 4.463121,2.956255,1.381781,0.495187}; int main() { /* dsp and periphiral initialization */ CSR=0x100; /* disable all interrupts */ IER=1; /* disable all interrupts except NMI */ ICR=0xffff; /* clear all pending interrupts */ *(unsigned volatile int *)EMIF_GCR = 0x3300; /* EMIF global control */ *(unsigned volatile int *)EMIF_CE0 = 0x30; /* EMIF CE0control */ *(unsigned volatile int *)EMIF_CE1 = 0xffffff03; /* EMIF CE1 control, 8bit async */ *(unsigned volatile int *)EMIF_SDCTRL = 0x07117000; /* EMIF SDRAM control *(unsigned volatile int *)EMIF_SDRP = 0x61a; /* EMIF SDRM refresh period */ *(unsigned volatile int *)EMIF_SDEXT = 0x54519; /* EMIF SDRAM extension */ mcbsp0_init(); codec_playback(); return(0); } void mcbsp0_init() { /* set up McBSP0 */ *(unsigned volatile int *)McBSP0_SPCR = 0; /* reset serial port */ *(unsigned volatile int *)McBSP0_PCR = 0; /* set pin control reg.; */ *(unsigned volatile int *)McBSP0_RCR = 0x10040; /* set rx control reg. one 16 bit data/frame */ *(unsigned volatile int *)McBSP0_XCR = 0x10040; /* set tx control reg. one 16 bit data/frame */
117

*/

return temp. while ( temp == 0) { temp = *(unsigned volatile int *)McBSP0_SPCR & 0x20000. mcbsp0_read(). } int mcbsp0_read() { int temp. mcbsp0_write(0).x[9]. z. mcbsp0_write(0x0386). temp = *(unsigned volatile int *)McBSP0_SPCR & 0x20000.. double output. mcbsp0_write(0). } *(unsigned volatile int *)McBSP0_DXR = out_data. mcbsp0_write(1). double y[9]. mcbsp0_read(). mcbsp0_read(). void mcbsp0_write(int out_data) { int temp. mcbsp0_read(). while ( temp == 0) { temp = *(unsigned volatile int *)McBSP0_SPCR & 0x2. mcbsp0_write(0). mcbsp0_write(0). 118 . mcbsp0_read(). // set up control register 3 for S/W reset mcbsp0_read(). *(unsigned volatile int *)McBSP0_SPCR = 0x12001. temp = *(unsigned volatile int *)McBSP0_SPCR & 0x2. } void codec_playback() { int temp. */ } /* setup SP control reg.*(unsigned volatile int *)McBSP0_DXR = 0. } temp = *(unsigned volatile int *)McBSP0_DRR. i. mcbsp0_read().