I was curious how long it would take to output a data series to my PC. So I set up some code for a test. I am using an 18F4620 @ 40MHz and 38400 baud. The Storeout() array is initialized with values between 33-122 (printable ASCII). I then used Darrel's code from this thread to time the output. Here are the key lines from my code:
Now, here is the strange thing. As above, it takes 4099.4uS to execute (with no variation regardless of actual values being sent). However, if I change the HSEROUT line by adding an additional value, like so:Code:gosub ClearTimer1 @ bsf T1CON, TMR1ON ' Start timer for count = 0 to 527 hserout [Storeout(count)] next eccrow @ bcf T1CON, TMR1ON ' Stop timer Hserout ["Serial Out Time = "] Gosub ShowTime
hserout [Storeout(count),0]
it only takes 1641.8uS to execute (with any value after the comma).
Note: Everything else about this works exactly as expected.
Any ideas why this is happening?
Steve B
Bookmarks