is it possible to break PAUSE statement with multiple interrupts?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2013
    Posts
    1,078

    Default is it possible to break PAUSE statement with multiple interrupts?

    Hello, here is my code:

    Code:
    lcdout $FE,1,"Duration:",#xangrdzlivoba, " us    "
    LCDOUT $FE, $C0,"Delay:", #dakovneba, " ms    "
    triala:
    IF PIRVELI=0 THEN GOSUB DROMINUS
    IF MEORE=0 THEN GOSUB DROPLUS
    IF MESAME=0 THEN GOSUB PAUSAMINUS
    IF MEOTXE=0 THEN GOSUB PAUSAPLUS 
    IF PIRVELI=1 AND MEORE=1 AND MESAME=1 AND MEOTXE=1 THEN GOSUB CAVIDA
    GOTO TRIALA
    DROPLUS:
    XANGRDZLIVOBA=XANGRDZLIVOBA+10
    if xangrdzlivoba>10000 then xangrdzlivoba=10000
    lcdout $FE,2,"Duration:",#xangrdzlivoba, " us    "
    LCDOUT $FE, $C0,"Delay:", #dakovneba, " ms    "
    PAUSE 50
    return
    DROMINUS:
    XANGRDZLIVOBA=XANGRDZLIVOBA-10
    if xangrdzlivoba<10 then xangrdzlivoba=10
    lcdout $FE,2,"Duration:",#xangrdzlivoba, " us    "
    LCDOUT $FE, $C0,"Delay:", #dakovneba, " ms    "
    PAUSE 50
    RETURN
    
    PAUSAPLUS:
    DAKOVNEBA=DAKOVNEBA+10
    if DAKOVNEBA>10000 then DAKOVNEBA=10000
    lcdout $FE,2,"Duration:",#xangrdzlivoba, " us    "
    LCDOUT $FE, $C0,"Delay:", #dakovneba, " ms    "
    PAUSE 50
    RETURN
    PAUSAMINUS:
    DAKOVNEBA=DAKOVNEBA-10
    if DAKOVNEBA<20 then DAKOVNEBA=20
    lcdout $FE,2,"Duration:",#xangrdzlivoba, " us    "
    LCDOUT $FE, $C0,"Delay:", #dakovneba, " ms    "
    PAUSE 50
    RETURN
    CAVIDA:
    HIGH ANTEBA
    PAUSEUS XANGRDZLIVOBA
    LOW ANTEBA
    PAUSE DAKOVNEBA 'this causes delay
    RETURN
    END
    It do controls stroboscope, so user presses buttons and sets strobe duration and delay between pulses. The problem is, that when delay is quite long, and code is executing apropriate PAUSE statement, buttons are not operable. So is it possible to add some code, that will end PAUSE statement prematurely, on any key press?

    I've tried to make a loop instead of pause, and check state of all buttons inside it, but since the delay can be quite short, such additional statements slow it down considerably. I'm using PIC16F870 @ 4mhz.

  2. #2
    Join Date
    Aug 2016
    Posts
    22


    Did you find this post helpful? Yes | No

    Default Re: is it possible to break PAUSE statement with multiple interrupts?

    Yes, I think it is possible to set a break point using 'pause' command with multiple interrupts.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: is it possible to break PAUSE statement with multiple interrupts?

    Without going into tricks like manipulating the system variables used for the PAUSE statement there's no way to terminate a PAUSE statement prematurely. If you're using interrupts (not ON INTERRUPT though) the program can be made to respond DURING the PAUSE statement but then any time spent handling those events will of course be "added" to the duration of the pause.

    The best way is probably to break the pause duration up in a a lot of shorter durations and check your inputs and what not as part of that loop. I read your response as if that's something you've tried but it's not clear why it didn't work for you. To keep accurate timin you must try Writing the "check-inputs-code" so that it always takes the same amount of time. Then of course I have no idea exactly how acurate you NEED to be.

    If the polling code take 120us to execute then do a loop with PAUSEUS 876 (tweak it match) and GOSUB your polling code each time.

    /Henrik.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: is it possible to break PAUSE statement with multiple interrupts?

    Yes, what I basically want, is to terminate PAUSE statement, when any key is pressed.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: is it possible to break PAUSE statement with multiple interrupts?

    And like I said, you basically can't without going to low level tricks. Instead my recommendation would be something like this:
    Code:
    Delay_ms = 1000
    GOSUB WaitHere
    
    WaitHere:
    For ms = 1 to Delay_ms
      Gosub CheckInputs
      PAUSEUS 900  ' Tweak this to get correct timing, value depends on execution time CheckInputs.
    NEXT
    
    RETURN
    
    CheckInputs:
    ' Do whatever here, but no pausing etc
    ' If the delay should be terminated set ms = Delay_ms which will then terminate the FOR-NEXT loop when it returns.
    RETURN
    /Henrik.

  6. #6
    Join Date
    Feb 2013
    Posts
    1,078


    Did you find this post helpful? Yes | No

    Default Re: is it possible to break PAUSE statement with multiple interrupts?

    Oh, thanks, will give it a try.

Similar Threads

  1. help in pic Basic Pro "Break statement"
    By boscox in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th May 2012, 11:53
  2. PAUSE statement
    By PlantBob in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th January 2011, 14:17
  3. DT interrupts and Pause
    By Luckyborg in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th February 2009, 22:47
  4. Handeling multiple Interrupts
    By BobSpencerr in forum General
    Replies: 15
    Last Post: - 1st March 2007, 01:12
  5. Multiple HW Interrupts
    By Radiance in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th August 2003, 22:35

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts