Pause that's not interrupted

Jeremy Leach

Senior Member
This is a very simple idea, and demonstrates how useful Timer can be...

The SetInt command in the manual explains "After the interrupt code has executed, program execution continues at the next program line in the main program. In the case of the interrupted pause,wait, play or tune command, any remaining time delay is ignored and the program continues with the next program line."

So you might have a very quick interrupt routine, but that will mess up any long pauses in your program. To get round this you can have a special pause routine, which in pseudo-code might look like ...

Code:
TPause:
    Peek TimeValue 'the time you want to pause
    SetTimer <suitable preload value>
    Timer = 0
    Do
    Loop Until Timer > TimeValue
Return
So during the Do Loop, if the interrupt fires it will return to the do loop and if the Timer has exceed Timevalue will end, otherwise will carry on looping.

This whole idea will work most effectively when the interrupt routine is short compared to the Pause time. For instance my interrupt is 50ms and I want to pause for a second, or two seconds to keep LEDs lit.
 
Top