SEROUT and SERIN SPSTR question
Moskog
Posts: 554
Let's say I have these variables:
firstVar····· VAR Byte
secondVar· VAR Byte
thirdVar···· VAR Byte
Then I send them away with this command:
SEROUT TX, Baud, [noparse][[/noparse]firstVar, secondVar, thirdVar]
Now I want to receive them another place and put them directly into SPRAM,
like this:
SERIN RX, Baud, [noparse][[/noparse]SPSTR 24]
If all the 3 variables contains a number, like DEC 255 each, ·then the SPSTR should save a string of 24 "ones" from location 0.
But what if all three variables contains a number, let's say DEC 7, or %00000111?
Will the SEROUT command then send all the leading zeros or will the string be just·3X3 "ones", like 111111111 and then wait for next transmission to fill all the twentyfour bits?
Is there a way to format variables before SEROUT so the SPSTR-string will be exactly the lenght I want it to be? Example: I want to send·one word,·one byte and one nib and want to be sure the string contains 28 bits because I then want to read them from location 0,1,2 and 3 of the SPRAM.
Comments and helps will be appreciated!
firstVar····· VAR Byte
secondVar· VAR Byte
thirdVar···· VAR Byte
Then I send them away with this command:
SEROUT TX, Baud, [noparse][[/noparse]firstVar, secondVar, thirdVar]
Now I want to receive them another place and put them directly into SPRAM,
like this:
SERIN RX, Baud, [noparse][[/noparse]SPSTR 24]
If all the 3 variables contains a number, like DEC 255 each, ·then the SPSTR should save a string of 24 "ones" from location 0.
But what if all three variables contains a number, let's say DEC 7, or %00000111?
Will the SEROUT command then send all the leading zeros or will the string be just·3X3 "ones", like 111111111 and then wait for next transmission to fill all the twentyfour bits?
Is there a way to format variables before SEROUT so the SPSTR-string will be exactly the lenght I want it to be? Example: I want to send·one word,·one byte and one nib and want to be sure the string contains 28 bits because I then want to read them from location 0,1,2 and 3 of the SPRAM.
Comments and helps will be appreciated!
Comments
[noparse][[/noparse]myword.byte0,myword.byte1,mybyte,mynib]
and those will be sent as 4 bytes, and on the other end SPSTR 4 will end up with those 4 bytes in SPram locations 0 to 3. If you are doing this without flow control, be sure to keep the baud rate low enough.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thank you so much!!