TI中文支持网
TI专业的中文技术问题搜集分享网站

关于DM642语音处理问题(AIC23B、MCASP)

一开始产生单频声音是好使的,后来加上延时就不好使了。本来并没有延时,只是我用来调试程序的(延时部分可以算作算法的部分),但此时,就没有声音发出了。使用的是奇想达DM642的板子。主函数如下:

for(;;)
	{
		if(MCASP_FGETH(QXDdm642codec,RSTAT,RDATA))
		{
			codecdata[0] = MCASP_RGETH(QXDdm642codec,RBUF1);

			MCASP_RSETH(QXDdm642codec,XBUF0,codecdata[0]);
			
			codecdata[1] = MCASP_RGETH(QXDdm642codec,RBUF3);
			MCASP_RSETH(QXDdm642codec,XBUF2,codecdata[1]);

//			for(b=0;b<1000;b++) {}//这一段代码加上后就没有声音发出了,当b=100或者更小时,有声音发出
			
			codecdata[2] = MCASP_RGETH(QXDdm642codec,RBUF5);		
			MCASP_RSETH(QXDdm642codec,XBUF4,15000*sin(0.1*PI*n));	
			
			codecdata[3] = MCASP_RGETH(QXDdm642codec,RBUF7);
			MCASP_RSETH(QXDdm642codec,XBUF6,codecdata[3]);	
			
			n++;
			if(n>20)
			n=0;	
		
		}
		else
		{asm(" nop");
		}

其中,AIC23B的配置如下:

#define QXDDM642_AIC23_DEFAULTCONFIG { \0x0017, /* Set-Up Reg 0左线输入通道音量控制 Left line input channel volume control */  \/* LRS0simultaneous left/right volume: disabled */\/* LIM0left line input mute: disabled */\/* XX00reserved */\/* LIV10111left line input volume: 0 dB */\\0x0017, /* Set-Up Reg 1右线输入通道音量控制 Right line input channel volume control */ \/* RLS0simultaneous right/left volume: disabled */\/* RIM0right line input mute: disabled */\/* XX00reserved */\/* RIV10111right line input volume: 0 dB */\\0x01f9, /* Set-Up Reg 2左通道耳机音量控制 Left channel headphone volume control */\/* LRS1simultaneous left/right volume: enabled */ \/* LZC1left channel zero-cross detect: enabled 过零检测*/ \/* LHV1111001left headphone volume: 0 dB */\\0x01f9, /* Set-Up Reg 3右通道耳机音量控制 Right channel headphone volume control */  \/* RLS1simultaneous right/left volume: enabled */ \/* RZC1right channel zero-cross detect: enabled */\/* RHV1111001right headphone volume: 0 dB */\\0x0011, /* 0x0011  0x0015Set-Up Reg 4  模拟音频路径控制Analog audio path control */\/* X0reserved */\/* STA00sidetone attenuation: -6 dB */\/* STE0sidetone: disabled */\/* DAC1DAC: selected */\/* BYP0旁路 bypass: off */\/* INSEL0ADC选择输入 线输入,为何不是MIC输入???input select for ADC: line*/\/* MICM0microphone mute: disabled */\/* MICB1麦克风增强 microphone boost: enabled C5509板子上程序没有增强*/\\0x0000, /* Set-Up Reg 5数字音频路径控制 Digital audio path control */\/* XXXXX00000reserved */\/* DACM0DAC soft mute: disabled */\/* DEEMP00deemphasis control: disabled */\/* ADCHP0ADC high-pass filter: disabled */\\0x0000, /* Set-Up Reg 6断电控制  Power down control */\/* X0reserved */\/* OFF0device power: on (i.e. not off) */\/* CLK0clock: on */\/* OSC0oscillator: on */\/* OUT0outputs: on */\/* DAC0DAC: on */\/* ADC0ADC: on */\/* MIC0microphone: on */\/* LINE0line input: on */\\0x0053, /* Set-Up Reg 7数字音频接口格式 Digital audio interface format */\/* XX00reserved */\/* MS1主模式 master/slave mode: master */\/* LRSWAP  0DAC的左/右互换 DAC left/right swap: disabled */\/* LRP0DAC lrp: MSB on 1st BCLK */\/* IWL00输入位长度:16位。input bit length: 16 bit */\/* FOR11数据格式:DSP格式 data format: DSP format */\\0x000e, /* Set-Up Reg 8采样率控制 Sample rate control//修改 原先为0002,ADC\DAC均为8Khz normal模式 */\/* X0reserved */\/* CLKOUT  0时钟输出分频:1  clock output divider: 1 MCLK */\/* CLKIN0时钟输入分频:1 clock input divider: 1 (MCLK) */\/* SR,BOSR 00110sampling rate: ADC  8 kHz DAC  8 kHz */  \/* USB/N0clock mode select (USB/nor  mal): normal */\\0x0001  /* Set-Up Reg 9数字接口激活 Digital interface activation */\/* XX..X00000000reserved */\/* ACT1active */\
}

