Trapping a flag/state change (rapidly)


Results 1 to 10 of 10

Threaded View

  1. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Trapping a flag/state change (rapidly)

    Quote Originally Posted by HenrikOlsson View Post
    Hi Hank,
    I'm not sure I can give you a general way of doing it.

    One (obvious but not elegant) way is to simply check the flag several times as you go thru the main loop.
    Hi Henrik,

    That's the way I'm doing it now, but it eats up program space!

    Previously, (to save repetition) I made the mistake of using a GOSUB to check the 'pattern' variable regularly throught all my program segments & if it had changed, to point it to a different part of the program ....whoah schoolboy error, my pic started reseting (becuase I wasn't returning cleanly out of the gosub).

    I'm not sure I'm understanding your other recommendation.

    For anyone not sure what my issue is, here's a high level flow of what's going on

    Code:
    pattern1:
    HIGH LED1
    PAUSE 100
    LOW LED1
    PAUSE 100
    HIGH LED2
    PAUSE 100
    LOW LED2
    PAUSE 100
     
    rinse, repeat....
     
    if pattern = 2 then goto pattern2
    goto pattern1
     
    pattern2:
    flash some other LED pattern
    if pattern = 1 then goto pattern1
    goto pattern2
     
    ISR:
    If a Switch is pressed in increment pattern variable

    you can clearly see that in pattern1, unless I check the variable called 'pattern' after every LED state change, that -especially with a few LEDS in play - it could be a while before the pattern variable change is picked up.
    Last edited by HankMcSpank; - 29th April 2011 at 12:12.

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