我在Code Composer Studio Version: 6.0.1.00040 中使用卡LCDK C6748 工作,但我认为这是一个更普遍的问题,通常与 CCS 有关。我正在尝试实现 LMS 来消除声学回声,这是我的 .c 文件的骨架:
void waitForInterrupt()
{
while (flag==0) {}
flag=0; // reach this line only when flag == 1
}
interrupt void interrupt4(void)
{
// Inputs
inputRight_micSignal = (float)input_right_sample();
// Outputs
outputLeft_referenceSignal= whiteNoiseSample;
codec_data.channel[RIGHT]= (uint16_t)outputRight_cleanedSound;
codec_data.channel[LEFT]= (uint16_t)outputLeft_referenceSignal;
output_sample(codec_data.uint);
flag = 1;
}
void main()
{
// variables decelerations
int i;
float filter_output;
// initialising filter coefficients
for (i=0 ; i<ADAPTIVE_FILT_SIZE ; i++) // initialise weights and delay line
{
w[i] = 0.0;
x[i] = 0.0;
}
// initialising the interrupt routine
L138_initialise_intr(FS_8000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_MIC_INPUT);
while(1) // adaptive filtering routine
{
waitForInterrupt();
whiteNoiseSample = getPrnFiltered();
for (i = ADAPTIVE_FILT_SIZE-1; i > 0; i--) // update delay line - TDL:merge later with w loop (still make sure no magic NaN's appear)
{
x[i] = x[i-1];
}
x[0] = outputLeft_referenceSignal; // input to adaptive filter
filter_output = 0; //reseting filter output
// compute adaptive filter output
for (i = 0; i < ADAPTIVE_FILT_SIZE; i++)
filter_output += (w[i]*x[i]);
outputRight_cleanedSound = inputRight_micSignal - filter_output; // compute error
for (i = ADAPTIVE_FILT_SIZE-1; i >= 0; i--) // update weights and delay line
{
w[i] = w[i] + beta*outputRight_cleanedSound*x[i]; // w[i]+=beta*"error"*"reference"
}
由于某种原因,当我将数组放入“监视表”x[]
并w[]
暂停程序的运行时(为了在一段时间后检查 w[] 系数,我看到它充满了 NaN - 而 x[] 包含“常规”值。当我在计算 w[] 的行内放置断点时:
w[i] = w[i] + beta*outputRight_cleanedSound*x[i]; // w[i]+=beta*"error"*"reference"
我看到流去那里。NaN的原因可能是什么?有没有办法在“观察表”中观看 w[] ?