Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

DMA to UART

I have downside program in order to realize transfer block data from onchip_memory to UART by DMA, however it doesn't work. The message shows the transter has completed, but there is no data transfered to UART.

I don't know is there some problem with my program or system set?

--- Quote Start ---

#include <stdio.h># include <stddef.h># include <stdlib.h># include "sys/alt_dma.h"# include "alt_types.h"# include <system.h>

/* flag used to indicate the transaction is complete */

volatile int dma_complete = 0;

/* function that is called when the transaction completes */

void dma_done (void* handle)

{

dma_complete = 1;

}

int main (void)

{

char buffer[32]="welcome to my nios2 world";

alt_dma_txchan tx;

/* Obtain a handle for the device */

if ((tx = alt_dma_txchan_open ("/dev/dma")) == NULL)

{

printf ("Error: failed to open device\n");

exit (1);

}

else

{

/* Post the receive request */

alt_dma_txchan_ioctl(tx,ALT_DMA_TX_ONLY_ON,UART_BASE);

if (alt_dma_txchan_send (tx, buffer, 32, dma_done, NULL) < 0)

{

printf ("Error: failed to post receive request\n");

exit (1);

}

/* Wait for the transaction to complete */

while (!dma_complete);

printf ("Transaction complete\n");

alt_dma_txchan_close (tx);

}

return 0;

}

--- Quote End ---

--- Quote Start ---

nios2-terminal: connected to hardware target using UART on /dev/com1 at 115200 b

aud

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate)

rrnnaattoo ooppeeee

--- Quote End ---

No RepliesBe the first to reply