我在Win7上使用CCS5v5,DSK6713。
我有两个不同的c文件和一个标题(white_noise.h)。
有两种不同的情景
Idk为什么?我不使用标题(white_noise.h)。我猜中断有时间问题?
非常感谢您的阅读! 问候 丹尼尔
white_noise.h
short IR[8000]={23670, -2424, -25025, 23474, 32467, -10922, -5724,....
NLMS.c
//Optimization Level 2
#include "refnoise.h" //cosine 312 Hz
#include "dplusn.h" //sin(1500) + sin(312)
//#define mue 1E-10 //rate of convergence
#define N 128 //# of weights (coefficients)
#define NS 128 //# of output sample points
#define delta 1E-10
#define alpha 1E-3
float w[N]; //buffer weights of adapt filter
float delay[N]; //input buffer to adapt filter,x
short output; //overall output
float yn, E; //output filter/"error" signal
float gamma=0.01;
float Px=4500.0;
float mue = 1E-10; //rate of convergence
float mue2;
short input_option=1;
short NLMS_function()
{
static short buffercount=0; //init count of # out samples
delay[0] = refnoise[buffercount]; //cos(312Hz) input to adapt FIR
Px= (1.0-gamma)*Px + gamma*delay[0]*delay[0];
short i;
yn = 0; //init output of adapt filter
for (i = 0; i < N; i++) //to calculate out of adapt FIR
{
yn += (w[i] * delay[i]); //output of adaptive filter
//Px= (1-gamma)*Px + gamma*delay[i]*delay[i];
}
E = dplusn[buffercount] - yn; //"error" signal=(d+n)-yn
mue= 0.01/(Px*N+delta);
for (i = N-1; i >= 0; i--) //to update weights and delays
{
w[i] = w[i] + mue*E*delay[i]; //update weights
delay[i] = delay[i-1]; //update delay samples
}
buffercount++; //increment buffer count
if (buffercount >= NS) //if buffercount=# out samples
buffercount = 0; //reinit count
output = ((short)E*10); //"error" signal overall output
return output; //return from ISR
}
的main.c
#include "DSK6713_AIC23.h"
//#include "white_noise.h"
short NLMS_function();
Uint32 fs= DSK6713_AIC23_FREQ_8KHZ;
//Define
#define LEFT 0 //stereo
#define RIGHT 1 //stereo
short input;
interrupt void c_int11() //ISR
{
DSK6713_LED_on(0);
output=NLMS_function();
output_sample(output); //overall output result
DSK6713_LED_off(0);
return; //return from ISR
}
main()
{
DSK6713_LED_init(); //init LEDs
short T=0;
for (T = 0; T < 30; T++)
{
w[T] = 0; //init buffer for weights
delay[T] = 0; //init buffer for delay samples
}
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop //infinite loop
}