TI中文支持网
TI专业的中文技术问题搜集分享网站

EDMA在进行pingpong 时link

各位专家好!

EDMA在进行link传输的时候,交替加载两组参数通过一个通道进行传输,我现在设置了两个源地址和两个目的缓冲区,交替往两个目的缓冲区传送数据,我希望的是在pong后回到ping 但是实际是触发第一次完成ping触发第二次完成了pong但触发第三次第四次都是pong,请问是什么原因呢?如果要达到希望的效果,应该做些什么修改?谢谢!

/**

*   @file  edma_test.c

*

*   @brief

*

*/

#include <stdio.h>

#include <ti/csl/csl_edma3.h>

#include <ti/csl/csl_edma3Aux.h>

#include <ti/csl/csl_cache.h>

#include <ti/csl/csl_cacheAux.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 */

Uint8 srcBuff1[512];

Uint8 srcBuff2[512];

Uint8 dstBuff1[512];

Uint8 dstBuff2[512];

/**********************************************************************

************************ EDMA TEST FUNCTIONS *************************

**********************************************************************/

/**

*  @b Description

*  @n

*      This is the example routine which perform EDMA ping pong buffer transfer

*      where channel is open in the global region.

*      It implements following steps

*          – Intializes and Opens the EDMA Module .

*          – Sets up the interrupt for the EDMA global region.

*          – Sets up the EDMA module using the API csl_edma3Hwsetup ()

*          – Enables the EDMA global region

*          – Opens the channel 'channelNum' get the param handle for PARAM 1, 2

*          – PING is mapped to PARAM Entry 1

*          – PONG is mapped to PARAM Entry 2

*          – PING is Linked with PONG…

*          – Enables the EDMA interrupt using CSL_EDMA3_CMD_INTR_ENABLE.

*          – Enables Interrupt (Bit 0-2) for the global region interrupts

*          – Manually triggers the DMA channel 'channelNum'(This should be PING)

*          – Polls on IPR bit 0 (Since TCC for PING is 0)

*          – Clear the pending bit

*          – Manually triggers the channel 'channelNum' (This should be PONG)

*          – Polls on IPR bit 1 (Since TCC for PONG is 1)

*          – Clears the pending bit

*          – Compares the data in the destination buffer is proper or not.

*          – Closes the EDMA module and channel.

*

*  @param[in]  instNum

*      EDMA Instance Number on which the test is executed.

*  @param[in]  channelNum

*      EDMA Channel Number on which the test is executed

*

*  @retval

*      Success –   0

*  @retval

*      Failure –   <0

*/

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;

   /* Start the EDMA PING-PONG test over the Global 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 */

   hModule = CSL_edma3Open(&edmaObj, instNum, NULL, &status);

   if ( (hModule == NULL) || (status != CSL_SOK))

   {

       printf ("Error: EDMA module open failed\n");

       return -1;

   }

   /* Channel open */

   chAttr.regionNum = CSL_EDMA3_REGION_GLOBAL;

   chAttr.chaNum    = channelNum;

   hChannel = CSL_edma3ChannelOpen(&chObj, instNum, &chAttr, &status);

   if ((hChannel == NULL) || (status != CSL_SOK))

   {

       printf ("Error: Unable to open EDMA Channel:%d\n", channelNum);

       return -1;

   }

   /* Change Channel Default queue setup from 0 to 3  */

   if(0)//if (CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_3) != CSL_SOK)

   {

       printf ("Error: EDMA channel setup queue failed\n");

       return -1;

   }

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

   if (hParamPing == NULL)

   {

       printf ("Error: EDMA Get Parameter Entry failed for 2.\n");

       return -1;

   }

   /* Obtain a handle to parameter set 1 */

   hParamPong = CSL_edma3GetParamHandle(hChannel, 1, &status);

   if (hParamPong == NULL)

   {

       printf ("Error: EDMA Get Parameter Entry failed for 1.\n");

       return -1;

   }

   /* Setup the parameter entry parameters (Ping buffer)//CSL_EDMA3_STATIC_EN我修改 */

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

   if (CSL_edma3ParamSetup(hParamPing,&myParamSetup) != CSL_SOK)

   {

       printf ("Error: EDMA Parameter Entry Setup failed\n");

       return -1;

   }

   /* Pong setup */

  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;

   myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(hParamPing,0);

   if (CSL_edma3ParamSetup(hParamPong,&myParamSetup) != CSL_SOK)

   {

       printf ("Error: EDMA Parameter Entry Setup failed\n");

       return -1;

   }

   //ZW added to keep the coherience between L1D and L2(MSM). Jun 1 2012

   CACHE_wbInvAllL1d(CACHE_NOWAIT);

   CACHE_wbInvAllL1dWait();

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

   /* Trigger channel 111111111111111*/

   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,&regionIntr);

   } while (!(regionIntr.intr & 0x1));

   /* Clear the pending bit清除挂起位  */

 CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,&regionIntr);

   /* Trigger Channel222222222222222 */

   CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);

   /* Poll on IPR bit 2 */

   do {

       CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,&regionIntr);

   } while (!(regionIntr.intr & 0x2));

   for (loopIndex = 0; loopIndex < 256; loopIndex++)

   {

       dstBuff1[loopIndex] = 0;

       dstBuff2[loopIndex] = 0;

   }

   /* Clear the pending bit清除挂起位  */

   CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,&regionIntr);

   /* Trigger Channel 33333333333333*/

     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,&regionIntr);

      } while (!(regionIntr.intr & 0x1));

      /* Trigger Channel 44444444444444*/

      CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);

      /* Poll on IPR bit 2 */

      do {

          CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,&regionIntr);

      } while (!(regionIntr.intr & 0x2));

   /* Close channel */

   if (CSL_edma3ChannelClose(hChannel) != CSL_SOK)

   {

       printf("Error: EDMA Channel Close failed\n");

       return -1;

   }

   /* Close EDMA module */

   if (CSL_edma3Close(hModule) != CSL_SOK)

   {

       printf("Error: EDMA Module Close failed\n");

       return -1;

   }

   /* The test passed. */

   return 0;

}

