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.

使能两个DMA便无法工作

我用dmaRcv来搬运SD卡的数据到DARAM,用dmaXmt将DARAM中的数据搬运到MCBSP(接着AIC23),可是dmaXmt无法正常工作,加上这句配置的语句    DMA_config(hDmaRcv,&dmaXmtConfig);

dmaRcv就不能进入中断,去掉就行,程序代码如下

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

#include <csl_mmc.h>
#include <csl_dma.h>
#include <csl_irq.h>

#define CODEC_ADDR 0x1A

#pragma DATA_SECTION(mmc0,"cslmem")
MMC_Handle mmc0;
MMC_CardObj *card, cardalloc;
MMC_CardIdObj *cid, cardid;

//MMC_callBackObj *callback;

int count, retVal;
Uint16 rca;
Uint16 cardtype;

#define N       256

#pragma DATA_SECTION(xmt,"dmaMem")
Uint16 xmt[N];
#pragma DATA_SECTION(rcv,"dmaMem")
Uint16 rcv[N];

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

#if CHIP_5509A
  MMC_SetupNative Init = {
    1,   /* Disable DMA for data read/write                 */
    0,   /* Set level of edge detection for DAT3 pin        */
    0,   /* Determines if MMC goes IDLE during IDLE instr   */
    1,   /* Memory clk reflected on CLK Pin                 */
    7,   /* CPU CLK to MMC function clk divide down         */
    5,   /* MMC function clk to memory clk divide down      */
    0,   /* No. memory clks to wait before response timeout */
    0,   /* No. memory clks to wait before data timeout     */
    512, /* Block Length must be same as CSD                */
  };
#else
  MMC_SetupNative Init = {
    0,   /* Disable DMA for data read/write                 */
    0,   /* Set level of edge detection for DAT3 pin        */
    0,   /* Determines if MMC goes IDLE during IDLE instr   */
    1,   /* Memory clk reflected on CLK Pin                 */
    3,   /* CPU CLK to MMC function clk divide down         */
    3,   /* MMC function clk to memory clk divide down      */
    0,   /* No. memory clks to wait before response timeout */
    0,   /* No. memory clks to wait before data timeout     */
    512, /* Block Length must be same as CSD                */
  };
