guanyu
Newbie level 2
Hello.
Why is it that whenever the ISR is executed in my code, it does not seem to return to the main loop?
I intended my code to function like this: RA0 led will continuously blink and whenever a bit change occurs in RB0, the RA0 LED will stop blinking and the RA1 LED will blink two times and return to wherever it left on the main loop. But the problem is that after blinking two times, the RA0 led does not blink anymore.
Can anyone help me?
Why is it that whenever the ISR is executed in my code, it does not seem to return to the main loop?
Code:
#include "p16f84a.inc"
__CONFIG _HS_OSC&_PWRTE_ON&_WDT_OFF&_CP_OFF
cblock 0X20
d1
d2
d3
TEMP
endc
org 0x00
goto main
org 0X04
goto ISR
ISR
bcf INTCON, GIE
movfw PORTA
movwf TEMP
bsf PORTA, 1
call Delay
bcf PORTA, 1
call Delay
bsf PORTA, 1
call Delay
bcf PORTA, 1
call Delay
movfw TEMP
movwf PORTA
movlw 0x00
movwf PORTB
bcf INTCON, INTF
bsf INTCON, GIE
retfie
main
BSF STATUS,RP0
BCF STATUS,RP1
movlw 0x00
movwf TRISA
movlw 0xFF
movwf TRISB
BCF STATUS,RP0
clrf PORTA
clrf PORTB
BSF INTCON, GIE
BSF INTCON, INTE
BCF INTCON, INTF
loop
bsf PORTA, 0
call Delay
bcf PORTA, 0
call Delay
goto loop
Delay
movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
goto $+1
goto $+1
goto $+1
return
end
I intended my code to function like this: RA0 led will continuously blink and whenever a bit change occurs in RB0, the RA0 LED will stop blinking and the RA1 LED will blink two times and return to wherever it left on the main loop. But the problem is that after blinking two times, the RA0 led does not blink anymore.
Can anyone help me?