I am trying to use software trigger for DMA transfer from RAM to RAM. However, I cannot see DMA starts to work as no data in destination. I am not sure where is the issue for my code, and I also have no idea about how to debug this case.
Here is my code for reference. Looking forward to your reply.
#define DMA_TEST_SRC_ADDRESS (uint32_t)(0x0807D200) // source data address
#define DMA_TEST_DEST_ADDRESS (uint32_t)(0x0807D400) // destination data address
#define DMA_TEST_DATA_SIZE (uint32_t)(0x100) // data size for DMA transfer
void DMA_Test_Src_Data_Init(uint8_t step)
{
uint32_t i = 0;
uint8_t *srcPtr = (uint8_t *)DMA_TEST_SRC_ADDRESS;
for(i=0; i< DMA_TEST_DATA_SIZE; i++)
*(srcPtr++) = i + step;
return;
}
void DMA_Test(void)
{
static uint8_t seqDMATest = 0;
uint8 u8PotStringBuf[64];
g_dmaCTRL g_dmaCTRLPKT1;
g_dmaCTRLPKT1.SADD = (uint32)DMA_TEST_SRC_ADDRESS; /* source address */
g_dmaCTRLPKT1.DADD = (uint32)DMA_TEST_DEST_ADDRESS; /* destination address */
g_dmaCTRLPKT1.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT1.FRCNT = 1; /* frame count */
g_dmaCTRLPKT1.ELCNT = DMA_TEST_DATA_SIZE; /* element count */
g_dmaCTRLPKT1.ELDOFFSET = 4; /* element destination offset */
g_dmaCTRLPKT1.ELSOFFSET = 4; /* element destination offset */
g_dmaCTRLPKT1.FRDOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT1.FRSOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT1.PORTASGN = PORTA_READ_PORTA_WRITE;
g_dmaCTRLPKT1.RDSIZE = ACCESS_8_BIT; /* read size */
g_dmaCTRLPKT1.WRSIZE = ACCESS_8_BIT; /* write size */
g_dmaCTRLPKT1.TTYPE = FRAME_TRANSFER ; /* transfer type */
g_dmaCTRLPKT1.ADDMODERD = ADDR_INC1; /* address mode read */
g_dmaCTRLPKT1.ADDMODEWR = ADDR_INC1; /* address mode write */
g_dmaCTRLPKT1.AUTOINIT = AUTOINIT_OFF; /* autoinit */
// Set control packet for channel 0
dmaSetCtrlPacket(DMA_TEST_CH, g_dmaCTRLPKT1);
// prepare data for DMA transfer
DMA_Test_Src_Data_Init(seqDMATest);
// Set DMA channel 0 to trigger on software request
dmaSetChEnable(DMA_TEST_CH, DMA_SW);
// enable DMA
dmaEnable();
while(dmaGetInterruptStatus(DMA_TEST_CH, BTC) != TRUE);
sprintf(u8PotStringBuf,"[Passed]-[Seq#%d]-DMA Test. \r\n", seqDMATest);
sciDisplayText(UART_Msg, u8PotStringBuf);
return;
}
This function is called in main function while loop every 15 seconds.