Sei sulla pagina 1di 26

DIGITAL SIGNAL PROCESSING

By Engr. Taha Hasan

DSP LAB
MANUAL
Instructor: Muhammad Usman
Steps:
Kit should be disconnected.

• VMware machine  power on button  Vm work station  file  open  XP.


• Open CC studio  ignore  project  new  target 67  browse  folder  new folder
 project name  lab1.
• File  new source file.
• Save as  open your project folder  name [lab1.c]
• Right click on project file(*.pjt)  add files to project  select your source file to add.
• Right click on project file(*.pjt)  add files to project  Desktop  Dsk6713 
.1. C6713dskinit.c
.2. Rts6700.lib
.3. Vector_intr.asm
.4. Csl6713.lib
.5. Dsk6713bsl.lib
• File  new  DSP bios configuration  dsk6713.cdb  scheduling  hardware interrupt
 HWF interrupt 11 (right click)  properties 
.1. Interrupt source  MCSP_1_Transmit
.2. Function  _c_int11 [small latter]
.3. Dispatcher tab  tick on use dispatcher
.4. Ok
• Ctrl + S  save configuration in your project folder.
• Right click on project file(*.pjt)  add files to project  open your project folder  select
configuration1.cdb
• Project menu  build option 
.1. basic  target revision  671x 
.2. Advance  memory module  far(mem.model data=far)
.3. Feedback  intelsing  OPT/c EASM
.4. Preprocessor  predefine symbol  CHIP_6713 [capital]
.5. Include search path  win+D  DSk6715/include  copy Address  past in include
search bar.
• For build press F7 key.
Close program And connect DSP kit through USB cable then reopen CC studio.
ALT + C  Ctrl + L  Debug  select (*.out) file.
Low pass Butterworth Filter
Cutoff=500Hz and Fs=8KHz with order=3
Matlab code
clc
clear all
close all
ftype='low';
ord=3;
w=2*pi*500;
fs=8000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
float w[4];
float d[4]={0.0051, 0.0154, 0.0154, 0.0051};
float c[3]={-2.2289, 1.7280, -0.4581};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3]);
w[3]=w[2];
w[2]=w[1];
w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=0;
comm_intr();
while(1);
}
Low pass Butterworth Filter
Cutoff=1000Hz and Fs=8KHz with order=4

Matlab code
clc
clear all
close all
ftype='low';
ord=4;
w=2*pi*1000;
fs=8000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
float w[5];
float d[5]={0.0087, 0.0348, 0.0522, 0.0348, 0.0087};
float c[4]={-2.0626, 1.8611, -0.7931, 0.1338};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4]);
w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=0;
comm_intr();
while(1);
}
Low pass Butterworth Filter
Cutoff=1500Hz and Fs=8KHz with order=5

Matlab code
clc
clear all
close all
ftype='low';
ord=5;
w=2*pi*1500;
fs=8000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
float w[6];
float d[6]={0.0113, 0.0567, 0.1134, 0.1134, 0.0567, 0.0113};
float c[5]={-1.589, 1.5234, -0.7619, 0.2165, -0.0254};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4];
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5]);
w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=0;
comm_intr();
while(1);
}
Low pass Butterworth Filter
Cutoff=500Hz and Fs=16KHz with order=3
Matlab code
clc
clear all
close all
ftype='low';
ord=3;
w=2*pi*500;
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[4];
float d[4]={0.0007, 0.0023, 0.0023, 0.0007};
float c[3]={-2.6092, 2.2910, -0.6757};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3]);
w[3]=w[2];
w[2]=w[1];
w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=0;
comm_intr();
while(1);
}
Low pass Butterworth Filter
Cutoff=1000Hz and Fs=16KHz with order=4

Matlab code
clc
clear all
close all
ftype='low';
ord=4;
w=2*pi*1000;
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[5];
float d[5]={0.0008, 0.0036, 0.0054, 0.0036, 0.0008};
float c[4]={-2.9896, 3.4488, -1.8052, 0.3603};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4]);
w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=0;
comm_intr();
while(1);
}
Low pass Butterworth Filter
Cutoff=1500Hz and Fs=16KHz with order=5

