Fix loops running quicker than timer
This fixes the freezes that can occur when the control loop loops quicker than the timer frequency by first checking if the timer event has already happened before waiting.
Would appreciate if it can be confirmed that this fixes things.
Edited by Vivian Roest