合众达5509dsk,AIC23B播放音频,McBSP1配置为AIC23b的数据口,I2C为控制口 aic23b配置如下: /*数字音频接口格式设置 AIC23为主模式,数据为DSP模式,数据长度16位*/ Uint16 digital_audio_inteface_format[2]={0x0e,0x53}; /*AIC23的波特率设置,采样率为44.1K*/ Uint16 sample_rate_control[2] = {0x10,0x23}; /*AIC23寄存器复位*/ Uint16 reset[2] ={0x1e,0x00}; /*AIC23节电方式设置,所有部分均所与工作状态*/ Uint16 power_down_control[2] ={0x0c,0x00}; /*AIC23模拟音频的控制 DAC使能,ADC输入选择为Line*/ Uint16 analog_aduio_path_control[2] ={0x08,0x10}; /*AIC23数字音频通路的控制*/ Uint16 digital_audio_path_control[2] ={0x0a,0x01}; /*AIC23数字接口的使能*/ Uint16 digital_interface_activation[2] ={0x12,0x01}; /*AIC23左通路音频调节*/ Uint16 left_line_input_volume_control[2] ={0x01,0x17}; /*AIC23右通路音频调节*/ Uint16 right_line_input_volume_control[2] ={0x3,0x17}; /*AIC23耳机左通路音频调节*/ Uint16 left_headphone_volume_control[2] ={0x05,0xFF}; /*AIC23耳机右通路音频调节*/ Uint16 right_headphone_volume_control[2] = {0x07,0xFF};
I2C_RSET(I2CMDR,0); /*设置预分频寄存器,I2C的mode clock is 12MHz*/ I2C_RSET(I2CPSC,0xb); I2C_RSET(I2CMDR,0x4620); // I2C_setup(&I2Cinit); /*设置I2C的Mater clock*/ I2C_RSET(I2CCLKL,55); I2C_RSET(I2CCLKH,55);
/*回放音频*/ aic23data= 0xff; MCBSP_write16(hMcbsp,aic23data);
while(TRUE) { while(!MCBSP_rrdy(hMcbsp)){}; aic23data = MCBSP_read16(hMcbsp); MCBSP_write16(hMcbsp,aic23data); };
以上为codec例程配置,运行回放音频,从mic输入,headphone输出,可以 后改动如下:
while(TRUE) { while(!MCBSP_xrdy(hMcbsp)){};
fat16_read_file(&fp, buf, 4); //读4个字节至buf aic23data[0] = (Uint16) buf[0] | (Uint16) buf[1]<< 8 ; aic23data[1] = (Uint16) buf[2] | (Uint16) buf[3]<< 8 ; MCBSP_write16(hMcbsp,aic23data[0]); MCBSP_write16(hMcbsp,aic23data[1]); i += 4; }; fp为PCM数据文件,16位双声道数据格式, headphone输出的声音完全不对 请教:程序错在哪里,如果改正,谢谢。
|