Shop OBEX P1 Docs P2 Docs Learn Events
problem with WATCH command SX/B — Parallax Forums

problem with WATCH command SX/B

dufflingduffling Posts: 73
edited 2006-03-14 22:25 in General Discussion
Ive been having some problems getting the watch command to work reliably

ive found if i have the watch command in a loop without any other commands inside the loop aside from INC counter1 it works

see my short program below

my watch in the debugger does not show the Counter1 variable increasing at all ..

what am·I doing wrong?

'
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ········· ·· 50000000
'

LED VAR RC.7
button········· var···· rb.0
counter1······· var···· BYTE
'
PROGRAM start
start:

COUNTER1=0

lOOP:

HIGH LED
PAUSE 1000

INC COUNTER1

WATCH COUNTER1,8,UDEC

LOW LED
PAUSE 1000

GOTO LOOP
·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-27 18:42
    Since WATCH is a directive for the debugger you don't need to put in a loop -- stick it up with your variable definitions so that you can remove it easier. Then, run your program in Debug mode and step through the program manually so that you can see the variable update.· What you seem to be wanting is for WATCH to behave like the BASIC Stamp DEBUG command; it doesn't work that way.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • John KauffmanJohn Kauffman Posts: 653
    edited 2006-03-12 23:25
    I also have problems getting the WATCH to behave as expected. I condensed Duffling's code even further and took Jon's advice to move the WATCH to the the VAR declarations, as follows:

    '
    DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
    FREQ 4_000_000
    '
    ' VARs DECLARATIONS
    counter1 var BYTE
    WATCH COUNTER1,8,UDEC
    '
    PROGRAM start

    start:
    COUNTER1=0
    lOOP:
    INC COUNTER1
    GOTO LOOP

    When I run in debug mode the code and register windows show stepping through the loop but Counter1 in the Watch window remains at zero.

    How to get Watch to show contents of a variable while stepping or walking in Debug mode?

    Thanks.
  • BeanBean Posts: 8,129
    edited 2006-03-13 12:51
    The code seems to debug fine.
    You do realize that SXB clears all the memory first and you must step through all that code ?
    To make life easier use "PROGRAM start NOSTARTUP" to eliminate the startup code.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module" Now available from Parallax for only $28.95

    http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module" Now available from Parallax for only·$49.95
    http://www.parallax.com/detail.asp?product_id=30015

    Product web site: www.sxvm.com

    "Wise men know when they're right. The wisest also·know when they're wrong."
    ·
  • John KauffmanJohn Kauffman Posts: 653
    edited 2006-03-14 22:25
    Good insight, Bean, to detect the real problem - I did not realize there was a memory clearing at start-up. I was watching it walk through the memory registers but my mind was leaping to wild speculations about how timing might work... I should have realized the obvious.

    'Program Start NOSTARTUP' works like a charm. Thanks.
Sign In or Register to comment.