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

📄 process_data.c

📁 This experiment uses the Blackfi n BF533/BF537 EZ-KIT to run a simple FIR fi lter on stereo channe
💻 C
字号:
///////////////////////////////////////////////////////////////////////////////
//
// 	
//  Experiment 6.11_BF533 Implement FIR filter using BF533 EZ-KIT
//  FILE name: Process_data.c
//
//  Description: Perform real-time FIR filtering on stereo signals.
//		 
//  
//  For the book "Embedded Signal Processing with the Micro Signal Architecture"
//		  By Woon-Seng Gan and Sen M. Kuo
//		  Publisher: John Wiley and Sons, Inc.
//
//  Tools used: VisualDSP++ v4.0 (running on BF533 EZ-KIT)
//
///////////////////////////////////////////////////////////////////////////////

#include "fir.h"

//--------------------------------------------------------------------------//
// Function:	Process_Data()												//
//																			//
//--------------------------------------------------------------------------//
void Process_Data(void)
{
	int i, cycleBegin, cycleEnd;
	
	if (pushbt_flag == 1)
	{
		*pFlashA_PortB_Data = *pFlashA_PortB_Data & 0xD8;
		*pFlashA_PortB_Data = *pFlashA_PortB_Data | 0x10;
	
		//=====Reading Cycle before the Task============
		cycleBegin = sysreg_read(reg_CYCLES);
		//==============================================
		
		firc(iCh0LeftIn, iCh0LeftOut,state1);
		
		
				
		firc(iCh0RightIn, iCh0RightOut,state2);
		//=====Reading Cycle after the Task=============
		cycleEnd = sysreg_read(reg_CYCLES);
		cycleCount = cycleEnd - cycleBegin;
		//==============================================
	}
	
	else
	{
		*pFlashA_PortB_Data = *pFlashA_PortB_Data & 0xE8;
		*pFlashA_PortB_Data = *pFlashA_PortB_Data | 0x20;
		/*	Perform a loopback	*/	
		for (i=0; i<IP_SIZE; i++)
		{
			iCh0LeftOut[i] = iCh0LeftIn[i];
			iCh0RightOut[i] = iCh0RightIn[i];
		}
	}
}
	
void firc(const fract16 in[], fract16 out[], fir_state_fr16 state)
{
	int i, j, k, nc;
	fract16 *coef;
	fract16 *rdelaybuf, *wdelaybuf, temp;
	fract32	acc = 0;
	
	coef=state.h;
	rdelaybuf=state.d;			// For reading delay buffer
	wdelaybuf=state.p;			// For updating delay buffer
	nc=state.k;
	
	for (i=0; i<IP_SIZE; i++)
	{
		wdelaybuf[0]=in[i];
		for (j=0; j<nc; j++)
			acc+=coef[j]*wdelaybuf[j];

		out[i] = (fract16) (acc >> 15);
		
		for (k=(nc-1); k>=1; k--)
		{
			wdelaybuf[k]=wdelaybuf[k-1];
								// Point to the next location 
								// to be shifted
		}
		acc = 0;
	}
}

⌨️ 快捷键说明

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