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

5509和AIC23做音频回放试验,LINEIN模式下可以回放,修改寄存器想在MICIN模式下回放但是不成功,请问可能是什么原因?

我正在用AIC23和DSP5509做语音回放试验。
我想请问一下为什么我按照datashee的设置了Uint16 analog_aduio_path_control[2] 和Uint16 power_down_control[2]这两个寄存器还是无法从耳机里听到MIC输入的声音呢?

我用的是标准的5509和AIC23语音回放的例程。程序如下所示。

当如源程序所设:

Uint16 power_down_control[2] ={0x0c,0x03};

Uint16 analog_aduio_path_control[2] ={0x08,0x10};//原程序,0x10代表模拟输入为linein

的时候,也就是通过linein输入声音时候,耳机是能够回放声音的。于是我修改寄存器,并且反注释了AIC23模拟通路如下所示:
//Uint16 power_down_control[2] ={0x0c,0x03}; //原程序,改成如下
Uint16 power_down_control[2] ={0x0c,0x01}; // 打开设备电源 时钟 振荡器 输出 打开DAC ADC 麦克风输入 线性输入关���

/*AIC23模拟音频的控制
DAC使能,ADC输入选择为Line*/
//Uint16 analog_aduio_path_control[2] ={0x08,0x10};//原程序,0x10代表模拟输入为line,所以如果用mic输入则听不到输出,改成如下
Uint16 analog_aduio_path_control[2] ={0x08,0x14}; //DAC选择麦克风输入,而非line,麦克风增益选择0db,随你要求

/*设置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
);

但是这时我无法听到MIC输入的声音。我用的是一个TAKSTAR PCM5550的话筒,通过示波器可以看出它确实输出了音频信号。硬件的原理图如附件所示。应该是没有问题的,所以我觉得还是软件方面的问题,又实在是找不出错误,请问这是为什么呢?

另外:我把AIC23的采样率从44.1k改成了8k,这个应该不会有什么问题吧?

附MIC输入HEADPHONE未成功的源代码:

#include <csl.h>
#include <csl_i2c.h>
#include <stdio.h>
#include <csl_pll.h>
#include <csl_mcbsp.h>

#define CODEC_ADDR 0x1A
#define N 10000
#define M 10

/*锁相环的设置*/
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
// 12, //PLL multiply value; multiply 24 times,经测试12 好像是不行的!
24, //测试有效,此时时钟=24*12/2=144MHz
1 //Divide by 2 PLL divide value; it can be either PLL dividevalue //(when PLL is enabled), or Bypass-mode divide value
//(PLL in bypass mode, if PLL multiply value is set to 1)
};

unsigned int play_mode; // 0:play 1:record and play

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
};/* This next struct shows how to use the I2C API */
/* Create and initialize an I2C initialization structure *//*通过IIC对语音编解码芯片进行初始化,首先要对DSP自身I2C进行初始化,利用库函数提供的初始化结构I2C_Setup
声明结构体设置IIC模块*/

I2C_Setup I2Cinit = {
0, /* 7 bit address mode */
0, /* own address – don't care if master */
84, /* clkout value (Mhz) */
//由于使用的晶振是12MHz,故而时钟输出为12MHz的倍数即可,本系统选用84MHz
50, /* a number between 10 and 400*/
//因为I2C总线的信息传递速率在10~400之内即可,本系统设为50kps
0, /* number of bits/byte to be received or transmitted(8)*/
0, /* DLB mode on*/
1 /* FREE mode of operation on*/
};

I2C_Config testI2C;

/*数字音频接口格式设置
AIC23为主模式,数据为DSP模式,数据长度16位*/Uint16 digital_audio_inteface_format[2]={0x0e,0x53};

/*AIC23的波特率设置,采样率为44.1K*/
//Uint16 sample_rate_control[2] = {0x10,0x23};
//MM:AIC23波特率设置为8K
Uint16 sample_rate_control[2] = {0x10,0x0d};

/*AIC23寄存器复位*/
Uint16 reset[2] ={0x1e,0x00};

/*AIC23节电方式设置,所有部分均所与工作状态*/
Uint16 power_down_control[2] ={0x0c,0x01}; //打开设备电源 时钟振荡器 输出 打开DAC和ADC 麦克风输入使能 线性输入关闭

/*AIC23模拟音频的控制*/
Uint16 analog_audio_path_control[2] ={0x08,0x14}; //DAC选择麦克风输入,而非line,麦克风增益选择0db

