Shop Learn P1 Docs P2 Docs Events
Spin2 equivalent of setse1, waitse1? — Parallax Forums

Spin2 equivalent of setse1, waitse1?

Can one do the equivalent of setse1 and waitse1 in Spin2?


  • aside from the obvious inline ASM, WAITCT.

  • mparkmpark Posts: 1,299

    Ha, good point, but nothing is obvious to me!

    Speaking of non-obvious, how would one use waitct to wait on a selectable event? I'm not getting it.

  • evanhevanh Posts: 14,637

    Not. The only relation is they are both hooked into the hardware event mechanism.

  • evanhevanh Posts: 14,637

    WAITSE1 isn't going to be very helpful to Spin code. May as well just test inputs and loop. Write a function and name it waitpin() or similar.

  • evanhevanh Posts: 14,637

    Here's a simple example. The timeout is future absolute CT value as per the WAITSE1 instruction. It can be removed of course.

    PUB  waitpin( pinnum, timeout )
            or  pinnum, #%001_000000    'falling edge
    '       or  pinnum, #%100_000000    'low level
            setse1  pinnum
            setq    timeout
  • mparkmpark Posts: 1,299

    @evanh Thanks for the snippet. I guess bits 8, 7, and 6 mean something; are they documented somewhere?

  • evanhevanh Posts: 14,637

    Silicon doc - section Events - sub-section Selectable Events -

  • mparkmpark Posts: 1,299

    Awesome; thanks!

Sign In or Register to comment.