Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,408 Views

alt_avalon_sgdma_construct_mem_to_mem_desc()

hi: 

"alt_avalon_sgdma_construct_mem_to_mem_desc()"can only transmit the number of data smaller than 65535 bytes ,so if I want to transmit data which the number is larger than 65535,how I can realize it? 

the following is the code which I have a try,but the niosII software always "suspend". 

 

for(i=0;i<=1;i++) 

alt_u32 *write_addr = (alt_u32 *)(DDR_SDRAM_BASE+0xDFFC*i); 

usleep(100000); 

alt_avalon_sgdma_construct_mem_to_mem_desc( 

&desc[0],  

&desc[1],  

read_addr, 

write_addr, 

65530, 

1, 

0); 

alt_avalon_sgdma_do_sync_transfer(sgdma_sdram, &desc[0]); 

when i=0,the 65530 bytes data transmits OK,but when i=1,the code seems to stop(cannot excute the following code). 

 

 

thanks ~
0 Kudos
6 Replies
Altera_Forum
Honored Contributor I
46 Views

Use the modular SGDMA available on altera.com. Just search for modular dma. 

 

Or, do what you are doing, but you can only initiate the transfer after all the descriptors are created. Then  

 

alt_avalon_sgdma_do_sync_transfer(sgdma_sdram, &desc[0]); 

 

The reason the second call fails, is the first transaction has to complete the way you are calling it. 

 

--dalon
Altera_Forum
Honored Contributor I
46 Views

how to created all the descriptors?is the following code right? 

 

/////////////////////////////////////////////////////////////////// 

alt_u32 *write_addr_1 = (alt_u32 *)(DDR_SDRAM_BASE); 

alt_u32 *write_addr_2 = (alt_u32 *)(DDR_SDRAM_BASE+0xDFFC); 

 

alt_avalon_sgdma_construct_mem_to_mem_desc( 

&desc[0],  

&desc[1],  

read_addr, 

write_addr_1, 

65530, 

1, 

0); 

 

alt_avalon_sgdma_construct_mem_to_mem_desc( 

&desc[2],  

&desc[3],  

read_addr, 

write_addr_2, 

65530, 

1, 

0); 

 

alt_avalon_sgdma_do_sync_transfer(sgdma_sdram, &desc[0]); 

 

////////////////////////////////////////////////////////////////// 

I have try both the DMA and sgdma, but I can only transmit the limited number of data(cannot use "for-loop" to translate larger data ), maybe I overlook configurating some registers or someting,I have read manualbook several times,and fanally failed,is there some advise for me,thanks~
Altera_Forum
Honored Contributor I
46 Views

I have realize the 320*240pixels data transmition,which the number of data is much larger than 65535,the code is as below: 

 

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

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, 

65530, 

1, 

0); 

alt_avalon_sgdma_do_async_transfer(); 

 

(PS: buffer_counter is the type of "alt_u32") 

 

////////////////////////////////////////////////////////// 

there is a question I am not understand: 

 

how to know the SGDMA transmition is over?  

I use the "alt_avalon_sgdma_register_callback" ,then add the code below after "alt_avalon_sgdma_do_async_transfer();",but the software seems stall there,so I hope someone could give me some advise!~ 

 

while(tx_done == 0) {} 

printf("The transmit SGDMA has completed\n");
Altera_Forum
Honored Contributor I
46 Views

what exactly do you mean by "can only transmit the limited number of data"? What happens when you try to send more? I don't see any for loop in the code you shown. 

If you use the alt_avalon_sgdma_do_sync_transfer() (and not the async version) it will only return once the transfer is finished.
Altera_Forum
Honored Contributor I
46 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 !
Altera_Forum
Honored Contributor I
46 Views

Use the sync function. The second call probably fails because the SGDMA is still transferring the first bunch of data. 

Just don't forget that the sync function's return value is different that the async function. It returns the SGDMA's status vector, so it won't be 0.