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.

Question about FIR filtering code structure using DSPlib FIR function

Hello:

 

I am the novice using the C6713 DSK to do a small audio signal processing project.

 

Although the TI websites have tons of reference materials and some example tutorials are available, it is still very difficult for me to figure out the solution to a very specific problem.

 

First, I designed an audio input and output template using the CODEC and Mcbsp to read in the sampled music signal and then output it without modification.  The signal reading and writing is at ISR.

 

What I want to do is that I want to use the DSPlib FIR filter function in ISR and do the real-time low-pass or high-pass filtering of the music or a deterministic signal and then send the filtered signal out.

 

It sounds not difficult, but I was stuck by three difficulties:

 

First, I refered to the DSPlib application material and the FIR function might be like DSPF_sp_fir( ). 

But how could I set the cut-off frequency, passband stopband and the magnitude of this FIR function? or I have to desgin my own FIR filter?

(The textbook taught that I should design a FIR filter and do the filtering by the frame-based dot product between ten samples and the impulse response h[i].  But I want to call FIR function at DSPlib directly in order to save the execution cycles for real-time processing).

 

This is my ISR code out of guess:

The filtered signal temp.channel[0] will be put out with write function.

 

My second trouble is that I need to input the audio signal of 16-bit and it is single channel signal.  But this template is used for the music input(the music usually has two channels). 

Could I use this template to receive the audio signal of single channel?

Do I need to do some modifications?

 

 

My third problem that troubled me for a long time is that:

I want to use the matlab to generate a sinewave signal of four frequency components like this:

 

x=2*cos(1000*n)+4*cos(2000*n)+8*cos(3000*n)+10*cos(8000*n);

 

And then I want to input this signal (about 16000 samples) into my project and do the low-pass filtering. Then I

want to see the spectrum of the output signal and check whether the filter has successfully filtered out the high

frequency components.

The problem is: How to input the signal generated from matlab into the DSK line in?

And if I received the output signal already filtered, how could I accumulate them or can I output them into the matlab and check its spectrum?  Or I need the external memory to store them and see the spectrum of them later?

 

My original c file (main part):

 

Please give me the suggestions in detail.

 

Thank you very much!

 

 

 

 

 

 

 

 

 

 

  • Hi Yu Zhang,

    Thanks for your post.

    It would be a better choice to use DSP library FIR functions in order to conserve CPU cycles as you specify and there are options to use different FIR filter functions such as to design generic FIR filter, radix2 FIR, complex radix 2 FIR etc as below:

    • DSPF_sp_fir_gen

    • DSPF_sp_fir_r2

    • DSPF_sp_fir_cplx

    Actually, DSP library filter is implemented in a way that, there would be three pointers refering to input floating point arrary, coefficient floating point array, output array and in addition to, two arguments which are number of coefficients and output values. These are the arguments passed to all C67x DSP library FIR filter kernel functions which does the FIR filtering capabilities. Usually here, the FIR filter coefficients would be generated directly through Filter design and analysis tools as part of MATLAB with standard filter specifications when we design a low-pass or high pass filter For instance, a LPF would have filter N type order, filtering method, sampling frequency and cut-off frequency to design any filter and the input data to a FIR filter would be generated as below:

    x[i] = (sin(2 * PI * F1 * i / Fs) + sin(2 * PI * F2 * i / Fs)); where F1 and F2 are the two input data frequencies and Fs is the sampling frequency.

    By the above way, all filtering coefficients , input data etc would be feeded through DSP library functions as pointer arguments where the values would be stored in some external memory. 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

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