⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 TI CCS开发环境下的FIR滤波器实现工程
💻 C
字号:
	/*temp file*/
	
#include <stdio.h>
	
#define FIR_FILTER_SIZE 51
			
signed long FIR_dual_filter_tmp( const int * filter_constants, signed int input) 
{
	 static int value[FIR_FILTER_SIZE]; /* Retain value between calls */
	 signed long output1;
	 signed long output2;
	 signed int i;  /* Index into filter constants */
	 signed long product;
	 static signed int j = 0; /* Index into input array */
	 //signed long mid_point;
	 static flag=1;int ii; 
	 if(flag)
	 {
	 	for(ii=0;ii<FIR_FILTER_SIZE;ii++)
	 	{
		 	value[ii]=0;
		 }
		 flag=0;
	 }
	 
	 product = 0;
#if 0	
	 value[j] = input;
	 	if ( j < FIR_FILTER_SIZE -1)
	 	{
	    	j++;
	 	}
		else
		{
	 	    j = 0;   /* Point to new value */
	 	}
	 
	 for ( i = 0 ; i < FIR_FILTER_SIZE ; i++)
	 {
	   /* Multiply input by corresponding coefficient. Divide by 32 */
	   /* to prevent overflow.                                      */
	 
	   product += (  (long)(value[j] * filter_constants[i]) >> 5);
	
	   if ( i == ((FIR_FILTER_SIZE-1)/2) )
	    {
	    // mid_point = value[j]; /* Not value[i] */
	    }
/*	  
		 if ( j > 0) 
	    {
	     j--;
	    }                    
	   else
	    {
	     j = FIR_FILTER_SIZE-1;    
	    }
*/
	 	if ( j < FIR_FILTER_SIZE -1)
	 	{
	    	j++;
	 	}
		else
		{
	 	    j = 0;   /* Point to new value */
	 	}
	    	
	 }
#else

	for ( i = FIR_FILTER_SIZE-1 ; i >0 ; i--)
		value[i] = value[i-1];
	 value[0] = input;
	for ( i = FIR_FILTER_SIZE-1 ; i >0 ; i--)
	   product += (  (long)(value[i] * filter_constants[i]) >> 5);
#endif	 
	 
	 /* One more increment of pointer is required */	 
	 
	 product >>= 10; /* Remove remains of fractional part */   
	 
	 //value[j] = input; /* Read in new value */
	 
	 //output1 = (mid_point- product); /* First output to high word */
	 //output1 = input - product;
	 output1 = value[(FIR_FILTER_SIZE-1)/2] - product;
	 output1 <<= 16; 
	 
	 output2 =  (product & 0xFFFF); /* Second output to low word */
	
	 /* Combine two outputs into a single return value */
	 
	 return( output1 | output2 ); 
	
	}      
	
	
	/***************************************************************************/
	/* End of FIR_filters.c                                                    */
	/***************************************************************************/
	
	  
	
	
	
	
	
	
	
	
	
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -