My platform is the Arduino DUE.
I know that the timer counts up to a certain value, then generates an interrupt.
In the Arduino DUE, you can specify the timer value. In other words, you can specify the frequency of the intterupts. You can do this via the
TC_SetRC(tc, channel, rc) function.
My question is how code flows in general. Obvisouly the arduino runs the setup function first. After that it jumps to loop. But when does tghe timer starts counting down? When you first jump to loop? Can you figure out how many instructions will be executed in the loop function, before a call to a timer interrupt is performed, for the given frequency you have specified?
After the interrupt is fired, all the code in the interrupt is run. Then code flow jumps back to loop()? And when the timer starts counting again? At the same time the code jumps to loop?
If you set up the timer interrupt frequnecy too high, do you run the risk of having code in you loop functin not run at all? (If, for example, you have lots of code inside the loop()).
In that case, would it be wise to put code that you would generally put inside the loop(), inside a timer interrupt?