- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I copied an example from the Altera Nios II Software Developer’s Handbook, chapter "Using DMA Devices" using memory to memory data transfer. I modified the code a bit .....
The good thing is that there are no error messages, but the dma-transfer does not complete by setting the rx_done flag. Perhaps a beginners fault? Can somebody help me? Freeck # 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/dma_0")) == NULL) { printf ("Failed to open transmit channel\n"); exit (1); } /* Create the receive channel */ if ((rxchan = alt_dma_rxchan_open("/dev/dma_0")) == 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; }Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've just tried to run your code on the 1C20 full design from the Nios II 1.1 kit. That worked fine. What hardware/version of the kit are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use the same kit, and using web edition 4.2 of QII.
Perhaps the problem has something to do with the SoPC design ? I have added a dma channel called dma_0 to the example project "my-first-nios". You too? PS: is it possible to add an attachment to this reply perhap I could sent the design to you.....- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was just using the "full" example design that comes with the kit. The one change I did have to make to your code was to chane the device name to /dev/dma to match what was used in the example.
Try comparing and contrasting these example with what you have to see if you can see the problem. It could be that you haven't connected the DMA read and write master ports so that it can access the memories you're tying to use.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are completely right!
I compiled the full featured version and everything worked well; after adapting my own design everything seems to work well. I had indeed forget to connect the read/write-master to the avalon-slave port. Thanks for the hint.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page