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.

CCS/OMAP-L137: How to implement simple FIR filter on TMS320C6747/OMAP-L137

Part Number: OMAP-L137

Tool/software: Code Composer Studio

Hello.

I'm studying ANC algorithm from LG Electronics, and I'm using TMS320C6747/OMAP-L137 DSP  STARTER KIT. 

First, I downloaded OMAPL137 RTOS SDK from http://software-dl.ti.com/processor-sdk-rtos/esd/OMAPL137/latest/index_FDS.html.

After that I used mcasp_test.c example code from C:\ti\pdk_omapl137_1_0_10\packages\ti\board\diag\mcasp\src\mcasp_test.c

I am trying to implement a FIR filter(low pass) on a TMS320C6747

Please see my code below.

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

                 short SampleCh0;
                 short SampleCh1;

                 float RegX1 = 0.0;
                 float RegX2 = 0.0;
                 float RegX3 = 0.0;
                 float RegX4 = 0.0;
                 float RegX5 = 0.0;
                 float RegX6 = 0.0;
                 float RegX7 = 0.0;
                 float RegX8 = 0.0;
                 float RegX9 = 0.0;

                 float RegX1_1 = 0.0;
                 float RegX2_1 = 0.0;
                 float RegX3_1 = 0.0;
                 float RegX4_1 = 0.0;
                 float RegX5_1 = 0.0;
                 float RegX6_1 = 0.0;
                 float RegX7_1 = 0.0;
                 float RegX8_1 = 0.0;
                 float RegX9_1 = 0.0;

                 float b[10] = {FIR filter coefficients};

 

                 ......

                 /*
                 ** Loop forever. if a new buffer is received, the lastFullRxBuf will be
                 ** updated in the rx completion ISR. if it is not the lastSentTxBuf,
                 ** buffer is to be sent. This has to be mapped to proper paRAM set.
                 */
                 while(1)
                 {
                 if(lastFullRxBuf != lastSentTxBuf)
                 {
                 // if(sampleCnt > TEST_SAMPLE_COUNT)
                 // {
                 // break;
                 // }

                 /*
                 ** Start the transmission from the link paramset. The param set
                 ** 1 will be linked to param set at PAR_TX_START. So do not
                 ** update paRAM set1.
                 */
                 parToSend = PAR_TX_START + (parOffTxToSend % NUM_PAR);
                 parOffTxToSend = (parOffTxToSend + 1) % NUM_PAR;
                 parToLink = PAR_TX_START + parOffTxToSend;

                 lastSentTxBuf = (lastSentTxBuf + 1) % NUM_BUF;

                 secondLastSentTxBuf = (secondLastSentTxBuf + 1) % NUM_BUF;

                 SampleCh0=*((void *)rxBufPtr[lastFullRxBuf] + 2 * i );     

                 SampleCh1=*((void *)rxBufPtr[lastFullRxBuf] + 2 * i + 1 );

                /* FIR filter processing */

                for(i = 0; i < NUM_SAMPLES_PER_AUDIO_BUF; i++)
                {
               SampleCh0_1 = b[0]*SampleCh0 + b[1]*RegX1 + b[2]*RegX2 + b[3]*RegX3 + b[4]*RegX4 + b[5]*RegX5 + b[6]*RegX6 + b[7]*RegX7 + b[8]*RegX8 + b[9]*RegX9;
               SampleCh1_1 = b[0]*SampleCh1 + b[1]*RegX1_1 + b[2]*RegX2_1 + b[3]*RegX3_1 + b[4]*RegX4_1 + b[5]*RegX5_1 + b[6]*RegX6_1 + b[7]*RegX7_1 + b[8]*RegX8_1 + b[9]*RegX9_1;
               RegX9=RegX8;
               RegX8=RegX7;
               RegX7=RegX6;
               RegX6=RegX5;
               RegX5=RegX4;
               RegX4=RegX3;
               RegX3=RegX2;
               RegX2=RegX1;
               RegX1=SampleCh0;

               RegX9_1=RegX8_1;
               RegX8_1=RegX7_1;
               RegX7_1=RegX6_1;
               RegX6_1=RegX5_1;
               RegX5_1=RegX4_1;
               RegX4_1=RegX3_1;
               RegX3_1=RegX2_1;
               RegX2_1=RegX1_1;
               RegX1_1=SampleCh1;

               }     

                *((void*)txBufPtr[lastSentTxBuf] + 2 * i) =  SampleCh0_1;
                *((void*)txBufPtr[lastSentTxBuf] + 2 * i + 1) =  SampleCh1_1;

                BoardDiag_BufferTxDMAActivate(lastSentTxBuf, NUM_SAMPLES_PER_AUDIO_BUF,
                (unsigned short)parToSend,
                (unsigned short)parToLink);
                sampleCnt += NUM_SAMPLES_PER_AUDIO_BUF;
                }
}

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

I separated audio input two channels (SampleCh0, SampleCh1), and applied the FIR filter algorithm.

Please let me know my code is right or not.

PS. I also tried another FIR filtering code example from https://e2e.ti.com/support/processors/f/791/t/409101, but I just heard noise with original input signal from output.

If you have any FIR filter, LMS, filtered-x LMS alogrithm code example, please let me know.

Any help is much appreciated. Thanks.