各位专家好!
EDMA在进行link传输的时候,交替加载两组参数通过一个通道进行传输,我现在设置了一个源地址和两个目的缓冲区,交替往两个目的缓冲区传送数据,我希望的是在往第一个缓冲区传输完数据后,将源缓冲区剩下的数据继续往另一个缓冲区传送,结果发现往第一个缓冲区传输完数据以后,EDMA又将源地址的数据全部的往第二个缓冲区传送了一遍,而不是希望的那样讲源地址剩下的数据传送到第二个缓冲区,请问是什么原因呢?如果要达到希望的效果,应该做些什么修改?谢谢!
#include <stdio.h>
#include <string.h>
#include <ti/csl/csl_edma3.h>
#include <ti/csl/csl_edma3Aux.h>
#include "Keystone_common.h"
#include "Keystone_EMIF16_init.h"
/* Global Buffers (Source and Destination) for PING-PONG */
// ping/pong的源缓冲区和目的缓冲区
Uint8 srcBuff[512];
Uint8 dstBuff1[512];
Uint8 dstBuff2[512]
static Int32 edma_ping_pong_xfer_gbl_region (Int32 instNum, Uint8 channelNum)
{
CSL_Edma3Handle hModule;
CSL_Edma3Obj edmaObj;
CSL_Edma3ParamHandle hParamPing;
CSL_Edma3ParamHandle hParamPong;
CSL_Edma3ChannelObj chObj;
CSL_Edma3CmdIntr regionIntr;
CSL_Edma3ChannelHandle hChannel;
CSL_Edma3ParamSetup myParamSetup;
CSL_Edma3Context context;
CSL_Edma3ChannelAttr chAttr;
CSL_Status status;
Uint32 loopIndex;
printf ("Debug: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d…\n", instNum, channelNum);
/* Initialize data数据初始化 */
for (loopIndex = 0; loopIndex < 256; loopIndex++)
{
srcBuff[loopIndex] = loopIndex;
dstBuff1[loopIndex] = 0;
dstBuff2[loopIndex] = 0;
}
/* Module initialization 模块初始化*/
if (CSL_edma3Init(&context) != CSL_SOK)
{
printf ("Error: EDMA module initialization failed\n");
return -1;
}
/* 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);
/* 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, 2);
/* Obtain a handle to parameter set 2*/
hParamPing = CSL_edma3GetParamHandle(hChannel, 2, &status);
/* Obtain a handle to parameter set 1 */
hParamPong = CSL_edma3GetParamHandle(hChannel, 1, &status);
/* Setup the parameter entry parameters (Ping buffer) */
myParamSetup.option = CSL_EDMA3_OPT_MAKE(CSL_EDMA3_ITCCH_DIS, \
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(256,1);
myParamSetup.dstAddr = (Uint32)dstBuff1;
myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(1,1);
myParamSetup.linkBcntrld= CSL_EDMA3_LINKBCNTRLD_MAKE(hParamPong,0); myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,1);
myParamSetup.cCnt = 1;
/* Ping setup */
CSL_edma3ParamSetup(hParamPing,&myParamSetup);
/* Pong setup 设*/
myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(hParamPing,0);
myParamSetup.option = CSL_EDMA3_OPT_MAKE(CSL_EDMA3_ITCCH_DIS, \
CSL_EDMA3_TCCH_DIS, \
CSL_EDMA3_ITCINT_DIS, \
CSL_EDMA3_TCINT_EN,\
1, CSL_EDMA3_TCC_NORMAL,\
CSL_EDMA3_FIFOWIDTH_NONE, \
CSL_EDMA3_STATIC_EN, \
CSL_EDMA3_SYNC_A, \
CSL_EDMA3_ADDRMODE_INCR, \
CSL_EDMA3_ADDRMODE_INCR );
myParamSetup.srcAddr = (Uint32)srcBuff;
myParamSetup.dstAddr = (Uint32)dstBuff2;
/* Pong setup */
CSL_edma3ParamSetup(hParamPong,&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 & 0x1));
/* Clear the pending bit */
CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
/* Trigger Channel */
CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
/* Poll on IPR bit 2 */
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
} while (!(regionIntr.intr & 0x2));
/* Close channel */
CSL_edma3ChannelClose(hChannel);
/* Close EDMA module 关闭EDMA模块*/
CSL_edma3Close(hModule);
/* The test passed. */
return 0;
}
void main (void)
{
Uint8 channelNum=0;
Uint8 instNum = 0;
printf("EDMA testing…\n");
edma_ping_pong_xfer_gbl_region(instNum, channelNum);
printf("Debug: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d passed\n", instNum, channelNum);
printf("EDMA test successful\n");
return;
}
King Wang1:
你好:
你在设置pong的Parameter的时候,这时的源地址应该和Ping的源地址不一样,需要增加偏移。
andy lee1:
回复 King Wang1:
King Wang
您好!请问Pong地址的偏移应该根据什么来增加呢?另外,如果源地址的数据比较多,需要进行多次pingpong链接传输,也就是在往pong缓冲区传输完数据以后需要重新链接ping参数,这个时候往ping缓冲区传输的数据的源地址应该和原来不一样了,也会发生偏移,那么最开始设置ping参数的时候怎么做到兼顾这一点呢?谢谢!
King Wang1:
回复 andy lee1:
您好:
每个parameter只能存放1组数据,源地址和目的地址应该事先都要预先计算好偏移。
如果需要一次触发进行3次搬移,那么需要3个parameter,pingpong通常只用于两次链接。
谢谢!