Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12455 Discussions

DMA problem on alt_dma_txchan_send

Honored Contributor II

Hi every body. 

I have a problem with the NIOS DMA setting. 

In my system, I need to read data from a device by a MM-Avalon interface, and write the data in a other device with the MM-Avalon interface. The memoryes in the devices are FIFO. The part of my code about DMA is: 


# include "system.h" 

# include <io.h> 

# include <stdio.h> 

# include <sys/alt_irq.h> 




int rc; 


alt_dma_txchan txchan; 

alt_dma_rxchan rxchan; 


void* tx_data = (void*) (MC_BASE+MC_READ);  

void* rx_buffer = (void*) (GIGAINT_BASE);  



if ((txchan = alt_dma_txchan_open(DMA_0_NAME)) == null




alt_dma_txchan_reg (*pTxchan); 




printf ("Failed to set ALT_DMA_SET_MODE_32 in TX\r\n"); 




printf ("Failed to set ALT_DMA_RX_ONLY_OFF in TX \r\n"); 




printf ("Failed to set ALT_DMA_TX_ONLY_ON in TX \r\n"); 






if ((rxchan = alt_dma_rxchan_open(DMA_0_NAME)) == null




printf ("Failed to set ALT_DMA_SET_MODE_32 in RX\r\n"); 




printf ("Failed to set ALT_DMA_TX_ONLY_OFF in RX \r\n");  




printf ("Failed to set ALT_DMA_RX_ONLY_ON in RX \r\n");  



rc = alt_dma_txchan_send ( txchan,tx_data,length,null,null); 

if (rc < 0) 

printf ("Failed to post transmit request, reason = %i\r\n", rc); 



rc = alt_dma_rxchan_prepare (rxchan,rx_buffer,length,done,null); 

if (rc < 0) 

printf ("Failed to post read request, reason = %i\r\n", rc); 



while (!rx_done); 




"done" is the function to call when the DMA end. 

"length" is 256, and teh DMA dimension is 1024 


The problem is the function < alt_dma_txchan_send > return -22, but i don't understand where is the bug.  


Help me!!! 


Thank you 






0 Kudos
1 Reply
Honored Contributor II

I had the same issue.  


In my case I had accidentally kept the width of DMA length register as 4 bits, resulting in the -22 error you described. To solve this, I adjusted the width of the DMA length register to 13 bits (default setting). This is good enough for most transfers.