Part Number:TMS320C6678
我将用例根据EDMA3手册第3.3.3的例子改写,代码如下:
#include <stdio.h>
#include <ti/csl/csl_edma3.h>
#include <ti/csl/csl_edma3Aux.h>
#include <ti/csl/csl_cacheAux.h>
#include <stdlib.h>
Int32 edma_ping_pong_xfer_gbl_region (Int32 instNum, Uint8 channelNum,float * srcBuff,float *dstBuff,Int32 aCnt,
Int32 bCnt,Int32 cCnt,Int32 srcBidx,Int32 dstBidx,Int32 srcCidx,Int32 dstCidx,int CacheNum)
{
CSL_Edma3Handle hModule;
CSL_Edma3Obj edmaObj;
CSL_Edma3ParamHandle htrans;
CSL_Edma3ChannelObj chObj;
CSL_Edma3CmdIntr regionIntr;
CSL_Edma3ChannelHandle hChannel;
CSL_Edma3ParamSetup myParamSetup;
CSL_Edma3Context context;
CSL_Edma3ChannelAttr chAttr;
CSL_Status status;
Uint32 loopIndex;
/* Module initialization */
CSL_edma3Init(&context) != CSL_SOK;
/* Open the EDMA Module using the provided instance number */
hModule = CSL_edma3Open(&edmaObj, instNum, NULL, &status);
/* Channel open */
chAttr.regionNum = CSL_EDMA3_REGION_GLOBAL;
chAttr.chaNum = channelNum;
hChannel = CSL_edma3ChannelOpen(&chObj, instNum, &chAttr, &status);
/* For EDMA instance 1 and 2 maximum of 4 TCs and 4 event queues are supported
* Change Channel Default queue setup from 0 to 3
*/
CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_3) ;
/* Map the DMA Channel to PARAM Block 2. */
CSL_edma3MapDMAChannelToParamBlock (hModule, channelNum, 1);
/* Obtain a handle to parameter set 2 */
htrans = CSL_edma3GetParamHandle(hChannel, 1, &status);
myParamSetup.option = CSL_EDMA3_OPT_MAKE(CSL_EDMA3_ITCCH_EN, \
CSL_EDMA3_TCCH_DIS, \
CSL_EDMA3_ITCINT_DIS, \
CSL_EDMA3_TCINT_EN, \
0, CSL_EDMA3_TCC_NORMAL,\
CSL_EDMA3_FIFOWIDTH_NONE, \
CSL_EDMA3_STATIC_DIS, \
CSL_EDMA3_SYNC_A, \
CSL_EDMA3_ADDRMODE_INCR, \
CSL_EDMA3_ADDRMODE_INCR );
myParamSetup.srcAddr = (Uint32)srcBuff;
myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(aCnt,bCnt);
myParamSetup.dstAddr = (Uint32)dstBuff;
myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(srcBidx,dstBidx);
myParamSetup.linkBcntrld= CSL_EDMA3_LINKBCNTRLD_MAKE(0xffff,0);
myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(srcCidx,dstCidx);
myParamSetup.cCnt = cCnt;
/* Ping setup */
CSL_edma3ParamSetup(htrans,&myParamSetup);
/* Interrupt enable (Bits 0-1) for the global region interrupts */
regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
regionIntr.intr = 0x3;
regionIntr.intrh = 0x0000;
CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTR_ENABLE,®ionIntr);
/* Trigger channel */
CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
regionIntr.intr = 0;
regionIntr.intrh = 0;
/* Poll on IPR bit 0 */
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
} while (!(regionIntr.intr & 0x0));
/* Clear the pending bit */
CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
Uint16 key;
/* Invalidate the cache before verification */
/* Disable Interrupts */
key = _disable_interrupts();
CACHE_invL1d ((void *)srcBuff, CacheNum, CACHE_WAIT);
CACHE_invL2 ((void *)srcBuff, CacheNum, CACHE_WAIT);
CACHE_invL1d ((void *)dstBuff, CacheNum, CACHE_WAIT);
CACHE_invL2 ((void *)dstBuff, CacheNum, CACHE_WAIT);
_mfence();
/* Re-enable Interrupts. */
_restore_interrupts(key);
/* Close channel */
CSL_edma3ChannelClose(hChannel) ;
/* Close EDMA module */
CSL_edma3Close(hModule) != CSL_SOK;
/* end. */
}
int main(){
float *a = malloc(sizeof(float)*4*1024);//数组a,放到DDR3中
float b[4096];//b放到
int i=0;
//a初始化
for(i=0;i<4096;i++)
{
a[i]=(float)i;
printf("%f ",a[i]);
if(i%100==0 && i!= 0)
printf("\n");
}
printf("\n");
printf("******************************************************\n");
int aCnt,bCnt,cCnt,srcBidx,dstBidx,srcCidx,dstCidx;
aCnt=4;//ACNT
bCnt=1024;//bcnt
cCnt=4;//CCNT
srcBidx=1;//srcBidx
dstBidx=cCnt*aCnt;//dstBidx
srcCidx=aCnt*bCnt;//srcCidx
dstCidx=aCnt;//dstCidx
//EMDA3
edma_ping_pong_xfer_gbl_region(0,0,a,b,aCnt,
bCnt,cCnt,srcBidx,dstBidx,srcCidx,dstCidx,4096);
for(i=0;i<4096;i++)
{
printf("%f ",b[i]);
if(i%100==0 && i!=0)
printf("\n");
}
return 0;
}
问题1:运行到轮询检测会陷入死循环,请问是什么原因?
问题2:regionIntr.intr = 0x3; 请问这句设置的是什么?
谢谢!
Nancy Wang:
Liam Yu 说:我将用例根据EDMA3手册第3.3.3的例子改写
您是想通过EDMA实现什么功能?需要ping pong传输?EDMA手册3.3只有data sorting,没有3.3.3.
Liam Yu 说:regionIntr.intr = 0x3; 请问这句设置的是什么?
是配置IESR的。
,
Liam Yu:
您好,我目前是把ping-pong的例子改成了单向传输,参数用的都是data sorting转置里的参数,想尝试实现data sorting