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

Spin2 equivalent of setse1, waitse1?

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

Comments

  • aside from the obvious inline ASM, WAITCT.

  • mparkmpark Posts: 1,305

    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: 15,192

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

  • evanhevanh Posts: 15,192

    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: 15,192

    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 )
        org
            or  pinnum, #%001_000000    'falling edge
    '       or  pinnum, #%100_000000    'low level
            setse1  pinnum
            setq    timeout
            waitse1
        end
    
  • mparkmpark Posts: 1,305

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

  • evanhevanh Posts: 15,192

    Silicon doc - section Events - sub-section Selectable Events - https://www.parallax.com/propeller-2/documentation/

  • mparkmpark Posts: 1,305

    Awesome; thanks!

Sign In or Register to comment.