/*AIC23数字音频通路的控制*/
Uint16 digital_audio_path_control[2] ={0x0a,0x05};
/*AIC23数字接口的使能*/
Uint16 digital_interface_activation[2] ={0x12,0x01};
/*AIC23左通路音频调节*/
Uint16 left_line_input_volume_control[2] ={0x00,0x17};
/*AIC23右通路音频调节*/
Uint16 right_line_input_volume_control[2] ={0x02,0x17};
/*AIC23耳机左通路音频调节*/
Uint16 left_headphone_volume_control[2] ={0x05,0xFF};
/*AIC23耳机右通路音频调节*/
Uint16 right_headphone_volume_control[2] = {0x07,0xFF};
/*定义McBSP的句柄*/
MCBSP_Handle hMcbsp;

Uint16 i2c_status;
Uint16 i,temp;

void delay(Uint32 k)
{
while(k–);
}

void main(void)
{

Uint16 aic23data = 0;

i2c_status = 1;
play_mode=1;

/* Initialize CSL library – This is REQUIRED !!! */
/*初始化CSL库*/
CSL_init();
/*设置系统的运行速度为140MHz*/
PLL_config(&myConfig);

I2C_RSET(I2CMDR,0);
/*设置预分频寄存器,I2C的mode clock is 10MHz*/
delay(100);
I2C_RSET(I2CSAR,0x001A);
I2C_RSET(I2CMDR,0x0620);

I2C_FSET(I2CSTR,BB,0x1); /* Writing a 1 to BB Bus busy bit is supposed toclear it*//* Initializes I2C registers using initialization structure *//* Need to calcualte I2CCLKL & I2CCLKH manually has functionnality not fullymiplmented in CSL*///也就是在配置I2C模块之前,需要把I2CSTR寄存器中的BB位置1。同时,在待用完毕I2C_setup函数后,再重新配置一下I2CCLKL和I2CCLKH寄存器。

I2C_setup(&I2Cinit);
/*设置I2C的Mater clock*/
I2C_RSET(I2CCLKL,100);
I2C_RSET(I2CCLKH,100);

I2C_getConfig(&testI2C);

/*初始化McBSP0*/
hMcbsp = MCBSP_open(MCBSP_PORT0,MCBSP_OPEN_RESET);
/*设置McBSP0*/
MCBSP_config(hMcbsp,&Mcbsp1Config);
/*启动McBSP0*/
MCBSP_start(hMcbsp, MCBSP_RCV_START | MCBSP_XMIT_START, 0);

MCBSP_getConfig(hMcbsp,&Mcbsptest);

/*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_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
);*/
/*设置数字通路*/
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 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( right_headphone_volume_control,//pointer to dataarray
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
); /*设置Line输入的音量*/
i2c_status = I2C_write( left_line_input_volume_control,//pointer to dataarray
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( right_line_input_volume_control,//pointer to dataarray
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_interface_activation,//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
);
/*回放音频*/
while(TRUE)
{
if(play_mode==1) //record and play // In this function ,every16bits are read and write.
{
while(!MCBSP_xrdy(hMcbsp)){};
//等待直到XRDY=1,
//transmit ready bit. XRDY=1 means transmitter ready, DXR[1,2]is ready toaccept new data.
// that means read data from AIC23.
aic23data = MCBSP_read16(hMcbsp);

/**********这个是同步回放数据的程序************************/
//通过查询RRDY(SPCR1.1)和XRDY(SPCR2.1)来确定接收器和发生器的状态,以实现读/写控制

for(temp=3000;temp>10;temp–);
while(!MCBSP_rrdy(hMcbsp)){};
//等待直到RRDY=1,receive ready bit.RRDY is set when data is ready to beread from DRR[1,2].
//Receive ready, new data can be read from DRR[1,2].
MCBSP_write16(hMcbsp,aic23data);
// that means write data to AIC23.
}
else //否则直接发出蜂鸣声即可
{
while(!MCBSP_rrdy(hMcbsp)){};
aic23data = 5000;

for(temp=30000;temp>0;temp-=100)
{
for(i=0;i<2;i++)
{
aic23data = 5000;
MCBSP_write16(hMcbsp,aic23data); delay(temp);
aic23data = 0;
MCBSP_write16(hMcbsp,aic23data); delay(temp);
}
}
}

};}

Shine:

建议您到codec论坛咨询AIC23设置方面的问题.

fengmei li:

回复 Shine:

不好意思啊,请问CODEC论坛在哪儿?

Shine:

回复 fengmei li:

音频论坛http://www.deyisupport.com/question_answer/analog/audio/f/42.aspx

赞(0)
未经允许不得转载:TI中文支持网 » 5509和AIC23做音频回放试验,LINEIN模式下可以回放,修改寄存器想在MICIN模式下回放但是不成功,请问可能是什么原因?
分享到: 更多 (0)