Altera_Forum
Honored Contributor
19 years agoAbout DMA problem..please help me
hi all
I have try the altera memory test project with Nios II IDE.. but always display "-Testing memory using DMA"... http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif the dma might be already open.. and didn`t display "Memory at 0x%X Okay"....... so...I found the code at nios forum...it should be work but it always display"wait for transfer to complete"...why? look like the same problem with memory test !? I use Quartus II 5.1 SP2 & Nios II IDE 5.1 SP1 the exception address is sram_0 at SOPC Builder the program memory & .rodata & .rwdata & heap memory & stack memory are sdram_0 and I sure I have connect the DMA read & write master with sdram_0 & avalon tristate bridge in the SOPC builder this is the code...please help me thanks.... # include <stdio.h># include "system.h"# include "sys/alt_dma.h"# include "alt_types.h" /* Create the transmit channel */ static volatile int rx_done = 0; /* ready handler*/ static void done (void* handle, void* data) { rx_done++; } int main (int argc, char* argv[], char* envp[]) { int rc; alt_u8 Inbuf[1024], Outbuf[1024]; alt_dma_txchan txchan; alt_dma_rxchan rxchan; void* tx_data = (void*) &Inbuf[0]; /* pointer to data to send */ void* rx_buffer = (void*) &Outbuf[0]; /* pointer to rx buffer */ if ((txchan = alt_dma_txchan_open("/dev/avalon_dma")) == NULL) { printf ("Failed to open transmit channel\n"); exit (1); } /* Create the receive channel */ if ((rxchan = alt_dma_rxchan_open("/dev/avalon_dma")) == NULL) { printf ("Failed to open receive channel\n"); exit (1); } /* Post the transmit request */ if ((rc = alt_dma_txchan_send (txchan,tx_data,1024,NULL,NULL)) < 0) { printf ("Failed to post transmit request, reason = %i\n", rc); exit (1); } /* Post the receive request */ if ((rc = alt_dma_rxchan_prepare (rxchan,rx_buffer,1024,done,NULL)) < 0) { printf ("Failed to post read request, reason = %i\n", rc); exit (1); } /* wait for transfer to complete */ printf ("wait for transfer to complete\n"); while (!rx_done); printf("Transfer successful!\n"); return 0; }