/**

*  @b Description

*  @n

*      Entry point for the test code.

*

*  @retval

*      Not Applicable.

*/

void main (void)

{

   Uint8  channelNum;

//    Int32  regionNum;

   Uint8  instNum = 0;

   printf ("**************************************************\n");

   printf ("******************* EDMA Testing *****************\n");

   printf ("**************************************************\n");

   /* EDMA Instance 0: Supports only 16 DMA Channels. */

   for (channelNum = 0; channelNum < 16; channelNum++)

   {

       if (edma_ping_pong_xfer_gbl_region(instNum, channelNum) < 0)

       {

           printf ("Error: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d FAILED\n", instNum, channelNum);

           return;

       }

       printf ("Debug: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d Passed\n", instNum, channelNum);

   }

   printf ("**************************************************\n");

   printf ("************* EDMA Testing Successful ************\n");

   printf ("**************************************************\n");

   return;

}

AMBER:

   /* Pong setup */

  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_DIS, \

                                            CSL_EDMA3_SYNC_A, \

                                            CSL_EDMA3_ADDRMODE_INCR, \

                                            CSL_EDMA3_ADDRMODE_INCR );

      修改成了            CSL_EDMA3_STATIC_DIS,  结果还是ping一次后 后面每次都只是 pong

lester zhang:

回复 Andy Yin1:

请问这段代码怎么理解

 /* Interrupt enable (Bits 0-1)  for the global region interrupts */

  regionIntr.region = CSL_EDMA3_REGION_GLOBAL;

  regionIntr.intr   = 0x3;

  regionIntr.intrh  = 0x0000;

我之前一直理解的是使能channel 0 和channel 1的中断,但是好像不对,求解答?

还有为什么是/* Poll on IPR bit 0 */ 和/* Poll on IPR bit 1 */啊

这是检查IPR位么,我理解的也是IPR的位应该对应的是channel啊。搞不懂

lester zhang:

回复 lester zhang:

如果我没理解错的话,代码里每运行一次edma_ping_pong_xfer_gbl_region(instNum, channelNum)

只open 了一个 channel啊 为什么会要使能2个channel的中断

并且link传输的话,应该是在同一个channel上传输吧

lester zhang:

回复 lester zhang:

这个问题困扰了我很久,希望有人能够解答。谢谢

Ryan KU:

回复 lester zhang:

lester zhang 你好:

        我之前单核做EDMA普通传输和PingPong传输的时候没有考虑channel和IPR一一对应的关系,现在做多核并行传输的时候看了一些帖子,对于PingPong传输下channel PaRAM TCC IPR这些参数间关系有点不太理解,不知你现在怎么理解这些参数间的关系,希望能够得到你的帮助和解答。

谢谢!

赞(0)
未经允许不得转载:TI中文支持网 » EDMA在进行pingpong 时link
分享到: 更多 (0)