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.
请问在EDMA3里的PingPong缓冲机制中,ping缓冲区和pong缓冲区时存在于哪里?是通道控制器还是每一个通道都分为ping缓冲区和pong缓冲区?另外,在进行pingpong传输的时候用的是一个通道还是多个通道呢?在进行ping-pong传输的时候,既然有ping pong两个目的缓冲区,那么也对应着两个源缓冲区,这两个源缓冲区又存在于什么位置呢?最后,我看的C6678自带的EDMA的例子里面,只是简单的用dstbuff1和dstbuff2代表ping/pong缓冲区,他们和实际的ping/pong缓冲区是怎么对应起来的呢?谢谢!
andy lee,
EDMA3中的ping pong机制是利用link transfer机制完成的。也可以实现三个或者以上的环形buffer的设计。具体可以看看下面文档中的“2.3.7 Linking Transfers”。pingpong机制,一般需要设置一个工作的参数表,一个ping参数表和一个pong参数表。附件是一个配置例子。
Yu Liu
您好!
我看了2.3.7关于linking的描述,我的理解是其实PingPong缓冲就是给一个通道设置Ping参数和Pong参数这两组相互链接的参数,然后利用这两组参数交替进行传输,请问我这样的理解是否正确?谢谢!
现在有一个问题是,如果在某一个确定的外设和内存之间进行数据传输,采用PingPong机制,那么Ping参数里的源地址和Pong参数里的源地址是否都为外设的地址?Ping参数里的目的地址和Pong参数里的目的地址是否都为内存的地址?如果不是的话,那么Ping参数和Pong参数里的目的地址和源地址应该根据什么进行设置呢?谢谢!
andy lee,
你的理解正确。
可以在源地址使用两个buffer也可以在目的地址使用两个buffer,也可以同时都设置两个buffer。你假设的外设地址不变,目的buffer变化时一种常用的用法。
andy lee,
上面的图有三个参数表,一个存ping的配置,一个存pong的配置,还有一个叫working参数表。初始如果working表放PING的配置就从ping开始。
Yu Liu
我在C6678自带的EDMA例子上进行了修改并测试以后,传输测试通过了,程序中只有两组参数ping参数和Pong参数,现在有个问题是,从程序中如何看出触发传输以后参数是如何加载的?先加载的哪一组参数?谢谢!
/**
*
*
* @brief
* This is the Example test code for theEDMA CSL Functional layer.
*/
#include <stdio.h>
#include <ti/csl/csl_edma3.h>
#include <ti/csl/csl_edma3Aux.h>
/**********************************************************************
************************** Global Variables **************************
**********************************************************************/
/* Global Variables which are used to dump the TPCC register overlay in the
* debugger... */
CSL_TpccRegs* gEDMACC0Regs = (CSL_TpccRegs*)CSL_EDMA0CC_REGS;
CSL_TpccRegs* gEDMACC1Regs = (CSL_TpccRegs*)CSL_EDMA1CC_REGS;
CSL_TpccRegs* gEDMACC2Regs = (CSL_TpccRegs*)CSL_EDMA2CC_REGS;
/* Global Buffers (Source and Destination) for PING-PONG */
// ping/pong的源缓冲区和目的缓冲区
Uint8 srcBuff1[512];
Uint8 srcBuff2[512];
Uint8 dstBuff1[512];
Uint8 dstBuff2[512];
/**********************************************************************
************************ EDMA TEST FUNCTIONS *************************
**********************************************************************/
/**
* @b Description
* @n
* This is utility function used by the EDMA example to verify the
* Data transfer.
*
* @retval
* Success - TRUE
* @retval
* Error - FALSE
*/
/****************************************************EDMA传输函数**************************************************/
static Int32 edma_ping_pong_xfer_gbl_region (Int32 instNum, Uint8 channelNum)//在全局Region执行EDMApingpong缓冲传输
{ //EDMACC实例号
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;
/* Start the EDMA PING-PONG test over the Global Region. 开始EDMA PING-PONG测试,全局region*/
printf ("Debug: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d...\n", instNum, channelNum);
/* Initialize data数据初始化 */
for (loopIndex = 0; loopIndex < 256; loopIndex++)
{
srcBuff1[loopIndex] = loopIndex;
srcBuff2[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使用提供的EDMA实例号打开EDMA模块 */
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.将DMA通道映射到参数RAM第2块 */
CSL_edma3MapDMAChannelToParamBlock(hModule, channelNum, 2);
/* Obtain a handle to parameter set 2 获得ping参数句柄*/
hParamPing = CSL_edma3GetParamHandle(hChannel, 2, &status);
/* Obtain a handle to parameter set 1 获得pong参数句柄 */
hParamPong = CSL_edma3GetParamHandle(hChannel, 1, &status);
/* Setup the parameter entry parameters (Ping buffer) 设置参数入口参数(PING缓冲区)*/
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)srcBuff1;
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 设置Ping */
CSL_edma3ParamSetup(hParamPing,&myParamSetup);
/* Pong setup 设置Pong*/
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)srcBuff2;
myParamSetup.dstAddr = (Uint32)dstBuff2;
/* Pong setup 设置Pong */
CSL_edma3ParamSetup(hParamPong,&myParamSetup);
/* Interrupt enable (Bits 0-1) for the global region interrupts 全局region的中断使能,0和1位的中断*/
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);//手动触发传输————手动设置通道事件,设置ESR某位
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;
}
/**
* @b Description
* @n
* Entry point for the test code.
*
* @retval
* Not Applicable.
*/
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;
}