Shop OBEX P1 Docs P2 Docs Learn Events
Frustration — Parallax Forums

Frustration

ArchiverArchiver Posts: 46,084
edited 2001-12-13 02:57 in General Discussion
Hello everyone! How are you? Good? Me too.

Here's my problem: The program that I am writing is a large one, but I won't
bother you with the details, just the ones that I know are significant. It is
stuck in a loop at this one spot and I can't figure it out. Please help me!! I'm
kinda new at this, and I think my problem may be the array, as I have not used
it in this way before.

Background:
y is a Byte value, as is x. They do NOT write over ANYTHING. They are
pre-defined by me. The array is a 10 WORD array, starting at B0. z is stored at
B0, which is where the array starts(the array is defined by the BS), but I dont
think there's a problem because the first time I write to z is here (z = x), and
I've already written the lowbyte of the array to the EEPROM and don't have any
use for the space. You see, after the array is written to the EEPROM, The space
it occupied can be written over (you see that ( "value(z) = 0" sets the entire
space occupied by the array to 0). "snap" simply goes to the rest of the
program. Feel free to ask any additional questions of me if it will help. The
debug shows me that there is a loop, y brings up something like this:
20, 22, 24, 26, 28, 30, 0, 2, 4, 6, 8, 10, 0, 2, 4, and repeats 0-10 forever.
x repeats 0-10 also, starting at 0. I'm stumped on this one!
y = 20
x = 0
here3:
DEBUG DEC y, CR
WRITE y, value.LOWBYTE(x)
z = x
y = y + 1
x = x + 1
WRITE y, value.LOWBYTE(x)
x = x + 1
y = y + 1
value(z) = 0
PAUSE 100
IF x = 19 THEN snap
GOTO here3



[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-12-11 23:16
    Did you debug x to see if it is inctementing?

    Sid
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-11 23:41
    Very good, Peter. I missed that.

    Sid
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-12 08:03
    Hi,

    You increment x by 2 each time before the IF X=19 THEN SNAP
    and you start with x=0 so x will never be 19.
    Change the if then line into
    IF X>19 THEN SNAP
    Now you should escape the loop

    Regards peter


    Oorspronkelijk bericht
    Van: Astro Fizzix [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=gdiiXMLkOmWPoj3Aw6Dz8xcbmmcoS_FwxYLM-_1DQBsqppE-6AXfINulyyLtav1Ayvbu0_mn8IiZ-9frjA]astro_fizzix@y...[/url
    Verzonden: dinsdag 11 december 2001 12:29
    Aan: Post BS Message
    Onderwerp: [noparse][[/noparse]basicstamps] Frustration

    Hello everyone! How are you? Good? Me too.

    Here's my problem: The program that I am writing is a large one, but I
    won't bother you with the details, just the ones that I know are
    significant. It is stuck in a loop at this one spot and I can't figure it
    out. Please help me!! I'm kinda new at this, and I think my problem may be
    the array, as I have not used it in this way before.

    Background:
    y is a Byte value, as is x. They do NOT write over ANYTHING. They are
    pre-defined by me. The array is a 10 WORD array, starting at B0. z is stored
    at B0, which is where the array starts(the array is defined by the BS), but
    I dont think there's a problem because the first time I write to z is here
    (z = x), and I've already written the lowbyte of the array to the EEPROM and
    don't have any use for the space. You see, after the array is written to the
    EEPROM, The space it occupied can be written over (you see that ( "value(z)
    = 0" sets the entire space occupied by the array to 0). "snap" simply goes
    to the rest of the program. Feel free to ask any additional questions of me
    if it will help. The debug shows me that there is a loop, y brings up
    something like this:
    20, 22, 24, 26, 28, 30, 0, 2, 4, 6, 8, 10, 0, 2, 4, and repeats 0-10
    forever.
    x repeats 0-10 also, starting at 0. I'm stumped on this one!
    y = 20
    x = 0
    here3:
    DEBUG DEC y, CR
    WRITE y, value.LOWBYTE(x)
    z = x
    y = y + 1
    x = x + 1
    WRITE y, value.LOWBYTE(x)
    x = x + 1
    y = y + 1
    value(z) = 0
    PAUSE 100
    IF x = 19 THEN snap
    GOTO here3



    [noparse][[/noparse]Non-text portions of this message have been removed]


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-12 15:51
    It still doesn't work guys. I've tried the greater than thing, but x
    is not getting above 10 for some reason. Here's the debug:
    2, 4, 6, 8, 10, 0, 2, 4, 6, 8, 10, 0, etc.
    I've tried the exact values of 20, 21, 22 but nothing. Is my syntax
    right? I think so, for I have been running test programs on byte
    addressing word arrays, so that's all good. I'm going to upload the
    entire code to
    http://www.geocities.com/astro_fizzix/documents/AF_LIGHT2.txt
    so if you want to take a look at the whole thing go there. I also
    have a pic on my site(leave out everything after the x to visit) of
    the circuit, but I probably won't do you much good because I've
    change some of the buttons and connections. What is the deal???
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-12 16:03
    One thing that makes me leery is this:

    rcB VAR W11
    rcA VAR W12
    value VAR WORD(10)

    y VAR B21
    x VAR B20
    z VAR B0
    oldpin VAR B4.LOWNIB
    lowbytey VAR B2
    highbytey VAR B3


    Usually you should use the VAR WORD/BYTE syntax OR the VAR Wxx/Bxx
    format, but not both. Are you sure you aren't overlyaing some variables
    here?

    Just looking at this part in the Stamp editor, the value variable is
    consuming all but W0-W2. So you are overlaying almost all your variables
    over value.

    Does that help?

    Al Williams
    AWC
    * Floating point math for the Stamp, PIC, SX, or any microcontroller
    http://www.al-williams.com/awce/pak1.htm


    >
    Original Message
    > From: astro_fizzix [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=DHco-ak-5yRz8lAeYTHR-T007KN-l-kQsOe23JT8ehaC7BoAdv3O1y59YSDLFOLFtwelJdeOXueA8f1ZPavq]astro_fizzix@y...[/url
    > Sent: Wednesday, December 12, 2001 9:51 AM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Re: Frustration
    >
    >
    > It still doesn't work guys. I've tried the greater than thing, but x
    > is not getting above 10 for some reason. Here's the debug:
    > 2, 4, 6, 8, 10, 0, 2, 4, 6, 8, 10, 0, etc.
    > I've tried the exact values of 20, 21, 22 but nothing. Is my syntax
    > right? I think so, for I have been running test programs on byte
    > addressing word arrays, so that's all good. I'm going to upload the
    > entire code to
    > http://www.geocities.com/astro_fizzix/documents/AF_LIGHT2.txt
    > so if you want to take a look at the whole thing go there. I also
    > have a pic on my site(leave out everything after the x to visit) of
    > the circuit, but I probably won't do you much good because I've
    > change some of the buttons and connections. What is the deal???
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-12 17:17
    OK guys, I've found the problem. to begin with, x was 0, so therefore z = 0.
    But when the loop came around again, x had added two, so z = 2. z was made to
    reset the array to zero values, but it was a 10word array. when x = 10, so did
    z, which made: values(10) = 0; z should've equaled 4 at this point. the array
    can only be address from 0 to 9, so the bs must've made W10 = 0, which was where
    x was stored and reset it to 0! Thanks for all your help, I appreciate it!


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-12 17:23
    Thanks for the info Al, but when I use lowbytey, the array has already been
    stored into the EEPROM, and so I can write over the array. oldpin is set to zero
    below the array, and it is overwritten by the array declarations at the
    beginning. It's a complicated code, and I don't know FOR SURE if the whole thing
    works, but I know my variables, and have gone through great pains to ensure a
    short program and non-overlapping variables! The main problem I've been having
    is that the program has been looping in that one spot, which I have remidied. If
    I have any more problems, I'll let you guys know. And when I'm finished, I'll
    give everyone an address to see the finished product!


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-13 02:13
    Hi,

    I rewrote your loop using the predefined names,
    And then summarized the actual changes.
    I noticed that the IF THEN line still holds
    the 19. I changed that.
    This loop should exit at B20=20. (x=20)
    I could not detect overlapping variables.

    Regards peter


    y VAR B21
    x VAR B20
    z VAR B0
    value var word(10) 'W0-W9 or B0-B19

    original fixed names chsnged variables
    y = 20 B21 = 20 B21 = 20
    x = 0 B20 = 0 B20 = 0
    here3: here3: here3:
    write y, value.lowbyte(x) write B21,B0(B20)
    z = x B0 = B20 B0 = B20
    y = y + 1 B21 = B21 + 1
    x = x + 1 B20 = B20 + 1
    write y, value.lowbyte(x) write B21,B0(B20)
    x = x + 1 B20 = B20 + 1 B20 = B20 + 2
    y = y + 1 B21 = B21 + 1 B21 = B21 + 2
    value(z) = 0 B0(B0) = 0 B0(B0) = 0
    B0(B0+1) = 0 B0(B0+1) = 0
    pause 100 pause 100
    IF x = 20 THEN snap if B20 = 20 then snap IF B20 = 20 THEN snap
    goto here3 goto here3 goto here3
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-13 02:40
    Hi,

    I spotted your error.
    It is the line value(z)=0.
    When x reaches 10, so does z,
    But value(10) cleares B20 and B21, hence the loop
    You should change it to value.lowbyte(z)=0

    Regards peter

    Oorspronkelijk bericht
    Van: peter verkaik [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=WiFcsJYvXYcsKv9NYar6Non2Dr9nsGLCVNGHHhp6jshTga1pOm7y93_JqWpK2FUkVIew2NhOJ19Vp-LB4XsrXg]peterverkaik@b...[/url
    Verzonden: woensdag 12 december 2001 18:13
    Aan: basicstamps@yahoogroups.com
    Onderwerp: RE: [noparse][[/noparse]basicstamps] Re: Frustration

    Hi,

    I rewrote your loop using the predefined names,
    And then summarized the actual changes.
    I noticed that the IF THEN line still holds
    the 19. I changed that.
    This loop should exit at B20=20. (x=20)
    I could not detect overlapping variables.

    Regards peter


    y VAR B21
    x VAR B20
    z VAR B0
    value var word(10) 'W0-W9 or B0-B19

    original fixed names
    chsnged variables
    y = 20 B21 = 20 B21 = 20
    x = 0 B20 = 0 B20 = 0
    here3: here3: here3:
    write y, value.lowbyte(x) write B21,B0(B20)
    z = x B0 = B20 B0 = B20
    y = y + 1 B21 = B21 + 1
    x = x + 1 B20 = B20 + 1
    write y, value.lowbyte(x) write B21,B0(B20)
    x = x + 1 B20 = B20 + 1 B20 = B20 +
    2
    y = y + 1 B21 = B21 + 1 B21 = B21 +
    2
    value(z) = 0 B0(B0) = 0 B0(B0) = 0
    B0(B0+1) = 0
    B0(B0+1) = 0
    pause 100 pause 100
    IF x = 20 THEN snap if B20 = 20 then snap IF B20 = 20
    THEN snap
    goto here3 goto here3 goto here3




    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2001-12-13 02:57
    Hi,

    The change alone is not sufficient as value.lowbyte(20)=0
    is executed before the IF statement, clearing B20.
    So you must move that line up as in the code below.

    Regards peter

    original
    y = 20
    x = 0
    here3:
    write y, value.lowbyte(x)
    z = x
    y = y + 1
    x = x + 1
    write y, value.lowbyte(x)
    x = x + 1
    y = y + 1
    IF x = 20 THEN snap
    value(z/2) = 0 'divide z by two, if z is 0-18 then z/2 is 0-9
    pause 100
    goto here3
Sign In or Register to comment.