TI论坛
直播中

马丹丹

7年用户 186经验值
私信 关注
[问答]

EDMA在进行link传输的时候,交替加载两组参数通过一个通道进行传输,触发第三次第四次都是pong,请问是什么原因呢?

本帖最后由 一只耳朵怪 于 2018-6-25 11:38 编辑

各位专家好!
EDMA在进行link传输的时候,交替加载两组参数通过一个通道进行传输,我现在设置了两个源地址和两个目的缓冲区,交替往两个目的缓冲区传送数据,我希望的是在pong后回到ping 但是实际是触发第一次完成ping触发第二次完成了pong但触发第三次第四次都是pong,请问是什么原因呢?如果要达到希望的效果,应该做些什么修改?谢谢!
  1. /**
  2. *   @file  edma_test.c
  3. *
  4. *   @brief
  5. *
  6. */
  7. #include
  8. #include <ti/csl/csl_edma3.h>
  9. #include
  10. #include
  11. #include
  12. /**********************************************************************
  13. ************************** Global Variables **************************
  14. **********************************************************************/
  15. /* Global Variables which are used to dump the TPCC register overlay in the
  16. * debugger... */
  17. CSL_TpccRegs*  gEDMACC0Regs  = (CSL_TpccRegs*)CSL_EDMA0CC_REGS;
  18. CSL_TpccRegs*  gEDMACC1Regs  = (CSL_TpccRegs*)CSL_EDMA1CC_REGS;
  19. CSL_TpccRegs*  gEDMACC2Regs  = (CSL_TpccRegs*)CSL_EDMA2CC_REGS;
  20. /* Global Buffers (Source and Destination) for PING-PONG */
  21. Uint8 srcBuff1[512];
  22. Uint8 srcBuff2[512];
  23. Uint8 dstBuff1[512];
  24. Uint8 dstBuff2[512];
  25. /**********************************************************************
  26. ************************ EDMA TEST FUNCTIONS *************************
  27. **********************************************************************/
  28. /**
  29. *  @b Description
  30. *  @n
  31. *      This is the example routine which perform EDMA ping pong buffer transfer
  32. *      where channel is open in the global region.
  33. *      It implements following steps
  34. *          - Intializes and Opens the EDMA Module .
  35. *          - Sets up the interrupt for the EDMA global region.
  36. *          - Sets up the EDMA module using the API csl_edma3Hwsetup ()
  37. *          - Enables the EDMA global region
  38. *          - Opens the channel 'channelNum' get the param handle for PARAM 1, 2
  39. *          - PING is mapped to PARAM Entry 1
  40. *          - PONG is mapped to PARAM Entry 2
  41. *          - PING is Linked with PONG...
  42. *          - Enables the EDMA interrupt using CSL_EDMA3_CMD_INTR_ENABLE.
  43. *          - Enables Interrupt (Bit 0-2) for the global region interrupts
  44. *          - Manually triggers the DMA channel 'channelNum'(This should be PING)
  45. *          - Polls on IPR bit 0 (Since TCC for PING is 0)
  46. *          - Clear the pending bit
  47. *          - Manually triggers the channel 'channelNum' (This should be PONG)
  48. *          - Polls on IPR bit 1 (Since TCC for PONG is 1)
  49. *          - Clears the pending bit
  50. *          - Compares the data in the destination buffer is proper or not.
  51. *          - Closes the EDMA module and channel.
  52. *
  53. *  @param[in]  instNum
  54. *      EDMA Instance Number on which the test is executed.
  55. *  @param[in]  channelNum
  56. *      EDMA Channel Number on which the test is executed
  57. *
  58. *  @retval
  59. *      Success -   0
  60. *  @retval
  61. *      Failure -   <0
  62. */
  63. static Int32 edma_ping_pong_xfer_gbl_region (Int32 instNum, Uint8 channelNum)
  64. [
  65.     CSL_Edma3Handle                 hModule;
  66.     CSL_Edma3Obj                    edmaObj;
  67.     CSL_Edma3ParamHandle            hParamPing;
  68.     CSL_Edma3ParamHandle            hParamPong;
  69.     CSL_Edma3ChannelObj             chObj;
  70.     CSL_Edma3CmdIntr                regionIntr;
  71.     CSL_Edma3ChannelHandle          hChannel;
  72.     CSL_Edma3ParamSetup             myParamSetup;
  73.     CSL_Edma3Context                context;
  74.     CSL_Edma3ChannelAttr            chAttr;
  75.     CSL_Status                      status;
  76.     Uint32                          loopIndex;
  77.     /* Start the EDMA PING-PONG test over the Global Region. */
  78.     printf ("Debug: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d...n", instNum, channelNum);
  79.     /* Initialize data  */
  80.     for (loopIndex = 0; loopIndex < 256; loopIndex++)
  81.     [
  82.         srcBuff1[loopIndex] = loopIndex;
  83.         srcBuff2[loopIndex] = loopIndex;
  84.         dstBuff1[loopIndex] = 0;
  85.         dstBuff2[loopIndex] = 0;
  86.     ]
  87.     /* Module initialization */
  88.     if (CSL_edma3Init(&context) != CSL_SOK)
  89.     [
  90.         printf ("Error: EDMA module initialization failedn");
  91.         return -1;
  92.     ]
  93.     /* Open the EDMA Module using the provided instance number */
  94.     hModule = CSL_edma3Open(&edmaObj, instNum, NULL, &status);
  95.     if ( (hModule == NULL) || (status != CSL_SOK))
  96.     [
  97.         printf ("Error: EDMA module open failedn");
  98.         return -1;
  99.     ]
  100.     /* Channel open */
  101.     chAttr.regionNum = CSL_EDMA3_REGION_GLOBAL;
  102.     chAttr.chaNum    = channelNum;
  103.     hChannel = CSL_edma3ChannelOpen(&chObj, instNum, &chAttr, &status);
  104.     if ((hChannel == NULL) || (status != CSL_SOK))
  105.     [
  106.         printf ("Error: Unable to open EDMA Channel:%dn", channelNum);
  107.         return -1;
  108.     ]
  109.     /* Change Channel Default queue setup from 0 to 3  */
  110.     if(0)//if (CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_3) != CSL_SOK)
  111.     [
  112.         printf ("Error: EDMA channel setup queue failedn");
  113.         return -1;
  114.     ]
  115.     /* Map the DMA Channel to PARAM Block 2. */
  116.     CSL_edma3MapDMAChannelToParamBlock (hModule, channelNum, 2);
  117.     /* Obtain a handle to parameter set 2 */
  118.     hParamPing = CSL_edma3GetParamHandle(hChannel, 2, &status);
  119.     if (hParamPing == NULL)
  120.     [
  121.         printf ("Error: EDMA Get Parameter Entry failed for 2.n");
  122.         return -1;
  123.     ]
  124.     /* Obtain a handle to parameter set 1 */
  125.     hParamPong = CSL_edma3GetParamHandle(hChannel, 1, &status);
  126.     if (hParamPong == NULL)
  127.     [
  128.         printf ("Error: EDMA Get Parameter Entry failed for 1.n");
  129.         return -1;
  130.     ]
  131.     /* Setup the parameter entry parameters (Ping buffer)//CSL_EDMA3_STATIC_EN我修改 */
  132.     myParamSetup.option = CSL_EDMA3_OPT_MAKE(CSL_EDMA3_ITCCH_DIS,
  133.                                              CSL_EDMA3_TCCH_DIS,
  134.                                              CSL_EDMA3_ITCINT_DIS,
  135.                                              CSL_EDMA3_TCINT_EN,
  136.                                              0, CSL_EDMA3_TCC_NORMAL,
  137.                                              CSL_EDMA3_FIFOWIDTH_NONE,
  138.                                              CSL_EDMA3_STATIC_DIS,
  139.                                              CSL_EDMA3_SYNC_A,
  140.                                              CSL_EDMA3_ADDRMODE_INCR,
  141.                                              CSL_EDMA3_ADDRMODE_INCR );
  142.     myParamSetup.srcAddr    = (Uint32)srcBuff1;
  143.     myParamSetup.aCntbCnt   = CSL_EDMA3_CNT_MAKE(256,1);
  144.     myParamSetup.dstAddr    = (Uint32)dstBuff1;
  145.     myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(1,1);
  146.     myParamSetup.linkBcntrld= CSL_EDMA3_LINKBCNTRLD_MAKE(hParamPong,0);
  147.     myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,1);
  148.     myParamSetup.cCnt = 1;
  149.     /* Ping setup */
  150.     if (CSL_edma3ParamSetup(hParamPing,&myParamSetup) != CSL_SOK)
  151.     [
  152.         printf ("Error: EDMA Parameter Entry Setup failedn");
  153.         return -1;
  154.     ]
  155.     /* Pong setup */
  156.    myParamSetup.option = CSL_EDMA3_OPT_MAKE(CSL_EDMA3_ITCCH_DIS,
  157.                                              CSL_EDMA3_TCCH_DIS,
  158.                                              CSL_EDMA3_ITCINT_DIS,
  159.                                              CSL_EDMA3_TCINT_EN,
  160.                                              1, CSL_EDMA3_TCC_NORMAL,
  161.                                              CSL_EDMA3_FIFOWIDTH_NONE,
  162.                                              CSL_EDMA3_STATIC_EN,
  163.                                              CSL_EDMA3_SYNC_A,
  164.                                              CSL_EDMA3_ADDRMODE_INCR,
  165.                                              CSL_EDMA3_ADDRMODE_INCR );
  166.     myParamSetup.srcAddr = (Uint32)srcBuff2;
  167.     myParamSetup.dstAddr = (Uint32)dstBuff2;
  168.     myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(hParamPing,0);
  169.     if (CSL_edma3ParamSetup(hParamPong,&myParamSetup) != CSL_SOK)
  170.     [
  171.         printf ("Error: EDMA Parameter Entry Setup failedn");
  172.         return -1;
  173.     ]
  174.     //ZW added to keep the coherience between L1D and L2(MSM). Jun 1 2012
  175.     CACHE_wbInvAllL1d(CACHE_NOWAIT);
  176.     CACHE_wbInvAllL1dWait();
  177.     /* Interrupt enable (Bits 0-1)  for the global region interrupts */
  178.     regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
  179.     regionIntr.intr   = 0x3;
  180.     regionIntr.intrh  = 0x0000;
  181.     CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTR_ENABLE,®ionIntr);
  182.     /* Trigger channel 111111111111111*/
  183.     CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
  184.     regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
  185.     regionIntr.intr   = 0;
  186.     regionIntr.intrh  = 0;
  187.     /* Poll on IPR bit 0 */
  188.     do [
  189.         CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
  190.     ] while (!(regionIntr.intr & 0x1));
  191.     /* Clear the pending bit清除挂起位  */
  192.   CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
  193.     /* Trigger Channel222222222222222 */
  194.     CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
  195.     /* Poll on IPR bit 2 */
  196.     do [
  197.         CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
  198.     ] while (!(regionIntr.intr & 0x2));
  199.     for (loopIndex = 0; loopIndex < 256; loopIndex++)
  200.     [
  201.         dstBuff1[loopIndex] = 0;
  202.         dstBuff2[loopIndex] = 0;
  203.     ]
  204.     /* Clear the pending bit清除挂起位  */
  205.     CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
  206.     /* Trigger Channel 33333333333333*/
  207.       CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
  208.       regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
  209.       regionIntr.intr   = 0;
  210.       regionIntr.intrh  = 0;
  211.        /* Poll on IPR bit 0 */
  212.        do [
  213.            CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
  214.        ] while (!(regionIntr.intr & 0x1));
  215.        /* Trigger Channel 44444444444444*/
  216.        CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
  217.        /* Poll on IPR bit 2 */
  218.        do [
  219.            CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
  220.        ] while (!(regionIntr.intr & 0x2));
  221.     /* Close channel */
  222.     if (CSL_edma3ChannelClose(hChannel) != CSL_SOK)
  223.     [
  224.         printf("Error: EDMA Channel Close failedn");
  225.         return -1;
  226.     ]
  227.     /* Close EDMA module */
  228.     if (CSL_edma3Close(hModule) != CSL_SOK)
  229.     [
  230.         printf("Error: EDMA Module Close failedn");
  231.         return -1;
  232.     ]
  233.     /* The test passed. */
  234.     return 0;
  235. ]
  236. /**
  237. *  @b Description
  238. *  @n
  239. *      Entry point for the test code.
  240. *
  241. *  @retval
  242. *      Not Applicable.
  243. */
  244. void main (void)
  245. [
  246.     Uint8  channelNum;
  247. //    Int32  regionNum;
  248.     Uint8  instNum = 0;
  249.     printf ("**************************************************n");
  250.     printf ("******************* EDMA Testing *****************n");
  251.     printf ("**************************************************n");
  252.     /* EDMA Instance 0: Supports only 16 DMA Channels. */
  253.     for (channelNum = 0; channelNum < 16; channelNum++)
  254.     [
  255.         if (edma_ping_pong_xfer_gbl_region(instNum, channelNum) < 0)
  256.         [
  257.             printf ("Error: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d FAILEDn", instNum, channelNum);
  258.             return;
  259.         ]
  260.         printf ("Debug: Testing EDMA(%d) Ping-Pong Test (Global) Region for Channel %d Passedn", instNum, channelNum);
  261.     ]
  262.     printf ("**************************************************n");
  263.     printf ("************* EDMA Testing Successful ************n");
  264.     printf ("**************************************************n");
  265.     return;
  266. ]

