Introduction #
The Propeller Spin language uses the single-tilde and double-tilde suffixes for compact single-bit manipulation on the DIRA and OUTA registers.
These are single-bit assignment operations that work only for the DIRA and OUTA registers and are an extremely concise way to set or clear a bit.
DIRA #
The command dira[Pin]~~ sets the direction of the specified I/O pin to Output mode.
- Function: It sets the corresponding bit in the DIRA register to 1.
- Result: The pin is configured as an Output, allowing its state to be driven HIGH or LOW by the OUTA register.
- Equivalent: The
dira[Pin]~~command is shorthand for the standard assignment:dira[Pin]:=1
| Command | Action | I/O Function | Traditional Equivalent |
|---|---|---|---|
| dira[Pin]∼ | Set LOW (Clear Bit) | Input | dira[Pin]:=0 |
| dira[Pin]∼∼ | Set HIGH (Set Bit) | Output | dira[Pin]:=1 |
OUTA #
The command outa[Pin]~ forces the state of the I/O pin specified by Pin in the output register (OUTA) to 0 (LOW).
- Function: It sets the corresponding bit in the OUTA register to 0.
- Result: The pin is driven LOW when the DIRA register is set to output.
- Equivalent: The
outa[Pin]~command is shorthand for the standard assignment:outa[Pin]:=0
| Command | Action | Bit Value | Traditional Equivalent |
|---|---|---|---|
| outa[Pin]∼ | Set LOW (Clear Bit) | 0 | outa[Pin]:=0 |
| outa[Pin]∼∼ | Set HIGH (Set Bit) | 1 | outa[Pin]:=1 |
| outa[Pin]∧=1 | Toggle (XOR) | Toggle | outa[Pin]∧=1 |
Resources #
Parallax Propeller 1 Documentation