Altera_Forum
Honored Contributor
15 years agoDMA - memory to memory writing problem..
hi folks,
i want to write data from one address to an other via dma like in the code below, problem is, it doesn't work. first i use the macros to set the addresses and the length and then i set the byte mask and the go mask. did i forget anything? thanks for your help ------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "sys/alt_dma.h"
#include "system.h"
#include "altera_avalon_dma_regs.h"
/* Callback function that obtains notification that the data is received.*/
int
main (void)
{
int i=0;
char sMSG_tx,sMSG_rx;
memset(sMSG_rx,0,sizeof(sMSG_rx));
memset(sMSG_tx,0x55,sizeof(sMSG_tx));
for(i=0;i<8;i++)
{
printf("%d",sMSG_tx);
}
printf("\n");
for(i=0;i<8;i++)
{
printf("%d",sMSG_rx);
}
printf("\n");
/*initialize*/
IOWR_ALTERA_AVALON_DMA_RADDRESS(DMA_RS485_BASE,(
int) sMSG_tx);
IOWR_ALTERA_AVALON_DMA_WADDRESS(DMA_RS485_BASE, (int)sMSG_rx);
IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_RS485_BASE, 8);
IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_RS485_BASE, ALTERA_AVALON_DMA_CONTROL_BYTE_MSK | ALTERA_AVALON_DMA_CONTROL_GO_MSK);
while(1)
{
if(IORD_ALTERA_AVALON_DMA_STATUS(DMA_RS485_BASE) & (ALTERA_AVALON_DMA_STATUS_DONE_MSK))
{
for(i=0;i<8;i++)
{
printf("%d",sMSG_tx);
}
printf("\n");
for(i=0;i<8;i++)
{
printf("%d",sMSG_rx);
}
break;
}
}
return 0;
}