DSP 5509音频信号低通滤波.doc_第1页
DSP 5509音频信号低通滤波.doc_第2页
DSP 5509音频信号低通滤波.doc_第3页
DSP 5509音频信号低通滤波.doc_第4页
DSP 5509音频信号低通滤波.doc_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include #include #include #include #include #include #include #include #include #include #include /#include hamming30fdacoefs.h#include hamming30hipsfdacoefs.h/30 points hamming window high pass FIR#include bandpass101fdacoefs.h/101 points bandpass FIR, 300Hz-1.5kHz/ #include eq110fdacoefs.h/ #include eq110hifdacoefs.h/ #define PI 3.14159265358979323846 / PI value/ #define CONV 32767.999999 / Q15- float conversion value = 215- 21-15 #define CODEC_ADDR 0x1A/ AIC23 I2C address#define ST1_55 *(int *)0x03#define ST3_55 *(int *)0x04#define LBDS1 (*(unsigned int *)0x600400)#define keyboard (*(unsigned int *)0x600C00)#define GPIO_SEL (*(unsigned int *)0x400000)#define hNX 1/ Fir input data length/ #define NH 31unsigned int uLED10=0x0db,0x50,0x6b,0x73,0xf0,0x0b3,0x0bb,0x51,0x0fb,0x0f3;DATA *aic23data,*voicedata;/ voice input & output data pointerDATA *dbptr /* = &db0 */;/ lopass fliter bufferDATA *dbptrhi;/ hipass fliter buffer/ void Delay(unsigned int nDelay);/ 延时子程序void aic_init();/ init aic23unsigned int time=0;unsigned int temp_key,temp_key1,firflag;/ key buffer & fliter select flag/*/void delay(Uint32 k)/ true delay func while(k-);/*/void dealkey()/ key func temp_key=keyboard;/ read key data temp_key=temp_key & 0x00ff; if(0xff!=temp_key)/ compare temp_key1=temp_key; delay(150); temp_key=keyboard; temp_key=temp_key & 0x00ff; if(temp_key = temp_key1) /time+; /keycodetime=temp_key; switch(temp_key) case 0x0fb:LBDS1=0x75;/ L/ recordflag=1;firflag = 0;/0: low passbreak;case 0x0f7:LBDS1=0x56;/ replayflag=1;break;case 0x0ef:LBDS1=0x07;/ H/ stopflag=1;firflag = 1;/1: high passbreak;case 0x0df:LBDS1=0;/ overflag=1;break;case 0x0bf:LBDS1=0x0ff-uLED5;/LED just for funbreak;case 0x07f:LBDS1=0x0ff-uLED6;break;case 0x0fd:LBDS1=0x0ff-uLED7;break;case 0x0fe:LBDS1=0x0ff-uLED8;break;default:break; /*/*/*/*锁相环的设置*/PLL_Config myConfig = 0, /IAI: the PLL locks using the same process that was underway /before the idle mode was entered 1, /IOB: If the PLL indicates a break in the phase lock, /it switches to its bypass mode and restarts the PLL phase-locking /sequence 24, /PLL multiply value; multiply 24 times 1 /Divide by 2 PLL divide value; it can be either PLL divide value /(when PLL is enabled), or Bypass-mode divide value /(PLL in bypass mode, if PLL multiply value is set to 1);EMIF_Config emiffig = 0x221, /EGCR : the MEMFREQ = 00,the clock for the memory is equal to cpu frequence / the WPE = 0 ,forbiden the writing posting when we debug the EMIF / the MEMCEN = 1,the memory clock is reflected on the CLKMEM pin / the NOHOLD = 1,HOLD requests are not recognized by the EMIF 0xFFFF,/EMI_RST: any write to this register resets the EMIF state machine 0x3FFF,/CE0_1: CE0 space control register 1 / MTYPE = 011,Synchronous DRAM(SDRAM),16-bit data bus width 0xFFFF, /CE0_2: CE0 space control register 2 0x00FF, /CE0_3: CE0 space control register 3 / TIMEOUT = 0xFF; 0x3FFF,/CE1_1: CE0 space control register 1 0xFFFF,/CE1_2: CE0 space control register 2 0x00FF,/CE1_3: CE0 space control register 3 0x1FFF,/CE2_1: CE0 space control register 1 0xFFFF,/CE2_2: CE0 space control register 2 0x00FF,/CE2_3: CE0 space control register 3 0x1FFF,/CE3_1: CE0 space control register 1 0xFFFF,/CE3_2: CE0 space control register 2 0x00FF,/CE3_3: CE0 space control register 3 0x2911, /SDC1: SDRAM control register 1 / TRC = 8 / SDSIZE = 0;SDWID = 0 / RFEN = 1 / TRCD = 2 / TRP = 2 0x0410,/SDPER : SDRAM period register / 7ns *4096 0x07FF, /SDINIT: SDRAM initialization register / any write to this register to init the all CE spaces, / do it after hardware reset or power up the C55x device 0x0131/SDC2: SDRAM control register 2 / SDACC = 0; / TMRD = 01; / TRAS = 0101; / TACTV2ACTV = 0001; ;MCBSP_Config Mcbsptest;/*McBSP set,we use mcbsp1 to send and recieve the data between DSP and AIC23*/MCBSP_Config Mcbsp1Config = MCBSP_SPCR1_RMK( MCBSP_SPCR1_DLB_OFF, /* DLB = 0,禁止自闭环方式 */ MCBSP_SPCR1_RJUST_LZF, /* RJUST = 2 */ MCBSP_SPCR1_CLKSTP_DISABLE, /* CLKSTP = 0 */ MCBSP_SPCR1_DXENA_ON, /* DXENA = 1 */ 0, /* ABIS = 0 */ MCBSP_SPCR1_RINTM_RRDY, /* RINTM = 0 */ 0, /* RSYNCER = 0 */ MCBSP_SPCR1_RRST_DISABLE /* RRST = 0 */ ), MCBSP_SPCR2_RMK( MCBSP_SPCR2_FREE_NO, /* FREE = 0 */ MCBSP_SPCR2_SOFT_NO, /* SOFT = 0 */ MCBSP_SPCR2_FRST_FSG, /* FRST = 0 */ MCBSP_SPCR2_GRST_CLKG, /* GRST = 0 */ MCBSP_SPCR2_XINTM_XRDY, /* XINTM = 0 */ 0, /* XSYNCER = N/A */ MCBSP_SPCR2_XRST_DISABLE /* XRST = 0 */ ), /*单数据相,接受数据长度为16位,每相2个数据*/ MCBSP_RCR1_RMK( MCBSP_RCR1_RFRLEN1_OF(1), /* RFRLEN1 = 1 */ MCBSP_RCR1_RWDLEN1_16BIT /* RWDLEN1 = 2 */ ), MCBSP_RCR2_RMK( MCBSP_RCR2_RPHASE_SINGLE, /* RPHASE = 0 */ MCBSP_RCR2_RFRLEN2_OF(0), /* RFRLEN2 = 0 */ MCBSP_RCR2_RWDLEN2_8BIT, /* RWDLEN2 = 0 */ MCBSP_RCR2_RCOMPAND_MSB, /* RCOMPAND = 0 */ MCBSP_RCR2_RFIG_YES, /* RFIG = 0 */ MCBSP_RCR2_RDATDLY_1BIT /* RDATDLY = 1 */ ), MCBSP_XCR1_RMK( MCBSP_XCR1_XFRLEN1_OF(1), /* XFRLEN1 = 1 */ MCBSP_XCR1_XWDLEN1_16BIT /* XWDLEN1 = 2 */ ), MCBSP_XCR2_RMK( MCBSP_XCR2_XPHASE_SINGLE, /* XPHASE = 0 */ MCBSP_XCR2_XFRLEN2_OF(0), /* XFRLEN2 = 0 */ MCBSP_XCR2_XWDLEN2_8BIT, /* XWDLEN2 = 0 */ MCBSP_XCR2_XCOMPAND_MSB, /* XCOMPAND = 0 */ MCBSP_XCR2_XFIG_YES, /* XFIG = 0 */ MCBSP_XCR2_XDATDLY_1BIT /* XDATDLY = 1 */ ), MCBSP_SRGR1_DEFAULT, MCBSP_SRGR2_DEFAULT, MCBSP_MCR1_DEFAULT, MCBSP_MCR2_DEFAULT, MCBSP_PCR_RMK( MCBSP_PCR_IDLEEN_RESET, /* IDLEEN = 0 */ MCBSP_PCR_XIOEN_SP, /* XIOEN = 0 */ MCBSP_PCR_RIOEN_SP, /* RIOEN = 0 */ MCBSP_PCR_FSXM_EXTERNAL, /* FSXM = 0 */ MCBSP_PCR_FSRM_EXTERNAL, /* FSRM = 0 */ 0, /* DXSTAT = N/A */ MCBSP_PCR_CLKXM_INPUT, /* CLKXM = 0 */ MCBSP_PCR_CLKRM_INPUT, /* CLKRM = 0 */ MCBSP_PCR_SCLKME_NO, /* SCLKME = 0 */ MCBSP_PCR_FSXP_ACTIVEHIGH, /* FSXP = 0 */ MCBSP_PCR_FSRP_ACTIVEHIGH, /* FSRP = 1 */ MCBSP_PCR_CLKXP_FALLING, /* CLKXP = 1 */ MCBSP_PCR_CLKRP_RISING /* CLKRP = 1 */ ), MCBSP_RCERA_DEFAULT, MCBSP_RCERB_DEFAULT, MCBSP_RCERC_DEFAULT, MCBSP_RCERD_DEFAULT, MCBSP_RCERE_DEFAULT, MCBSP_RCERF_DEFAULT, MCBSP_RCERG_DEFAULT, MCBSP_RCERH_DEFAULT, MCBSP_XCERA_DEFAULT, MCBSP_XCERB_DEFAULT, MCBSP_XCERC_DEFAULT, MCBSP_XCERD_DEFAULT, MCBSP_XCERE_DEFAULT, MCBSP_XCERF_DEFAULT, MCBSP_XCERG_DEFAULT, MCBSP_XCERH_DEFAULT; MCBSP_Handle hMcbsp;/* This next struct shows how to use the I2C API */* Create and initialize an I2C initialization structure */I2C_Setup I2Cinit = 0, /* 7 bit address mode */ 0, /* own address - dont care if master */ 7, /* clkout value (Mhz) */ 400, /* a number between 10 and 400*/ 0, /* number of bits/byte to be received or transmitted (8)*/ 0, /* DLB mode on*/ 1 /* FREE mode of operation on*/;I2C_Config testI2C;/all config bit zero, it works/ I2C: addr 7bit + data 9bit/*数字音频接口格式设置/ see tlv320a23b datasheetAIC23为主模式,数据为DSP模式,数据长度16位*/ Uint16 digital_audio_inteface_format2=0x0e,0x53;/*AIC23的波特率设置,0x23采样率为44.1K,0x0c采样率为8K*/Uint16 sample_rate_control2 = 0x10,0x0c;/*AIC23寄存器复位*/Uint16 reset2 =0x1e,0x00;/*AIC23节电方式设置,所有部分均所与工作状态*/Uint16 power_down_control2 =0x0c,0x01;/*AIC23模拟音频的控制DAC使能,ADC输入选择为MIC*/Uint16 analog_aduio_path_control2 =0x08,0x14;/*AIC23数字音频通路的控制*/Uint16 digital_audio_path_control2 =0x0a,0x05;/*AIC23数字接口的使能*/Uint16 digital_interface_activation2 =0x12,0x01;/*AIC23左通路音频调节*/ Uint16 left_line_input_volume_control2 =0x00,0x17;/*AIC23右通路音频调节*/ Uint16 right_line_input_volume_control2 =0x02,0x17;/*AIC23耳机左通路音频调节*/Uint16 left_headphone_volume_control2 =0x05,0x79;/*AIC23耳机右通路音频调节*/Uint16 right_headphone_volume_control2 = 0x07,0x79;/*定义McBSP的句柄*/Uint16 i2c_status;/Uint16 temp;/Uint16 nin=0,bcount=0;/long dec_sour,dec_temp;void main(void)i2c_status = 1;/ i2c status CSL_init();/ init cslCHIP_RSET(XBSR,0x0a01);GPIO_RSET(IODIR,0xFF);/*设置系统的运行速度为144MHz*/ PLL_config(&myConfig);EMIF_config(&emiffig);/set sdram dbptr = (short *)0x021000;/point to sdramdbptrhi = (short *)0x022000;I2C_RSET(I2CMDR,0);/*设置预分频寄存器,I2C的mode clock is 12MHz*/delay(100);I2C_RSET(I2CSAR,0x001A);I2C_RSET(I2CMDR,0x0620); I2C_setup(&I2Cinit); /*设置的Mater clock*/I2C_RSET(I2CCLKL,100);I2C_RSET(I2CCLKH,100); I2C_getConfig(&testI2C);/*初始化McBSP1*/hMcbsp = MCBSP_open(MCBSP_PORT1,MCBSP_OPEN_RESET);/*设置McBSP0*/MCBSP_config(hMcbsp,&Mcbsp1Config);/*启动McBSP0*/MCBSP_start(hMcbsp, MCBSP_RCV_START | MCBSP_XMIT_START, 0); MCBSP_getConfig(hMcbsp,&Mcbsptest); aic_init(); aic23data = (DATA *)0x023000;/point to sdramvoicedata = (DATA *)0x023100;while(1) dealkey();/MCBSP_write16(hMcbsp,aic23data); while(!MCBSP_rrdy(hMcbsp);/ check McBSP read stauts/if(MCBSP_rrdy(hMcbsp)*aic23data = (DATA)(MCBSP_read16(hMcbsp) - 63800);/ receive mic data/ if(firflag)/firflag :0:low pass, 1:high passfir(/ fir from DSP Libaic23data,/x, / input data arrayBhi,/h, / voicedata,/r, dbptrhi, hNX, BhiL/NH);elsefir(aic23data,/x, B,/h, voicedata,/r, dbptr, hNX, BL/NH);while(!MCBSP_xrdy(hMcbsp);/if(MCBSP_xrdy(hMcbsp)MCBSP_write16(hMcbsp,(unsigned int)(*voicedata + 63800);/ send voice data/*/void aic_init() /*reset AIC23*/ i2c_status = I2C_write( reset, /pointer to data array 2,/length of data to be transmitted 1,/master or slaver CODEC_ADDR, /slave address to transmit to 1,/transfer mode of operation 30000/time out for bus busy ); delay(1000); /*设置AIC23各部分均工作*/ i2c_status = I2C_write( power_down_control,/pointer to data array 2,/length of data to be transmitted 1,/master or slaver CODEC_ADDR, /slave address to transmit to 1,/transfer mode of operation 30000/time out for bus busy ); /*设置AIC23的数字接口*/i2c_status = I2C_write( digital_audio_inteface_format,/pointer to data array 2,/length of data to be transmitted 1,/master or slaver CODEC_ADDR, /slave address to transmit to 1,/transfer mode of operation 30000/time out for bus busy ); /*设置AIC23模拟通路*/i2c_status = I2C_write( analog_aduio_path_control,/pointer to data array 2,/length of data to be transmitted 1,/master or slaver CODEC_ADDR, /slave address to transmit to 1,/transfer mode of operation 30000/time out for bus busy );/*设置数字通路*/i2c_status = I2C_write( digital_audio_path_control,/pointer to data array 2,/length of data to be transmitted 1,/master or slaver CODEC_ADDR, /slave address to transmit to 1,/transfer mode of operation 30000/time out for bus busy ); /*设置AIC23的采样率*/i2c_status = I2C_write( sample_rate_control,/pointer to data array 2,/length of data to be transmitted 1,/master or slaver CODEC_ADDR, /slave address to transmit to 1,/transfer mode of operation 30000/time out for bus busy );/*设置耳机音量*/i2c_status = I2C_write( left_headphone_volume_control,/pointer

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论