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++
12600 Discussions

Timing DMA routines and wondering about measurements observed.

Honored Contributor II

I have a "free standing" NIOS II design with hard PCIe connecting to a host system. 


The NIOS II code processes descriptors generated by the host ARM system and uses the Avalon MM DMA controller to perform data movement when the  

descriptor requires it ... ( the descriptor may request other non-data movement tasks for the NIOS II to perform ). 


I used one of the user_LED's on the Arria V starter kit to measure time in various code sections. 


I am trying to understand the numbers as they look too large. The bulk of the time is in the alt_dma_rxchan_prepare (rxchan,rx_buffer,64,done,NULL) routine, 

then alt_dma_txchan_send (txchan,tx_data,64,NULL,NULL) and a small time waiting for rx_done to be set by the callback routine. 


As a sanity check , toggling the LED was achieved in about 2 uS. 

I can debug through the code, but suspect something else is at play. 


In addition, the 1.5 uS waiting for the rx_done to be set, is very repeatable, BUT on occasions it gets stretched out to a much longer value like an 

interrupt service routine went active and interrupted normal activity. I can try to turn off all console output as I would think only the JTAG_UART could  

involve such long delays. 




Thanks in Advance, Bob Dixon. 





/* Post the transmit request */ 

// 29 uS 

leds = 0xFFFF; // all on 


if ((rc = alt_dma_txchan_send (txchan,tx_data,64,NULL,NULL)) < 0) 

printf ("Failed to post transmit request, reason = %i\n", rc); 

exit (1); 

leds = 0x0000; // all off 


/* Post the receive request */ 

// 87 uS 





if ((rc = alt_dma_rxchan_prepare (rxchan,rx_buffer,64,done,NULL)) <0 ) 

printf ("Failed to post read request, reason = %i\n", rc); 

exit (1); 


// printf ("Passed post read request\n"); 





/* wait for transfer to complete */ 

// 1.5 uS 

while (!rx_done) 

printf ("Waiting on rx_done = %i\n", rx_done); 



// printf ("Transfer done!\n\n");
0 Kudos
0 Replies