Shop OBEX P1 Docs P2 Docs Learn Events
Escaping waitpeq or pne — Parallax Forums

Escaping waitpeq or pne

T ChapT Chap Posts: 4,223
edited 2010-09-09 00:28 in Propeller 1
I heard a trick once about connecting a prop pin to another pin to create an escape route by another cog. But, what about having another cog go to the Dira and change the pin to an output and set it high or low and escape as well?

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-09-08 23:19
    T Chap wrote: »
    But, what about having another cog go to the Dira and change the pin to an output and set it high or low and escape as well?

    Perfectly OK. As long as the waitpxx listens to it you can use any arrangement you want. Careful with setting it low though. It's OR logic so if the pin is high already it won't change.

    I usually sacrifice a second (timeout) pin and connect a counter to it.
  • T ChapT Chap Posts: 4,223
    edited 2010-09-08 23:27
    Thanks for the comments. I am trying to create an out for the PING in case it fails or is unplugged, it stops the whole program and needs a way out.
  • TinkersALotTinkersALot Posts: 535
    edited 2010-09-08 23:32
    Just a wild thought scribbled on a napkin back ... but how about this: ?

    do the ping check in another cog, and have the "primary cog" wait for an appropriate signal from the "check the ping cog" to indicate a ping was found on board -- if the signal does not come, then kill the secondary cog and assume the ping is MIA
  • T ChapT Chap Posts: 4,223
    edited 2010-09-08 23:37
    No cogs :) Else, correct there would be no need to escape it. However, I suspect that there could be a clever counter trick.
  • T ChapT Chap Posts: 4,223
    edited 2010-09-09 00:28
    Very simple to replace the WAITPxx with IF's. This works fine below.
    repeat 10000
       if ina[pin] == 1    'was waitpeq
          cnt1 := cnt
          quit
    repeat 10000
       if ina[pin] == 0    'was waitpne
       cnt2 := cnt
       microseconds := || ( cnt2 - cnt1)  xxxxxxxxxx
       quit
    

    This will need some code to tell the caller that there was no PING found if that is the case, so it does not try to calculate the duration.
Sign In or Register to comment.