Hello,
Can anyone tell me why my QDMA function runs but when I print out srcBuff1 and dstBuff1, dstBuff1 is not filled with srcBuff1?
/* Global Variables */
Uint8 srcBuff1[512];
Uint8 dstBuff1[512];
/* EDMA Setup */
#define PCIE_DMA_NOT_INITIALIZED -1
#define PCIE_DMA_TRANSFER_FAIL -1
#define PCIE_DMA_NOT_CLOSED -1
#define SUCCESS 0
/*****************************************************************************
* Function: Transfer srcBuff to dstBuff
****************************************************************************/
int DMA_All_in_One_Transfer(void) {
CSL_Edma3Handle hModule;
CSL_Edma3Obj edmaObj;
CSL_Edma3ParamHandle hParamBlock;
CSL_Edma3ChannelObj chObj;
CSL_Edma3CmdIntr regionIntr;
CSL_Edma3CmdDrae regionAccess;
CSL_Edma3ChannelHandle hChannel;
CSL_Edma3ParamSetup myParamSetup;
CSL_Edma3Context context;
CSL_Edma3ChannelAttr chAttr;
CSL_Edma3CmdQrae qraeSetup;
CSL_Status status;
Uint32 channelNum = 16;
Uint32 instNum= 0;
int regionNum = -1;
Uint32 loopIndex;
printf ("Testing EDMA(%d), (Shadow) Region %d, for QDMA Channel %d...\n",
instNum, regionNum, channelNum);
/* Initialize data */
for (loopIndex = 0; loopIndex < 256; loopIndex++) {
srcBuff1[loopIndex] = loopIndex;
dstBuff1[loopIndex] = 0;
}
/* Module initialization */
if (CSL_edma3Init(&context) != CSL_SOK)
{
printf ("Error: EDMA module initialization failed\n");
return PCIE_DMA_NOT_INITIALIZED;
}
/* Module level open */
hModule = CSL_edma3Open(&edmaObj, instNum, NULL, &status);
if ((hModule == NULL) || (status != CSL_SOK))
{
printf ("Error: EDMA module open failed\n");
return PCIE_DMA_NOT_INITIALIZED;
}
/* Is this for GLOBAL or SHADOW Region */
if (regionNum != CSL_EDMA3_REGION_GLOBAL)
{
/* Shadow Region: Enable DRAE enable(Bits 0-15) it. */
regionAccess.region = regionNum;
regionAccess.drae = 0xFFFF;
regionAccess.draeh = 0x0000;
if (CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_DMAREGION_ENABLE, ®ionAccess) != CSL_SOK)
{
printf ("Error: EDMA region enable command failed\n");
return -1;
}
/* Enable access for all QDMA channels in the SHADOW Region. */
qraeSetup.region = regionNum;
qraeSetup.qrae = 0xFF;
if (CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_QDMAREGION_ENABLE, &qraeSetup) != CSL_SOK)
{
printf ("Error: EDMA QDMA region enable command failed\n");
return -1;
}
}
/* QDMA 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: EDMA channel open failed\n");
return PCIE_DMA_NOT_INITIALIZED;
}
/* Map QDMA Channel to the Param Block 1 */
CSL_edma3HwChannelSetupParam (hChannel, 1);
/* Setup the trigger word for the QDMA Channel. */
CSL_edma3HwChannelSetupTriggerWord(hChannel, 7);
/* Block Parameter Entry Handle */
hParamBlock = CSL_edma3GetParamHandle(hChannel, 1, &status);
if (hParamBlock == NULL)
{
printf ("Error: EDMA get handle for param entry 1 failed\n");
return PCIE_DMA_NOT_INITIALIZED;
}
/* Setup param entry */
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_EN, \
CSL_EDMA3_SYNC_AB, \
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(CSL_EDMA3_LINK_NULL, 0);
myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,0);
myParamSetup.cCnt = 1;
/* Setup Block to operate with this PARAM Entry. */
if (CSL_edma3ParamSetup(hParamBlock, &myParamSetup) != CSL_SOK)
{
printf ("Error: EDMA param setup failed\n");
return PCIE_DMA_TRANSFER_FAIL;
}
/* Enable Channel */
if (CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_ENABLE, NULL) != CSL_SOK)
{
printf ("Error: EDMA channel enable command failed\n");
return PCIE_DMA_NOT_INITIALIZED;
}
/* Trigger the word by writing to the trigger word... */
if (CSL_edma3ParamWriteWord(hParamBlock, 7, 1) != CSL_SOK)
{
printf ("Error: EDMA param write word failed\n");
return PCIE_DMA_TRANSFER_FAIL;
}
/* Poll IPR bit */
regionIntr.region = regionNum;
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
} while (!(regionIntr.intr & 0x1));
/* Clear pending interrupt */
if (CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR, ®ionIntr) != CSL_SOK)
{
printf ("Error: EDMA clear interrupt pend command failed\n");
return PCIE_DMA_TRANSFER_FAIL;
}
printf ("Data Transmission via DMA Module Successful\n");
/* Disable the channel */
CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_DISABLE, NULL);
/* Close channel */
if (CSL_edma3ChannelClose(hChannel) != CSL_SOK)
{
printf("Error: EDMA channel close failed\n");
return PCIE_DMA_NOT_CLOSED;
}
/* Close EDMA module */
if (CSL_edma3Close(hModule) != CSL_SOK)
{
printf("Error: EDMA module close failed\n");
return PCIE_DMA_NOT_CLOSED;
}
printf ("DMA Module Closed Successfully\n");
return SUCCESS;
}
In main, I call the function then read out part of the buffers:
DMA_All_in_One_Transfer();
/*Print out a section of the buffers */
Uint32 i;
for (i = 0; i < 16; i++)
{
System_printf("srcBuff1[%d]: %d\n", i, srcBuff1[i]);
System_printf("dstBuff1[%d]: %d\n", i, dstBuff1[i]);
}
Any suggestion of changes I can make to my code would be helpful.
Thx
Charles