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.

Simple filter implementation for TMS320C6748 on top of mcasp example from Starterware

Other Parts Discussed in Thread: TMS320C6748

Hi guys,

I am trying to implements a filter(high pass) on a TMS320C6748 DSP development kit.

I installed and went through Starterware's mcasp example (located on \build\c674x\cgt_ccs\c6748\lcdkC6748\mcasp). 

Now I want to implement simple high pass filter on top of that sample code, what steps I need to take, I am not good on Signal processing and on DSP boards,

I would appreciate if you could give me detailed instructions?

Thanks,

YK

PS. I tried to use DSPF_sp_fir_gen (FIR Filter) from DSPLIB, but I couldn't figured out what to do

  • YK,

    You use the Starterware example to capture a buffer of some number of sample, maybe 20. That number is up to you and your system tradeoffs. If the example you chose does not help you do this, then there may be another example you could choose instead.

    You next use a filter design tool or your own filter design knowledge and skills from your training, and by that you generate the list of coefficients for your filter. There should be a lot of information on the web for learning to use these, if you do not already know how to do this; since you are 'not good on Signal processing", my guess is that you do not.

    With a set of input samples and a set of coefficients, you can then use DSPF_sp_fir_gen to run the filter you have designed.

    The output of DSPF_sp_fir_gen will be the output buffer that would be the output side of the Starterware McASP example you are using.

    That gives you the filter on a TI DSP.

    The design part is what you learned in college getting that degree. I am not really qualified to teach that. We can certainly point you to the tools you have found to build a filter once it is designed.

    Regards,
    RandyP
  • Hi guys,

    This is my implementation of FIR filter (coeffs are generated by matlab fdatool, window(kneser), order 10):
    However, the code is still not working what should I do?

    1) I noticed that txBuf and rxBuf are in unsigned char type and 4 bytes per sample, does it mean that I need to take four consecutive chars as one value?

    2) How data is stored in rxBuf, left and right channels are alternating?

    3) Is the samples stored in rxBuf compressed, or it is raw data acquired from ADC?

    I know that I need to copy new (ORDER-1) samples into the end of input buffer, but for now I don't want to deal with that problem.

    Or, is there any other way where I can set a filter type and value, for example in codec?

    Thanks,
    YK


    static float xBuf[AUDIO_BUF_SIZE+ORDER-1]; //input buffer
    static float yBuf[AUDIO_BUF_SIZE]; //output buffer

    const float COEFFS[ORDER]= {0.0593, 0.0383, -0.0397, -0.1522, -0.2519, 0.7083, -0.2519, -0.1522, -0.0397, 0.0383, 0.0593}; //coeffs are flipped

    . . . . .

    memcpy((void *)xBuf, (void *)rxBufPtr[lastFullRxBuf], AUDIO_BUF_SIZE);

    for(i=0; i < AUDIO_BUF_SIZE; i++)
    {
       sum = 0;
       for( j=0 ; j < ORDER ; j++)  
       {
          sum += xBuf[i+j]*COEFFS[j];
       }
       yBuf[i] = sum;
    }

    memcpy((void *)txBufPtr[lastSentTxBuf], (void *)yBuf, AUDIO_BUF_SIZE);

    .....

  • Hi,

    Thanks for your update.

    For question 1), Yes, it takes 4 character bytes per audio sample which is 32-bits per sample value.

    For question 2) I believe, left and right channel data should be alternating

    For question 3) ADC should capture raw PCM samples from LINEIN/MICIN which are not compressed and the digital data would be stored in rxbuf which are again derived from raw samples. I don't think, there are encoder/decoder chips in c6748 development kit to compress/expand audio data.

    Thanks & regards,

    Sivaraj K

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

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

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

  • Thank you, for the reply.

    1) I want to ask about data type I should use for 4 char byte samples, do I need to use int, unsigned int of float?
    2) My FIR coefficients are real numbers, when I perform convolution operation, data types of samples may change if they are "int" for example, do I need to round them?

    Thanks,
    YK
  • YK,

    In your example code for the McASP access, does it handle data separately for the left and right channels? You will want to handle the data the same way as the example. Some examples I have seen build one 32-bit word that has the left channel in the high 16 bits and the right channel in the low 16 bits. Other examples write one 16-bit sample for the left channel and then write one 16-bit sample for the right channel. Whichever way your example does this is the way for you to do it for your application.

    Similarly, the data type used in your example is the same data type to use for your application, at least for the direct McASP access code. For example, if the McASP requires 16-bit signed integers, you would use the short data type for those values or the array of those values.

    If your application uses floats for the intermediate calculations, then you will want to do a conversion of some type. This could require scaling or truncation or other method.

    Regards,
    RandyP
  • Thank you for the reply,

    I give up trying to implement FIR filter myself and decided just to adjust sampling rate which automatically filters out high frequency components.

    Regards,

    YK

  • Hello sir IS tms320c6748 helps in analysing harmonics of a power signal(voltage signal) or which dsp processor is best to use..please give your suggestion sir
  • Ramya,

    Please start a new thread with the details of your question and an appropriate title line.

    Regards,
    RandyP