Forum Discussion
Altera_Forum
Honored Contributor
15 years agoHave you tried changing the addresses to for example 0x9000000 and 0x9000104 (with a smaller data length?). And are you sure your program can't access that memory? For example that your program runs in the same memory as you try to perform the DMA transfers in.
I have a similar problem though. My code can be found in this thread: http://www.alteraforum.com/forum/showthread.php?p=105717#post105717 (one of the last posts) The code in this thread works fine, but if I add streaming mode by adding the following after the ALT_DMA_SET_MODE_32 it stops working. if i add: if ((rc = alt_dma_txchan_ioctl(txchan, ALT_DMA_TX_ONLY_ON, tx_data)) < 0) { printf ("Failed to set tx ioctl to TX_ONLY_ON, reason = %i\n", rc); exit (1); } my code hangs (while (!txrx_done) never completes). and if i add if ((rc = alt_dma_rxchan_ioctl(rxchan, ALT_DMA_RX_ONLY_ON, rx_buffer)) < 0) { printf ("Failed to set rx ioctl to RX_ONLY_ON, reason = %i\n", rc); exit (1); } i get back: Failed to set rx ioctl to RX_ONLY_ON, reason = -5 Ok if I change my code using some of the code in the startpost (cheers :P) I get the following code (the rest can be found in the forementioned thread):
txrx_done=0;
if((txchan = alt_dma_txchan_open(dma_name)) == 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(dma_name)) == 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);
}
/* Post the transmit request */
if ((rc = alt_dma_txchan_send (txchan, tx_data, length, 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, length, txrxDone, NULL)) < 0)
{
printf ("Failed to post read request, reason = %i\n", rc);
exit (1);
}
/* wait for transfer to complete */
printf(
"Waiting on DMA...");
while (!txrx_done)
printf(".");
printf(" Done!\n");
/* Close channels */
alt_dma_txchan_close(txchan);
alt_dma_rxchan_close(rxchan);
This code works for me, but it reads from a constant address and writes to an incrementing address. I would like to turn that around, I think I have tried all the combinations, but it doesn't seem to work. Anyone knows how to turn this around?