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

📄 main.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: main.c
//
//  Description: Perform real-time FIR filtering on stereo signals.
//		 The incoming audio data on left and right channel is fed
//		 into a set of FIR filters that filter the individual  	
//		 channels. The coefficients are pre-determined in MATLAB.
//		 This program sets up the SPI port on the ADSP-BF533 to  
//		 configure the AD1836 codec.  The SPI port is disabled 	
//		 after initialization.  The data to/from the codec are 	
//		 transfered over SPORT0 in I2S mode.
// 
//
//  Connections: Connect RSCLK0 to TSCLK0 together (Turn SW9 pin 6 on)	
//		 Connect RFS0 to TFS0 together (Turn SW9 pin 5 ON)							
//		 Connect an input source (such as a sound card) to the audio	
//		 input jack and an output source (such as headphones) to 
//		 the audio output jack	
//
//  Mode of operation
//  	  SW7	: to switch to talkthrough mode
// 	  	  SW6	: to switch to FIR filtering mode
//  
//  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"

//--------------------------------------------------------------------------//
// Variables																//
//																			//
//				The values in the array iCodec1836TxRegs can be modified to //
//				set up the codec in different configurations according to   //
//				the AD1836 data sheet. In our case, we have set it to 		//
//				in the I2S mode (see data sheet).							//
//																			//
// Note: iCh0xx corresponds to data for/from Channel 1						//
//		 iCh1xx corresponds to data for/from Channel 2						//																			
//--------------------------------------------------------------------------//
// left input data from ad1836
short iCh0LeftIn[IP_SIZE], iCh1LeftIn[IP_SIZE];
// right input data from ad1836
short iCh0RightIn[IP_SIZE], iCh1RightIn[IP_SIZE];
// left output data for ad1836	
short iCh0LeftOut[IP_SIZE], iCh1LeftOut[IP_SIZE];
// right output data for ad1836
short iCh0RightOut[IP_SIZE], iCh1RightOut[IP_SIZE];
// a flag to signify which button is being pressed!
int pushbt_flag;
int cycleCount;

fir_state_fr16	state1;	// declare filter state
fir_state_fr16	state2;

fract16 lpf[TAPS] = {
	#include "coef32.dat"
};

fract16 ldelay[TAPS]={0};
fract16 rdelay[TAPS]={0};


//--------------------------------------------------------------------------//

// array for registers to configure the ad1836
// names are defined in "Talkthrough.h"
volatile short sCodec1836TxRegs[CODEC_1836_REGS_LENGTH] =
{									
					DAC_CONTROL_1	| 0x010,
					DAC_CONTROL_2	| 0x000,
					DAC_VOLUME_0	| 0x3FF,
					DAC_VOLUME_1	| 0x3FF,
					DAC_VOLUME_2	| 0x3FF,
					DAC_VOLUME_3	| 0x3FF,
					DAC_VOLUME_4	| 0x000,
					DAC_VOLUME_5	| 0x000,
					ADC_CONTROL_1	| 0x024,
					ADC_CONTROL_2	| 0x020,
					ADC_CONTROL_3	| 0x00A
					
};
// SPORT0 DMA transmit buffer
volatile short iTxBuffer1[FRAME_SIZE*IP_SIZE*4];
// SPORT0 DMA receive buffer
volatile short iRxBuffer1[FRAME_SIZE*IP_SIZE*4];

////////////////////
// BTC Definitions
////////////////////
BTC_MAP_BEGIN
//             Channel Name,            Starting Address,   Length
BTC_MAP_ENTRY("Cycle Counter", 			(long)&cycleCount, 	sizeof(cycleCount))
BTC_MAP_END

//--------------------------------------------------------------------------//
// Function:	main														//
//																			//
// Description:	After calling a few initalization routines, main() just 	//
//				waits in a loop forever.  The code to process the incoming  //
//				data can be placed in the function Process_Data() in the 	//
//				file "Process_Data.c".										//
//--------------------------------------------------------------------------//
void main(void)
{
	sysreg_write(reg_SYSCFG, 0x32);		//Initialize System Configuration Register
	Init_EBIU();
	Init_Flash();
	Init1836();
	Init_LED();
	Init_GPIO();
	Init_Sport0();
	Init_DMA();
	Init_Interrupts();
	Init_Filter();
	Enable_DMA_Sport();
	
	btc_init();
	while(1)
		btc_poll();
}

⌨️ 快捷键说明

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