Shop OBEX P1 Docs P2 Docs Learn Events
SPRAM and SEROUT — Parallax Forums

SPRAM and SEROUT

FalconFalcon Posts: 191
edited 2012-04-15 04:59 in BASIC Stamp
Hello,

Recently Mike Green helped me figure out how to use the SP STR L modifier with the SERIN command to accept multiple bytes of data and move them immediately to Scratchpad RAM to save variable space on the receiving end of two Serially-connected BS2Px's. I'm now using this code:
SERIN SI\FC, baud, 100, notalk,[WAIT ("Report"), SPSTR 6]         ' Serial In from Remote BS2

PAUSE 50

HIGH FC

FOR index = 0 TO 5
GET index, work
'DEBUG work, CR
PUT index + 50, work
NEXT


Now, how can I save space on the sending end? I hope to use the GET command to retreive the data from Scratchpad RAM and send it immediately out with the SEROUT command.

I know that the SP STR L modifier only applies to the SERIN command so that's not an option.

How could the STR ByteArray {\L} modified be used to send multiple bytes retreived from Scratchpad RAM

This example from the BSM requires a byte-array which I want to avoid in order to minimize variable space.
serStr VAR Byte(5) ' create 5-byte array
Main:
serStr(0) = "H" ' fill array
serStr(1) = "E"
serStr(2) = "L"
serStr(3) = "L"
serStr(4) = "O"
SEROUT 1, 16468, [STR serStr\5] ' transmit


Is it possible to use a FOR-NEXT loop to send multiple bytes like so?
FOR idx = 0 TO 5
GET idx, a2dResult
SEROUT SO\FC, Baud, 2, Main, [ "Report", a2dResult]         ' Serial Out to Remote BS2
NEXT

Or would I need to send individual SEROUT commands for each BYTE with a different WAIT statements, i.e. "Report1" etc.?

falcon

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-14 20:21
    Unfortunately you can't send directly from SPRAM. You have to use a FOR / NEXT loop, get the bytes you want one at a time and send them individually with a SEROUT statement.
    serout so\fc, Baud, 2, Main,["Report "]
    for idx = 0 to 5
    get idx,temp
    serout so\fc, Baud, 2, Main, [temp]
    next
    
  • FalconFalcon Posts: 191
    edited 2012-04-15 04:59
    Thanks Mike,

    So I can still use "Report" to signal that bytes are about to be sent. Then I can send those 6 bytes individually instead of in the one SEROUT statement. The SERIN (as written in the 1st post) will still accept the first six bytes that follow "Report".

    I'll give that a try.

    falcon
Sign In or Register to comment.