abbtech
- 15th February 2011, 22:37
I am using a 16F1827 I need to use the ASM style interrupt routine to free up some program space. There are two pins that will fire if they go high. Either fires the interrupt properly, the existing output can be turned low properly but for some reason changing the input to an output and making it high is not functioning and the LED flashing routine doesn't change based on the interrupt as it should. I am sure I am missing something simple but I just can't seem to figure it out...
The interrupt is very simple, all I am needing to do is:
Change an input to an output
Make the new output high
Make an existing output low
Determine which one of two interrupts got tripped and goto a LED flashing routine for user feedback
Continue in an endless loop flashing the indication LED
'setup the interrupts
DEFINE INTHAND intRoutine 'where to go when an interrupt fires
IOCBP = %00001100
INTCON = %10011000 ' Enable interrupt
;the following is the interrupt routine
ASM
intRoutine
;turn off interrupts
MOVLW b'00000000'
MOVWF INTCON
;disable all interrupts that were previously enabled
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
MOVLW b'11110110'
MOVWF TRISB
;turn on RB3 (doesn't go high)
BSF PORTB,3
;turn off detection power (this is working fine)
BCF PORTA,0
;check to see what tripped the interrupt
;(this always goes to detectionFlash even when lighting activated the interrupt)
;IOCBF.2 = detection
;IOCBF.3 = lighting
BTFSS IOCBF,3
GOTO detectionFlash
GOTO lightingFlash
lightingFlash
BSF _overCurrentLED
CALL Delay
BCF _overCurrentLED
CALL Delay
CALL Delay
GOTO lightingFlash
detectionFlash
BSF _overCurrentLED
CALL Delay
BCF _overCurrentLED
CALL Delay
BSF _overCurrentLED
CALL Delay
BCF _overCurrentLED
CALL Delay
CALL Delay
GOTO detectionFlash
endASM
The interrupt is very simple, all I am needing to do is:
Change an input to an output
Make the new output high
Make an existing output low
Determine which one of two interrupts got tripped and goto a LED flashing routine for user feedback
Continue in an endless loop flashing the indication LED
'setup the interrupts
DEFINE INTHAND intRoutine 'where to go when an interrupt fires
IOCBP = %00001100
INTCON = %10011000 ' Enable interrupt
;the following is the interrupt routine
ASM
intRoutine
;turn off interrupts
MOVLW b'00000000'
MOVWF INTCON
;disable all interrupts that were previously enabled
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
MOVLW b'11110110'
MOVWF TRISB
;turn on RB3 (doesn't go high)
BSF PORTB,3
;turn off detection power (this is working fine)
BCF PORTA,0
;check to see what tripped the interrupt
;(this always goes to detectionFlash even when lighting activated the interrupt)
;IOCBF.2 = detection
;IOCBF.3 = lighting
BTFSS IOCBF,3
GOTO detectionFlash
GOTO lightingFlash
lightingFlash
BSF _overCurrentLED
CALL Delay
BCF _overCurrentLED
CALL Delay
CALL Delay
GOTO lightingFlash
detectionFlash
BSF _overCurrentLED
CALL Delay
BCF _overCurrentLED
CALL Delay
BSF _overCurrentLED
CALL Delay
BCF _overCurrentLED
CALL Delay
CALL Delay
GOTO detectionFlash
endASM