Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 equivalent of cnt — Parallax Forums

Spin2 equivalent of cnt

celtic3celtic3 Posts: 16
edited 2024-08-02 21:39 in Propeller 1

What is the spin2 equivalent to this line of code.....
'''
waitcnt(clkfreq + cnt)
'''
I cannot locate anything except CNT is a constant and waitcnt is waitct

Comments

  • JonnyMacJonnyMac Posts: 9,064
    edited 2024-08-02 21:44

    In Spin2 you would do this:

      waitct(clkfreq + getct())
    
  • evanhevanh Posts: 15,620

    There is also newer functions like waitms(1000) that will provide the same one second of delay.

  • JonnyMacJonnyMac Posts: 9,064

    I agree with Evan if you're just going to insert brute force delay. Using waitct() is useful for synchronized delays so that a loop will run at a predictable rate.

      t := getct()
      repeat
        ' do some code
        waitct(t += LOOP_TIX)
    
Sign In or Register to comment.