I'm working with a virtex-ii pro board. I don't have previous embedded system experience, so I have some wonders about the execution time I measured. I use XTime_GetTime() function in xtime_l.h to retrieve the execution time of the part I want to take the measurement. The following is a simple example I experimented.
Alan is most likely on the right track. The program is slowed down by printing to the Uart.
Looking at the numbers I'd say the speed of your UART is 115200 baud. Taking the start and stop bits into account it takes 10 bits to transfer a character resulting in 11520 characters per second maximum throughput on the UART. The program prints 15 characters for the start message, i.e. the program has to wait 14 times before it can print the next character. Thus, the number of cycles it takes to print the start message can be calculated by:
14 characters / 11520 characters per second * 300000000 cycles per second = 364583 cycles
That's pretty close to your measured numbers.
To improve the situation you can:
- use a UART with a buffer (ie. 16550). The hardware will buffer up the characters and send them at the appropriate time. Works for short strings.
- use an interrupt driven UART, ideally combined with a buffer. Software and hardware will buffer the characters and send them at the appropriate time. The buffer in the UART helps to limit to number of interrupts.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.