Forum Discussion

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

Failed to post DMA transmit request

Hi,

I tried to use the general Avalon-MM DMA controller in Qsys and use the following C code to implement the DMA transmit:

# include <stdio.h># include "system.h"# include "io.h"# include "sys/alt_dma.h"
# define CUSTOM_BASE_ADDR 0x00800000
int i = 0;
alt_u32 data ;
alt_dma_txchan tx;
int main()
{
    /*fill the array*/
        for(i=0;i<10;i++)
        {
            data = i;
        }
    /*DMA*/
    tx = alt_dma_txchan_open("/dev/dma_import");
    if(tx != NULL)
    {
        printf("DMA TX channel open\n");
        if(alt_dma_txchan_ioctl(tx, ALT_DMA_TX_ONLY_ON, CUSTOM_BASE_ADDR)<0)
        {
            printf("Error: Failed to configure the DMA\n");
        }
        if(alt_dma_txchan_send(tx, data , 5, NULL, NULL)<0)
        {
            printf("Error: failed to post transmit request\n");
        }
        else
        {
            printf("DMA done\n");
        }
        alt_dma_txchan_close(tx);
    }
    else
    {
        printf("Error: Failed to open tx channel!\n");
    }
  return 0;
}

Where the array is stored in an external memory while the CUSTOM_BASE_ADDR is a separate peripheral. The connection among NIOS, external memory and custom peripheral should be fine since I've tested with general reading/writing.

Turned out "alt_dma_txchan_send(tx, data , 5, NULL, NULL)" always failed.

Currently I'm not sure if the problem lies in the hardware part or the software. Please suggest if there's any problem in the above code.

Thanks!
No RepliesBe the first to reply