Hi all,
I have a small problem wiht Edma3
I want to check the transmission of two blocks of data ping and pong
Program is shown below
namespace dsp1
{
/* Global Buffers (Source and Destination) for PING-PONG */
Uint8 srcBuff10[512];
Uint8 srcBuff20[512];
Uint8 dstBuff10[512];
Uint8 dstBuff20[512];
static Int32 _edma3_gbl_region1 (Int32 instNum, Uint8 channelNum);
static Bool Verify_Transfer1 (
Uint16 aCnt,
Uint16 bCnt,
Uint16 cCnt,
Uint16 srcBIdx,
Uint16 dstBIdx,
Uint16 srcCIdx,
Uint16 dstCIdx,
Uint8 *srcBuff,
Uint8 *dstBuff,
Bool abSync
);
static void full_src_dst(Int32 border, Int32 ChN);
Int32 _edma3_gbl(Int32 instNum, Uint8 channelNum) {
Uint8 chNum = channelNum;
return _edma3_gbl_region1(instNum, chNum);
}
static Int32 _edma3_gbl_region1 (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;
CSL_Edma3HwSetup setup_hw;
CSL_Status status_channel;
CSL_Edma3HwDmaChannelSetup dmahwSetup[64];
CSL_Edma3HwQdmaChannelSetup qdmahwSetup[8];
/* Initialize data */
full_src_dst(512, channelNum);
/* Initialize EDMA3 module */
status = CSL_edma3Init(&context);
hModule = CSL_edma3Open(&edmaObj,instNum,NULL,&status);
chAttr.regionNum = CSL_EDMA3_REGION_GLOBAL;
chAttr.chaNum = channelNum;
hChannel = CSL_edma3ChannelOpen(&chObj, instNum, &chAttr, &status);
/* in this case */
if (!instNum) {
status_channel = CSL_edma3HwChannelSetupQue(hChannel, CSL_EDMA3_QUE_1);
} else {
status_channel = CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_3);
}
CSL_edma3MapDMAChannelToParamBlock(hModule, channelNum, 2);
/* obtain handle parameters block */
hParamPing = CSL_edma3GetParamHandle(hChannel, 2, &status);
/* first block not map */
hParamPong = CSL_edma3GetParamHandle(hChannel, 1, &status);
/* setup 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)srcBuff10;
myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(512,1);
myParamSetup.dstAddr = (Uint32)dstBuff10;
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 */
status = CSL_edma3ParamSetup(hParamPing,&myParamSetup);
/* 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)srcBuff20;
myParamSetup.dstAddr = (Uint32)dstBuff20;
status = CSL_edma3ParamSetup(hParamPong,&myParamSetup);
/* Interrupt enable (Bits 0-1) for the global region interrupts */
regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
regionIntr.intr = 0x3;
regionIntr.intrh = 0x0000;
status = CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTR_ENABLE,®ionIntr);
/* Trigger channel */
status = 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 {
status = CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
} while (!(regionIntr.intr & 0x1));
/* Trigger Channel */
CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
/* Poll on IPR bit 2 */
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
} while (!(regionIntr.intr & 0x2));
if(Verify_Transfer1( 512, 1, 1, 0, 0, 0, 0, srcBuff10, dstBuff10, TRUE) == FALSE)
{
printf ("Error: Verification (Source1/Destination1) Failed\n");
return -1;
}
if(Verify_Transfer1( 512, 1, 1, 0, 0, 0, 0, srcBuff20, dstBuff20, 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;
}
return 0;
}
static Bool Verify_Transfer1 (
Uint16 aCnt, Uint16 bCnt, Uint16 cCnt,
Uint16 srcBIdx,Uint16 dstBIdx, Uint16 srcCIdx,
Uint16 dstCIdx,Uint8 *srcBuff, Uint8 *dstBuff,
Bool abSync
)
{
Uint32 loopIndex1;
Uint32 loopIndex2;
Uint32 loopIndex3;
Uint8* srcArrayPtr = (Uint8*)srcBuff;
Uint8* dstArrayPtr = (Uint8*)dstBuff;
Uint8* srcFramePtr = (Uint8*)srcBuff;
Uint8* dstFramePtr = (Uint8*)dstBuff;
Uint16 key;
/* Invalidate the cache before verification */
/* Disable Interrupts */
key = _disable_interrupts();
CACHE_invL1d ((void *)srcBuff, 512, CACHE_FENCE_WAIT);
CACHE_invL2 ((void *)srcBuff, 512, CACHE_FENCE_WAIT);
CACHE_invL1d ((void *)dstBuff, 512, CACHE_FENCE_WAIT);
CACHE_invL2 ((void *)dstBuff, 512, CACHE_FENCE_WAIT);
_mfence();
/* Re-enable Interrupts. */
_restore_interrupts(key);
for (loopIndex1 = 0; loopIndex1 < cCnt; loopIndex1++) {
for (loopIndex2 = 0; loopIndex2 < bCnt; loopIndex2++) {
for (loopIndex3 = 0; loopIndex3 < aCnt; loopIndex3++)
if (srcArrayPtr[loopIndex3] != dstArrayPtr[loopIndex3])
return FALSE;
srcArrayPtr = srcArrayPtr + srcBIdx;
dstArrayPtr = dstArrayPtr + dstBIdx;
}
if (abSync) {
srcFramePtr = srcFramePtr + srcCIdx;
srcArrayPtr = srcFramePtr;
dstFramePtr = dstFramePtr + dstCIdx;
dstArrayPtr = dstFramePtr;
}
else {
srcFramePtr = srcArrayPtr + srcCIdx - srcBIdx;
srcArrayPtr = srcFramePtr;
dstFramePtr = dstArrayPtr + dstCIdx - dstBIdx;
dstArrayPtr = dstFramePtr;
}
}
return TRUE;
}
static void full_src_dst(Int32 border, Int32 chN) {
for (Int32 i = 0; i < border; ++i)
{
srcBuff10[i] = chN + i +1;
srcBuff20[i] = chN + i +2 ;
dstBuff10[i] = chN + i;
dstBuff20[i] = chN + i;
}
}
}
I have two problems:
1. Function _edma3_gbl_region1 does not give errors before calling Verify_Transfer1,
but don't transfer the source and destination buffers
2. When recalling after
CACHE_invL1d ((void *)srcBuff, 512, CACHE_FENCE_WAIT);
CACHE_invL2 ((void *)srcBuff, 512, CACHE_FENCE_WAIT);
CACHE_invL1d ((void *)dstBuff, 512, CACHE_FENCE_WAIT);
CACHE_invL2 ((void *)dstBuff, 512, CACHE_FENCE_WAIT);
the restored old values of buffers
Thank