Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

Time problems with loopback-to-FIR polling algorithm

$
0
0

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;

}

(Please visit the site to view this file)

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!


Viewing all articles
Browse latest Browse all 17527

Trending Articles