Is there a better way to sleep/delay other than what basically seems like 100% CPU usage in a subtraction loop?
This would take a fair bit more code to configure the timer, and setup an interrupt to handle the timer.
Using the interrupt driven approach, can led to better performance both in CPU time (async communication with slower periphials etc) and battery life (sleep states).
Here is an example in C using libopencm3, that uses timers to trigger an interrupt used to flash LEDs https://github.com/libopencm3/libopencm3-examples/tree/maste...