主程序中有:

	/*AIC23B的初始化*/
	hQXDdm642i2c = I2C_open(I2C_PORT0,I2C_OPEN_RESET);
	I2C_config(hQXDdm642i2c,&QXDDM642IIC_Config);
	/*配置第一路到第四路音频输入*/
	/*第一通路AIC23工作在主模式*/
//	codecstate.regs[QXDDM642_AIC23_DIGIF] = 0x13; 

	dm642aic23handle0 = EVMDM642_AIC23_open(hQXDdm642i2c,0,&codecstate);

	codecstate.regs[QXDDM642_AIC23_DIGIF] = 0x13;	
		/*其它三路工作在从模式*/
	dm642aic23handle1 = EVMDM642_AIC23_open(hQXDdm642i2c,1,&codecstate);
	dm642aic23handle2 = EVMDM642_AIC23_open(hQXDdm642i2c,2,&codecstate);
//	dm642aic23handle3 = EVMDM642_AIC23_open(hQXDdm642i2c,3,&codecstate);

MCASP的配置如下:

	/*MCASP的初始化*/
	QXDdm642codec = QXDDM642_AIC23_openCodec();

MCASP_ConfigGbl mcaspCfgDataGbl = {0x00000000, // PFUNC -All pins as McASP ,所有的管脚均为McAPS功能0x00000055, //* PDIR  -0,2,4,6为input,1,3,5,7为XMT DATA output, 其它的为输入0x00000000, //* DITCTL -DIT mode disable ,使用TDM mode or burst mode.0x00000000, //* DLBCTL -Loopback disabled */0x00000000  //* AMUTE  -Never drive AMUTE */
};

MCASP_ConfigRcv mcaspCfgDataRcv = {0xffffffff, //* RMASK -Use all 32 bits,左声道与右声道各16位0x000180f8, //* RFMT -MSB first, 32-bit slots,0-pad,CPU bus, 0 bit delay,数据格式0x00000200, //* AFSRCTL -4-slots TDM, single bit frame sync, ext FS 帧同步的格式,修改过,原先为2000x00000080, /* ACLKRCTL -  时钟上升沿有效, 时钟不分频, 外部时钟模式from ACLKR pin. */0x00000000, //* AHCLKRCTL - External HCLK  外部接收高频时钟来自AHCLKR pin. */0x0000000f, /* RTDM -Slots 1,3,5,7 are active */0x00000000, /* RINTCTL -关闭所有中断 No interrupts */0x00000000  /* RCLKCHK -Not used */ 
};

