mig29fulcrum
Junior Member level 1
Hi
I wanna use a switch to toggle one pin using external interrupt(INT0) and I'm running a simulation in Proteus,but switch does not work.i found that when i add "bsf INTCON,INT0IF" before"bra $" i have an interrupt and after that nothing happens.
I will appreciate if you help me with this .
TNX...
I wanna use a switch to toggle one pin using external interrupt(INT0) and I'm running a simulation in Proteus,but switch does not work.i found that when i add "bsf INTCON,INT0IF" before"bra $" i have an interrupt and after that nothing happens.
I will appreciate if you help me with this .
TNX...
Code:
list p=18f4550
#include p18f4550.inc
config FOSC=INTOSC_EC
config WDT=OFF
;===========jump to main=============
org 0h
goto main
;===========jump into ISR============
org 8h
goto isr
;============main program============
org 100h
main
bcf TRISD,0 ;led
bsf TRISB,INT0 ;switch
bsf INTCON,GIE ;global interrupt enable
bsf INTCON,INT0IE ;RB0 interrupt enable
bra $
;===================ISR==============
org 200h
isr
btfss INTCON,INT0IF ;ckeck for interrupt
retfie ;if no then return
btg LATD,0 ;toggle led
bcf INTCON,INT0IF ;clean interrupt flag
retfie
end