回帖(6)

马丹丹

2018-6-25 01:12:25
   /* 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
举报

杨娟

2018-6-25 01:30:18
引用: healson2001 发表于 2018-6-25 01:12
   /* Pong setup */
  myParamSetup.option = CSL_EDMA3_OPT_MAKE(CSL_EDMA3_ITCCH_DIS,
                                            CSL_EDMA3_TCCH_DIS,

需要使用3个PaRAM set,第一个PaRAM set与channel映射;第一个与第三个PaRAM set中存储ping对应的配置参数,link到第二个PaRAM set;第二个PaRAM set中存储pong的参数,并link到第三个PaRAM set。
                                                                          

举报

周烜

2018-6-25 01:44:35
引用: zbb9612 发表于 2018-6-25 01:30
需要使用3个PaRAM set,第一个PaRAM set与channel映射;第一个与第三个PaRAM set中存储ping对应的配置参数,link到第二个PaRAM set;第二个PaRAM set中存储pong的参数,并link到第三个PaRAM set。
                                                                          

请问这段代码怎么理解
 /* 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啊。搞不懂
举报

周烜

2018-6-25 02:04:29
引用: bisong13 发表于 2018-6-25 01:44
请问这段代码怎么理解
 /* Interrupt enable (Bits 0-1)  for the global region interrupts */
  regionIntr.region = CSL_EDMA3_REGION_GLOBAL;

如果我没理解错的话,代码里每运行一次edma_ping_pong_xfer_gbl_region(instNum, channelNum)
只open 了一个 channel啊 为什么会要使能2个channel的中断
并且link传输的话,应该是在同一个channel上传输吧
举报

更多回帖

发帖
×
20
完善资料,
赚取积分