
Originally Posted by
HenrikOlsson
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.
Bookmarks