Not in quartus.
NIOS IDE -> Project -> System lib config
Adam
Reply by ●January 29, 20082008-01-29
quartus II sopc builder, jtag debugging mode, tri-state avalon bridge,
sdram, on-chip ram, etc
On Jan 29, 5:04 am, G=F3rski Adam
<gorskia@.................wp....................pl..................>
wrote:
> BigJames...@gmail.com pisze:
>
> > 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 <stdio.h>
> > #include <stdlib.h>
> > #include <sys/alt_dma.h>
> > #include "system.h"
>
> > static volatile int rx_done =3D 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]=3D"abcdefghijklmn\0";
> > alt_dma_txchan txchan;
> > alt_dma_rxchan rxchan;
>
> > void* tx_data =3D (void*) buff; /* pointer to data to
> > send */
> > void* rx_buffer =3D (void*) 0x01000000; /* on_chip_memory addr*/
>
> > /* Create the transmit channel */
> > if ((txchan =3D alt_dma_txchan_open("/dev/dma_0")) =3D=3D NULL)
> > {
> > printf ("Failed to open transmit channel\n");
> > exit (1);
> > }
>
> > /* Create the receive channel */
> > if ((rxchan =3Dalt_dma_rxchan_open("/dev/dma_0")) =3D=3D NULL)
> > {
> > printf ("Failed to open receive channel\n");
> > exit (1);
> > }
>
> > /* Post the transmit request */
> > if ((rc =3D alt_dma_txchan_send (txchan,tx_data,128,NULL,NULL)) < 0)
> > {
> > printf ("Failed to post transmit request, reason =3D %i\n", rc);
> > exit (1);
> > }
>
> > /* Post the receive request */
> > if ((rc =3D alt_dma_rxchan_prepare (rxchan,rx_buffer,128,done,NULL)) <=
> > 0)
> > {
> > printf ("Failed to post read request, reason =3D %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;
> > }
>
> What is set in system configuration ?
>
> Adam
Reply by Mark McDougall●January 29, 20082008-01-29
BigJamesLau@gmail.com wrote:
> here is my codes. I want to verify the result and display at the end,
> however I got like "cdcd", what's wrong? thanks
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<<31)|(addr))
What's the width on your DMA register? Not 7 bits I hope! :O
You also use 0x01000000 for the rx_buffer yet you're printing the contents
of INCHIP_MEMORY_0_BASE, which IMHO is bad practise.
Otherwise it looks OK to me...
Regards,
--
Mark McDougall, Engineer
Virtual Logic Pty Ltd, <http://www.vl.com.au>
21-25 King St, Rockdale, 2216
Ph: +612-9599-3255 Fax: +612-9599-3266
Reply by ●January 29, 20082008-01-29
BigJamesLau@gmail.com pisze:
> 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 <stdio.h>
> #include <stdlib.h>
> #include <sys/alt_dma.h>
> #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;
> }
What is set in system configuration ?
Adam
Reply by ●January 29, 20082008-01-29
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 <stdio.h>
#include <stdlib.h>
#include <sys/alt_dma.h>
#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;
}