这是一个将 EDMA搬数 应用于 PCIE 地址段的部分代码,平台为C6678,结合一个EDMA的基础例程,已经实现了L2 DDR3 MSMC之间的互搬,但是PCIE的地址段就搬不动,是不是通道选择的问题,请问选择的通道之间有什么区别么?
2-24 KeyStone Architecture Peripheral Component Interconnect Express (PCIe) User Guide SPRUGS6D—September 2013
Submit Documentation Feedback
Chapter 2—Architecture www.ti.com
2.9.3.2 Memory Read Transfer
The following example details how to perform an EDMA transfer from PCIe memory
to the device destination (for example, L2 or EMIF). For the EDMA configuration,
please see the EDMA user’s guide.
Example 2-5 Memory Read
/* Configure PCIESS module and prepare transfer parameters*/
/* Initialize the PCIESS module */
/* Define payload size and buffer size */
pcie_max_payload = 128; /* Assume pcie maximum payload size is 128 bytes */
buff_size= 2048; /* Assume the transfer buffer size 2048 bytes */
/* Define PCIe data starting address for EDMA transfer */
pcieAddr = <PCIe data starting address defined in device-specific data manual>
...
/* Setup EDMA module and enable the DMA region */
/* Setup EDMA PARAM */
/* The OPT register contains following bit fields:
ITCCHEN = 0x0; TCCHEN = 0x0; ITCINTEN = 0x0; TCINTEN = 0x1;
TCC = 0x0; TCCMODE = 0x0; FWID = 0x0; STATIC = 0x0; SYNCDIM = 0x1; DAM
= 0x0; SAM = 0x0 */
paramSetup_pcie.option = CSL_EDMA3_OPT_MAKE(0,0,0,1,0,0,0,0,1,0,0);
paramSetup_pcie.aCntbCnt = CSL_EDMA3_CNT_MAKE(pcie_max_payload,
buff_size/pcie_max_payload);
paramSetup_pcie.srcDstBidx =
CSL_EDMA3_BIDX_MAKE(pcie_max_payload,pcie_max_payload);
paramSetup_pcie.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,0);
paramSetup_pcie.cCnt = 1;
paramSetup_pcie.linkBcntrld =
CSL_EDMA3_LINKBCNTRLD_MAKE(CSL_EDMA3_LINK_NULL,0);
paramSetup_pcie.srcAddr = (Uint32)pcieAddr;
paramSetup_pcie.dstAddr = (Uint32)dstAddr;
/* Setup EDMA Channel */
/* Enable the EDMA Channel */
/* Wait for a transmit completion */
End of Example 2-5
EDMA的例子为:
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <ti/csl/csl_chip.h>
#include <c6x.h>
#include <ti/csl/csl_chip.h>
#include <ti/csl/src/intc/csl_intc.h>
#include <ti/csl/csl_cpintcAux.h>
#include "csl_edma3.h"
#include "csl_edma3Aux.h"
#pragma DATA_SECTION(srcbuf,".EXRAM") //DDR3 0x80000000
#pragma DATA_SECTION(dstbuf,".MSRAM") //共享内存 0x0C000000
unsigned char srcbuf[512],dstbuf[512];
CSL_Edma3ParamHandle hParamPing;
CSL_Edma3ParamSetup myParamSetup;
CSL_Edma3ChannelHandle hChannel;
CSL_Edma3Handle hMoudle;
int Edma3Example()
{
CSL_Edma3Obj edmaObj;
CSL_Edma3ChannelObj chObj;
CSL_Edma3CmdIntr regionIntr;
CSL_Edma3Context context;
CSL_Edma3ChannelAttr chAttr;
CSL_Status status;
unsigned char channelNum = 0;
unsigned char instNum = 1;
CSL_edma3Init(&context);
hMoudle = CSL_edma3Open(&edmaObj,instNum,NULL,&status);
chAttr.regionNum = CSL_EDMA3_REGION_GLOBAL;
chAttr.chaNum = channelNum;
hChannel = CSL_edma3ChannelOpen(&chObj,instNum,&chAttr,&status);
CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_0);
CSL_edma3MapDMAChannelToParamBlock(hMoudle,channelNum,0);
hParamPing = CSL_edma3GetParamHandle(hChannel,0,&status);
regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
regionIntr.intr = 0x1;
regionIntr.intrh = 0x0;
CSL_edma3HwControl(hMoudle,CSL_EDMA3_CMD_INTR_ENABLE,®ionIntr);
myParamSetup.option = 0x00100008;
myParamSetup.srcAddr = (Uint32)srcbuf;
myParamSetup.aCntbCnt = 0x00010040;
myParamSetup.dstAddr = (Uint32)dstbuf;
myParamSetup.srcDstBidx = 0x0;
myParamSetup.linkBcntrld = 0x0000ffff;
myParamSetup.srcDstCidx = 0x0;
myParamSetup.cCnt = 0x00000001;
CSL_edma3ParamSetup(hParamPing,&myParamSetup);
CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
regionIntr.intr = 0x0;
regionIntr.intrh = 0x0;
do
{
CSL_edma3GetHwStatus(hMoudle,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
}
while (!(regionIntr.intr & 0x1));
CSL_edma3HwControl(hMoudle,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
CSL_edma3ChannelClose(hChannel);
CSL_edma3Close(hMoudle);
return 0;
}
void main()
{
int i,j;
for(i=0;i<512;i++)
{
srcbuf[i] = 0xFF; //src为数据发送端,存放在DDR3上
dstbuf[i] = 0x00; //dst为数据接收端,存放在MSMC上
//数据搬了64个下来
}
printf("srcbuf的地址为0x%08x=%d,dstbuf的地址为0x%08x=%d\n",srcbuf,srcbuf[0],dstbuf,dstbuf[0]);
Edma3Example();
printf("srcbuf的地址为0x%08x=%d,dstbuf的地址为0x%08x=%d\n",srcbuf,srcbuf[0],dstbuf,dstbuf[0]);
printf("dstbuf[0] = %d\n",dstbuf[0]);
printf("dstbuf[63] = %d\n",dstbuf[63]);
printf("dstbuf[64] = %d\n",dstbuf[64]);
}
对应的CMD文件为:
-c
-heap 0x2000
-stack 0x2000
MEMORY
{
VECTORS: origin=0x10800000 length=0x00000400
LL2MEM: origin=0x10800400 length=0x0007FC00
MSMCRAM: origin=0x0C000000 length=0x00400000
DDR3RAM: origin=0x80000000 length=0x20000000
}
SECTIONS
{
.csl_vect > VECTORS
.text > LL2MEM
.data > LL2MEM
.fasttext > LL2MEM
.cinit > LL2MEM
.bss > LL2MEM
.const > LL2MEM
.far > LL2MEM
.switch > LL2MEM
.sysmem > LL2MEM
.cio > LL2MEM
.heap > LL2MEM
.fardata > LL2MEM
.neardata > LL2MEM
.rodata > LL2MEM
.INRAM > LL2MEM
.MSRAM > MSMCRAM
.EXRAM > DDR3RAM
}