Hello
I have a problem with cache and EDMA.
I work with the example edmaTest and have add the use off MMU and Cache to it
void EDMAAppEDMA3Test() { volatile unsigned int index = 0u; volatile unsigned int count = 0u; EDMA3CCPaRAMEntry paramSet; unsigned char data = 0u; volatile unsigned int retVal = 0u; unsigned int isTestPassed = false; unsigned int numEnabled = 0u; unsigned int aCount = EDMAAPP_MAX_ACOUNT; unsigned int bCount = EDMAAPP_MAX_BCOUNT; unsigned int cCount = EDMAAPP_MAX_CCOUNT; /* Initalize source and destination buffers */ for (count = 0u; count < (aCount * bCount * cCount); count++) { SrcBuff[count] = data++; /* ** No need to initialize the destination buffer as it is ** being invalidated. */ } // Clean cache to achieve coherence between cached memory and main memory CacheDataCleanBuff((unsigned int)SrcBuff, EDMAAPP_MAX_BUFFER_SIZE); // CacheDataCleanAll(); /* Request DMA channel and TCC */ retVal = EDMA3RequestChannel(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_TYPE, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_TCC_NUM, EDMAAPP_DMA_EVTQ); /* Registering Callback Function */ EDMAAppCallbackFxn[EDMAAPP_DMA_TCC_NUM] = &EDMAAppCallback; if(TRUE == retVal) { /* Fill the PaRAM Set with transfer specific information */ paramSet.srcAddr = (unsigned int)(SrcBuff); paramSet.destAddr = (unsigned int)(DstBuff); paramSet.aCnt = (unsigned short)aCount; paramSet.bCnt = (unsigned short)bCount; paramSet.cCnt = (unsigned short)cCount; /* Setting up the SRC/DES Index */ paramSet.srcBIdx = (short)aCount; paramSet.destBIdx = (short)aCount; if(EDMA3_SYNC_A == EDMAAPP_DMA_SYNC_TYPE) { /* A Sync Transfer Mode */ paramSet.srcCIdx = (short)aCount; paramSet.destCIdx = (short)aCount; } else { /* AB Sync Transfer Mode */ paramSet.srcCIdx = ((short)aCount * (short)bCount); paramSet.destCIdx = ((short)aCount * (short)bCount); } /* Configure the paramset with NULL link */ paramSet.linkAddr = (unsigned short)0xFFFFu; paramSet.bCntReload = (unsigned short)0u; paramSet.opt = 0u; /* Src & Dest are in INCR modes */ paramSet.opt &= ~(EDMA3CC_OPT_SAM | EDMA3CC_OPT_DAM); /* Program the TCC */ paramSet.opt |= ((EDMAAPP_DMA_TCC_NUM << EDMA3CC_OPT_TCC_SHIFT) & EDMA3CC_OPT_TCC); /* Enable Intermediate & Final transfer completion interrupt */ paramSet.opt |= (1u << EDMA3CC_OPT_ITCINTEN_SHIFT); paramSet.opt |= (1u << EDMA3CC_OPT_TCINTEN_SHIFT); if(EDMA3_SYNC_A == EDMAAPP_DMA_SYNC_TYPE) { paramSet.opt &= ~EDMA3CC_OPT_SYNCDIM; } else { /* AB Sync Transfer Mode */ paramSet.opt |= (1u << EDMA3CC_OPT_SYNCDIM_SHIFT); } /* Now, write the PaRAM Set. */ EDMA3SetPaRAM(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, ¶mSet); EDMA3GetPaRAM(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, ¶mSet); } /* ** Since the transfer is going to happen in Manual mode of EDMA3 ** operation, we have to 'Enable the Transfer' multiple times. ** Number of times depends upon the Mode (A/AB Sync) ** and the different counts. */ if(TRUE == retVal) { /* Need to activate next param */ if(EDMA3_SYNC_A == EDMAAPP_DMA_SYNC_TYPE) { numEnabled = bCount * cCount; } else { /* AB Sync Transfer Mode */ numEnabled = cCount; } for(index = 0u; index < numEnabled; index++) { IrqRaised = EDMAAPP_IRQ_STATUS_XFER_INPROG; /* ** Now enable the transfer as many times as calculated above. */ retVal = EDMA3EnableTransfer(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_TRIG_MODE); /* Wait for the Completion ISR. */ while(EDMAAPP_IRQ_STATUS_XFER_INPROG == IrqRaised) { /* ** Wait for the Completion ISR on Master Channel. ** You can insert your code here to do something ** meaningful. */ } /* Check the status of the completed transfer */ if(IrqRaised < (int)EDMAAPP_IRQ_STATUS_XFER_INPROG) { /* Some error occured, break from the FOR loop. */ ConsoleUtilsPrintf("\r\nEDMA3Test: Event Miss Occured!!!\r\n"); /* Clear the error bits first */ EDMA3ClearErrorBits(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_EVTQ); break; } } } /* Match the Source and Destination Buffers. */ if(TRUE == retVal) { for(index = 0u; index < (aCount * bCount * cCount); index++) { if(SrcBuff[index] != DstBuff[index]) { isTestPassed = false; ConsoleUtilsPrintf("EDMA3Test: Data write-read matching FAILED.\r\n"); ConsoleUtilsPrintf("The mismatch happened at index : %d\r\n", ((int)index + 1u)); break; } } if(index == (aCount * bCount * cCount)) { isTestPassed = true; ConsoleUtilsPrintf("EDMA3Test: Data write-read matching PASSED.\r\n"); } /* Free the previously allocated channel. */ retVal = EDMA3FreeChannel(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_CH_TYPE, EDMAAPP_DMA_CH_NUM, EDMAAPP_DMA_TRIG_MODE, EDMAAPP_DMA_TCC_NUM, EDMAAPP_DMA_EVTQ); /* Unregister Callback Function */ EDMAAppCallbackFxn[EDMAAPP_DMA_TCC_NUM] = NULL; if(TRUE != retVal) { ConsoleUtilsPrintf("EDMA3Test: EDMA3_DRV_freeChannel() FAILED.\r\n"); } } if(true == isTestPassed) { ConsoleUtilsPrintf("EDMA3Test PASSED.\r\n"); } else { ConsoleUtilsPrintf("EDMA3Test FAILED\r\n"); } }
But the code don't work.
If I disable the Cache for all allthing is OK, but if Cache is enabled the DMA don't work.
Thanks for your help.