Forum Discussion

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

my DMA controller doesn't works

I'm trying to integrate my custom hardware DSP blocks in my system using Cyclone III NIOSII evaluation kit (EP3C25). But I'm having some troubles by using DMA controllers for sending and receiving data from DDR memory to the DSP blocks.

I have my hardware configured in SOPC Builder such as image shows, compilation in QuartusII is free of errors.

The system.h generated by SOPC and using from NIOSII is attached also.

I've been using <alt_dma.h> in NIOS EDS in order to configure and send/receive data to/from hardware by using the Tx and Rx DMA controllers.


alt_dma_txchan txchan;
alt_dma_rxchan rxchan;
if ( (txchan= alt_dma_txchan_open ("dev/im_loader") ) == NULL )
    printf ("Error");
if ( (rxchan= alt_dma_rxchan_open ("dev/im_store") ) == NULL )
    printf ("Error");

My code was succesfully compilated but when the program is running the opening of both DMA channels always gets error.

Any suggestion??

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    According to your "system.h" file and your SOPC builder image, you've got your file names wrong.

    You should be using

    "/dev/dma_load_img"

    and

    "/dev/dma_store_img"

    Jake
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Jack thanks for your correction, I've change the name in both DMA channels according with <system.h> and DMA Channels are free of errors when opening

    Now I've tried to send and receive through the Tx & Rx DMA channels using this,

    
        /* flag used to indicate the transaction is complete */
        static volatile int rx_done = 0;
        // Callback function that obtains notification that the data has
        static void done (void* handle, void* data){
            rx_done++;
        }
        alt_u8 img_buffer;
    in main():
                printf ("starting data transfer...\n");
                /* Post the transmit request */
                if ((rc = alt_dma_txchan_send (txchan,img_buffer,128,NULL,NULL)) < 0){
                //if ((rc = alt_dma_txchan_ioctl(txchan,ALT_DMA_TX_ONLY_ON,img_buffer)) < 0            
                    printf ("Failed to post transmit request, reason = %i\n", rc);
                }
                /* Post the receive request */
                if ((rc = alt_dma_rxchan_prepare (rxchan,img_buffer,128,done,NULL)) < 0){
                //if ((rc = alt_dma_rxchan_ioctl(rxchan,ALT_DMA_RX_ONLY_ON,img_buffer)) < 0){            
                    printf ("Failed to post read request, reason = %i\n", rc);
                }
                /* wait for transfer to complete */
        
                while (!rx_done);
                OSTimeDlyHMSM(0,0,1,50);
                printf ("Transfer successful!\n");  
    

    I've check both alt_dma_txchan_send & alt_dma_txchan_ioctl options, but the program always hangs waiting for DMA done transfer.

    I don't know when If I use alt_dma_rxchan_ioctl how to specify the number of bytes to be sent/received