You do realize the operating system is constantly interrupting your code?
It's almost impossible to get a clean pulse train out of a Raspberry Pi if it's strictly software generated.
The multi-tasking OS is constantly stealing CPU cycles in an unpredictable way, in short, it's a total fail for any precision timing task.
Try this simple experiment:
Write the simplest program to output a square wave, set pin HI, Delay, set pin LOW Delay (repeat in loop).
Watch the horrible jittery mess that comes out with an oscilloscope.
It's almost impossible to get a clean pulse train out of a Raspberry Pi if it's strictly software generated.
The multi-tasking OS is constantly stealing CPU cycles in an unpredictable way, in short, it's a total fail for any precision timing task.
Try this simple experiment:
Write the simplest program to output a square wave, set pin HI, Delay, set pin LOW Delay (repeat in loop).
Watch the horrible jittery mess that comes out with an oscilloscope.