Page 1 of 1

Can a Flowcode DELAY be terminated via a hardware interrupt?

Posted: Sun Sep 06, 2015 1:07 pm
by gtc
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?

Re: Can a Flowcode DELAY be terminated via a hardware interr

Posted: Sun Sep 06, 2015 2:50 pm
by kersing
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

Re: Can a Flowcode DELAY be terminated via a hardware interr

Posted: Sun Sep 06, 2015 11:54 pm
by gtc
Thanks, good idea.