Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

dma code problem

Altera_Forum
Honored Contributor II
1,326 Views

Hello,  

 

First I tried the DMA code example from the sw datasheet. 

Than I used the single line codes.  

I see the DMA register working and status on 0x800020 changing. 

But somehow the sent data to the memory register 0x800000 does not change. 

Any idea? Any good code example? 

I did find out if you don't init the DMA the length register update can change the whole DMA registers. 

# include <stdio.h># include "sys/alt_dma.h"# include "system.h"# include "altera_avalon_dma_regs.h"# include "altera_avalon_dma.c" // for init function 

unsigned int *p = (unsigned int*)(0x400000); 

void *pdma = (void*) DMA_0_BASE; 

 

int main(void) 

{  

//init 

IOWR_ALTERA_AVALON_DMA_STATUS(DMA_0_BASE, 0); 

IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_0_BASE, 0); 

//dma 

IOWR_ALTERA_AVALON_DMA_RADDRESS(DMA_0_BASE, (int)p); 

IOWR_ALTERA_AVALON_DMA_WADDRESS(DMA_0_BASE, 0x00800000); 

IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_0_BASE, 20); 

// wcon 1, rcon 0, leen 1, ween 0, Reen 0, I_en 1, go 1,32 bit 100 -> ok 

IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_0_BASE, 0x029C);  

 

printf ("Transfer successful!\n"); 

 

return( 0 ); 

}
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
586 Views

Two suggestions: 

1) Clear the DMA control register before doing anything else: 

 

IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_0_BASE, 0);  

 

(This ensures that the DMA init code within the HAL won&#39;t interfere with your operation). 

 

2) Double-check that the DMA write master is connected to the slave at address 0x00800000.
0 Kudos
Altera_Forum
Honored Contributor II
586 Views

Check your bus configuration in SOPC.  

That caught me once. Everyting was running fine, except the data was not coming through.  

It turned out to be a missing bus connection.
0 Kudos
Reply