Bruce
Let me take one step back.
Here is the code I used originally to test my PCB
You said I was clearing the RB0 flag which I agree with but unless I clear this the program doesn't work!!
If I use the INTCON.0 = 0 the code doesn't work but using INTCON.1=0 makes the program work.
I'm very confused and going round in circles as what I would expect to work doesn't. Do I need to enable the Global interrupt GIE INTCON.7=1 before exiting the ISR?
I've reread the 16f877 data sheet and what I'm doing shouldn't work, but it does.
Rob
***************************************
DEFINE LOADER_USED 1 'Boot Loader
'Define inputs held low by external resistors
sw1 VAR PORTB.6
sw2 VAR PORTB.4
SW3 VAR PORTB.0
' Define the pins that are connected to LEDs
led1 VAR PORTC.0
led2 VAR PORTC.1
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
on interrupt goto ISR
main: ' main program begins here
' Check any button pressed to toggle on LED
NAP 7 ' Go to sleep. When the watchdog is
' disabled, NAP won't wake up until
' an interrupt occurs.
GoTo main ' Do it again upon waking
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
'***HERE*************
'INTCON.0 = 0 ' Clear the RB port change flag bit( this doesn't)
INTCON.1 = 0 ' Clear interrupt flag (this works)
RESUME
ENABLE
Bookmarks