Correct. But remember that if/when you start adding more interrupt sources you need to determine which one it was that tripped so checking the interrupt flag is probably good practice. But as have been said, it's not strictly needed in this case.IF INTCON.2=1
is not needed in the interrupt routine, that is what send the code there in the first place.
You seem to have a GOTO Main inside the ISR - you can do that but it is probably not a good idea as it will restart from the beginning of the program and not where it got interrupted. This MAY not be a problem in THIS particular program but can cause some interesting results so - try not to do that.
Have a look at this:
/Henrik.Code:DISABLE TLOOP: IF INTCON.2 = 1 THEN 'TMR0 Interrupt? I = I + 1 'Increment counter IF I = 100 THEN 'Has it reached 100? TOGGLE GPIO.2 'If so, toggle LED... I = 0 '...and reset counter ENDIF INTCON.2 = 0 'Reset interrupt flag ENDIF RESUME 'back to work. ENABLE




Bookmarks