内容发布更新时间 : 2024/11/19 14:45:28星期一 下面是文章的全部内容请认真阅读。
(2)ToneIIRLP02rt.c
extern void InitC5402(void); extern void OpenMcBSP(void); extern void CloseMcBSP(void); extern void READAD50(void); extern void WRITEAD50(void);
/*********************************************************************** ** Main Function Program
***********************************************************************/ #include \ #include \ #define pi 3.1415926
double fs,nlpass,nlstop,nhpass,nhstop,a[3],b[3],x,y;
void biir2lpdes(double fs, double nlpass, double nlstop, double a[], double b[]);
void biir2lpdes(double fs, double nlpass, double nlstop, double a[], double b[])
{
int i,u,v; double wp,omp,gsa,t; wp=nlpass*2*pi;
omp=tan(wp/2.0); gsa=omp*omp; for (i=0; i<=2; i++) { u=i%2; }
for (i=0; i<=2; i++) { u=i%2;
b[i]=gsa*pow(2,u); } t=a[0];
for (i=0; i<=2; i++) { a[i]=a[i]/t;
v=i-1;
a[i]=gsa*pow(2,u)-sqrt(2)*omp*v+pow(-2,u);
b[i]=b[i]/t; } }
void main(void) { int i,j; int x_ad,y_da;
InitC5402(); /* initialize C5402 DSP */ OpenMcBSP();
fs=16000;
int *px = (int*)0x3000; int *py = (int*)0x3100; double w2,w1,w0; w2=w1=w0=0.0;
for ( ; ; )
{ /* IIR LP filter */ for (i=0; i<=1; i++) {
nlpass = 0.11-(i/10.0);
nlstop = 0.31-(i/10.0); biir2lpdes(fs,nlpass,nlstop,a,b);
for (j=-32000; j<=32000; j++) {
READAD50(); px = (int*)(0x3000);
x_ad = *px;
x = x_ad/32768.0; w2=x-a[1]*w1-a[2]*w0; y=b[0]*w2+b[1]*w1+b[2]*w0; w0=w1; w1=w2;
y_da=(int)(y*32768.0); py = (int*)(0x3100); *py = y_da;
WRITEAD50(); }
}
}
}
/*void PROCESSING(void) {
do the necessery operations here!*/
/*********************************************************************** ** End of File –– exp08.c
*****************************