Shop OBEX P1 Docs P2 Docs Learn Events
Problem with a loop. Look OK! — Parallax Forums

Problem with a loop. Look OK!

Sniper KingSniper King Posts: 221
edited 2008-07-01 15:14 in Propeller 1
This loop looks right.· I cant talk about what it is for and probably could get in trouble with this code.· But I am stuck here.·


the output for this example should be :

<*A*>
<*B*>
<*C*>


The true Output is :

<*A*>
<*A*>
<*A*>
<*A*>
<*A*>
<*A*>
<*A*>
<*A*>

HELP!!!!!!!!!

·
································

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Was it pin 11 or 26?· Hmmm....··I think the smell of smoke tells the whole story.· Must be 26.



Michael King
Application Engineer
R&D
Digital Technology Group

Comments

  • RaymanRayman Posts: 14,233
    edited 2008-06-30 16:33
    I'd guess that the memory space for W is been overwritten somehow... How is mess defined? What does "clearbuffer" do?

    Or, you might not have enough stack space.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2008-06-30 16:39
    Is this also being run in a loop? If so could nav = 1 so that it exits before getting the chance to do the other letters.

    Otherwise it looks OK to me other than your messy indenting.

    Graham
  • Sniper KingSniper King Posts: 221
    edited 2008-06-30 17:08
    thank you guys. I know my coding is a mess but I clean it up when it works! LOL You were right about the memory overwrites. I am still learning russian here i mean spin!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·- Was it pin 11 or 26?· Hmmm....··I think the smell of smoke tells the whole story.· Must be 26.



    Michael King
    Application Engineer
    R&D
    Digital Technology Group
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-06-30 18:23
    hello Michael,

    OK i try to establish a new acronym

    AYCS !

    Attach Your Complete Sourcecode

    best regards

    Stefan
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2008-06-30 19:38
    He said he couldn't talk about what it is for so I suspect full source is out of the question.

    Besides I prefer:

    AMRCDNW

    Attach Minimal Runable Code that Does Not Work (preferably on proto or demo board). Creating the latter normally shows the problem anyway.

    Grhaam
  • MarkSMarkS Posts: 342
    edited 2008-07-01 01:29
    Well, first off, 'W' is not the same as 'w', at least in most languages. SPIN is case sensitive, correct?
  • Sniper KingSniper King Posts: 221
    edited 2008-07-01 04:09
    Thank you for your help. Stack space I beleive is the answer. Not good at this microcontroller stuff yet. Cut my teeth on the BS2P so still learning a more powerful chip. Can you expand on the 'Stack space for me' i remember playing with an 8088 assembly programming/compiler board when I was about 14yrs old.... 23 years ago.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·- Was it pin 11 or 26?· Hmmm....··I think the smell of smoke tells the whole story.· Must be 26.



    Michael King
    Application Engineer
    R&D
    Digital Technology Group
  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-01 04:21
    When a copy of the Spin interpreter is started, it requires some working space in the main (hub) memory for local variables and return addresses for calls, etc. This is handled as a stack (first in ... last out) and the starting (low) address of a stack area is passed to the Spin interpreter. This stack area has to be large enough for the method (subroutine) being started and anything that it calls. The main Spin program has a default stack which starts at the end of the program and goes to the end of memory.

    When a method is called, the return address and some other internal information is placed into the stack followed by a long for the return value (if any) and one for each parameter and local variable. During the execution of the method, other temporary values may be placed into the stack and, if another method is called, the process begins all over again.
  • MarkSMarkS Posts: 342
    edited 2008-07-01 14:52
    OK, once again...

    You're using the uppercase 'W' as a counter, but you are comparing the lower case 'w'. I believe that SPIN sees these as two separate variables. 'W' is incrementing correctly, but 'w' is set at what ever the Prop initializes it to, which is obviously not what you want it to be. Fix the case issue and your problem will likely go away.

    In other words, this:

    if w==0
      mess:="A"
                  
    if w==1
      mess:="B"
    
    if w==2
      mess:="C"
    
    if w==3
      mess:="D"
    
    if w==4
      mess:="E"    
    
    



    should be this:

    if W==0
      mess:="A"
                  
    if W==1
      mess:="B"
    
    if W==2
      mess:="C"
    
    if W==3
      mess:="D"
    
    if W==4
      mess:="E"   
    
    



    Or this:

    W:=0
    ...
    W++
    
    



    should be this:

    w:=0
    ...
    w++
    
    



    Take your pick.

    Post Edited (MarkS) : 7/1/2008 2:59:21 PM GMT
  • RaymanRayman Posts: 14,233
    edited 2008-07-01 15:10
    Spin is case insensitive... Manual page 159.
  • MarkSMarkS Posts: 342
    edited 2008-07-01 15:14
    Ah. Nevermind then...
Sign In or Register to comment.