Shop OBEX P1 Docs P2 Docs Learn Events
Best way to use waitpeq to check the status of a range of pins — Parallax Forums

Best way to use waitpeq to check the status of a range of pins

gergtechgergtech Posts: 7
edited 2012-09-07 18:34 in Propeller 1
Hello,

I'm obviously new....but I'm trying to pause the my program until pins ina[1] though ina[20] = 0 using waitpeq.

Ive tried to use the Propeller manual to figure this out, but I don't get the examples.

This is probably a Prop 101 question,

Thank you for the help

Greg Pfrommer
Atlanta Ga

Comments

  • JonnyMacJonnyMac Posts: 9,194
    edited 2012-09-07 13:21
    If you're wanting to hold the program until all those pins clear you can do something as simple as this
    repeat while (ina[20..1])
    


    Yep, one line. If any pin is high (1) the expression will evaluate as true.
  • gergtechgergtech Posts: 7
    edited 2012-09-07 13:23
    THAT'S IT, Thank you, I knew I was trying to do this the hard way.

    I so need to go back to school?
  • JonnyMacJonnyMac Posts: 9,194
    edited 2012-09-07 13:48
    School is one place (of many) to learn. There's lots of good stuff posted in these forums by people who go beyond theory into practical, real-world applications.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-09-07 14:36
    gergtech,

    Welcome to the forum!

    Jon's solution works and is easy to grasp, since it's able to use the ina[20..1] notation. However, you can use waitpeq, if you like, and it does save power consumption during the wait. Do it this way:
    waitpeq(0, $001f_fffe, 0)
    

    The first argument to waitpeq is the pin state you're waiting for; the second argument, a mask whose "one" bits identify which pins of ina you're checking. The third argument should always be zero, since there is no inb.

    -Phil
  • lardomlardom Posts: 1,659
    edited 2012-09-07 18:34
    @gergtech, Welcome. The speed at which you will learn here may surprise you. The level of knowledge and experience in this community is hard to match. Have fun.
Sign In or Register to comment.