在ST的DSP库 中,提供了一个FIR滤波函数,我在matlab中计算出了滤波系数
typedef struct
{
long *h;
u32 nh;
}COEFS;
extern u16 ADC_ConvertedValueTab[92];
long fout[N]; /*filter output vector*/
long h[29]={ 97, 131, 208, 338, 528, 779, 1085, 1434, 1807,
2182, 2535, 2840, 3076, 3226, 3277, 3226, 3076, 2840,
2535, 2182, 1807, 1434, 1085, 779, 528, 338, 208,
131, 97};
void fir(void)
{
int m;
COEFS fir_coefs; /*coefficients structure*/
fir_coefs.nh=M; /*number of coefficients for FIR*/
fir_coefs.h =h; /*Pointer on FIR coefficient vector*/
fir_16by16_stm32(fout,(long*)ADC_ConvertedValueTab,&fir_coefs,N);//performs the FIR filtering
for(m=0;m<64;m++)
{
fout[m]=fout[m]/32768.0;
// GPIO_Write(GPIOD,fout[m]);
}
}
我想请问下,ADC_ConvertedValueTab[92]是正数,h系数也是正数,为什么经过fir后会有负数啊,是溢出问题么,但是我这定义了long型啊,求解 |