Altera_Forum
Honored Contributor
15 years ago[Problem] Simple Memory to Memory DMA example
here, i got rid of some code from full program.
my program go into infinite loop while(!rx_done)
that is, i can't get "done" from rxchan..
this is just example which stated in the altera document!
i can't figure out what problem is.. can you help me? # include <stdio.h> # include <stdlib.h> # include "sys/alt_dma.h" # include "altera_avalon_jtag_uart_regs.h" # include "system.h" # include "alt_types.h" # include "altera_avalon_dma_regs.h" # include <sys/alt_alarm.h> # include <sys/alt_timestamp.h> # include <string.h> static volatile int tx_done = 0; void software_display(FILE *fp_LCD); void hardware_display(FILE *fp_LCD); void displayMemory(char *address, int length); void check(void); static volatile int rx_done = 0; static void done (void *handle, void* data){ rx_done = 1; } void hardware_display(FILE *fp_LCD){ int rc; alt_dma_txchan txchan; alt_dma_rxchan rxchan; void* tx_data = 0x9000000; void* rx_buffer = 0x9001000; if((txchan = alt_dma_txchan_open("/dev/dma")) == NULL){ printf("Failed to open transmit channel\n"); exit (1); } else{ alt_dma_txchan_ioctl(txchan, ALT_DMA_SET_MODE_32, NULL); alt_dma_txchan_ioctl(txchan, ALT_DMA_TX_ONLY_ON, rx_buffer); alt_dma_txchan_ioctl(txchan, ALT_DMA_RX_ONLY_OFF, NULL); } if((rxchan = alt_dma_rxchan_open("/dev/dma")) == NULL){ printf("Failed to open receive channel\n"); exit (1); } else{ alt_dma_rxchan_ioctl(rxchan, ALT_DMA_SET_MODE_32, NULL); alt_dma_rxchan_ioctl(rxchan, ALT_DMA_TX_ONLY_OFF, NULL); alt_dma_rxchan_ioctl(rxchan, ALT_DMA_RX_ONLY_ON, tx_data); } if((rc = alt_dma_txchan_send(txchan, tx_data, 0x1000, NULL, NULL)) <0 ){ printf("Failed to post transmit request, reason = %i\n",rc); exit (1); } if((rc = alt_dma_rxchan_prepare(rxchan, rx_buffer, 0x1000, done, NULL)) <0){ printf("Failed to post read request, reason = %i\n",rc); exit (1); } while(!rx_done); alt_dma_txchan_close(txchan); alt_dma_rxchan_close(rxchan); printf("Transfer successful!\n"); }