This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

aic23采集声音信号问题

Other Parts Discussed in Thread: TMS320VC5509A

我用的板子是TMS320VC5509A,我想用它来采集声音信号,在官方提供的第27个例子中,连接电脑能听到电脑播放的音乐,如果我想在输入口接个麦克风采集声音信号,该怎么处理呢?直接用这个程序能不能实现,我用的是虚拟机XP系统,我现在直接用程序的话,感觉麦克风不起作用,运行后有噪音,这个是什么问题我该怎么解决?

程序如下:#include <csl.h>
#include <csl_i2c.h>
#include <stdio.h>
#include <csl_pll.h>
#include <csl_mcbsp.h>

#define CODEC_ADDR 0x1A


/*锁相环的设置*/
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
  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)
};


MCBSP_Config Mcbsptest;
/*设置McBSP,使用McBSP1来发送和接收来自DSP 和 AIC23的数据*/
/*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 DX引脚延时使能打开*/
    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 接收阶段1的帧长为1个字 */
          MCBSP_RCR1_RWDLEN1_16BIT               /* RWDLEN1 = 2 接收阶段1的字长为16位 */
  ),
  MCBSP_RCR2_RMK(   
    MCBSP_RCR2_RPHASE_SINGLE,              /* RPHASE  = 0 接收帧的阶段数*/
    MCBSP_RCR2_RFRLEN2_OF(0),              /* RFRLEN2 = 0 接收阶段2关闭*/
    MCBSP_RCR2_RWDLEN2_8BIT,               /* RWDLEN2 = 0 接收阶段2的字长为8位*/
    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 发送阶段1的帧长(一个)*/
    MCBSP_XCR1_XWDLEN1_16BIT               /* XWDLEN1 = 2 发送阶段1的字长16位*/
   
),   
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
};   
/*创建和初始化I2C模块*/  
/* 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 - don't care if master */
        84,            /* clkout value (Mhz)  */
        50,            /* 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;


/*数字音频接口格式设置
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,0x03};

/*AIC23模拟音频的控制
DAC使能,ADC输入选择为Line*/
Uint16 analog_aduio_path_control[2] ={0x08,0x10};
/*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;
    /* Initialize CSL library - This is REQUIRED !!! */
    /*初始化CSL库*/
    CSL_init();
       
        /*设系统的运行速度为140MHz*/
    PLL_config(&myConfig);
   
    /* Initialize I2C, using parameters in init structure */
    /*初始化I2C的格式*/

//        I2C_config(&Config);
//        I2C_start();
       
