FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5892 Discussions

result=alt_avalon_sgdma_do_async_transfer(sgdma_sd ram, &desc[0])

Altera_Forum
Honored Contributor II
985 Views

hi: 

in the niosII BST ,I am puzzled in the the code below : 

...... 

result=alt_avalon_sgdma_do_async_transfer(sgdma_sdram, &desc[0]); 

if(!result) 

printf("Writing the head of the receive descriptor list to the DMA failed\n"); 

...... 

 

I use the NiosII debug mode to test the code,after executting "alt_avalon_sgdma_do_async_transfer",I can look into the sdram which the data is translated in,and they seems right,but I cannot get the "result "value which should be "0",it is that ,the program is stalling or something. 

I guess that the data is still translating ,so "alt_avalon_sgdma_do_async_transfer" return nothing,but I donnot kown how to resolve the problem?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
261 Views

the async function returns immediately, so it's possible that the transfer is still going on when it returns. The return value just says if the DMA could be started correctly or not. 

Use the sync function if you wan t to wait for the end of transfer. The returned value will be the SGDMA status at the end of transfer.
0 Kudos
Altera_Forum
Honored Contributor II
261 Views

thanks for your reply~ 

in short, I want to translate a frame of image by SGDMA, that is, translating 320*230=76800 bytes from FIFO(custom sopc component) to sdram. 

 

according to the manual, alt_avalon_sgdma_construct_mem_to_mem_desc() can translate 65535(length type is alt_u16),so I should use "for-loop"to translate 76800 bytes data.the code is below: 

 

for(buffer_counter=0;buffer_counter<=1;buffer_coun ter++) 

alt_u32 *write_addr = (alt_u32 *) (DDR_SDRAM_BASE+0xE000*buffer_counter); 

 

alt_avalon_sgdma_construct_mem_to_mem_desc( 

&desc[buffer_counter],  

&desc[buffer_counter+1],  

read_addr, 

write_addr, 

65535, 

1, 

0); 

result=alt_avalon_sgdma_do_async_transfer(); 

if(!result)  

printf("Writing the head of the receive descriptor list to the DMA failed\n"); 

 

 

I use niosII debug mode test the above code,I find that "result" cannot be set to 1 or 0,I donnot know the reason,then I try to change the 65535 to 1024 ,2048..which the translation length is much less than 65530,then I can get the "result" which the value is "0". 

 

in short ,can I translate image data using SGDMA like the above way?which details I have overlook?  

 

 

thanks !
0 Kudos
Reply