Shop OBEX P1 Docs P2 Docs Learn Events
SPSTR L help — Parallax Forums

SPSTR L help

FalconFalcon Posts: 191
edited 2012-04-11 17:05 in BASIC Stamp
I am using this code on a BS2PX-equipped Base Unit to receive six BYTES of data from a remote STAMP, and it's working flawlessly.
SERIN SI\FC, baud, 100, notalk,[WAIT ("Report"), a2dResult0, a2dResult1, a2dResult2, a2dResult3, a2dResult4, a2dResult5]         ' Serial In from Remote BS2

However, I'm short on variable space for further development. I'm interested in using the SPSTR L modifier to save this data straight into the SPRAM.

1. Can the SPSTR L modifier be used with the WAIT modifier in the same SERIN statement?

If so, would the following be the correct approach?
SERIN SI\FC, baud, 100, notalk,[WAIT ("Report"), SPSTR 6, a2dResult0, a2dResult1, a2dResult2, a2dResult3, a2dResult4, a2dResult5]         ' Serial In from Remote BS2

2. If I have another SERIN statement further along in the code with the SPSTR L modifier would it over-ride the data written by the previous SERIN statement, or would it write to the next available SPRAM location? Is there a way around for the former outcome?

falcon

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-10 19:04
    Yes, you can use a WAIT and SPSTR in the same statements.

    No, the 2nd use of SPSTR would overwrite the data from the 1st use and the only way around this is to move the data somewhere else before the 2nd use. You could move it elsewhere in the scratchpad RAM since the SPSTR modifier always starts at location zero of the scratchpad RAM.

    You'd leave out the a2dResult0 ... a2dResult5 variables since those bytes go into the scratchpad RAM
  • FalconFalcon Posts: 191
    edited 2012-04-11 17:05
    Thanks Mike,

    That worked like a charm. Required lots of GET statements but I just saved 7 bytes of variable space giving me enough to develop the last phase of my project. And I see a few opportunities to save even more space.

    falcon
Sign In or Register to comment.