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.

5509的codec问题,关于A/D,D/A,mcbsp



我将5509板子自带示例中的codec代码中的mcbsp部分全部去掉,生成的代码如下,结果上电之后还能从phone out处听到line in 输入的音频,是不是硬件板子有问题?

/******************************************************************************/


/*----------------------------------------------------------------------------*/
/* DESCRIPTION:                   */
/*                       */
/* This is an example for EMIF of C5509            */
/*----------------------------------------------------------------------------*/
/* MODULE NAME... I2C and Mcbsp              */
/* FILENAME...... codec.c                 */
/* DATE CREATED.. Mon 02/4/2004                 */
/* COMPONENT.....                  */
/* PREREQUISITS..                  */
/*----------------------------------------------------------------------------*/
/* DESCRIPTION:                  */ 
/*                       */
/* this example is that the codec is controled by the I2C and Mcbsp     */
/*----------------------------------------------------------------------------*/

#include <csl.h>
#include <csl_i2c.h>
#include <stdio.h>
#include <csl_pll.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
  0             //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)
};

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


/* 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 */
        144,            /* clkout value (Mhz)  */
        100,            /* 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,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] ={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};

 

Uint16 i,temp;

 

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


void main(void)
{

   


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

 

    /*reset AIC23*/
    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
                   );
 
    /*设置AIC23各部分均工作*/
    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_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_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_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_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_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_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_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_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
         );
        

                                 
}

 


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

 

 

附电路图

DSP5509.pdf