Toggle program branch ussing interrupot by button?


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Toggle program branch ussing interrupot by button?

    Sorry for the delay, but I don’t think that would be a good solution since the ISR should only spend enough time in there to update values, take readings, turn things ON/OFF, etc.. Pretty much just get in and get out.

    Your example is like the one Henrik suggested but within the ISR.

    But got another wild idea if your tight loop can sacrifice just a little time to test the ISR flag bit:
    Code:
    INT VAR BIT
    
    INT = 0
    '------------------------
        
    loop1:
        code
        IF INT THEN GOTO loop2   ' Jump to loop2 after loop1 finished if interrupt triggered
    GOTO loop1                                                  
    
    loop2:
        more code
        IF !INT THEN GOTO loop1  ' Jump to loop1 after loop2 finished if interrupt triggered
    GOTO loop2
    
    
    ; --------------  ISR toggles a flag bit ----------
    Button_ISR:
        
        INT = !INT
        
    @ INT_RETURN
    This way, I'm thinking, any one of the loops can complete it's mission before jumping to the other routine should an interrupt happen. Or just continue in it's loop until the button is pushed.
    Louie

  2. #2
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Toggle program branch ussing interrupot by button?

    LOL, I already did in the same way, just it became necessary to rise clock frequency to 32mhz. But I don't use any interrupts, and it works just fine.

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Did it already

    Hehe, that is funny.
    Glad you got it going.
    Louie

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


    Did you find this post helpful? Yes | No

    Default Re: Did it already

    Yes, but I still want to get with interrupts, because I have more choices to do with button, and putting many IF THENs slows down code considerably (it should run with 100 microsecond accuracy).

Similar Threads

  1. TOGGLE will not go LOW
    By SUNFLOWER in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 10th August 2014, 16:53
  2. toggle switches and buttons-- need little help
    By electromark in forum General
    Replies: 2
    Last Post: - 25th October 2012, 22:35
  3. Toggle command
    By mr.sneezy in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 16th December 2011, 02:07
  4. toggle or count?
    By earltyso in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th May 2008, 08:54
  5. BRANCH/BRANCHL for GOSUB
    By selbstdual in forum PBP Wish List
    Replies: 11
    Last Post: - 20th February 2007, 14:29

Members who have read this thread : 0

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