Shop OBEX P1 Docs P2 Docs Learn Events
An issue with the stack maybe? — Parallax Forums

An issue with the stack maybe?

I have encountered a problem that appears like it might be related to the stack if the basic stamp uses a stack like I assume it does. I call this particular routine but it never returns and instead resets the stamp. “Found it” prints but neither “fell through” or “Back” does. This call to find_motion is the one and only call to that routine. Any Ideas?


GOSUB find_motion
DEBUG " Back ",CR
PAUSE 1400

'______________________________________________________________
find_motion:
''DEBUG "Finding Motion", CR
GOSUB Sweep_find
Whereisit = 0
...
...
...
LOW 8
LOW 0
LOW 1
DEBUG "found it",CR
'PAUSE 2000
SLEEP 1
RETURN

DEBUG "fell through"

Comments

  • MarkCrCo.

    The BS2 is limited in how many GOSUBs that can be nested. (GOSUB does a GOSUB which does a GOSUB, etc.)

    I think the limit is 8 but it's mentioned in the BASIC Stamp Manual.
  • The limit is 4. See the description in the chapter on the GOSUB statement in the Basic Stamp Manual
  • Would have to see the entire program, but what you show there will fall into the subroutine after the PAUSE 1400.
  • There is more code after the pause 1400 which includes an end statement. I'll check on the number of gosubs, it is possible I have too many.
Sign In or Register to comment.