Hi All
I'm away on holiday programming by torch light in the middle of a forest (seriously) and only have web access via a mobile phone. I've tried finding my answers in the archieves but with no joy so forgive me for asking a question which has probably been asked elsewhere.


I'm using a 16f877 20MHz with all the RB ports held high using external resisitors.
I have a tri coloured LED connected to RC0 & RC1 and Ground.

My problem is the Interrupt routine below works fine and turns the LED on and off.However when the interrupt occurs I need to call another routine. As soon as I add any other command into the routine it appears to permanently call the routine! and screws everything else up although the LED's still work OK.

I happy that the RB pins are not changing state so why is my interrupt routine running! am I not clearing a flag somewhere?
or am I missing something very obvious?
I've made sure I have no other references to the RB pins in my code and the ISR can not be executed by the code running into it as it is at the end of my code.
if I remove the "ON INTERRUPt" line the rest of my code functions normally and the LEDs stop working.

Rob
(desperate of Hampshire)


'Interrupts stuff********************************************* *
TRISB = %11111111 ' Set PORTB to all input
INTCON.3 = 1 ' Enable the RB port change interrupt
OPTION_REG = $7f ' Enable PORTB pull-ups
'TRISC = %00000011 ' Set PORTB.0-2 (LEDs) to output, 3-7 to input

sw1 VAR PORTB.6
sw2 VAR PORTB.4
'SW3 VAR PORTB.7
' Define the pins that are connected to LEDs
led1 VAR PORTC.0
led2 VAR PORTC.1
ON INTERRUPT GOTO ISR




****BIG SNIP************
RETURN
DISABLE
:ISR

IF sw1 = 1 Then
high LED1

else
low led1
endif

IF sw2 = 1 Then
HIGH led2
else
low led2
endif

IF sw3 = 1 Then
HIGH led1
HIGH led2
else
low led1
low led2
endif

TempwData var WORD
Tempwdata = wData 'stores the current wdata pointer

************HERE the problem happens********************
if (sw1 = 1) then
wData = 7*256 + 0 : GOSUB Send
wData = $1F00 + $62 : GOSUB Send
else
wData = 7*256 + 0 : GOSUB Send
wData = $1000 + $0b : GOSUB Send 'b
endif
wdata = TempWData 'Restores the original wdata pointer

INTCON.1 = 0 ' Clear interrupt flag xxxxx
resume
ENABLE