Hi, i am working withe the EDMA3 ressource on the DSP, the execution of the programme, transfer data from a source to a destination buffer.
please there is any person can explain me wahy the distination buffer dont get any value.
#include <stdio.h>
#include "csl_tsc.h"
#include <ti/csl/csl_cache.h>
#include <ti/csl/csl_cacheAux.h>
#include "DSPF_sp_fftSPxSP.h"
#include <ti/csl/csl_edma3.h>
#include <ti/csl/csl_edma3Aux.h>
static unsigned long long st,fn,val;
// EDMA3
#define EDN (EDN_A*EDN_B) //taille maximale à transferé
#define EDN_A 10 //ACNT
#define EDN_B 20 //BCNT
unsigned int srcBuff1[EDN]; //Source à transferé
unsigned int dstBuff1[EDN]; //ditination
/*utilisation da la directive paragma pour stocker les données dans la mémoire d'une facon adjacente */
#pragma DATA_SECTION(srcBuff1,".cData"); // source dans L2SRAM
#pragma DATA_SECTION(dstBuff1,".mData"); // Destination dans MSMCSRAM et pour DDR3 on a .fData
void cacheinit(void) {
// activate L1D as cache
CACHE_setL2Size(CACHE_0KCACHE);
CACHE_setL1DSize((CACHE_L1Size)CACHE_L1_32KCACHE);
CACHE_setL1PSize((CACHE_L1Size)CACHE_L1_32KCACHE);
}
Int32 edma_transfer (Int32 instNum, Uint8 channelNum)
{
CSL_Edma3Handle hModule; // this is a pointer to the object CSL_EDMA3Obj, it is passed to all EDMA module level CSL APIs
CSL_Edma3Obj edmaObj; // this object contains the refeence to the instance of EDMA module.
// CSL_EDMA3Obj : the pointer to this object is passed as EDMA handles to all EDMA module CSL APIs
CSL_Edma3ParamHandle hParamPing;//PaRAM set handle to the PaRAM set register
CSL_Edma3ChannelObj chObj; // EDMA channel object, the pointer of this object to define the EDMA chanel controller module
CSL_Edma3CmdIntr regionIntr; // EDMA controle/query controle command structure, used to issu command for interrupt related APIs
CSL_Edma3ChannelHandle hChannel; // the pointer to the EDMA chanel object
CSL_Edma3ParamSetup myParamSetup; //EDMA3 PaRAM setup structure, used to program the PaRAM set for DMA/QDMA transfer.
CSL_Edma3Context context; // Module specific context information, used to initialize the EDMA module
CSL_Edma3ChannelAttr chAttr; // EDMA3 channel parameter structure used to open a chanel
CSL_Status status; // CSL status
/* Module initialization */
if (CSL_edma3Init(&context) != CSL_SOK)
/* This function initializes the context object and it needs to be invoked before using an EDMA3 module.
Upon success, this function returns CSL_status CSL_SOK*/
{
printf ("Error: EDMA module initialization failed\n");
return -1;
}
/*The next step to accomplish is to open the EDMA3 module requested, CSL_edma3Open().
The function returns an EDMA3 handle; it is the input for the rest of the APIs used within the EDMA3 module*/
/* 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;
/*CSL_edma3ChannelOpen returns a handle for the specified EDMA Channel for use
Return Value : CSL_Edma3ChannelHandle*/
/*Functions CSL_edma3Init(), CSL_edma3Open() must be invoked successfully in order before
calling this API*/
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;
}
if(!instNum) //
{
/*CSL_edma3HwChannelSetupQue programs the channel to Queue mapping. This writes the DMAQNUM/QDAMQNUM
appropriately.*/
/* For first EDMA instance there are only 2 TCs and 2 event queues
* Modify the channel default queue setup from 0 to 1
*/
if (CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_1) != CSL_SOK)
{
printf ("Error: EDMA channel setup queue failed\n");
return -1;
}
}
else
{
/* For EDMA instance 1 and 2 maximum of 4 TCs and 4 event queues are supported
* 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);
/*CSL_edma3GetParamHandle acquires the PaRAM entry as specified by the argument.*/
/* 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;
}
/* 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_AB, \
CSL_EDMA3_ADDRMODE_INCR, \
CSL_EDMA3_ADDRMODE_INCR );
myParamSetup.srcAddr = (Uint32)srcBuff1;
myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(EDN_A,EDN_B);
myParamSetup.dstAddr = (Uint32)dstBuff1;
myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(EDN_A,EDN_A);
myParamSetup.linkBcntrld= CSL_EDMA3_LINKBCNTRLD_MAKE(0xFFFF,EDN_B);
myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,1);
myParamSetup.cCnt = 1;
/* Ping setup */
/*CSL_edma3ParamSetup configures the EDMA Parameter RAM (PaRAM) entry using the values passed in
through the PaRAM setup structure
Arguments (hParamHndl : Handle to the PaRAM entry, setup: Pointer to PaRAM setup structure */
if (CSL_edma3ParamSetup(hParamPing,&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,®ionIntr);
/* Trigger channel */
CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
regionIntr.intr = 0;
regionIntr.intrh = 0;
st=_CSL_tscRead();
/* Poll on IPR bit 0 */
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr); //
} while (!(regionIntr.intr & 0x1));
fn=_CSL_tscRead();
/* Clear the pending bit */
CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
/* 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;
}
void main(void) {
double gigabyte;
int loopIndex;
cacheinit();
_CSL_tscEnable();
printf("**** Debut de Test *******");
for (loopIndex = 0; loopIndex < EDN; loopIndex++)
{
srcBuff1[loopIndex] = loopIndex;
dstBuff1[loopIndex] = 0;
}
edma_transfer(0,0);
val=fn-st;
gigabyte=EDN/(double)val;
printf("\n elapsed cycles : %lld\n",val);
printf("Gbytes/s=%lf\n",gigabyte*0.93);
for (loopIndex = 0; loopIndex < EDN; loopIndex++)
{
if (srcBuff1[loopIndex]!=dstBuff1[loopIndex]) printf("error at %d, la valeur de source %d, destination %d \n",loopIndex,srcBuff1[loopIndex],dstBuff1[loopIndex]);
}
printf("fin test c66x\n");
}
#include <stdio.h>
#include "csl_tsc.h"
#include <ti/csl/csl_cache.h>
#include <ti/csl/csl_cacheAux.h>
#include "DSPF_sp_fftSPxSP.h"
#include <ti/csl/csl_edma3.h>
#include <ti/csl/csl_edma3Aux.h>
static unsigned long long st,fn,val;
// EDMA3
#define EDN (EDN_A*EDN_B) //taille maximale � transfer�
#define EDN_A 10 //ACNT
#define EDN_B 20 //BCNT
unsigned int srcBuff1[EDN]; //Source � transfer�
unsigned int dstBuff1[EDN]; //ditination
/*utilisation da la directive paragma pour stocker les donn�es dans la m�moire d'une facon adjacente */
#pragma DATA_SECTION(srcBuff1,".cData"); // source dans L2SRAM
#pragma DATA_SECTION(dstBuff1,".mData"); // Destination dans MSMCSRAM et pour DDR3 on a .fData
void cacheinit(void) {
// enable DDR3 caching
CACHE_enableCaching(128);
CACHE_enableCaching(129);
CACHE_enableCaching(130);
CACHE_enableCaching(131);
CACHE_enableCaching(132);
CACHE_enableCaching(133);
CACHE_enableCaching(134);
CACHE_enableCaching(135);
CACHE_enableCaching(136);
CACHE_enableCaching(137);
CACHE_enableCaching(138);
CACHE_enableCaching(139);
CACHE_enableCaching(140);
CACHE_enableCaching(141);
CACHE_enableCaching(142);
CACHE_enableCaching(143);
CACHE_enableCaching(144);
CACHE_enableCaching(145);
CACHE_enableCaching(146);
CACHE_enableCaching(147);
CACHE_enableCaching(148);
CACHE_enableCaching(149);
CACHE_enableCaching(150);
CACHE_enableCaching(151);
CACHE_enableCaching(152);
CACHE_enableCaching(153);
CACHE_enableCaching(154);
CACHE_enableCaching(155);
CACHE_enableCaching(156);
CACHE_enableCaching(157);
CACHE_enableCaching(158);
CACHE_enableCaching(159);
// activate L1D as cache
CACHE_setL2Size(CACHE_0KCACHE);
CACHE_setL1DSize((CACHE_L1Size)CACHE_L1_32KCACHE);
CACHE_setL1PSize((CACHE_L1Size)CACHE_L1_32KCACHE);
}
Int32 edma_transfer (Int32 instNum, Uint8 channelNum)
{
CSL_Edma3Handle hModule; // this is a pointer to the object CSL_EDMA3Obj, it is passed to all EDMA module level CSL APIs
CSL_Edma3Obj edmaObj; // this object contains the refeence to the instance of EDMA module.
// CSL_EDMA3Obj : the pointer to this object is passed as EDMA handles to all EDMA module CSL APIs
CSL_Edma3ParamHandle hParamPing;//PaRAM set handle to the PaRAM set register
CSL_Edma3ChannelObj chObj; // EDMA channel object, the pointer of this object to define the EDMA chanel controller module
CSL_Edma3CmdIntr regionIntr; // EDMA controle/query controle command structure, used to issu command for interrupt related APIs
CSL_Edma3ChannelHandle hChannel; // the pointer to the EDMA chanel object
CSL_Edma3ParamSetup myParamSetup; //EDMA3 PaRAM setup structure, used to program the PaRAM set for DMA/QDMA transfer.
CSL_Edma3Context context; // Module specific context information, used to initialize the EDMA module
CSL_Edma3ChannelAttr chAttr; // EDMA3 channel parameter structure used to open a chanel
CSL_Status status; // CSL status
/* Module initialization */
if (CSL_edma3Init(&context) != CSL_SOK)
/* This function initializes the context object and it needs to be invoked before using an EDMA3 module.
Upon success, this function returns CSL_status CSL_SOK*/
{
printf ("Error: EDMA module initialization failed\n");
return -1;
}
/*The next step to accomplish is to open the EDMA3 module requested, CSL_edma3Open().
The function returns an EDMA3 handle; it is the input for the rest of the APIs used within the EDMA3 module*/
/* 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;
/*CSL_edma3ChannelOpen returns a handle for the specified EDMA Channel for use
Return Value : CSL_Edma3ChannelHandle*/
/*Functions CSL_edma3Init(), CSL_edma3Open() must be invoked successfully in order before
calling this API*/
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;
}
if(!instNum) //
{
/*CSL_edma3HwChannelSetupQue programs the channel to Queue mapping. This writes the DMAQNUM/QDAMQNUM
appropriately.*/
/* For first EDMA instance there are only 2 TCs and 2 event queues
* Modify the channel default queue setup from 0 to 1
*/
if (CSL_edma3HwChannelSetupQue(hChannel,CSL_EDMA3_QUE_1) != CSL_SOK)
{
printf ("Error: EDMA channel setup queue failed\n");
return -1;
}
}
else
{
/* For EDMA instance 1 and 2 maximum of 4 TCs and 4 event queues are supported
* 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);
/*CSL_edma3GetParamHandle acquires the PaRAM entry as specified by the argument.*/
/* 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;
}
/* 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_AB, \
CSL_EDMA3_ADDRMODE_INCR, \
CSL_EDMA3_ADDRMODE_INCR );
myParamSetup.srcAddr = (Uint32)srcBuff1;
myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(EDN_A,EDN_B);
myParamSetup.dstAddr = (Uint32)dstBuff1;
myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(EDN_A,EDN_A);
myParamSetup.linkBcntrld= CSL_EDMA3_LINKBCNTRLD_MAKE(0xFFFF,EDN_B);
myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0,1);
myParamSetup.cCnt = 1;
/* Ping setup */
/*CSL_edma3ParamSetup configures the EDMA Parameter RAM (PaRAM) entry using the values passed in
through the PaRAM setup structure
Arguments (hParamHndl : Handle to the PaRAM entry, setup: Pointer to PaRAM setup structure */
if (CSL_edma3ParamSetup(hParamPing,&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,®ionIntr);
/* Trigger channel */
CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
regionIntr.region = CSL_EDMA3_REGION_GLOBAL;
regionIntr.intr = 0;
regionIntr.intrh = 0;
st=_CSL_tscRead();
/* Poll on IPR bit 0 */
do {
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr); //
} while (!(regionIntr.intr & 0x1));
fn=_CSL_tscRead();
/* Clear the pending bit */
CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
/* 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;
}
void main(void) {
double gigabyte;
int loopIndex;
cacheinit();
_CSL_tscEnable();
printf("**** Debut de Test *******");
for (loopIndex = 0; loopIndex < EDN; loopIndex++)
{
srcBuff1[loopIndex] = loopIndex;
dstBuff1[loopIndex] = 0;
}
edma_transfer(0,0);
val=fn-st;
gigabyte=EDN/(double)val;
printf("\n elapsed cycles : %lld\n",val);
printf("Gbytes/s=%lf\n",gigabyte*0.93);
for (loopIndex = 0; loopIndex < EDN; loopIndex++)
{
if (srcBuff1[loopIndex]!=dstBuff1[loopIndex]) printf("error at %d, la valeur de source %d, destination %d \n",loopIndex,srcBuff1[loopIndex],dstBuff1[loopIndex]);
}
printf("fin test c66x\n");
}