Matlab code
clc
clear all
close all
ftype='low';
ord=5;
w=2*pi*1500;
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[6];
float d[6]={0.0008, 0.0043, 0.0086, 0.0086, 0.0043, 0.0008};
float c[5]={-3.1529, 4.2066, -2.9130, 1.0386, -0.1517};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4];
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5]);
w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=0;
comm_intr();
while(1);
}
High pass Butterworth Filter
Cutoff=500Hz and Fs=16KHz with order=3
Matlab code
clc
clear all
close all
ftype='high';
ord=3;
w=2*pi*500;
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[4];
float d[4]={0.8220, -2.4659, 2.4659, -0.8220};
float c[3]={-2.6092, 2.2910, -0.6757};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3]);
w[3]=w[2];
w[2]=w[1];
w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=0;
comm_intr();
while(1);
}
High pass Butterworth Filter
Cutoff=1000Hz and Fs=16KHz with order=4

Matlab code
clc
clear all
close all
ftype='high';
ord=4;
w=2*pi*1000;
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[5];
float d[5]={0.6002, -2.4010, 3.6015, -2.4010, 0.6002};
float c[4]={-2.9896, 3.4488, -1.8052, 0.3603};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4]);
w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=0;
comm_intr();
while(1);
}
High pass Butterworth Filter
Cutoff=1500Hz and Fs=16KHz with order=5

Matlab code
clc
clear all
close all
ftype='high';
ord=5;
w=2*pi*1500;
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[6];
float d[6]={0.3895, -1.9473, 3.8946, -3.8946, 1.9473, -0.3895};
float c[5]={-3.1529, 4.2066, -2.9130, 1.0386, -0.1517};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4];
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5]);
w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=0;
comm_intr();
while(1);
}
High pass Butterworth Filter
Cutoff=500Hz and Fs=24KHz with order=3
Matlab code
clc
clear all
close all
ftype='high';
ord=3;
w=2*pi*500;
fs=24000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_24KHZ;
float w[4];
float d[4]={0.8774, -2.6322, 2.6322, -0.8774};
float c[3]={-2.7388, 2.5105, -0.7698};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3]);
w[3]=w[2];
w[2]=w[1];
w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=0;
comm_intr();
while(1);
}
High pass Butterworth Filter
Cutoff=1000Hz and Fs=24KHz with order=4

Matlab code
clc
clear all
close all
ftype='high';
ord=4;
w=2*pi*1000;
fs=24000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_24KHZ;
float w[5];
float d[5]={0.7109, -2.8435, 4.2653, -2.8435, 0.7109};
float c[4]={-3.3207, 4.1833, -2.3647, 0.5053};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]);
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4]);
w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=0;
comm_intr();
while(1);
}
High pass Butterworth Filter
Cutoff=1500Hz and Fs=24KHz with order=5

