You may use any of the following methods: a) use tmr0 to increment on external pulse on RA4. b) test your port to detect a rising edge or fulling edge c) use interrupts to detect a rising edge or state change Read option register configuration bits to find out how to set TMR0 with external counter. More later. Norayr