Shop OBEX P1 Docs P2 Docs Learn Events
Timing a loop — Parallax Forums

Timing a loop

wanderingjeepwanderingjeep Posts: 3
edited 2010-10-29 14:24 in Propeller 1
I have a loop that needs to run about 10 seconds. It doesnt need to be exact. I need code to funtion during that time. The code is running at rcslow.
Is this correct?
Repeat
    count:=cnt
       HitCount:=HitCount+1
       
   repeat  while  ina[15]
    outa[18]:=1
    outa[18]:=0
   
   if cnt>count+200000
    quit

Comments

  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-10-29 10:43
    Something like this?
    wait := cnt
      REPEAT UNTIL ((cnt - wait) => 200000)
        '' Do stuff here
    
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-10-29 14:20
    I think you want to use UNTIL ahead of the check:
    wait := cnt
      REPEAT UNTIL ((cnt - wait) => 200000)
        '' Do stuff here
    
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-10-29 14:24
    oops, good catch.
    JonnyMac wrote: »
    I think you want to use UNTIL ahead of the check:
    wait := cnt
      REPEAT UNTIL ((cnt - wait) => 200000)
        '' Do stuff here
    
Sign In or Register to comment.