Matlab code
clc
clear all
close all
ftype='high';
ord=5;
w=2*pi*1500;
fs=24000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_24KHZ;
float w[6];
float d[6]={0.5313, -2.6567, 5.3135, -5.3135, 2.6567, -0.5313};
float c[5]={-3.7474, 5.7387, -4.4694, 1.7653, -0.2823};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4];
y=(w[0]*d[0])+ (w[1]*d[1])+ (w[2]*d[2])+ (w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5]);
w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return;
}
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=0;
comm_intr();
while(1);
}
Band pass Butterworth Filter
Cutoff=(500 –1000)Hz and Fs=8KHz with order=3
Matlab code
clc
clear all
close all
ftype='bandpass';
ord=3;
w=2*pi*[500 1000];
fs=8000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
float w[7];
float d[7]={0.0042, 8.8818*10^-16, -0.0126, 7.1054*10^-15, 0.0126,
1.7764*10^-15, -0.0042};
float c[6]={-4.5260, 9.1576,-10.4978,7.1855,-2.7871,0.4842};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band pass Butterworth Filter
Cutoff=(1000 –1500)Hz and Fs=8KHz with order=3
Matlab code
clc
clear all
close all
ftype='bandpass';
ord=3;
w=2*pi*[1000 1500];
fs=8000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
float w[7];
float d[7]={0.0030, -2.2204*10^-15, -0.0089, -6.2172*10^-15, 0.0089,
-2.2204*10^-15, -0.0030};
float c[6]={-3.3523, 6.1359,-6.7771,4.9655,-2.1930,0.5298};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band pass Butterworth Filter
Cutoff=(1500 –2000)Hz and Fs=16KHz with order=3
Matlab code
clc
clear all
close all
ftype='bandpass';
ord=3;
w=2*pi*[1500 2000];
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[7];
float d[7]={0.0005, 4.4409*10^-15, -0.0017, 3.5527*10^-14, 0.0017,
1.8652*10^-14, -0.0005};
float c[6]={-4.4780, 9.3448,-11.2796,8.3109,-3.5419,0.7036};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band pass Butterworth Filter
Cutoff=(500 –1000)Hz and Fs=24KHz with order=3
Matlab code
clc
clear all
close all
ftype='bandpass';
ord=3;
w=2*pi*[500 1000];
fs=24000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_24KHZ;
float w[7];
float d[7]={0.0002, -4.4409*10^-15, -0.0007, -4.2633*10^-14, 0.0007,
-1.9540*10^-14, -0.0002};
float c[6]={-5.6434, 13.3668,-17.0070,12.2590,-4.7469,0.7715};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band pass Butterworth Filter
Cutoff=(1000 –1500)Hz and Fs=24KHz with order=4
Matlab code
clc
clear all
close all
ftype='bandpass';
ord=4;
w=2*pi*[1000 1500];
fs=24000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_24KHZ;
float w[9];
float d[9]={1.4034*10^-5,2.6645*10^-15,-5.6135*10^-5,7.8160*10^-14,
8.4203*10^-5,1.1369*10^-13,-5.6135*10^-5,2.3981*10^-14,1.4034*10^-5};
float c[8]={-7.2828, 23.5684,-44.2379,52.6581,-40.7001,19.9496,-5.6718,
0.7166};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4])-
(w[6]*c[5])-(w[7]*c[6])-(w[8]*c[7]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6])+(w[7]*d[7])+(w[8]*d[8]);
w[8]=w[7]=w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=0;
comm_intr();
while(1); }
Band pass Butterworth Filter
Cutoff=(1500 –2000)Hz and Fs=48KHz with order=5
Matlab code
clc
clear all
close all
ftype='bandpass';
ord=5;
w=2*pi*[1500 2000];
fs=48000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_48KHZ;
float w[11];
float d[11]={3.1715*10^-8,8.8818*10^-15,-1.5857*10^-7,3.1264*10^-13,
3.1715*10^-7,9.6634*10^-13,-3.1715*10^-7,6.1107*10^-13,1.5857*10^-7,
6.0396*10^-14,-3.1715*10^-8};
float c[10]={-9.5435,41.2188,-106.1203,180.3249,-211.3122,172.9392,
-97.6055,36.3588,-8.0727,0.8113};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4])-
(w[6]*c[5])-(w[7]*c[6])-(w[8]*c[7]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6])+(w[7]*d[7])+(w[8]*d[8]);
w[11]=w[10]=w[9]=w[8]=w[7]=w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main (){
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=w[9]=w[10]=w[11]=0;
comm_intr();
while(1); }
Band Stop Butterworth Filter
Cutoff=(500 –1000)Hz and Fs=8KHz with order=3
Matlab code
clc
clear all
close all
ftype='stop';
ord=3;
w=2*pi*[500 1000];
fs=8000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
float w[7];
float d[7]={0.6958, -3.5773, 8.2178, -10.6563, 8.2178, -3.5773, 0.6958};
float c[6]={-4.5260, 9.1576,-10.4978,7.1855,-2.7871,0.4842};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band Stop Butterworth Filter
Cutoff=(1000 –1500)Hz and Fs=8KHz with order=3
Matlab code
clc
clear all
close all
ftype='stop';
ord=3;
w=2*pi*[1000 1500];
fs=8000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
float w[7];
float d[7]={0.7279, -2.7264, 5.5877, -6.8695, 5.5877, -2.7264, 0.7279};
float c[6]={-3.3523, 6.1359,-6.7771,4.9655,-2.1930,0.5298};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band Stop Butterworth Filter
Cutoff=(1500 –2000)Hz and Fs=16KHz with order=3
Matlab code
clc
clear all
close all
ftype='stop';
ord=3;
w=2*pi*[1500 2000];
fs=16000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ;
float w[7];
float d[7]={0.8388, -3.9894, 8.8409, -11.3208, 8.8409, -3.9894, 0.8388};
float c[6]={-4.4780, 9.3448,-11.2796,8.3109,-3.5419,0.7036};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band Stop Butterworth Filter
Cutoff=(500 –1000)Hz and Fs=24KHz with order=3
Matlab code
clc
clear all
close all
ftype='stop';
ord=3;
w=2*pi*[500 1000];
fs=24000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_24KHZ;
float w[7];
float d[7]={0.8784, -5.1806, 12.8203, -17.0361, 12.8203, -5.1806, 0.8784};
float c[6]={-5.6434, 13.3668,-17.0070,12.2590,-4.7469,0.7715};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3]-(w[5]*c[4]-
(w[6]*c[5]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6]);
w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=0;
comm_intr();
while(1);
}
Band Stop Butterworth Filter
Cutoff=(1000 –1500)Hz and Fs=48KHz with order=4
Matlab code
clc
clear all
close all
ftype='stop';
ord=4;
w=2*pi*[1000 1500];
fs=48000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_48KHZ;
float w[9];
float d[9]={0.9186, -7.2546, 25.1601, -50.0458, 62.4435, -50.0458, 25.1601,
-7.2546, 0.9186 };
float c[8]={-7.7302, 26.2417, -51.0953, 62.4110, -48.9701, 24.1043, -6.8052,
0.8437 };
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4])-
(w[6]*c[5])-(w[7]*c[6])-(w[8]*c[7]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6])+(w[7]*d[7])+(w[8]*d[8]);
w[8]=w[7]=w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main ()
{
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=0;
comm_intr();
while(1); }
Band Stop Butterworth Filter
Cutoff=(1500 –2000)Hz and Fs=48KHz with order=5
Matlab code
clc
clear all
close all
ftype='Stop';
ord=5;
w=2*pi*[1500 2000];
fs=48000;
cf='s';
f=linspace(0,3000);
[b,a]=butter(ord,w,ftype,cf);
ha=freqs(b,a,2*pi*f);
plot(f,20*log10(abs(ha)))
xlabel('frequency');
ylabel('Amplitude in db')
hold on
[d,c]=bilinear(b,a,fs);
hd=freqz(d,c,f,fs);
plot(f,20*log10(abs(hd)),'r');
grid minor

