main.c
#include"math.h"
#define PI 3.1415926
#define COEFFNUMBER 16
#define INPUTNUMBER 1024
int FIRLMS(int *nx,float *nh,int nError,int nCoeffNumber);
float h[COEFFNUMBER],fU;
int xx[INPUTNUMBER],rr[INPUTNUMBER],wc[INPUTNUMBER];
main()
{
int i,nLastOutput;
nLastOutput=0;
fU=0.0005;
for ( i=0;i<COEFFNUMBER;i++ ) h[i]=0;
for ( i=0;i<INPUTNUMBER;i++ )
{
xx[i]=256*sin(i*2*PI/34);
rr[i]=wc[i]=0;
}
for ( i=COEFFNUMBER+1;i<INPUTNUMBER;i++ )
{
nLastOutput=FIRLMS(xx+i,h,nLastOutput-xx[i-1],COEFFNUMBER); // break point
rr[i]=nLastOutput;
wc[i]=rr[i]-xx[i];
}
exit(0);
}
int FIRLMS(int *nx,float *nh,int nError,int nCoeffNumber)
{
int i,r;
float fWork;
r=0;
for ( i=0;i<nCoeffNumber;i++ )
{
fWork=nx[i]*nError*fU;
nh[i]+=fWork;
r+=(nx[i-i]*nh[i]);
}
r/=128;
return r;
}
配置文件
-w
-stack 500
-sysstack 500
-l rts55x.lib
MEMORY
{
DARAM: o=0x100, l=0x7f00
VECT : o=0x8000, l=0x100
DARAM2: o=0x8100, l=0x200
DARAM3: o=0x8300, l=0x7d00
SARAM: o=0x10000, l=0x30000
SDRAM: o=0x40000, l=0x3e0000
}
SECTIONS
{
.text: {} > DARAM
.vectors: {} > VECT
.trcinit: {} > DARAM
.gblinit: {} > DARAM
frt: {} > DARAM
.cinit: {} > DARAM
.pinit: {} > DARAM
.sysinit: {} > DARAM
.bss: {} > DARAM3
.far: {} > DARAM3
.const: {} > DARAM3
.switch: {} > DARAM3
.sysmem: {} > DARAM3
.cio: {} > DARAM3
.MEM$obj: {} > DARAM3
.sysheap: {} > DARAM3
.sysstack {} > DARAM3
.stack: {} > DARAM3
}
大神们可以加我qq 369140260
|