Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
706 Views

DMA Example HAL

Have anyone a good sample how works with DMA in HAL mode? I need something  

like to project Streaming with irq and streaming transfer. Thank you so much for any help http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
0 Kudos
2 Replies
Highlighted
Valued Contributor III
2 Views

Re: DMA Example HAL

I&#39;ve made it next: 

 

unsigned int *p = (unsigned int*)(SDRAM_BASE + 0xF4240); 

void *pdma = (void*) SD_DMA_BASE; 

 

void isr_dma(void* context, alt_u32 id) 

if ((IORD_ALTERA_AVALON_DMA_STATUS(SD_DMA_BASE))&&0x01) { 

IOWR_ALTERA_AVALON_DMA_STATUS(SD_DMA_BASE, 0); 

IOWR_ALTERA_AVALON_DMA_RADDRESS(SD_DMA_BASE, (int)p); 

IOWR_ALTERA_AVALON_DMA_WADDRESS(SD_DMA_BASE, SD_BASE); 

IOWR_ALTERA_AVALON_DMA_LENGTH(SD_DMA_BASE, 40); 

IOWR_ALTERA_AVALON_DMA_CONTROL(SD_DMA_BASE, 0x02DC); 

 

}  

 

int main(void) 

{  

unsigned int *p = (unsigned int*)(SDRAM_BASE + 0xF4240); 

 

............. 

 

//Write to memory something (in this case 10 words) 

for (i=0, pattern=0xFFAAFFAA; i<10; i++) 

IOWR_32DIRECT(p+i, 0, pattern); 

 

alt_irq_register(SD_DMA_IRQ, pdma, isr_dma); 

 

//Send to some device 10 words 

IOWR_ALTERA_AVALON_DMA_STATUS(SD_DMA_BASE, 0); 

IOWR_ALTERA_AVALON_DMA_RADDRESS(SD_DMA_BASE, (int)p); 

IOWR_ALTERA_AVALON_DMA_WADDRESS(SD_DMA_BASE, SD_BASE); 

IOWR_ALTERA_AVALON_DMA_LENGTH(SD_DMA_BASE, 40); 

IOWR_ALTERA_AVALON_DMA_CONTROL(SD_DMA_BASE, 0x02DC); 

............... 

}
0 Kudos
Highlighted
Valued Contributor III
2 Views

Re: DMA Example HAL

Just to clarify, that&#39;s _not_ an example of the use of the DMA HAL - it&#39;s a demonstration of how to do a DMA transaction with direct register reads and writes. 

 

By the way, instead of  

 

if ((IORD_ALTERA_AVALON_DMA_STATUS(SD_DMA_BASE)) && 0x01) 

 

you want: 

 

if ((IORD_ALTERA_AVALON_DMA_STATUS(SD_DMA_BASE)) & 0x01) 

 

even better: 

 

if ((IORD_ALTERA_AVALON_DMA_STATUS(SD_DMA_BASE))&  

ALTERA_AVALON_DMA_STATUS_DONE_MSK)
0 Kudos