//        I2C_getConfig(&Config1);
        /*I2C is undet reset*/
        I2C_RSET(I2CMDR,0);
        /*设置预分频寄存器,I2C的mode clock is 10MHz*/
        delay(100);
        I2C_RSET(I2CSAR,0x001A);
        I2C_RSET(I2CMDR,0x0620);
               
    I2C_setup(&I2Cinit);
          /*设置I2C的Mater clock*/
        I2C_RSET(I2CCLKL,100);
        I2C_RSET(I2CCLKH,100);

    I2C_getConfig(&testI2C);

        /*初始化McBSP0*/
        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);

    /*reset AIC23*/
    i2c_status = I2C_write( reset,          //pointer to data array  指向发送数据的数组
                                    2,                                //length of data to be transmitted  发送数据的长度16位
                                    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 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 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
                                    );  
        /*设置Line输入的音量*/
        i2c_status = I2C_write( left_line_input_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_line_input_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
                                    );
        /*启动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)
        {
                while(!MCBSP_rrdy(hMcbsp)){};
                aic23data = MCBSP_read16(hMcbsp);
                MCBSP_write16(hMcbsp,aic23data);      
            }
}

还有就是,我要先看声音信号的图,那么我的开始地址应该设为哪个参数呢?这个程序的输入数据在什么地方体现?

  • LINE 和 MIC 是不同的通道, 软件控制中更换输入通道应该就能完成.

  • 具体在程序里面怎么改呢
  • 改成这句就是了,就是选择麦克风输入

    /*AIC23模拟音频的控制,ADC输入选择为MIC*/
    Uint16 analog_aduio_path_control[2] ={0x08,0x14};

  • 程序进行MIC设置,但是还是没有反应,请问程序还需要修改什么呀???修改的地方用标记出来了。。

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

    #define CODEC_ADDR 0x1A


    /*锁相环的设置*/
    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
    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)
    };


    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 */
    I2C_Setup I2Cinit = {
    0, /* 7 bit address mode */
    0, /* own address - don't care if master */
    84, /* clkout value (Mhz) */
    50, /* 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;


    /*数字音频接口格式设置
    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,0x01}; //打开设备电源 时钟
    //振荡器 输出 打开DAC和ADC 麦克风输入使能 线性输入关闭
    /*AIC23模拟音频的控制
    DAC使能,ADC输入选择为MIC*/
    Uint16 analog_aduio_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;
    /* Initialize CSL library - This is REQUIRED !!! */
    /*初始化CSL库*/
    CSL_init();

    /*设置系统的运行速度为140MHz*/
    PLL_config(&myConfig);

    /* Initialize I2C, using parameters in init structure */
    /*初始化I2C的格式*/

    // I2C_config(&Config);
    // I2C_start();

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

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

    I2C_getConfig(&testI2C);

    /*初始化McBSP0*/
    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);

    /*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 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 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
    );
    /*设置Line输入的音量*/
    i2c_status = I2C_write( left_line_input_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_line_input_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
    );
    /*启动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)
    {
    while(!MCBSP_rrdy(hMcbsp)){};
    aic23data = MCBSP_read16(hMcbsp);
    MCBSP_write16(hMcbsp,aic23data);
    }
    }


    /******************************************************************************\
    * End of i2c2.c
    \******************************************************************************/

  • 这是我之前调试用的,你对比下,哪些地方不一样

    /************************************Copyright(c)***************************************
    **
    **
    **---------------------------------文件信息-------------------------------------
    **文 件 名:
    **创 建 人:
    **最后修改日期:
    **描 述:
    **
    **---------------------------------历史版本信息---------------------------------
    **创建人:
    **版 本:
    **日 期:
    **描 述:
    **
    **------------------------------------------------------------------------------
    **修改人:
    **版 本:
    **日 期:
    **描 述:
    **
    **---------------------------------当前版本修订---------------------------------
    **修改人:
    **日 期:
    **描 述:
    **
    **------------------------------------------------------------------------------
    ***************************************************************************************/

    /**********************************头文件**********************************************/
    #include <csl.h>
    #include <csl_i2c.h>
    #include <stdio.h>
    #include <csl_pll.h>
    #include <csl_mcbsp.h>
    #include <math.h>
    /**********************************变量************************************************/
    #define CODEC_ADDR 0x1A //语音芯片AIC23地址
    #define SAMPLENUMBER 512 //定义抽取样本数为512
    int c[SAMPLENUMBER];
    /**********************************函数声明************************************/


    /***********************************锁相环的设置*******************************/
    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
    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)
    };
    //////////////////////////////////////////////////////////////////////////////////////////

    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
    };
    /***********************下面结构体说明如何使用I2C的API函数创建和初始化一个I2C初始化结构体*********************/
    I2C_Setup I2Cinit = {
    0, /* 7 bit address mode */
    0, /* own address - don't care if master */
    84, /* clkout value (Mhz) */
    50, /* 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;
    /**************************************AIC23寄存器配置********************************************************/
    Uint16 digital_audio_inteface_format[2] = {0x0e,0x53}; /*AIC23为主模式,数据为DSP模式,数据长度16位*/
    Uint16 sample_rate_control[2] = {0x10,0x20}; /*AIC23的采样率设置,采样率为44.1K*/
    Uint16 reset[2] = {0x1e,0x00}; /*AIC23寄存器复位*/
    Uint16 power_down_control[2] = {0x0c,0x01}; /*AIC23节电方式设置,所有部分均所与工作状态*/
    Uint16 analog_aduio_path_control[2] = {0x08,0x15}; /*AIC23模拟音频的控制DAC使能,ADC输入选择为MIC*/
    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,0x00}; /*AIC23左通芬羝档鹘?/
    Uint16 right_line_input_volume_control[2] = {0x02,0x00}; /*AIC23右通路音频调节*/
    Uint16 left_headphone_volume_control[2] = {0x05,0x79}; /*AIC23耳机左通路音频调节*/
    Uint16 right_headphone_volume_control[2] = {0x07,0x79}; /*AIC23耳机右通路音频调节*/
    /**************************************定义McBSP的句柄*******************************************************/
    MCBSP_Handle hMcbsp; //定义MCBSP的句柄,命名为hMcbsp
    Uint16 i2c_status;
    /**************************************延时函数**************************************************************/
    void delay(Uint32 k)
    {
    while(k--);
    }
    /**************************************主函数****************************************************************/
    void main()
    {
    int i = 0;
    i2c_status = 1;

    CSL_init(); //初始化CSL库,将.csldata的地址保存到0x7b
    PLL_config(&myConfig); //设置系统的运行速度为140MHz
    I2C_RSET(I2CMDR,0); //复位 I2C(寄存器名,写入值)
    delay(100); //延时
    I2C_RSET(I2CSAR,0x001A); //从设备地址为0x1A
    I2C_RSET(I2CMDR,0x0620); //配置I2C
    I2C_setup(&I2Cinit); //使用初始化结构体初始化I2C寄存器
    /*设置I2C的Mater clock*/
    I2C_RSET(I2CCLKL,100); //Clock Divider Low register
    I2C_RSET(I2CCLKH,100); //Clock Divider High register
    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, //指向数组首地址
    2, //传输数据长度
    1, //主机或从机设置
    CODEC_ADDR, //从机地址
    1, //传输模式
    30000 //忙信号等待延时
    );
    delay(1000); //延时,等待AIC23完成重启
    /*设置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 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 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
    );
    /*设置Line输入的音量*/
    i2c_status = I2C_write( left_line_input_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_line_input_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
    );
    /*启动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)
    {
    while(!MCBSP_rrdy(hMcbsp)){};
    aic23data = MCBSP_read16(hMcbsp);
    MCBSP_write16(hMcbsp,aic23data);
    }
    }

    /******************************************************************************\
    * End of Audio time analysis.c
    \******************************************************************************/

  • 你当时调试通了么 为啥我的还是调试不同呀???

  • 我当时是调试通了的,对着麦克风讲话,耳机里是能听见声音的,我把源码发上来,你再参考下。

  • 我直接把你的程序考进去,不过不知道为啥还是没反应!!!

  • 请问一下,后来解决了么,我也是这个原因,没有反应
  • 请问你现在解决这个问题了吗?我也遇到了这个问题

  • 你好,请问你是在做音频实时处理的吗?想和你交流一下,方便加下联系方式吗?我的QQ是:873511507,希望可以和你交流一下!