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?

Comments

  • aside from the obvious inline ASM, WAITCT.

  • mparkmpark Posts: 1,284

    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,038

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

  • evanhevanh Posts: 14,038

    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,038

    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,284

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

  • evanhevanh Posts: 14,038

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

  • mparkmpark Posts: 1,284

    Awesome; thanks!

Sign In or Register to comment.