Shop OBEX P1 Docs P2 Docs Learn Events
How to assign only 3 of 4 pins for OUTC to a variable.... — Parallax Forums

How to assign only 3 of 4 pins for OUTC to a variable....

cthomascthomas Posts: 17
edited 2009-08-14 03:48 in BASIC Stamp
Here is what I'm doing, and it works fine....

.
thumbselect VAR OUTC 'includes I/O 8, 9, 10, and 11 as output pins. 11 is for an edge or face state, 8, 9, and 10 decode which thumbwheel to read
.
.
FOR idx = 0 TO 7

thumbselect = idx 'Assigns idx value to Nib OUTC thus setting up which thumbwheel to read
Digit(idx) = INB 'Stores the current value of the thumbwheel at Digit(idx) and will fill the Digit array with the starting values of all thumbwheels

NEXT
.
.

What I'd like to do instead is assign only I/O pins 8, 9, and 10 to thumbselect....leaving I/0 pin 11 available for other use.

I was trying to use pin 11 for something else, forgetting that it is periodically forced low by the above FOR NEXT loop. I'm out of pins and can't move to a larger Stamp. Any thoughts or suggestions received with gratitude.
Thanks.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-14 02:57
    If you use I/O 11 as an input pin, it won't be affected by the use of OUTC for output. When a pin is an input, the I/O pin is disconnected from the output register (which OUTC changes). The output register bits 8-11 will all change, but I/O pin 11 will remain an input, unaffected by OUT11.

    If you need I/O 11 as an output, this scheme won't work. You'll have to assign values individually to OUT8, OUT9, and OUT10. This might look like:

    OUT8 = idx.bit0
    OUT9 = idx.bit1
    OUT10 = idx.bit2

    Another idea, if bit11 is a bit variable used for I/O 11, you could do:

    OUTC = (bit11<<3) + idx

    This always keeps I/O 11 current when you change I/O 8-11
  • cthomascthomas Posts: 17
    edited 2009-08-14 03:48
    Thanks very much. Simple and quick. I'm using your suggestion on assigning OUT8, OUT9, and OUT10 separately.
    Works perfectly.
Sign In or Register to comment.