Quote Originally Posted by Bruce View Post
You need to enable the interrupt.
Code:
TRISA = %00010000    ' Set PORTA.4 (TOCKI) to input for timer0

   OPTION_REG = %00111000 
   'Transition on TOCKI (RA4), 
   'Increment on falling edge
   'Prescalar assigned to WDT for a 1:1 TMR0 ratio.
   INTCON.2 = 0 ' Clear Timer0 int flag
   INTCON.5 = 1 ' Enable Timer0 int
   TMR0 = $FF   ' Set TMR0 to 255.  So one more tick and TMROIF will be set.

   ON INTERRUPT GOTO LapCount
Main:
   ' Do something here
   goto Main

   disable
LapCount:
   If INTCON.2 = 1 then
   i = i + 1
   endif
   toggle PORTB.3
   TMR0 = $FF      ' Indicate we're in interrupt handler
   INTCON.2 = 0    ' Clear TMR0 Interrupt Flag (Bit 2)
   
   Resume 
   Enable
Place a 10K pull-up resistor on RA4. Have your input switch ground RA4 when pressed to toggle RB3 (or any available port pin).
I test and work fine , but i see a problem(
I connect a button to RA4.When push the button one time the i increment +1 and after release the button the i increment one +1 again.Why;