C-Code for dsp Kit:


#include<dsk6713.h>
#include<dsk6713_aic23.h>
Uint32 fs=DSK6713_AIC23_FREQ_48KHZ;
float w[11];
float d[11]={0.9007, -8.7788, 38.7278, -101.8264, 176.6980, -211.4427
, 176.6980, -101.8264, 38.7278, -8.7788, 0.9007};
float c[10]={-9.5435,41.2188,-106.1203,180.3249,-211.3122,172.9392,
-97.6055,36.3588,-8.0727,0.8113};
void c_int11(void)
{
Short sample_in;
float y;
sample_in= (short)input_right_sample();
w[0]=sample_in-(w[1]*c[0])-(w[2]*c[1])-(w[3]*c[2])-(w[4]*c[3])-(w[5]*c[4])-
(w[6]*c[5])-(w[7]*c[6])-(w[8]*c[7]);
y=(w[0]*d[0])+(w[1]*d[1])+(w[2]*d[2])+(w[3]*d[3])+(w[4]*d[4])+(w[5]*d[5])
+(w[6]*d[6])+(w[7]*d[7])+(w[8]*d[8]);
w[11]=w[10]=w[9]=w[8]=w[7]=w[6]=w[5]=w[4]=w[3]=w[2]=w[1]=w[0];
output_right_sample((short)y);
return; }
void main (){
w[0]=w[1]= w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=w[9]=w[10]=w[11]=0;
comm_intr();
while(1); }

Potrebbero piacerti anche