Hi,

I've been searching for an answer to this with no success so apologies if I've just been looking in the wrong place or I'm stupid

I'm building a control circuit / program for a photo trap which needs to do the following:

1) Count down from 30secs to 0sec while displaying the remaining seconds on a serial LCD. No problems with that bit !
2) If at any time during the 30sec "window" an input changes state, I want to immediately jump to a subroutine with the shortest possible delay.

As I understand it, interrupts only work at the end of a command so if I pause 1sec the interrupt would only execute at the end of the pause ? Same as if I paused 1sec then just read an input pin.

I could go round and around an input read loop with an if...then...goto for enough times to add up to 1sec and then decrease the second counter, refresh the lcd, then round'n'round for another sec. In that case how long do PBP instructions take to execute ? I know it's 4clock cycles per command in assembly language but how many commands per PBP instruction so I can calculate times ?

I can't help but feel that there might be a really simple/elegant way of doing this.

Thanks in advance for any tips,

Andrew