Well, I bet this has been asked a million times before, but I haven't been able to find it.
I'm looking for a delay. A pretty special delay, since it will generate pwm cycles on the parallel port.
Sleep() tends to be bad, since windows doesn't manage timeshares pretty good. And it's pretty slow, too.
I've got a dual core at 3Ghz, so I'm sure I can definitely pull out something more than 1ms (1khz). I'm aiming for 20khz, so it will be outside the audible spectra, since it will control stepper motors and they will make sounds
I was thinking - a loop, but it's definitely going to be a big one. How can I 'calibrate' this loop, so that in a second it will give out x pulses on the parallel port? I know how to interface the port and generate the frequency and pwm, but I'm not able to find a method for computing the delay.
Any ideas? Thanks.
Edit: Oh, and I don't really mind if it will go to 100% cpu usage.