hello,
i wanted to test an interrupt in a simple small code , i found a code on the internet and modified it and got this:
@ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF
DEFINE OSC 4
OSCCON=%01101000 ' INTRC = 8MHz
ANSEL=%00000000
CMCON=%00000111
OPTION_REG.6=1 'Trigger on rising edge
INTCON = %10010000 'Enable INTE
INTCON.1 = 0 'Clear RB0/INT External Interrupt Flag bit
On Interrupt Goto UpdateCounter
PORTB=0 ' PORTBs are outputs
Pause 500 ' Wait for startup
'LOW PORTB.6
loop:
low portb.6
HIGH PORTB.5
Pause 2000 ' Wait 2 second
low portb.6
LOW PORTB.5
Pause 2000 ' Wait 2 second
Goto loop ' Do it forever
Disable
UpdateCounter:
LOW PORTB.5
HIGH PORTB.6
pause 500
low portb.5
LOW PORTB.6
pause 500
INTCON.1=0 're-enable interrupts
resume
ENABLE
GOTO loop
END
the code works, but the interrupt routine doesn't work, doesn t light the led connected to pin portb.6.
I mean when the portb.0 is connected to ground the led connected to portb.5 blinks as soon as i connect the portb.0 to +5v the portb.5 stops to blink and nothing happens to portb.6 led.
can you help me on that please???
how can I use a digital signal to activate the interrupt for example, with an if statement??
if portb.0 = 1 , the interrupt is activated and the program jumps to the int subroutine and if portb.0 = 0 the program comes back to the main loop???????
please can any one help me??
thank you
Bookmarks