Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Объявления
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Обсуждение

help on using NIOS II DMA in the design

Altera_Forum
Почетный участник II
1 235Просмотр.

Hi, 

 

I am trying use the DMA example code as it is given in the nios 2 s/w handbook, 

 

the code is as given below, 

 

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

static volatile int rx_done = 0; 

/* 

* Callback function that obtains notification that the data 

* is received. 

*/ 

static void done (void* handle, void* data) 

rx_done++; 

/* 

*/ 

int main (int argc, char* argv[], char* envp[]) 

int rc; 

alt_dma_txchan txchan; 

alt_dma_rxchan rxchan; 

void* tx_data = (void*) 0x901000; /* pointer to data to send */ 

void* rx_buffer = (void*) 0x902000; /* pointer to rx buffer */ 

/* Create the transmit channel */ 

if ((txchan = alt_dma_txchan_open("/dev/dma_0")) == NULL) 

printf ("Failed to open transmit channel\n"); 

exit (1); 

/* Create the receive channel */ 

if ((rxchan = alt_dma_rxchan_open("/dev/dma_0")) == NULL) 

printf ("Failed to open receive channel\n"); 

exit (1); 

/* Post the transmit request */ 

if ((rc = alt_dma_txchan_send (txchan, tx_data, 128, 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, 

128, 

done, 

NULL)) < 0) 

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

exit (1); 

/* Post the receive request */ 

if ((rc = alt_dma_rxchan_prepare (rxchan, 

rx_buffer, 

128, 

done, 

NULL)) < 0) 

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

exit (1); 

/* wait for transfer to complete */ 

while (!rx_done); 

printf ("Transfer successful!\n"); 

return 0; 

 

But code is exiting, with an error ( Failed to open transmit channel ). 

 

I want to understand, where am I doing worng. 

0 баллов
3 Ответы
Altera_Forum
Почетный участник II
567Просмотр.

Does your SOPC system include a DMA controller called dma_0 ?

Altera_Forum
Почетный участник II
567Просмотр.

yes, dma_0 module is included in the sopc. how the dma should be configured in sopc to make use of the HAL API's.

Altera_Forum
Почетный участник II
567Просмотр.

Are you sure the component is a simple DMA and not a SGDMA? Could you show a printscreen of your SOPC system?

Ответить