Can a Flowcode DELAY be terminated via a hardware interrupt?
I want to be able to bail out of a long delay via a hardware interrupt (using the INT0 pin on a PIC16F88).
The application is a fairly trivial timer, so the simple DELAY function is quite suitable rather than having to use a timer macro based on one of the chip's internal timers.
However, I gather that DELAY is implemented in code via a loop of NOOP instructions, so I guess the return from interrupt will continue execution from where it broke off within that loop, rather than after the delay loop itself -- is that true?
Can a Flowcode DELAY be terminated via a hardware interrupt?
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Can a Flowcode DELAY be terminated via a hardware interr
You are right, an interrupt does not terminate a delay.
A simple solution would be to use a loop with delay in it, use and use a flag variable to terminate the loop. Set the flag variable to a value that exits the loop in the interrupt.
Something like:
terminate=false (global boolean variable)
count=0
while not terminate and count < 1000
delay 10ms
count = count+1
end loop
And in the interrupt routine:
terminate = true
A simple solution would be to use a loop with delay in it, use and use a flag variable to terminate the loop. Set the flag variable to a value that exits the loop in the interrupt.
Something like:
terminate=false (global boolean variable)
count=0
while not terminate and count < 1000
delay 10ms
count = count+1
end loop
And in the interrupt routine:
terminate = true
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis