Thanks Darrel that clears up why things were not working as I expected!
Most things are working great now except one very strange thing. The LED that is to be used to indicate this interrupt state (on RB0) works fine when RB3 has initiated the interrupt however when RB2 has initiated the interrupt when I attempt to flash RB0 it somehow turns off RB2 which is the pin that was changed from an input to an output and made high.
In the code shown below I am using the wrong LED (RA6) to indicate the RB2 interrupt condition and everything works fine other than the wrong LED flashing.
I am thinking that there is some strange property that RB0 has but I am very confused why it doesn't mess up when RB3 has initiated the interrupt.
Code:
;the following is the interrupt routine
ASM
intRoutine
;turn off interrupts
MOVLW b'00000000'
MOVWF INTCON
;disable all interrupts that were previously enabled
MOVLB 0x07 ;select BANK 7
MOVLW b'00000000'
MOVWF IOCBP
;RB3 is currently an input, change it to an output and make it high
;prior to this operation TRISB would be 11111110
MOVLB 0x01 ;select BANK 1
MOVLW b'11110110'
MOVWF TRISB
;turn on RB3 (doesn't go high)
MOVLB 0x00 ;select BANK 0
BSF PORTB,3
;turn off detection power (this is working fine)
BCF PORTA,0
;check to see what tripped the interrupt
;IOCBF.2 = detection
;IOCBF.3 = lighting
MOVLB 0x07 ;select BANK 7
BTFSS IOCBF,3
GOTO detectionFlash
GOTO lightingFlash
lightingFlash
MOVLB 0x00 ;select BANK 0
BSF PORTB,0
CALL Delay
BCF PORTB,0
CALL Delay
CALL Delay
GOTO lightingFlash
detectionFlash
MOVLB 0x00 ;select BANK 0
BSF PORTA,6 ;this is the wrong LED but works properly when this one is selected instead of PORTB,0
CALL Delay
BCF PORTA,6
CALL Delay
BSF PORTA,6
CALL Delay
BCF PORTA,6
CALL Delay
CALL Delay
GOTO detectionFlash
endASM
Bookmarks