Quote Originally Posted by Optech View Post
I have removed some of the code for clarity but the basis of the program is as follows
That's probably the problem right there. You aren't helping us by doing that...

I can think of a few things that'll cause the timing to be off, but not to the tune of 4-5ms (i.e. not accounting for the time spent doing other instructions which also take time to accomplish, oscillator being out of tune, the list goes on).