MCASP_ConfigXmt mcaspCfgDataXmt = {0xffffffff, /* XMASK -Use all 32 bits,左声道与右声道各16位 */0x000180f8, /* XFMT -MSB first, 32-bit slots, CPU bus, 0 bit delay */0x00000200, /* AFSXCTL -burst, single bit frame sync, ext FS 4 slot TDM*/0x00000080, /* ACLKXCTL -  Sample on falling CLK, divide by 1, ext CLK ,发送与接收同步*/0x00000000, /* AHCLKXCTL - External HCLK */0x00000005, /* XTDM -0,2,4,6 enable*/0x00000000, /* XINTCTL -No interrupts */0x00000000  /* XCLKCHK -Not used */
};

MCASP_ConfigSrctl mcaspCfgDataSrctl = {0x00000005, /* SRCTL0 -Receive, active high101发送  110接收 */0x00000006, /* SRCTL1 -Transmit, active high*/0x00000005, /* SRCTL2 -Receive, active high */0x00000006, /* SRCTL3 -Transmit, active high */0x00000005, /* SRCTL4 -Receive, active high */0x00000006, /* SRCTL5 -Transmit, active high*/0x00000005, /* SRCTL6 -Receive, active high */0x00000006  /* SRCTL7 -Transmit, active high */
};

MCASP_Config mcaspCfgData = {&mcaspCfgDataGbl,&mcaspCfgDataRcv,&mcaspCfgDataXmt,&mcaspCfgDataSrctl
};

/***************************************************************************/
/*  ======== EVMDM642_AIC23_openCodec ========*/
/*  Open the codec and return a codec handle*/
/***************************************************************************/
MCASP_Handle QXDDM642_AIC23_openCodec()
{Uint32 gblctl;/* AIC23 handles,定义McASP的句柄*/MCASP_Handle QXDDM642_AIC23_hMcASP;/* Open and configure the McASP*/QXDDM642_AIC23_hMcASP = MCASP_open(MCASP_DEV0, MCASP_OPEN_RESET);/*配制McASP */MCASP_config(QXDDM642_AIC23_hMcASP, &mcaspCfgData);/* Clear transmit and receive status ,清除发送与接收状态*/MCASP_RSETH(QXDDM642_AIC23_hMcASP, RSTAT, 0xffff);MCASP_RSETH(QXDDM642_AIC23_hMcASP, XSTAT, 0xffff);/* Clear GBLCTL,将所有的单元复位 */gblctl = 0;MCASP_RSETH(QXDDM642_AIC23_hMcASP, GBLCTL, gblctl);gblctl = 0x404;/*使能发送与接收的串行寄存器*/MCASP_RSETH(QXDDM642_AIC23_hMcASP, GBLCTL, 0x404);/* Enable transmit/receive state machines */MCASP_RSETH(QXDDM642_AIC23_hMcASP, XBUF0, 0);MCASP_RSETH(QXDDM642_AIC23_hMcASP, XBUF2, 0);MCASP_RSETH(QXDDM642_AIC23_hMcASP, XBUF4, 0);MCASP_RSETH(QXDDM642_AIC23_hMcASP, XBUF6, 0);gblctl = 0x0c0c;MCASP_RSETH(QXDDM642_AIC23_hMcASP, GBLCTL, gblctl);return QXDDM642_AIC23_hMcASP;
}

实在不知道问题出在哪里,怎么解决。求各位帮忙,谢谢!

user151383853:

通常增加延迟并不会影响数据交换. 除非在要求连续传输的数据中间引起数据传输超时错误了

li wan1:

我也在用这个DSP,用的代码和你的一样,但是我只要更改AIC23B的采样率后,就不能发声了;另外,当右击变量查看变化后或者暂停程序后再启动后,突然就听不到声音了,调试了好久都没能解决,你能不能把你的这个文件发给我一份,或者帮我之处我的问题所在,我的邮箱wl596121344@163.com,万分感谢

赞(0)
未经允许不得转载:TI中文支持网 » 关于DM642语音处理问题(AIC23B、MCASP)
分享到: 更多 (0)