#endif

  /* Create DMA Receive Side Configuration */
  DMA_Config  dmaRcvConfig = {
    DMA_DMACSDP_RMK(
      DMA_DMACSDP_DSTBEN_NOBURST,				//Destination burst :-不使用突发
      DMA_DMACSDP_DSTPACK_OFF,				//Destination packing :-目标口禁止打包
      DMA_DMACSDP_DST_DARAM,					//Destination selection :-接收的目标口是DARAM
  	//00 SARAM;01 DARAM;10 EMIF;11 PERIPH
      DMA_DMACSDP_SRCBEN_NOBURST,				//Source burst :-源突发禁止
      DMA_DMACSDP_SRCPACK_OFF,				//Source packing :-源口禁止打包
      DMA_DMACSDP_SRC_PERIPH,					//Source selection :-外设mcbsp www
//	  DMA_DMACSDP_SRC_DARAM,					//Source selection :-外设mcbsp
      DMA_DMACSDP_DATATYPE_16BIT				 //Data type :-设置数据类型16bit字长
    ),                                       /* DMACSDP  */
    DMA_DMACCR_RMK(
      DMA_DMACCR_DSTAMODE_POSTINC,			//Destination address mode :-自动执行后增量(由于本程序中数据类型是16bit,所以+2)
      DMA_DMACCR_SRCAMODE_CONST,				//Source address mode :-源地址为恒定地址
      DMA_DMACCR_ENDPROG_ON,					//End of programmation bit :-
      DMA_DMACCR_REPEAT_OFF,					//Repeat condition :(AUTOINIT=1)才有效?-0 管编程配置结束位 1 不管编程配置结束位,结束传输自动初始化开始
  											//0:Repeat only if ENDPROG = 1(AUTOINIT=1)
      DMA_DMACCR_AUTOINIT_OFF,				//Auto initialization bit :-
      DMA_DMACCR_EN_STOP,						//Channel enable :-设置时先关闭通道
//      DMA_DMACCR_PRIO_LOW,					//Channel priority :-设置为低优先级
	  DMA_DMACCR_PRIO_HI,
      DMA_DMACCR_FS_DISABLE,					//(FS_ELEMENT 单元事件同步)
//      DMA_DMACCR_SYNC_REVT1					//Synchronization control bits 同步控制位   www
	  DMA_DMACCR_SYNC_REVT2
    ),                                       /* DMACCR   */
    DMA_DMACICR_RMK(
      DMA_DMACICR_BLOCKIE_OFF,				//Whole block interrupt enable :-块传输完成后中断不使能
      DMA_DMACICR_LASTIE_OFF,					//Last frame interrupt enable :-
      DMA_DMACICR_FRAMEIE_ON,					//Whole frame interrupt enable :-帧传输完成后中断使能
      DMA_DMACICR_FIRSTHALFIE_OFF,			//Half frame interrupt enable :-
      DMA_DMACICR_DROPIE_OFF,					//Sync. event drop interrupt enable :-
      DMA_DMACICR_TIMEOUTIE_OFF				//Time out interrupt enable :-
    ),                                       /* DMACICR  */
      (DMA_AdrPtr)(MMC_ADDR(MMCDRR1)),        /* DMACSSAL 源地址低位*/
//	(DMA_AdrPtr)&xmt,
      0,                                     /* DMACSSAU 源地址高位*/
      (DMA_AdrPtr)&rcv,                      /* DMACDSAL 目的地址低位*/
      0,                                     /* DMACDSAU 目的地址高位*/
      N,                                     /* DMACEN   1帧内数据长度 N个数据一个帧*/
      1,                                     /* DMACFN   帧数大小*/
      0,                                     /* DMACFI  */
      0                                      /* DMACEI  */
    };

  /* Create DMA Xmt Side Configuration */
  DMA_Config  dmaXmtConfig = {
    DMA_DMACSDP_RMK(
      DMA_DMACSDP_DSTBEN_NOBURST,				//Destination burst :-不使用突发
      DMA_DMACSDP_DSTPACK_OFF,				//Destination packing :-目标口禁止打包
//      DMA_DMACSDP_DST_DARAM,					//Destination selection :-接收的目标口是DARAM
	  DMA_DMACSDP_DST_PERIPH,
  	//00 SARAM;01 DARAM;10 EMIF;11 PERIPH
      DMA_DMACSDP_SRCBEN_NOBURST,				//Source burst :-源突发禁止
      DMA_DMACSDP_SRCPACK_OFF,				//Source packing :-源口禁止打包
//      DMA_DMACSDP_SRC_PERIPH,					//Source selection :-外设mcbsp www
	  DMA_DMACSDP_SRC_DARAM,					//Source selection :-外设mcbsp
      DMA_DMACSDP_DATATYPE_16BIT				 //Data type :-设置数据类型16bit字长
    ),                                       /* DMACSDP  */
    DMA_DMACCR_RMK(
      DMA_DMACCR_DSTAMODE_CONST,			//Destination address mode :-自动执行后增量(由于本程序中数据类型是16bit,所以+2)
	  DMA_DMACCR_SRCAMODE_POSTINC,				//Source address mode :-源地址为恒定地址
      DMA_DMACCR_ENDPROG_ON,					//End of programmation bit :-
      DMA_DMACCR_REPEAT_OFF,					//Repeat condition :(AUTOINIT=1)才有效?-0 管编程配置结束位 1 不管编程配置结束位,结束传输自动初始化开始
  											//0:Repeat only if ENDPROG = 1(AUTOINIT=1)
      DMA_DMACCR_AUTOINIT_OFF,				//Auto initialization bit :-
      DMA_DMACCR_EN_STOP,						//Channel enable :-设置时先关闭通道
      DMA_DMACCR_PRIO_LOW,					//Channel priority :-设置为低优先级
      DMA_DMACCR_FS_DISABLE,					//(FS_ELEMENT 单元事件同步)
//      DMA_DMACCR_SYNC_REVT1					//Synchronization control bits 同步控制位   www
	  DMA_DMACCR_SYNC_XEVT1
    ),                                       /* DMACCR   */
    DMA_DMACICR_RMK(
//      DMA_DMACICR_BLOCKIE_OFF,				//Whole block interrupt enable :-块传输完成后中断不使能
	  DMA_DMACICR_BLOCKIE_ON,
      DMA_DMACICR_LASTIE_OFF,					//Last frame interrupt enable :-
//      DMA_DMACICR_FRAMEIE_ON,					//Whole frame interrupt enable :-帧传输完成后中断使能
	  DMA_DMACICR_FRAMEIE_OFF,
      DMA_DMACICR_FIRSTHALFIE_OFF,			//Half frame interrupt enable :-
      DMA_DMACICR_DROPIE_OFF,					//Sync. event drop interrupt enable :-
      DMA_DMACICR_TIMEOUTIE_OFF				//Time out interrupt enable :-
    ),                                       /* DMACICR  */
      (DMA_AdrPtr)&xmt,        /* DMACSSAL 源地址低位*/
//	(DMA_AdrPtr)&xmt,
      0,                                     /* DMACSSAU 源地址高位*/
      (DMA_AdrPtr)(MCBSP_ADDR(DRR10)),                      /* DMACDSAL 目的地址低位*/
      0,                                     /* DMACDSAU 目的地址高位*/
//      N,                                     /* DMACEN   1帧内数据长度 N个数据一个帧*/
//     1,                                     /* DMACFN   帧数大小*/
      2,                                     /* DMACEN   1帧内数据长度 N个数据一个帧*/
      N/2,                                     /* DMACFN   帧数大小*/
      0,                                     /* DMACFI  */
      0                                      /* DMACEI  */
    };

  /* Define a DMA_Handle object to be used with DMA_open function */
  DMA_Handle hDmaRcv,hDmaXmt;

  volatile Uint16 transferComplete = FALSE;
  Uint16 err = 0;
  Uint16 old_intm;
  Uint16 rcvEventId,xmtEventId;

