你好,在使用 ADSP 21571 iir硬件加速器的时候,碰到输出异常的问题,下面是我的代码,请帮忙看看配置是否正确
int iir_init(IIR_CHANNEL_HANDLE* iir_channel_handle,int ch_num)
{
int ch_idx;
for(ch_idx = 0; ch_idx < ch_num ; ch_idx++)
{
iir_tcb[ch_idx].nIIRControl2 = ((iir_channel_handle[ch_idx].nNumBiquads - 1u) << BITP_IIR_CTL2_BIQUADS)
| ((iir_channel_handle[ch_idx].nWindowSize - 1u) << BITP_IIR_CTL2_WINDOW);
iir_tcb[ch_idx].nCoeffCount = iir_channel_handle[ch_idx].nCoefficientCount;
iir_tcb[ch_idx].pCoeffIndex = ConvertAddr(iir_channel_handle[ch_idx].pCoefficientBuff);
iir_tcb[ch_idx].nCoeffModify = iir_channel_handle[ch_idx].nCoefficientModify;
iir_tcb[ch_idx].pInputBase = ConvertAddr(iir_channel_handle[ch_idx].pInputBuffBase);
iir_tcb[ch_idx].pInpu
tindex = ConvertAddr(iir_channel_handle[ch_idx].pInputBuffIndex);
iir_tcb[ch_idx].nInputCount = iir_channel_handle[ch_idx].nInputBuffCount;
iir_tcb[ch_idx].nInputModify = iir_channel_handle[ch_idx].nInputBuffModify;
iir_tcb[ch_idx].pOutputBase = ConvertAddr(iir_channel_handle[ch_idx].pOutputBuffBase);
iir_tcb[ch_idx].pOutputIndex = ConvertAddr(iir_channel_handle[ch_idx].pOutputBuffIndex);
iir_tcb[ch_idx].nOutputCount = iir_channel_handle[ch_idx].nOutputBuffCount;
iir_tcb[ch_idx].nOutputModify = iir_channel_handle[ch_idx].nOutputBuffModify;
//iir_tcb[ch_idx].pNextTCB = ConvertAddr( iir_tcb.nIIRControl2);
}
/*layout TCB*/
for(ch_idx = 0; ch_idx < ch_num ; ch_idx++)
{
if(ch_idx < (ch_num-1))
{
iir_tcb[ch_idx].pNextTCB = ConvertAddr( iir_tcb[ch_idx+1].nIIRControl2);
}
else
{
iir_tcb[ch_idx].pNextTCB = ConvertAddr( iir_tcb[0].nIIRControl2);
}
}
*pREG_IIR0_CHNPTR = (uint32_t)ConvertAddr( iir_tcb[0].nIIRControl2);
*pREG_IIR0_CTL1 = IIR_DEF_IIRCTL1;
*pREG_IIR0_CTL1 = (*pREG_IIR0_CTL1 ~BITM_IIR_CTL1_CCINTR) | BITM_IIR_CTL1_CCINTR;
return 0;
}
int iir_calc(void)
{
*pREG_IIR0_CTL1 = IIR_DEF_IIRCTL1;
// asm("nop;nop;nop;nop;");
#if defined(__ADSPSC573_FAMILY__)
*pREG_IIR0_CTL1 = ((IIR_CH_NUM-1u) << BITP_IIR_CTL1_CH) | BITM_IIR_CTL1_EN | BITM_IIR_CTL1_DMAEN | BITM_IIR_CTL1_BURSTEN;
#else
*pREG_IIR0_CTL1 = ((IIR_CH_NUM-1u) << BITP_IIR_CTL1_CH) | BITM_IIR_CTL1_EN | BITM_IIR_CTL1_DMAEN;
#endif
return 0;
}
先调用iir_init进行初始化,然后,中断中周期性调用iir_calc()进行计算,对1k sine信号进行滤波,
系数如下
1.00000000000000000000e+000,
0.666666666666666,
-0.530581468189800,
1.00000000000000000000e+000,
-0.725420951973028,
0.00000000000000000000e+000,
0.00000000000000000000e+000