Hi, im trying to understand how to use ON INTERRUPT, so I created this little program:

Code:
@ device pic16F628A, intrc_osc_noclkout, wdt_on, mclr_off, protect_off
DEFINE OSC 4

trisb   =%00110000
trisa   =%00000000
'ansel   =%00000001  
cmcon   =%00000111  'Comparators Off
vrcon   =%00000000
intcon  =%10101000  'interrupts enable    
OPTION_REG =%01010001     

but1    var trisb.4
but2    var trisb.5
ledwork var trisa.0
led1    var trisa.1
led2    var trisa.2
led3    var trisa.3
rs      var trisa.5


conta   var byte


on interrupt goto interrupcion

;SerOut rs,2,[10,13]
;SerOut rs,2,["inicio"]
;SerOut rs,2,[10,13]

enable
loop:

;disable
;SerOut rs,2,[10,13]
;SerOut rs,2,["Loop"]
;SerOut rs,2,[10,13]
;enable

for conta=0 to 255 step 16  'working led rise routine
    pwm ledwork, conta, 10  
next conta
high ledwork

for conta =0 to 100
    pause 10
next conta

low led1    'set status buttons leds off
low led2
low led3

for conta=0 to 255 step 16  'Fall routine
    pwm ledwork, 255-conta, 10 
next conta
low ledwork

for conta =0 to 100
    pause 10
next conta

low led1   'set button status leds off
low led2
low led3

goto loop

end
disable 
interrupcion:
;SerOut rs,2,[10,13]
;SerOut rs,2,["Interrupt"]
;SerOut rs,2,[10,13]
    intcon.0=0
    intcon.1=0
    intcon.2=0
        if but1=1 then
            but1=0
            high led1
        endif
        if but2=1 then
            but2=0
            high led2
        endif
high led3   
    resume
enable
The idea is to trigger an interrupt when any of the buttons (but1 & but2) are pressed, to show the status a led (led1 & led2) is turned on for a second and off again. led3 is used as a way to know an interruption has been triggered.

To simulate a real loop the "payload" of the program is a PWM pulse on ledwork

There are serouts all over the place, but since I cant make the basic version to work, these are commented out.


IMHO this program should work, but it doesn't. Could someone guide me in the right direction to fully understand how this should work?

Thanks!