Electrical – why many timers in microcontrollers

microcontrollertimer

I was going through timers in pic and found that there are so many timers available in micro controllers. For example a PWM time base is driven by Timer2. My doubt is why there are so many timers? Why cannot be there a single timer for example just timer1 alone for the complete micro controller.

Best Answer

Because embedded systems often need to generate time intervals with many different periods or frequencies, for things like:

  • internal timekeeping
  • sampling analog signals
  • generating pulse trains (including PWM)
  • serial communications of various types (UART, SPI, I2C, etc.)

Having dedicated timers for each of these means that the operation is more autonomous, and fewer CPU cycles need to be spent on keeping them going.