This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

FIR filter design : Unable to check o/p in CRO with following code

Hi I have tried to emulate the following code on "FIR filters" using DSP board TMS320C6713,But unable to see any o/p  on CRO (connected to LINE_OUT port). Am using Function generator to give i/p throgh LINE_IN port.So please help me if any mistakes in the code and debugging process.

Filter coefficients are taken from MATLAB for cutoff frequency 1000Hz for low pass kaiser filter.

Here is the code:

#include<dsk6713.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<dsk6713_aic23.h>
#include<DSKintr.h>

float filter_Coeff[]={
0.0000, -0.0000, -0.0001, -0.0003, -0.0004, 0.0000, 0.0009, 0.0019, 0.0018, -0.0000,
-0.0034, -0.0064, -0.0059, 0.0000, 0.0096, 0.0171, 0.0152, -0.0000, -0.0238, -0.0426,
-0.0387, 0.0000, 0.0711, 0.1554, 0.2237, 0.2500, 0.2237, 0.1554, 0.0711, 0.0000,
-0.0387, -0.0426, -0.0238, -0.0000, 0.0152, 0.0171, 0.0096, 0.0000, -0.0059, -0.0064,
-0.0034, -0.0000, 0.0018, 0.0019 , 0.0009, 0.0000, -0.0004, -0.0003, -0.0001, -0.0000,
0.0000

}; //100KHz
static short in_buffer[100];


/* Codec configuration settings */
/* See dsk6713_aic23.h and the TLV320AIC23 Stereo Audio CODEC Data Manual */
/* for a detailed description of the bits in each of the 10 AIC23 control */
/* registers in the following configuration structure. */

DSK6713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */ \
0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */ \
0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */ \
0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */ \
0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */ \
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control (48 kHz) */ \
0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};

//float test(float,float);

void main()
{

DSK6713_AIC23_CodecHandle hCodec;
Uint32 l_input,r_input,l_output,r_output;


DSK6713_init(); /* In the BSL library */

/* Start the codec */

hCodec = DSK6713_AIC23_openCodec(0, &config);

/* Change the sampling rate to 16 kHz */

DSK6713_AIC23_setFreq(hCodec, 1);

while(1)
{
while(!DSK6713_AIC23_read(hCodec, &l_input));
while(!DSK6713_AIC23_read(hCodec, &r_input));
l_output=(Int16)FIR_FILTER(&filter_Coeff,l_input);
r_output=(Int16)FIR_FILTER(&filter_Coeff,r_input);
while(!DSK6713_AIC23_write(hCodec, l_output));
while(!DSK6713_AIC23_write(hCodec, r_output));
DSK6713_AIC23_closeCodec(hCodec);
}

}

signed int FIR_FILTER(float *h,signed int x)
{
int i=0;
signed long output=0;
in_buffer[0]=x;
for(i=51;i>0;i--)
in_buffer[i]=in_buffer[i-1];
for(i=0;i<51;i++)
output=output+h[i]*in_buffer[i];
return(output);
}

  • Hi Kartheek,
    Moved this thread to correct forum for faster response. Thank you for your patience.
  • Hi,

    Thanks for your post.

    For more details to design a low pass FIR filter, you could refer a good FIR example in section 3.1.4 from C67x DSP LIB signal processing example app. report as below:

    http://www.ti.com/lit/an/spra947a/spra947a.pdf

    It can be your choice to design a low pass FIR filter specification in choosing cut-off frequency, sampling frequency, filter order etc and accordingly, generate coefficients through MATLAB tools which can be later feeded as pointer array arguments through DSP library FIR filter functions.

    For more details on each FIR filter functions, its description, prototype arguments, filter benchmarks, algorithm etc, kindly refer the below C67x DSP library programmer's guide:

    http://www.ti.com/lit/ug/spru657c/spru657c.pdf (refer section 4.1.4)

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question

    -------------------------------------------------------------------------------------------------------