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.

5509A MCBSP DRR接收不到数据

Other Parts Discussed in Thread: PCM4204

5509的语音回放程序,但是DRR寄存器没变化,是不是配置错了?可是我是参考的实验例子。。。请老师帮忙看看问题出在哪了啊
/******************************************************************************/
/*  Copyright 2004 by SEED Electronic Technology LTD.                         */
/*  All rights reserved. SEED Electronic Technology LTD.                      */
/*  Restricted rights to use, duplicate or disclose this code are             */
/*  granted through contract.                                                 */
/*                                                                            */
/*                                                                            */
/******************************************************************************/
/*----------------------------------------------------------------------------*/
/* 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>
#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
  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)
};
/*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 */
    MCBSP_SPCR1_ABIS_DISABLE,              /* ABIS   = 0 */
    MCBSP_SPCR1_RINTM_RRDY,                /* RINTM  = 0 */
    0,                                     /* RSYNCER = 0 */
    0,                                     /* RFULL = 0 N/A */
    0,                                     /* RRDY = 0 N/A */
    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 */
    0,                                     /* XEMPTY = N/A */
    0,                                     /* XRDY   = 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   */
   MCBSP_PCR_SCLKME_NO,                    /* SCLKME   = 0   */
   0,                                      /* CLKSSTAT = N/A */
   0,                                      /* DXSTAT = N/A   */
   0,                                      /* DRSTAT = N/A   */
   MCBSP_PCR_CLKXM_INPUT,                  /* CLKXM    = 0   */
   MCBSP_PCR_CLKRM_INPUT,                  /* CLKRM    = 0   */
   MCBSP_PCR_FSXP_ACTIVEHIGH,              /* FSXP     = 0   */
   MCBSP_PCR_FSRP_ACTIVELOW,               /* 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 */
        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*/
};

/*
数字音频接口格式设置

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};
/*
定义McBSP的句柄
*/
MCBSP_Handle hMcbsp;

void main(void)
{

    Uint16 aic23data = 0;
    /* Initialize CSL library - This is REQUIRED !!! */
    /*
初始化CSL
*/
    CSL_init();
       
        /*
设置系统的运行速度为
144MHz*/
    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 12MHz*/
        I2C_RSET(I2CPSC,0xb);
        I2C_RSET(I2CMDR,0x4620);
               
//  I2C_setup(&I2Cinit);
          /*
设置I2C的
Mater clock*/
        I2C_RSET(I2CCLKL,55);
        I2C_RSET(I2CCLKH,55);
        /*
初始化
McBSP1*/
        hMcbsp = MCBSP_open(MCBSP_PORT1,MCBSP_OPEN_RESET);
        /*
设置
McBSP1*/
        MCBSP_config(hMcbsp,&Mcbsp1Config);
        /*
启动
McBSP1*/
        MCBSP_start(hMcbsp,
                MCBSP_RCV_START | MCBSP_XMIT_START,
                0);
    /*
设置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_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
                       );
        /*
设置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
                       );
        /*
启动
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
                       );
                      
        /*
回放音频
*/                                                                  
        while(TRUE)
        {
                while(!MCBSP_rrdy(hMcbsp)){};
                aic23data = MCBSP_read16(hMcbsp);
                MCBSP_write16(hMcbsp,aic23data);        
        };                                                                            
}
  • 问题补充:请问老师,我现在做的是利用MCBSP接收外部AD数据,但是下面的这个图我不是很懂难道AD接MCBSP1时除了位时钟,帧同步时钟外,还需要CLKS管脚也接一个时钟吗?这个可以理解成MCBSP的工作时钟吗?但是这个引脚找不到啊?难道是需要内部产生?另外,请问老师,MCBSP可以接收IIS数据格式吗?我看SPCR1的RJUST位只有左移和右移,因为我的AD是PCM4204,如下图那么是不是我只能选择左对齐或者右对齐的数据格式 再在寄存器里设置呢??请老师解答,谢谢了!!!!!

  • 刚刚查了手册 发现是IIS兼容设备

  • 前辈,您的问题解决了吗,我最近也遇到了和您一样类似的问题,也是McBsp1接收数据寄存器DRR接收到数据基本上是固定值,没什么变化。求教。。