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

edma改变通道

现在遇到的问题是,使用edma3的通道0将通过EMIF接口可以将ram的数据搬移到L2中,但是当我改变通道时就不行了,我参考了其它人的代码,但是还会不行。我把我的edma3的设置代码贴上来,谁能帮我看看,非常感谢!芯片是6455的。

#include <csl.h>
#include <stdio.h>
#include <csl_edma3.h>
#include "csl_error.h"

#define EDMA_IPR         *(volatile int*)(0x02A01068)//interupt
//#define EVT_CLR1   (*(volatile int*)(0x01800044)
/*****************************************************************************/
 CSL_Edma3Handle             hModule;
// CSL_Edma3Handle             hModule1
    CSL_Edma3HwSetup            hwSetup;
    CSL_Edma3Obj                edmaObj;
    CSL_Edma3ParamHandle        hParamBasic;
 CSL_Edma3ParamHandle        hParamBasic1;
    CSL_Edma3ChannelObj         chObj;
 CSL_Edma3ChannelObj         chObj1;
    CSL_Edma3CmdIntr            regionIntr;
    CSL_Edma3CmdDrae            regionAccess;
    CSL_Edma3ChannelHandle      hChannel;
 CSL_Edma3ChannelHandle      hChannel1;
    CSL_Edma3ParamSetup         myParamSetup;
 CSL_Edma3ParamSetup         myParamSetup1;
    CSL_Edma3Context            context;
    CSL_Edma3ChannelAttr        chAttr;
    CSL_Status                  status;
    CSL_Status                  status1;
 CSL_Status                  status2;
    Uint16      paramNum=14;
   // CSL_Edma3HwDmaChannelSetup  dmahwSetup;    CSL_Edma3HwDmaChannelSetup dmahwSetup[CSL_EDMA3_NUM_DMACH] =
         CSL_EDMA3_DMACHANNELSETUP_DEFAULT;

void initial_Edma3(void)

  status = CSL_edma3Init(&context);
    if (status != CSL_SOK) {
        printf ("Edma module initialization failed\n");          return;
    }
       /* Module level open */
    hModule = CSL_edma3Open(&edmaObj,CSL_EDMA3,NULL,&status);
    if ( (hModule == NULL) || (status != CSL_SOK)) {
        printf ("Edma module open failed\n");           return;
    }
       /* Module setup */
   /// dmahwSetup[8 ].paramNum = 8;
    dmahwSetup[CSL_EDMA3_CHA_3].que      = CSL_EDMA3_QUE_0;
    hwSetup.dmaChaSetup = dmahwSetup;
    hwSetup.qdmaChaSetup = NULL;
    status = CSL_edma3HwSetup(hModule,&hwSetup);
    if (status != CSL_SOK) {
         printf ("Hardware setup failed\n");
         CSL_edma3Close (hModule);
         return;
    }         /* DRAE enable(Bits 0-15) for the shadow region 5 */
    regionAccess.region = CSL_EDMA3_REGION_5;
    regionAccess.drae =   0xFFFF ;      regionAccess.draeh =  0x0 ;
    status = CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_DMAREGION_ENABLE, \
                               &regionAccess);    if (status != CSL_SOK) {
        printf ("Edma region enable command failed\n");
        return;
    }

    /* Channel 3 open in context of shadow region 5 */
    chAttr.regionNum = CSL_EDMA3_REGION_5;
    chAttr.chaNum = CSL_EDMA3_CHA_3;
    hChannel = CSL_edma3ChannelOpen(&chObj, CSL_EDMA3, &chAttr, &status);      if ((hChannel == NULL) || (status != CSL_SOK)) {
        printf ("Edma channel open failed\n");
        return;
    }

    /* Get the PaRAM number associated with this channel */
    status = CSL_edma3GetHwChannelSetupParam(hChannel,&paramNum);
    if (status1 != CSL_SOK) {
       // Sys_Count ++;           return;
    }

    /* Obtain a handle to parameter set 3  ,3 通道对应 14 param*/
    hParamBasic = CSL_edma3GetParamHandle(hChannel, paramNum, &status);
    if (hParamBasic == NULL) {
        printf ("Edma get param handle for param entry 0 failed\n");           return;
    }

 myParamSetup.option = CSL_EDMA3_OPT_MAKE( CSL_EDMA3_ITCCH_DIS, \
                                              CSL_EDMA3_TCCH_DIS, \
                                              CSL_EDMA3_ITCINT_DIS, \
                                              CSL_EDMA3_TCINT_EN,\
                                              CSL_EDMA3_CHA_3, \
                                              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)(src);            myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(acnt,bcnt);          myParamSetup.dstAddr = (Uint32)dst;           myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(0,0);        myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(CSL_EDMA3_LINK_NULL,0);        myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,0);        myParamSetup.cCnt = 1;

 status = CSL_edma3ParamSetup(hParamBasic,&myParamSetup);
    if (status != CSL_SOK) {
        printf("Edma parameter entry setup is failed\n");
        return;
    }
  /* Enable channel 3 */
    status = CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_ENABLE, NULL);
    if (status != CSL_SOK) {
        printf("Edma channel enable command for channel 3 is failed\n");
        return;
    }
                                            /* Manually trigger the channel */
    status = CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
    if (status != CSL_SOK) {
        printf("Edma channel set command is failed\n");
        return;
    }
       regionIntr.region = CSL_EDMA3_REGION_5;
    regionIntr.intr = 0x8;
    regionIntr.intrh = 0;
       do {
        /* Poll on interrupt bit 0 */
        CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,&regionIntr);
    } while (!(regionIntr.intr & 0x8));

    /* Clear interrupt bit 0 */
    status = CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR, \
                               &regionIntr);      if (status != CSL_SOK) {
        printf("Edma clear interrupt bit 0 command is failed\n");
        return;
    }   
     /* Channel close */    
   status = CSL_edma3ChannelClose(hChannel);
    if (status != CSL_SOK) {
        printf ("Edma channle close failed\n");
        return;
    }
    
    /* Edma module close */    
    status = CSL_edma3Close(hModule);       if (status != CSL_SOK) {
        printf ("Edma module close failed\n");
        return;
    }
       return; 

字体为红色的部分的参数是我改后的,但是这样不行,我不知道原因,希望能得到帮助,非常感谢!

Hong Lan:

代码修改不完全。

    /* Get the PaRAM number associated with this channel */    status = CSL_edma3GetHwChannelSetupParam(hChannel,&paramNum);    if (status1 != CSL_SOK) {       // Sys_Count ++;            return;    }

这里调用函数的返回值赋给了status ,但是下面判断却是用status1 ,导致程序return。这里又没有错误打印。

实际上只要单步跟踪一下就能发现。或者和未修改的代码比较一下也能发现。

另外,要确保你的bcnt=1。注意你的EDMA是A_SYNC,每次触发只会copy ACNT个字节。但是你只使能了TCINT,没有使能ITCINT,也就是说当bcnt不等于1时,必须copy完 bcnt * acnt的字节才会有IPR。

还有一个小问题是你虽然给paraNum赋了14,但是函数status = CSL_edma3GetHwChannelSetupParam(hChannel,&paramNum)是让EDMA自己给paraNum重新赋一个值的,也就是说执行这个函数后paraNum可能会改变。不过这个不影响你的结果。 

赞(0)
未经允许不得转载:TI中文支持网 » edma改变通道
分享到: 更多 (0)