Propeller Manual

Table Of Contents
DIRA, DIRB – Spin Language Reference
DIRA, DIRB
Register: Direction Register for 32-bit Ports A and B.
((PUB PRI))
DIRA [Pin(s)]
((PUB PRI))
DIRB [Pin(s)] (Reserved for future use)
Returns: Current value of direction bits for I/O Pin(s) in Ports A or B, if used as a source
variable.
Pin(s) is an optional expression, or a range-expression, that specifies the I/O pin, or
pins, to access in Port A (0-31) or Port B (32-63). If given as a single expression,
only the pin specified is accessed. If given as a range-expression (two expressions in
a range format; x..y) the contiguous pins from the start to end expressions are
accessed.
Explanation
DIRA and DIRB are one of six registers (DIRA, DIRB, INA, INB, OUTA and OUTB) that directly affect
the I/O pins. The
DIRA register holds the direction states for each of the 32 I/O pins in Port A;
bits 0 through 31 correspond to P0 through P31. The
DIRB register holds the direction states
for each of the 32 I/O pins in Port B; bits 0 through 31 correspond to P32 through P63.
NOTE:
DIRB is reserved for future use; the Propeller P8X32A does not include Port B I/O
pins so only
DIRA is discussed below.
DIRA is used to both set and get the current direction states of one or more I/O pins in Port A.
A low (0) bit sets the corresponding I/O pin to an input direction. A high (1) bit sets the
corresponding I/O pin to an output direction. All the
DIRA register’s bits default to zero (0)
upon cog startup; all I/O pins are specified as inputs by that cog until the code instructs
otherwise.
Each cog has access to all I/O pins at any given time. Essentially, all I/O pins are directly
connected to each cog so that there is no hub-related mutually exclusive access involved.
Each cog maintains its own
DIRA register that gives it the ability to set any I/O pin’s direction.
Each cog’s
DIRA register is ORd with that of the other cogs’ DIRA registers and the resulting
32-bit value becomes the I/O directions of Port A pins P0 through P31. The result is that
each I/O pin’s direction state is the “wired-OR” of the entire cog collective. See I/O Pins on
page 26 for more information.
Page 104 · Propeller Manual v1.1