Accuracy is very important in Real-time applications. Especially with time-critical applications. so whenever we need something time critical we always need accurate timings. In such cases, we cannot rely on nop instructions based delays. We need something more powerful and more accurate. To handle this kind of errors we always use hardware-based timers. luckily Microchip pic have built-in hardware-based timers circuitry.
Most of the Microchip’s PIC16F family have 3 hardware-based timers.
1. Timer 0
2. Timer 1
3. Timer 2
In case of Timer 0, it is the 8-bit timer with high priority interrupt. So it is used for creating short delays. Timer 2 is also 8-bit timer but timer 1 is 16bit, so it is spanned on two 8-bit registers as the Microchip PIC16 family is 8bit family.
These timers also associated with some other hardware peripherals like compare and capture module for creating PWM or for capturing the length of the pulse.
On the other hand, Special timer interrupts are provided so that time-critical applications don’t lose even a single clock cycle of the microcontrollers.