Reading and generating square waves at the same time.

Good call, I was getting some drift with the output v input, I changed the code and now they are acting like that are locked in phase. NICE! I guess the way i had it any errors were compounding over time where now each time it is resetting. I did not even think about that.

But the problem is still there, I think you are right i don't need to use interrupts for the input, The library does state it is made to use with interrupts.

I think jitter in the output would be a more accurate description of what i am having problems with. At 120hz i am getting .9hz jitter and at 500hz i am getting 10HZ. I need it to have less than 1hz jitter at 5khz. It seems the jitter gets worse as the frequency gets higher.

Is there a more accurate way to make a square wave that i can change on the fly?