Sunnyhgh

ADSP-21375 EZ-KIET Lite block based talkthru添加FIR程序的问题

Sunnyhgh 在 2015-10-27 建立的討論區
最後回覆由adi_susan於2015-10-29提供

将1KHZ 0dBv 正弦波信号输入ADSP-21375 EZ-KIET Lite

从ADC口观察输出时,正弦波不正常。

如果将左右声道的FIR滤波器语句注释掉的话,输出正弦波是正常的。

另外,FIR滤波器经测试是正常的,用DSP自己产生正弦波,经过FIR滤波之后,测试DAC输出也正常的。

 

 

QQ截图20151027125538.png

 

原程序基本不变,程序中的DMA ISR中断和音频数据处理如下:

 

void TalkThroughISR(int sig_int) /* No argument is passed in this ISR */

{

 

  //Increment the block pointer

if(isProcessing)ProcessingTooLong();

    int_cntr++;

    int_cntr %= 3;

    blockReady = 1;

}

 

下面的音频处理程序加上了FIR滤波处理

 

// DMA TX/RX BUFFER为384个字

#define NUM_SAMPLES 384

//滤波器有83个抽头

#define TAPS  83

// TAPS-1  /2=FIR的群延时 也就是FIR输出前41个是无效的

#define DL  ((TAPS-1)/2)

//定义FIR输入输出数组的元素个数

#define N (NUM_SAMPLES/2+DL )

//FIR输入数组的数据形式:从0~191是音频数据,后41个为添加的数据“0"

float adinputL[N];

float adoutputL[N];

//FIR输出数组的数据形式:从0~40是因群延时的无效数据,随后第41~233个是有效音频数据

float adinputR[N];

float adoutputR[N];

// FIR状态数组

float adstateL[TAPS+1];

float adstateR[TAPS+1];

//滤波器系数

float pm adcoeffs[TAPS]={

  -0.000403038195722,7.129271485026e-19,0.0004522593913585, 0.000761363609974,

  0.0007434622863051,0.0003094515963677,-0.0004442989071892,-0.001205202031486,

  -0.001534621077612,-0.001081448704452,0.0001678836573597, 0.001753810988894,

  0.002855118076214, 0.002664598363695,0.0008806529073619, -0.00195388951795,

  -0.004519403955275,-0.005269625469738,-0.003268848605737, 0.001101928378573,

  0.006016016776022, 0.008867545545789, 0.007545053831489, 0.001734700999099,

  -0.00647021389647, -0.01314835726836, -0.01426439863309,-0.007835843180117,

  0.004512188464698,  0.01755834878578,  0.02438698214213,  0.01959828726337,

  0.002481210944641, -0.02141101045025, -0.04132638701527, -0.04497487457391,

  -0.02353071250617,  0.02404398954612,  0.08930034378228,  0.1562204820565,

    0.2062782787256,  0.2248164317383,  0.2062782787256,  0.1562204820565,

    0.08930034378228,  0.02404398954612, -0.02353071250617, -0.04497487457391,

  -0.04132638701527, -0.02141101045025, 0.002481210944641,  0.01959828726337,

    0.02438698214213,  0.01755834878578, 0.004512188464698,-0.007835843180117,

  -0.01426439863309, -0.01314835726836, -0.00647021389647, 0.001734700999099,

  0.007545053831489, 0.008867545545789, 0.006016016776022, 0.001101928378573,

  -0.003268848605737,-0.005269625469738,-0.004519403955275, -0.00195388951795,

  0.0008806529073619, 0.002664598363695, 0.002855118076214, 0.001753810988894,

  0.0001678836573597,-0.001081448704452,-0.001534621077612,-0.001205202031486,

  -0.0004442989071892,0.0003094515963677,0.0007434622863051, 0.000761363609974,

  0.0004522593913585,7.129271485026e-19,-0.000403038195722

};

/* Place the audio processing algorithM here. The input and output are given

  as unsigned integer pointers.*/

void processBlock( int *block_ptr)

{

  volatile int i,j;

    int temp_out;

    isProcessing = 1;

    /*Clear the Block Ready Semaphore*/

    blockReady = 0;

  //分离左右声道的数据,并转成float-point格式

    j=0;

    for(i=0;i<NUM_SAMPLES;i+=2)

    {

      *(adinputL+j)= __builtin_conv_RtoF((*(block_ptr+i)));

    *(adinputR+j)= __builtin_conv_RtoF((*(block_ptr+i+1)));

    j++;

    }

  // FIR处理

    fir (adinputL,adoutputL,adcoeffs,adstateL,N,TAPS);

    fir (adinputR,adoutputR,adcoeffs,adstateR,N,TAPS);

 

  //将FIR输出的数据转换成INT格式,并将结果复制进入TX DMA BUFFER

    j=0;

    for(i=0;i<NUM_SAMPLES;i+=2)

    { 

      (*(block_ptr+i ))=__builtin_conv_FtoR(*(adoutputL+DL+j));

      (*(block_ptr+i+1))=__builtin_conv_FtoR(*(adoutputR+DL+j));

      j++;

    }

    /*Set the Processing Active Semaphore before starting processing*/

    isProcessing=0;

}

結果