Hi,
If you look at the datasheet you can find that the hardware TIMERS can be used in 2 different ways (timer or counter).
In the counter setup you have an external signal (TMR0 CLOCK INPUT for ie timer0) that will increment the counter on a selectable edge (rising or falling edge).
This way the hardware is counting everything in the background and after you have setup the counter in the SW you dont have to care at all about it until you want to read the counted number.
Just make sure you choose a timer that fits your biggest counted number. Some counters have 8 bit and some are 16 bit. As long as you make sure you do not overflow the counter it will not miss a single edge regardless what you do in your code.
Bookmarks