PDA

View Full Version : Strange HSEROUT execution times



SteveB
- 21st May 2006, 07:13
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:


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


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:

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

mister_e
- 21st May 2006, 08:40
the main difference reside in the overflow of TMR1 + time to send a Byte. Do the same thing but remove the For To Next loop... how about now?

SteveB
- 21st May 2006, 18:34
Thanks steve. It was late, my eyes were crossed and I could not see the forest for all the trees! I played with the prescale and overflow/interupt flag and got something workable.

Steve B