I have been trying to find the easiest way to create a 1KHz clock to clock a digital pot. It doesn't have to be super accurate and it also doesn't have to have a 50/50 duty cycle. I want to try using this on an ATTiny 25/45/85. I saw something about a tone library and it seems pretty simple.
And the question was ease of use. I have been reading so many threads that seem to make it so difficult using timers and prescalers, I am guessing thats what the Tone lib does.
I missed you are not using it well. For better consistency you should use
timer+=interval;
instead of
timer=micros();
If you add anything nontrivial to your code the frequency will decrease.
That pot can be clocked at up to 50MHz; again, why 1kHz +/- 20Hz? What's special about the clock rate? What in your code/project requires this specific clock rate?
Also, if you used tone() or a direct timer manipulation, how do you determine how many clock pulses are sent? You've only got 64 steps to work with after all...