Hello,
I am working of DM6446 DSP and i want to access emif through edma, i am using event number-5 of this processor, i am transmitting from a buffer(ASP_BUFFER) to FPGA connected on CS-3 of the processor, but edma event is not triggering, i have attached my code and event number of the processor.
Thanks.
#include <stdio.h>
#include <csl_edma3.h>
#include <csl_intc.h>
#include <soc.h>
#include <bsp.h>
#include <edma.h>
#include <edmaCommon.h>
/* Global Edma Tcc handler table */
#pragma DATA_SECTION(TccHandlerTable,".testMem");
EdmaTccHandler TccHandlerTable[64];
/*
* =============================================================================
* @func eventEdmaHandler
*
* @arg
* handle - Edma module handle
*
* @desc
* This is the interrupt handler routine for edma interrupt
*
* @return
* NONE
*
* =============================================================================
*/
void eventEdmaHandler (
void *handle
)
{
CSL_Edma3Handle hModule = (CSL_Edma3Handle)handle;
CSL_BitMask32 maskVal;
CSL_Edma3CmdIntr regionIntr;
Uint32 tcc;
Uint32 intr;
Uint32 intrh;
/* Read the IPR */
regionIntr.region = CSL_EDMA3_REGION_1;
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND, ®ionIntr);
while (regionIntr.intr || regionIntr.intrh) {
intr = regionIntr.intr;
intrh = regionIntr.intrh;
tcc = 0;
while (intr) {
maskVal = 1 << tcc;
if (intr & maskVal) {
InvokeHandle(tcc);
intr &= ~maskVal;
}
tcc++;
}
tcc = 0;
while (intrh) {
maskVal = 1 << tcc;
if (intrh & maskVal) {
InvokeHandle((tcc+32));
intrh &= ~maskVal;
}
tcc++;
}
CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTRPEND_CLEAR,®ionIntr);
CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INTRPEND,®ionIntr);
}
}
/*
* =============================================================================
* @func EdmaEventHook
*
* @arg
* tcc - Tcc number
* fxn - Pointer to function which points to edma isr
*
* @desc
* This is the interrupt handler routine for edma interrupt
*
* @return
* NONE
*
* =============================================================================
*/
void EdmaEventHook (
Uint16 tcc,
EdmaTccHandler fxn
)
{
TccHandlerTable[tcc] = (fxn);
}
/* Intc declaration */
CSL_IntcContext intcContext;
CSL_IntcEventHandlerRecord EventHandler[30];
CSL_IntcObj intcObjEdma;
CSL_IntcHandle hIntcEdma;
CSL_IntcGlobalEnableState state;
CSL_IntcEventHandlerRecord EventRecord;
CSL_IntcParam vectId;
/* Globals */
Uint8 srcBuff[512];
Uint8 dstBuff[512];
volatile Uint32 intFlag = 0;
Uint32 passStatus = 1;
/* Edma handle */
CSL_Edma3Handle hModule;
/* Forward declaration */
void tcc1Fxn(void);
void edma_interrupt_example (void);
/*
* =============================================================================
* @func main
*
* @desc
* This is the main routine for the file.
*
* =============================================================================
*/
/*
* =============================================================================
* @func edma_interrupt_example
*
* @arg
* NONE
*
* @desc
* This is the example routine which perform edma interrupt test
*
* @return
* NONE
*
* =============================================================================
*/
void edma_interrupt_example (void)
{
CSL_Edma3HwSetup hwSetup;
CSL_Edma3Obj edmaObj;
CSL_Edma3ParamHandle hParamBasic;
CSL_Edma3ChannelObj chObj;
CSL_Edma3CmdIntr regionIntr;
CSL_Edma3CmdDrae regionAccess;
CSL_Edma3ChannelHandle hChannel;
CSL_Edma3ParamSetup myParamSetup;
CSL_Edma3Context context;
CSL_Edma3ChannelAttr chAttr;
CSL_Status status;
CSL_Edma3HwDmaChannelSetup dmahwSetup[CSL_EDMA3_NUM_DMACH] =
CSL_EDMA3_DMACHANNELSETUP_DEFAULT;
Uint32 loopIndex;
/* Initialize data buffers */
for (loopIndex = 0; loopIndex < 512; loopIndex++) {
srcBuff[loopIndex] = loopIndex;
dstBuff[loopIndex] = 0;
}
/* Module initialization */
status = CSL_edma3Init(&context);
if (status != CSL_SOK) {
printf ("Edma module initialization failed\n");
return;
}
/* Intc module initialization */
intcContext.eventhandlerRecord = EventHandler;
intcContext.numEvtEntries = 10;
CSL_intcInit(&intcContext);
/* Enable NMIs */
CSL_intcGlobalNmiEnable();
/* Enable global interrupts */
CSL_intcGlobalEnable(&state);
/* Opening a intc handle for edma event */
/* vectId = CSL_INTC_VECTID_4;
hIntcEdma = CSL_intcOpen (&intcObjEdma, CSL_INTC_EVENTID_EDMA3CC_GINT, \
&vectId , NULL);
*/
vectId = CSL_INTC_VECTID_5;
hIntcEdma = CSL_intcOpen (&intcObjEdma, EDMA3CC_INT1, \
&vectId , NULL);
/* Edma module open */
hModule = CSL_edma3Open(&edmaObj,CSL_EDMA3,NULL,&status);
if ( (hModule == NULL) || (status != CSL_SOK)) {
printf ("Edma module open failed\n");
return;
}
/* Edma module setup */
dmahwSetup[EDMA_H3AEVT].paramNum = EDMA_H3AEVT;
dmahwSetup[EDMA_H3AEVT].que = CSL_EDMA3_QUE_1;
hwSetup.dmaChaSetup = dmahwSetup;
hwSetup.qdmaChaSetup = NULL;
status = CSL_edma3HwSetup(hModule,&hwSetup);
if (status != CSL_SOK) {
printf ("Hardware setup failed\n");
CSL_edma3Close (hModule);
return;
}
/* Setup the DRAE masks
* DRAE enable(Bits 0-15) for the shadow region 1.
*/
regionAccess.region = CSL_EDMA3_REGION_1 ;
regionAccess.drae = 0xFFFFFFFF ;
regionAccess.draeh = 0x00000000 ;
status = CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_DMAREGION_ENABLE, \
®ionAccess);
if (status != CSL_SOK) {
printf("Edma region enable command failed\n");
return;
}
/* Channel open */
chAttr.regionNum = CSL_EDMA3_REGION_1;
chAttr.chaNum = EDMA_H3AEVT;
hChannel = CSL_edma3ChannelOpen(&chObj, CSL_EDMA3, &chAttr, &status);
if ( (hChannel == NULL) || (status != CSL_SOK)) {
printf ("Edma channel open failed\n");
return;
}
/* Enable interrupts */
regionIntr.region = CSL_EDMA3_REGION_1 ;
regionIntr.intr = 0xFFFFFFFF ;
regionIntr.intrh = 0xFFFFFFFF;
status = CSL_edma3HwControl(hModule,CSL_EDMA3_CMD_INTR_ENABLE,®ionIntr);
if (status != CSL_SOK) {
printf ("Edma interrupt enable command failed\n");
return;
}
/* Get the parameter handle */
hParamBasic = CSL_edma3GetParamHandle(hChannel,5,&status);
if (hParamBasic == NULL) {
printf("Edma get param handle failed\n");
return;
}
/* Edma parameter entry Setup */
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)ASP_RxBuffer; // input buffer
myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(2,512);
myParamSetup.dstAddr = (Uint32) ((0x04000000) + (0x200 << 5)) ; // this is chip select-3 of dm6446 connected to fpga
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 param setup failed\n");
return;
}
/* Association of an EDMA event handler with the INTC routine */
EventRecord.handler = &eventEdmaHandler;
EventRecord.arg = (void*)(hModule);
CSL_intcPlugEventHandler(hIntcEdma,&EventRecord);
/* Enabling event edma */
CSL_intcHwControl(hIntcEdma,CSL_INTC_CMD_EVTENABLE,NULL);
/* Hook up the EDMA event with an completion code function handler */
EdmaEventHook(5, tcc1Fxn);
/* Manually trigger the channel */
status = CSL_edma3HwChannelControl(hChannel,CSL_EDMA3_CMD_CHANNEL_SET,NULL);
if (status != CSL_SOK) {
printf ("Edma channel set command failed\n");
return;
}
/* Wait for completion */
while (!intFlag);
/* Verify destination buffer to be equal to the source buffer */
// if(Verify_Transfer(512, 1, 1, 0, 0, 0, 0, srcBuff, dstBuff,TRUE) == FALSE)
// passStatus = 0;
if (passStatus == 1)
printf ("<<EXAMPLE PASSED>>: Edma Interrupt Example Passed\n");
printf ("=============================================================\n");
/* 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;
}
/*
* =============================================================================
* @func tcc1Fxn
*
* @arg
* NONE
*
* @desc
* This is the interrupt service routine for edma interrupt
*
* @return
* NONE
*
* =============================================================================
*/
void tcc1Fxn(void)
{
intFlag = 1;
}
enum EDMA_Event{ //Pg-36, EDMA.pdf
EDMA_XEVT = 2, // ASP Transmit Event
EDMA_REVT = 3, //ASP Receive Event
EDMA_HISTEVT= 4,// VPSS Histogram Event
EDMA_H3AEVT = 5, // VPSS H3A Event
EDMA_PRVUEVT = 6, // VPSS Previewer Event
EDMA_RSZEVT = 7, //VPSS Resizer Event
EDMA_IMXINT = 8, // VICP Interrupt
EDMA_VLCDINT = 9, // VICP VLCD Interrupt
EDMA_ASQINT = 10, // VICP ASQ Interrupt
EDMA_DSQINT = 11 , //VICP DSQ Interrupt
EDMA_SPIXEVT = 16, // SPI Transmit Event
EDMA_SPIREVT = 17, //SPI Receive Event
EDMA_URXEVT0 = 18, // UART 0 Receive Event
EDMA_UTXEVT0 = 19, // UART 0 Transmit Event
EDMA_URXEVT1 = 20 , // UART 1 Receive Event
EDMA_UTXEVT1 = 21,// UART 1 Transmit Event
EDMA_URXEVT2 = 22, //UART 2 Receive Event
EDMA_UTXEVT2 = 23, //UART 2 Transmit Event
EDMA_MMCRXEVT = 26, // MMC Receive Event
EDMA_MMCTXEVT = 27, //MMC Transmit Event
EDMA_I2CREVT=28, //I2C Receive Event
EDMA_I2CXEVT=29, //I2C Transmit Event
EDMA_GPINT0=32, //GPIO 0 Interrupt
EDMA_GPINT1=33, //GPIO 1 Interrupt
EDMA_GPINT2=34, //GPIO 2 Interrupt
EDMA_GPINT3=35, //GPIO 3 Interrupt
EDMA_GPINT4=36, //GPIO 4 Interrupt
EDMA_GPINT5=37, //GPIO 5 Interrupt
EDMA_GPINT6=38, //GPIO 6 Interrupt
EDMA_GPINT7=39, //GPIO 7 Interrupt
EDMA_GPBNKINT0=40, //GPIO Bank 0 Interrupt
EDMA_GPBNKINT1=41, //GPIO Bank 1 Interrupt
EDMA_GPBNKINT2=42, //GPIO Bank 2 Interrupt
EDMA_GPBNKINT3=43, //GPIO Bank 3 Interrupt
EDMA_GPBNKINT4=44, //GPIO Bank 4 Interrupt
EDMA_TINT0=48, //Timer 0 Interrupt
EDMA_TINT1=49, //Timer 1 Interrupt
EDMA_TINT2=50, //Timer 2 Interrupt
EDMA_TINT3=51, //Timer 3 Interrupt
EDMA_PWM0=52, //PWM 0 Event
EDMA_PWM1=53, //PWM 1 Event
EDMA_PWM2=54 //PWM 2 Event
};