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.

Time problems with loopback-to-FIR polling algorithm

Hi everybody!

I wrote in this forum a couple of weeks ago asking for this algorithm too, so here I go again.

I'm trying to make this audio polling loopback work as a FIR filtering function and it doesn't work. But analising it these two weeks i've discovered (or i think i've discovered) the reason of this. It's a time problem.

If i make the FIR function use only three coeficients this works correctly. But if I use more than that (increasing the "count" variable) it doesn't work at all.

I supose it's a problem with the McASP TDM work mode, but i don't know for sure, and obviously i don't know how to solve it. Can anyone give me a solution?

Here is the "main" code i'm using, with the FIR function included:

//-----------------------------------------------------------------------------
// \file    main.c
// \brief   implementation of main() 
//
//-----------------------------------------------------------------------------

#include "main.h"

float h[10]={0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1};
float delay[10]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
int count=3;

//-----------------------------------------------------------------------------
// \brief   entry point for bsl test code.
//
// \param   none.
//
// \return  none.
//-----------------------------------------------------------------------------

int main(void)
{
   int16_t dataInput,dataOutput;       	// Input Sample
   uint16_t GpioToggle=0;		// toggle gpio output
   
    // init the i2c for all to use.
	USTIMER_init();
   	I2C_init(I2C0, I2C_CLK_400K);
  	
  	// set gpio output
  	SetGpio();
  	  	   
   	McASP_Init();				// Init McASP
   	
	AIC3106_Init();					// init AIC3106
	
	McASP_Start();				// STart McASP
	
		
	
     while (1){
     	
     		GPIO_setOutput(GPIO_BANK7,GPIO_PIN7,GpioToggle);
     		GpioToggle^=1;
     		
            // wait for receive ready and copy the sample to the output register    
            while (!CHKBIT(MCASP->SRCTL12, RRDY)){}
            dataInput = MCASP->XBUF12;

            if (!MCASP->RSLOT)
            	{
            		dataOutput=(dataInput & 0xFFFF);

            		dataOutput=(int16_t)FIR(h,delay,count,dataOutput);

            		MCASP->XBUF11 = dataOutput;
            	}
            	else
            	{
            		dataOutput=(dataInput & 0xFFFF);
            		MCASP->XBUF11 = dataOutput;
            	}
            	
     }   
}

//-----------------------------------------------------------------------------
// SetGpio
// config pinmux for gpio
//-----------------------------------------------------------------------------

void SetGpio(void)
{
	uint32_t	errchk;
		
	EVMC6748_pinmuxConfig(PINMUX_MCASP_REG_17,PINMUX_MCASP_MASK_17,PINMUX_MCASP_VAL_17);
	errchk=GPIO_setDir(GPIO_BANK7,GPIO_PIN7,GPIO_OUTPUT);
		
}

float FIR(float *coefs,float *delay,int count,int16_t dataOutput)
{

	//Variable declaration

	int i;
	float y;


	y=0.0;

	//Delay Line Loop
	for(i=count-1; i>0; i--){
		delay[i]=delay[i-1];
	}

	//Sample to first delay position
	delay[0]=(float)dataOutput;

	//Filtering loop
	for(i=0;i<count;i++){

		y+=coefs[i]*delay[i];

	}

	return y;

}

1263.audio_lpbk_poll.rar

I've also uploaded the entire project, in case someone got the time to take a look at it.

Thank you so much for your time!

  • Hi Angel,

    Thanks for your post.

    Did you get any chance to look into the sample example code with the project from DSPF_sp_fir_gen which can be found in the DSPLIB package under the path:

    ~:\ti\dsplib_c674x_3_2_0_1\packages\ti\dsplib\src\DSPF_sp_fir_gen

    Please give it a try to see the sample implementation and check to see if you are using the API in a similar fashion.

    I think, you could also look the below E2E post which i belive, it would help you better

    http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/115/t/344273.aspx

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    -------------------------------------------------------------------------------------------------------
  • Hello Sivaraj,

    First of all, thank you for your time. Of course i've seen the DSPF_sp_fir_gen, but this example it's not useful for me for two reasons:

    1º) I don't want to use DSP libraries.

    2º) I'm not using the EDMA, it's a polling algorithm.

    As you can see in my code, i've written the FIR function, which is very simple, and i want to use THAT function. I know it's not the optimal way of work, but this code has academic purpose (it has to serve as a sort of introduction to DSP programming).

    So, i repeat my first question, is there a way to solve the timing problem i have with the code?

    Again, thank you so much for your time, and I'm waiting for your answers!