https://embetronicx.com/tutorials/microcontrollers/pic16f877a/pic16f877a-timer-tutorial/
PIC16F877A - Timer/Counter Tutorial