Syntax: GET Location,{Word} Variable {,{Word} Variable ...}
Read value(s) from Scratchpad RAM, starting at Location and store in Variable(s)*.
*Note: The optional arguments require PBASIC 2.5.
BS2e and BS2sx | BS2p, BS2pe, and BS2px | |
Scratchpad RAM size and organization | 64 bytes (0 – 63). Organized as bytes only. | 136 bytes (0 – 135). Organized as bytes only. |
General purpose locations | 0 - 62 | 0 – 126 |
Special use location | Current program slot number in read-only location 63. | Current program slot number in lowest nibble of read-only location 127. Current read/write slot number in highest nibble of location 127. |
Additional locations | None | Locations 128 - 135 (read-only) hold state of polled input pins. |
Related Commands | PUT | PUT, STORE |
PBASIC 2.5 Syntax Options |
Multiple sequential variables may be read from the Scratchpad RAM. The optional Word modifier may be specified to retrieve 16-bit values. |
By default, the GET command reads a byte-sized value from the specified Scratchpad RAM location and stores it into variable. All values in all locations can be retrieved from within any of the eight program slots.
Scratchpad RAM is useful for passing data to programs in other program slots and for additional workspace. It is different than regular RAM in that symbol names cannot be assigned directly to locations and each location is always configured as a byte only. The following code will read the value at location 25, store it in a variable called temp and display it:
The following example illustrates this:
temp VAR Byte Main: GET 25, temp DEBUG DEC temp END
When using the $PBASIC 2.5 directive, multiple sequential variables may be read from the Scratchpad RAM, starting at Location, and the Word modifier may be specified for 16-bit values.
' {$PBASIC 2.5} value VAR Word value2 VAR Word addr VAR Word ' EEPROM address test VAR Byte ' test byte read back Main: value = $11 value2 = $2003 PUT 0, value, Word value2 ' write value to SP location 0 ' and value2 to SP locations 1 & 2 value = $FF ' modify variables value2 = $FFFF GET 0, value, Word value2 ' retrieve from Scratchpad DEBUG HEX2 ? value ' display DEBUG HEX4 ? value2 END
The low nibble of location 63 (BS2e and BS2sx) and location 127 (BS2p, BS2pe, and BS2px) is a special, read-only location that always contains the number of the currently running program slot. On the BS2p, BS2pe, and BS2px, the high nibble of location 127 also contains the current program slot that will be used for the READ and WRITE commands. See the demo program for an example of use.
On the BS2p and BS2pe, the state of polled input pins can be retrieved from upper Scratchpad locations:
This information can be used to determine which input pin (or pins) has triggered a polled event.
BASIC Stamp Help Version 2.5.4
Copyright © Parallax Inc.
8/8/2012