Shop OBEX P1 Docs P2 Docs Learn Events
propeller freeze up? — Parallax Forums

propeller freeze up?

CrosswindsCrosswinds Posts: 182
edited 2009-10-13 17:13 in Propeller 1
Hello everyone!

I have a strange problem with my propeller.

I have done my own clock with temperature-information, that displays on the parallax serial 2-line display.

everything works fine, and i have just made the final code for the clock-setting.

So fine i set the clock to test it out, and noticed that about 7 minutes later it have freezed!

I have tested it again and again, and it always freezes at different times, the longest it have "worked" is one hour and 20minutes.

Dont know if its a programming fault or a hardware fault.
Doesnt really seem like a programming fault when its in such a big timespan, but i maybe wrong.

Does anyone have any idea of what it can be?

Its not the time-chip that freezes, becouse if i reset the propeller when it have froze, it gets the right time again, no problem, so the timechip keeps the time.


timekeepingchip: DS1302
temperature: DS1620


Using objects for them downloaded from parallax site.


I hope you guys can have some idea of what it could be!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-11 22:37
    The Propeller "freezes" because of an error in your program. Without the exact source code you're using, it's impossible to tell exactly what's wrong, but this is a familiar story. Usually some part of the program is writing over another part of the program. Sometimes it's the stack area that's overwriting something.

    If you want further help with this, you'll have to post your source code (as an attachment to a message ... NOT cut and paste). If you're using objects from the Object Exchange and you've made absolutely no changes to them, you could provide a link to the object rather than a copy of the source code. It's often best to use the archive feature of the Propeller Tool since it includes all the source files that you've used.
  • CrosswindsCrosswinds Posts: 182
    edited 2009-10-12 16:44
    Thank you mike for your reply,

    i have attached my archive to this post now, hopefully someone can help me with what i have done wrong.


    Its probably full of mistakes, new to propeller for about a week or so [noparse]:)[/noparse]


    The "roomtemperature.spin" is the· main object.
  • whickerwhicker Posts: 749
    edited 2009-10-12 17:43
    Looks like you are recursively calling main in a strange and creative way.

    Doing that is kind of missing the point of calling and returning from subroutines.

    There should be a blank "repeat" in main...

    Actually, just replace "PUB main" with "repeat" and indent everything underneath it until "PUB watchbutton".
    Then remove any and all calls to "main".

    main, by itself on a line, in the case of your program is not a "jump" or a "goto". It is saying, "call this", with the intention of returning to the statement right after it. Your call stack just keeps growing and growing, overwriting anything in memory.
  • CrosswindsCrosswinds Posts: 182
    edited 2009-10-12 17:54
    whicker thank you for your very informative post!



    Could you please check the code again, to see if i got a hang of what you meant?


    I have attatched it here
  • whickerwhicker Posts: 749
    edited 2009-10-12 18:38
    yes.

    now it's just a matter of getting rid of the endless loops caused by the repeat statements in:

    PUB sethour
    PUB setmin
    PUB finalsetting

    fixing "finalsetting" is easy. just get rid of the repeat. The other two need a bit more work about what exactly you're trying to accomplish.
  • CrosswindsCrosswinds Posts: 182
    edited 2009-10-12 19:32
    Well firstly, as you can see watchbutton, looks for a button-stroke every "cycle" of the code.

    When it detects one, it goes in "sethour" and the hourset shows at the display, then it waits for a button-stroke again, and for every stroke it detects, it adds +1 to the hour.

    And it also "feels" if the user is holding in the button for some time, and the jumps to setmin.

    I have to do this, becouse i cant have 2 buttons since the demoboard Pins is full with both the IC´s and one button, probably a bit simpler with atleast 2 buttons!

    And im sure there is some simplier way to do this with one button to [noparse]:)[/noparse]

    But now you maybe are able to understand how my thoughts are about those loops? [noparse]:)[/noparse]

    Thank you again!

    Post Edited (Crosswinds) : 10/12/2009 7:37:13 PM GMT
  • CrosswindsCrosswinds Posts: 182
    edited 2009-10-12 21:45
    As i see it, the prop has to stop and wait for button-input from the user or am i totaly wrong in that, then im confused :P

    would command: "repeat while" be a good idea for it to repeat until the input get high?
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-13 05:05
    Hello Crosswinds,

    repeat while keeps on looping as long as a condition is TRUE

    repeat until keeps on looping as long as a condition is FALSE

    so it just depends on your coding

    let's assume you want wait until button is pressed which means INA[noparse][[/noparse] 7] = high

    WAITING for INA[noparse][[/noparse] 7] = high can be coded
      repeat until INA[noparse][[/noparse] 7] == 1
    
    


    or
      repeat while INA[noparse][[/noparse] 7] == 0
    
    


    a second hint: you use hardcoded ticks in your waitcnt

    use the systemvariable ClkFreq. Then the waiting times stay the same even if you change Clocksettings
        waitcnt (30_000_000 + cnt)
    
    


    is around 30_000_000 / 80_000_000 = 0.375 seconds

    this can be achived by coding
      Waitcnt(ClkFreq / 2 + cnt)    'ClkFreq / 2 = 0.5 seconds
    
    


    if you would like to have the exact amount of time
      Waitcnt(ClkFreq * 3 / 8  + cnt)    
    
    


    by the way: if you need some more inputs you can use the mouse and keyboard-connector-sockets

    If you take a look into the schematic the DIN-connectors have a current-limiting resistor of 100 Ohm (good to have them in serial to the input)
    and a 10kOhm pull-up-resistor which you need anyway for buttons

    You can make "creative" use of the TV-output as an output-pin to drive a transistor
    same with the RGB V- and H-pin of the VGA-connector.
    You can use them as Output to drive the base of a transistor.

    best regards

    Stefan

    Post Edited (StefanL38) : 10/13/2009 9:04:54 AM GMT
  • whickerwhicker Posts: 749
    edited 2009-10-13 05:14
    yes, something along the lines of:

    repeat while ina[noparse][[/noparse]7]==1
    ··{stuff}

    or

    if ina[noparse][[/noparse]7]==0
    ··return

    that way, when the button is released, it can fall back to the main loop.


    I think you're logic looks like:

    Is button pressed?

    Is button not held down?
    return early if it isn't (debounce)

    Is button really still held down?
    -If so, go to the portion where we repeatedly change the minutes until button is released, then return.
    Else
    -Increment the hour once.
    Set the final result.
    Finally return back to main loop
  • CrosswindsCrosswinds Posts: 182
    edited 2009-10-13 17:13
    Stefan and whicker,

    Wow! Thank you guys very much with all your help and explanations.

    You have really helped me on the way with this, and explained (so that i understood) why i shouldnt do what i did in the first place.

    I will redesign the whole "setting-code" with my newfound knowledge [noparse]:)[/noparse]

    Thank you!
Sign In or Register to comment.