/* Read and write buffers */
Uint16 datasend[512];
Uint16 datareceive[512];


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


extern void VECSTART(void);

interrupt void dmaRcvIsr(void);
interrupt void dmaXmtIsr(void);

void taskFxn(void);

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


void main(void)
{

    Uint16 aic23data = 0;
	i2c_status = 1;
    /* Initialize CSL library - This is REQUIRED !!! */
    /*初始化CSL库*/
    CSL_init();

    /* Set IVPD/IVPH to start of interrupt vector table */
    IRQ_setVecs((Uint32)(&VECSTART));

    for (i = 0; i <= N - 1; i++) {
        xmt[i] =  i + 1;
        rcv[i] = 0;
    }

    printf ("\nMMC Single block read-write test\n");

    for (count=0;count<=256;count++){
        datasend[count]    = count;
        datareceive[count] = 0xFFFF;
    }

	/*设置系统的运行速度为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_PORT0,MCBSP_OPEN_RESET);
	/*设置McBSP0*/
	MCBSP_config(hMcbsp,&Mcbsp1Config);
	/*启动McBSP0*/
	MCBSP_start(hMcbsp, 
                MCBSP_RCV_START | MCBSP_XMIT_START, 
                0);

    MCBSP_getConfig(hMcbsp,&Mcbsptest);


    /* A detailed explanation of MMC initialization is provided in mmc_setup example */
    mmc0 = MMC_open(MMC_DEV1);
    MMC_setupNative(mmc0,&Init);

  //  MMC_sendGoIdle(mmc0);
    MMC_sendCmd(mmc0, SD_GO_IDLE_STATE ,0, 0,1);

    for (count=0;count<4016;count++)
    	asm("	NOP");

    cardtype = MMC_sendOpCond(mmc0,0x00100000);

  //  MMC_setCallBack(mmc0, &callback);
  //  MMC_intEnable(mmc0, 0x400);

    if (cardtype == MMC_CARD){
       cid = &cardid;
       MMC_sendAllCID(mmc0,cid); // get the CID structure for all cards.
       rca = 10;
       card = &cardalloc;
       retVal = MMC_setRca(mmc0,card,rca);
    } else {
       cid = &cardid;
       SD_sendAllCID(mmc0,cid); // get the CID structure for all cards.
       card = &cardalloc;
       rca = SD_sendRca(mmc0,card);
       printf ("RCA sent by the SD card is 0x%x\n", rca);
    }

    /* Select the card to transfer data to/from. This step puts the card into the *
     * transfer state where it is ready to read/write data                        */

    retVal = MMC_selectCard(mmc0,card);

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

	  printf ("Reading data from card...\n");
	  taskFxn();
	//  retVal = MMC_read(mmc0,0x219a00,datareceive,512);
	//  MMC_RSET(MMCBLEN1,512);
	  MMC_sendCmd(mmc0, SD_SET_BLOCKLEN ,0, 512,1);
	  MMC_sendCmd(mmc0, SD_READ_SINGLE_BLOCK ,0, 0,1);

	  /* Verify that data read corresponds to data transferred                      */

	  /* Wait for DMA transfer to be complete */
	  while (!transferComplete){
	      ;
	  }

	  /*------------------------------------------*\
	   * Compare values
	  \*------------------------------------------*/
	  for(i = 0; i <= N - 1; i++){
	      if (rcv[i] != xmt[i]){
	          ++err;
	          break;
	     }
	  }

	  printf ("%s\n",err?"TEST FAILED" : "TEST PASSED");

	  /* Restore status of global interrupt enable flag */
	  IRQ_globalRestore(old_intm);

	  /* We're done with MCBSP and DMA , so close them */
	  DMA_close(hDmaRcv);
	  DMA_close(hDmaXmt);


}

