regarding DMA memory to memory copy in NIOS II

here is my codes. I want to verify the result and display at the end, however I got like "cdcd", what's wrong? thanks

/* * "Hello World" example. * * This example prints 'Hello from Nios II' to the STDOUT stream. It runs on * the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example * designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT * device in your system's hardware. * The memory footprint of this hosted application is ~69 kbytes by default * using the standard reference design. * * For a reduced footprint version of this template, and an explanation of how * to reduce the memory footprint for a given application, see the * "small_hello_world" template. * */

#include #include #include #include "system.h"

static volatile int rx_done = 0;

/*

  • Callback function that obtains notification that the data has
  • been received.
*/ static void done (void* handle, void* data) { rx_done++; }

int main(int argc, char* argv[], char* envp[]) { int rc; static char buff[256]="abcdefghijklmn\0"; alt_dma_txchan txchan; alt_dma_rxchan rxchan;

void* tx_data = (void*) buff; /* pointer to data to send */ void* rx_buffer = (void*) 0x01000000; /* on_chip_memory addr*/

/* Create the transmit channel */ 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,128,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,128,done,NULL)) <

0) { printf ("Failed to post read request, reason = %i\n", rc); exit (1); }

/* wait for transfer to complete */ while (!rx_done); printf ("Transfer successful!\n"); printf ("%s",(ONCHIP_MEMORY_0_BASE)); return 0; }

Reply to
BigJamesLau
Loading thread data ...

snipped-for-privacy@gmail.com pisze:

What is set in system configuration ?

Adam

Reply to
Górski Adam

You need to ensure that the memory involved in the transfer is not cached

- you can simply set bit 31 of the address to bypass the NIOS cache. I use a macro thusly: #define UNCACHED(addr) ((1

Reply to
Mark McDougall

quartus II sopc builder, jtag debugging mode, tri-state avalon bridge, sdram, on-chip ram, etc

Reply to
BigJamesLau

snipped-for-privacy@gmail.com pisze:

Not in quartus. NIOS IDE -> Project -> System lib config

Adam

Reply to
Górski Adam

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.