These routines
need to be extremely fast to execute, and it is often best to simply set a number of flags or states within the Interrupt Service Routine, then evaluate them when required in your normal thread code in loop().
only fire when the configured timer overflows
are restricted to a small number of timers depending on the MCU hardware in use.
can only set values to variables declared with VOLATILE, which ensures they arent optimized away, and can be used reliably in the ISR and in the main loop() code
NOTE - Timer interrupts may interfere with other functionality (PWM for example) depending on the timer chosen to configure.
e.g. ESP8266 gas 2 x Timers available:
0 (Used by WiFi), 1 is available to configure.
e.g. Arduino Uno has 3 x Timers available:
Timer0 - An 8 bit timer used by Arduino functions delay(), millis() and micros().
Timer1 - A 16 bit timer used by the Servo() library
Timer2 - An 8 bit timer used by the Tone() library
The Mega boards have Timers 3,4,5 which may be used instead
hope this helps