Like I said, it turns ON again because YOU turn it on in your main loop - continously. If you don't want it to turn on again then stop turning it on. Set it one time, before you enter the loop.
If you want it to trig (turn off the LED) with an interrupt but then start "working" again as soon as the fault signal "goes away" then simply read the state of the pin in your Main routine and turn on the LED once it's high:
Code:
Main:
If PortB.0 = 1 THEN 'Turn on LED only when signal is high.
HIGH LED
ENDIF
'Do whatever else needs to be done.
Goto Main
If want it to trig with an interrupt and stay off untill another input "restart it" then use a flag/semaphore:
Code:
FAULT VAR BIT
LED VAR PortC.4
Restart VAR PortC.5 'Pulled up thru resistor, pull to GND to "activate"
High LED
Main:
If Fault = 1 then 'If we are in fault state...
If Restart = 0 then '...we check the restart button....
HIGH LED '....if it's pressed we turn LED on again...
Fault = 0 '...and reset the fault flag/state
ENDIF
ENDIF
'Do whatever else here.
Goto Main
Then, in your interrupt routine you turn off the LED and set the Fault flag, like:
Code:
LOW LED
Fault = 1 'Set flag
Finally, be careful with the word Loop as a label, in newer versions of PBP that is a reserved word and can't be used as a label, what version are you using.
Bookmarks