我刚用C6711的simulator试了一下,使用dsp67x.lib, 从TI的网站下载sprc121.zip解压缩之后就有这个库文件. 当调用DSPF_sp_biquad时只要最后一个参数(滤波的点数)不是3的倍数,程序就从那个函数里出不来.
#include <stdio.h>
#include "dspf_sp_biquad.h"
float B[] = {1.0, 0, 0};
float A[] = {0, 0};
float inbuf[128];
float outbuf[128];
float delay[2];
void main(void)
{
int i, j;
float *pIn, *pB, *pA, *pDly, *pOut;
int cnt;
cnt = 128;
for (i=0; i<cnt; i++)
{
inbuf[i] = i+1;
outbuf[i] = 0.0;
}
delay[0] = 0.;
delay[1] = 0.;
pIn = inbuf;
pB = B;
pA = A;
pDly = delay;
pOut = outbuf;
DSPF_sp_biquad(pIn, pB, pA, pDly, pOut, 3);
j = cnt;
}
TI的DSPF_sp_biquad函数C程序如下:
void DSPF_sp_biquad (
float x[], //Pointer to input samples
float b[], //Pointer to numerator coefficients b[0], b[1] and b[2]
float a[], //Pointer to denominator coefficients a[1] and a[2]
float delay[], //Pointer to filter delays, delay[0] and delay[1]
float r[], //Pointer to output samples
int nx //Number of input/output samples
)
{
int i;
float a1, a2, b0, b1, b2, d0, d1, x_i;
a1 = a[0];
a2 = a[1];
b0 = b[0];
b1 = b[1];
b2 = b[2];
d0 = delay[0];
d1 = delay[1];
for (i = 0; i < nx; i++)
{
x_i = x[i];
r[i] = b0 * x_i + d0;
d0 = b1 * x_i - a1 * r[i] + d1;
d1 = b2 * x_i - a2 * r[i];
}
delay[0] = d0;
delay[1] = d1;
}
从C程序看不出点数必须是3的倍数, 所以估计库里的函数是汇编实现的,搞不懂哪里出问题了. |