void taskFxn(void)
{
    Uint16 srcAddrHi, srcAddrLo;
    Uint16 dstAddrHi, dstAddrLo;
    Uint16 i;

    /* By default, the TMS320C55xx compiler assigns all data symbols word */
    /* addresses. The DMA however, expects all addresses to be byte       */
    /* addresses. Therefore, we must shift the address by 2 in order to   */
    /* change the word address to a byte address for the DMA transfer.    */
//    srcAddrHi = (Uint16)(((Uint32)(&xmt)) >> 15) & 0xFFFFu;
//    srcAddrLo = (Uint16)(((Uint32)(&xmt)) << 1) & 0xFFFFu;
    srcAddrHi = (Uint16)(((Uint32)(MMC_ADDR(MMCDRR1))) >> 15) & 0xFFFFu;
    srcAddrLo = (Uint16)(((Uint32)(MMC_ADDR(MMCDRR1))) << 1) & 0xFFFFu;
    dstAddrHi = (Uint16)(((Uint32)(&rcv)) >> 15) & 0xFFFFu;
    dstAddrLo = (Uint16)(((Uint32)(&rcv)) << 1) & 0xFFFFu;

    dmaRcvConfig.dmacssal = (DMA_AdrPtr)srcAddrLo;
    dmaRcvConfig.dmacssau = srcAddrHi;
    dmaRcvConfig.dmacdsal = (DMA_AdrPtr)dstAddrLo;
    dmaRcvConfig.dmacdsau = dstAddrHi;

    srcAddrHi = (Uint16)(((Uint32)(&xmt[0])) >> 15) & 0xFFFFu;
    srcAddrLo = (Uint16)(((Uint32)(&xmt[0])) << 1) & 0xFFFFu;
    dstAddrHi = (Uint16)(((Uint32)(MCBSP_ADDR(DXR10))) >> 15) & 0xFFFFu;
    dstAddrLo = (Uint16)(((Uint32)(MCBSP_ADDR(DXR10))) << 1) & 0xFFFFu;

    dmaXmtConfig.dmacssal = (DMA_AdrPtr)srcAddrLo;
    dmaXmtConfig.dmacssau = srcAddrHi;
    dmaXmtConfig.dmacdsal = (DMA_AdrPtr)dstAddrLo;
    dmaXmtConfig.dmacdsau = dstAddrHi;

    /* Open MCBSP Port 1 and set registers to their power on defaults */
//    hMcbsp = MCBSP_open(MCBSP_PORT1, MCBSP_OPEN_RESET);

    /* Open DMA channels 4 & 5 and set regs to power on defaults */
    hDmaRcv = DMA_open(DMA_CHA4,DMA_OPEN_RESET);
    hDmaXmt = DMA_open(DMA_CHA5,DMA_OPEN_RESET);

    /* Get interrupt event associated with DMA receive and transmit */
    rcvEventId = DMA_getEventId(hDmaRcv);
    xmtEventId = DMA_getEventId(hDmaXmt);

    /* Temporarily disable interrupts and clear any pending */
    /* interrupts for MCBSP transmit */
    old_intm = IRQ_globalDisable();

    /* Clear any pending interrupts for DMA channels */
    IRQ_clear(rcvEventId);
    IRQ_clear(xmtEventId);

    /* Enable DMA interrupt in IER register */
    IRQ_enable(rcvEventId);
    IRQ_enable(xmtEventId);

    /* Set Start Of Interrupt Vector Table */
    IRQ_setVecs(0x10000);

    /* Place DMA interrupt service addresses at associate vector */
    IRQ_plug(rcvEventId,&dmaRcvIsr);
    IRQ_plug(xmtEventId,&dmaXmtIsr);


    /* Write values from configuration structure to DMA control regs */
    DMA_config(hDmaRcv,&dmaRcvConfig);
    DMA_config(hDmaRcv,&dmaXmtConfig);

	/* Enable all maskable interrupts */
    IRQ_globalEnable();


    /* Enable DMA */
    DMA_start(hDmaRcv);
//    DMA_start(hDmaXmt);


#endif

}


interrupt void dmaXmtIsr(void) {
   DMA_stop(hDmaXmt);
   IRQ_disable(xmtEventId);
   transferComplete = TRUE;
}

interrupt void dmaRcvIsr(void) {
   DMA_stop(hDmaRcv);
   IRQ_disable(rcvEventId);

   for (i = 0; i <= N - 1; i++) {
       xmt[i] =  rcv[i];
   }
   DMA_start(hDmaXmt);
}

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