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.

6678 EDMA问题



6678的csl里的edma代码是不是有错误啊,为什么一直死在循环里啊

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 (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) */
    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.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;   
    if (CSL_edma3ParamSetup(hParamPong,&myParamSetup) != CSL_SOK)
    {
        printf ("Error: EDMA Parameter Entry Setup failed\n");   
        return -1;
    }
   
    /* 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 */
    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 Channel */
    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));

    /* Check transfer by comparing the source and destination buffers */
    if(Verify_Transfer( 256, 1, 1, 0, 0, 0, 0, srcBuff1, dstBuff1, TRUE) == FALSE)
    {
        printf ("Error: Verification (Source1/Destination1) Failed\n");
        return -1;
    }
    if(Verify_Transfer( 256, 1, 1, 0, 0, 0, 0, srcBuff2, dstBuff2, TRUE) == FALSE)
    {
        printf ("Error: Verification (Source2/Destination2) Failed\n");
        return -1;
    }
 
    /* 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;
}

把红颜色部分改成

do {

/* Trigger channel */
    CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
        CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,&regionIntr);

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

也不行啊,求解决

  • src和dest地址需要是全局地址,如果src及dest buffer是放在LL2,则需要转换成全局地址,如局部地址0x00800000对应core0的全局地址为0x10800000,对应core1地址为0x11800000.

    查看PaRAM set中配置的地址是否符合上述要求,如果没有问题的话,再查看channel与set的映射关系配置、set中的配置及channel是否使能等。

  • 首先非常感谢您的解答,在另外一个贴子里你说的那个A-SYNC问题确实是我错了。是触发一次就可以了,如果BCNT=256在A-SYNC方式下才是触发256次,谢谢!在csl的这个edma(D:\ccs5\pdk_C6678_1_0_0_9_beta2\packages\ti\csl\example\edma),例程中的src地址和dest地址都是他自己定义的空间,如下:

    /* Global Buffers (Source and Destination) for PING-PONG */
    Uint8 srcBuff1[512];
    Uint8 srcBuff2[512];
    Uint8 dstBuff1[512];
    Uint8 dstBuff2[512];

    其中cmd文件如下:

    -c
    -heap  0x2000
    -stack 0x2000


    /* Memory Map 1 - the default */
    MEMORY
    {
            L1D:     o = 00f00000h   l = 00007FFFh
            L1P:     o = 00e00000h   l = 00007FFFh
            MSMC:    o = 0C000000h   l = 001FFFFFh
    }

    SECTIONS
    {
        .csl_vect   >       MSMC
        .text       >       MSMC
        .stack      >       MSMC
        .bss        >       MSMC
        .cinit      >       MSMC
        .cio        >       MSMC
        .const      >       MSMC
        .data       >       MSMC
        .switch     >       MSMC
        .sysmem     >       MSMC
        .far        >       MSMC
        .testMem    >       MSMC 
    }

    之所以不能搬运,我是不是应该改一下cmd文件啊,应该怎么改啊,谢谢!

  • 从你的cmd文件来看源和目的地址都是放在SL2,也就是说地址范围在0x0C000000开始的地址段,此时已经是全局地址,你可以看map文件确认。如果已经是SL2的话,不需要地址转换,问题应该不在这里,你需要确认一下EDMA其他的参数配置。

  • 你好,仔细有看了一遍代码,发现时例程里一个参数配置不对,6678的edma0只有两个事件队列,例程中把edma0的触发事件放到队列3了,所以无法触发edma事件!另外,把目的地址放到ddr(0x80000000)或者core0的L2缓存。这样就能正常运行了!如果放到0x0C000000只能触发一次edma搬运。

    谢谢您的解答~

    另外,看了一下mcsdk关于bootload的东西,还是不太明天,能否给一个例程!最好是有二次引导的例程。还有,c6678不写二次引导行不!