Shop OBEX P1 Docs P2 Docs Learn Events
newbie question, setting all pins to low — Parallax Forums

newbie question, setting all pins to low

ArchiverArchiver Posts: 46,084
edited 2002-04-24 22:36 in General Discussion
Hey great list! I'm learning a lot by lurking.

Now I have a super-newbie question, is there a way to set all the pins to
low at once? I can do it with a loop, but I'm sure there is a more
efficient way, no?

thanks!

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-04-24 22:09
    Yes, you can, by using the [noparse][[/noparse]internal] variables Dirs and Outs. Both are
    16-bit registers and correspond to the output pins. Here's how:

    Outs = $0000 ' clear outputs
    Dirs = $FFFF ' make all pins outputs

    Note that on reset, the BASIC Stamp will make both Dirs and Outs zero, making
    all pins inputs. This puts the pins in a safe mode. Make sure you don't
    have any direct shorts before you make the pins outputs.

    See Table 4.2 in the BASIC Stamp manual (Version 2.0) for the details
    regarding Dirs and Outs.

    -- Jon Williams
    -- Parallax


    In a message dated 4/24/02 4:04:52 PM Central Daylight Time, raoul@c...
    writes:


    > Hey great list! I'm learning a lot by lurking.
    >
    > Now I have a super-newbie question, is there a way to set all the pins to
    > low at once? I can do it with a loop, but I'm sure there is a more
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-04-24 22:36
    Assuming they are all already outputs (and you are using a BS2):

    OUTS=0

    If you want to set the direction to outputs try:

    DIRS=$FF ' all outputs
    OUTS=0 ' zero to all outputs

    If you want to just do a byte, try:

    OUTH=0

    Or

    OUTL=0

    Depending on which byte you want.

    You can also use OUTA, OUTB, OUTC, and OUTD for nibbles (or nybbles as I
    was taught to spell it).

    Al Williams
    AWC
    * Floating point A/D
    http://www.al-williams.com/awce/pak9.htm



    >
    Original Message
    > From: raoul vaneigem [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=JTsfugbykYO5pJC4uSFt1i1ImW3P_5ZUdlT8oFDzaoT9YQFnyO4gp-3oos-J0ak4uHnk5Wc3QjcNsfg]raoul@c...[/url
    > Sent: Wednesday, April 24, 2002 3:03 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] newbie question, setting all pins to low
    >
    >
    > Hey great list! I'm learning a lot by lurking.
    >
    > Now I have a super-newbie question, is there a way to set all
    > the pins to
    > low at once? I can do it with a loop, but I'm sure there is a more
    > efficient way, no?
    >
    > thanks!
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
Sign In or Register to comment.