Hi, Rubik

a 555 running at 40 khz would easily solve your headache ...without any program timing difficulties ...

Alain