The advance() function updates the time0 variable and then sets the output
pins to the corresponding state for the next step. If an interrupt service
routine gets executed after time0 has been updated but before all pins
have been set correctly, the duration of the next state will be shortened
by the time it took to service the interrupt. This can result in missed
steps.
This change moves the update of the time0 variable to the end of advance().
This errs on the side of longer instead of shorter delays when interrupts
are handled while advance() is being executed.
The advance() function updates the time0 variable and then sets the output pins to the corresponding state for the next step. If an interrupt service routine gets executed after time0 has been updated but before all pins have been set correctly, the duration of the next state will be shortened by the time it took to service the interrupt. This can result in missed steps.
This change moves the update of the time0 variable to the end of advance(). This errs on the side of longer instead of shorter delays when interrupts are handled while advance() is being executed.