Goal: Move stepper motor 1 microstep every 750 microSeconds.
Need: Code to do this
If I understand the documentation correctly, the micros() function only works with multiples of 4, which does not work with my timing requirement (which I have also proven with my prototype board)
There is a fair amount discussion at AVR level about enabling higher resolutions for reading input but I am having difficulty finding one for output AND,
Also, I cannot speak at AVR levels and much of the discussion is quite beyond me.
Anyone have any code that can accomplish my goal?
Right now I am using simple digitalWrite commands to step the motor, and not using any stepper control libraries (different issue on another post).
The number 750 gives 187.5 when divided by 4. That suggests that using micros() for timing should give an error of about 2µsecs. That's only 0.27%. And if you accumulate the count of micros() the error will not accumulate. In other words if the first movement is 2µsecs in error the next move will probably be exactly on time.
The reason micros() works at 4µsec intervals is because anything shorter would absorb too many CPU cycles.
If the small error using micros() is unacceptable you can probably use one of the Hardware Timers to give you a 750µsec interrupt interval - provided, of course, that it does not occur in the middle of a micros() interrupt
Just to note, the STM32F103C8T6 has a clock of 72MHz, which can make things faster to run, than in an ordinary arduino of 16MHz. And it can still be programmed with the Arduino IDE
Goal: Move stepper motor 1 microstep every 750 microSeconds.
Need: Code to do this
If I understand the documentation correctly, the micros() function only works with multiples of 4, which does not work with my timing requirement (which I have also proven with my prototype board)
No, 4us resolution is perfectly adequate. The steps are 750 us apart, 4 us is way down in the noise and
irrelevant. 100us resolution would probably work in fact, certainly for small microsteps.