Shop OBEX P1 Docs P2 Docs Learn Events
Repeat loop for set amount of time? — Parallax Forums

Repeat loop for set amount of time?

Carl LawhonCarl Lawhon Posts: 36
edited 2009-03-08 00:35 in Propeller 1
Hey guys, this should be an easy one. How can I repeat a loop for a set number of clock cycles (a set amount of time)? Say I want to repeat a loop for 500 clock cycles, how could I do that?

Comments

  • CassLanCassLan Posts: 586
    edited 2009-03-07 22:09
    Is this for a delay?

    Will the loop always execute the same commands?

    Rick
  • Carl LawhonCarl Lawhon Posts: 36
    edited 2009-03-07 22:14
    This is not for a delay. The loop will not always execute the same commands.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-07 22:15
    Carl,
    Do you want to delay something by 500 clock cycles (just use a WAITCNT) or do you want to exit the loop if at least 500 clock cycles have passed? In the latter case, you save the initial clock setting, then start the REPEAT and exit when at least 500 clock cycles have passed (like this):
    start := cnt ' save initial time
    repeat
       '' something
    until (cnt - start) => 500
    
  • Carl LawhonCarl Lawhon Posts: 36
    edited 2009-03-08 00:35
    THanks Mike. That's what I was looking for. Also, how can I clear out the entire eeprom? Basically, here's the problem I am having. I loaded a large program to the eeprom of the prop. Then I loaded a significantly smaller program to the eeprom. However, it would seem that some parts of the larger program have been left behind, as they sometimes start running in the middle of my new program. Could clearing the eeprom entirely fix this?
Sign In or Register to comment.