Creating a 1KHz clock O/P

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.