Professor Chaos
11-19-2006, 09:52 AM
Hi all -
I'm just starting out with the BS2 and am wondering about serial behavior. I am reading input from a serial device that communicates with 3-byte commands at 9600 baud. If I read the input according to the following:
Array VAR BYTE(3)
DO
SERIN 0,16468, [STR Array \3] 'Wait for 3 bytes on Pin 0
DEBUG BIN8 Array(0), " ",BIN8 Array(1)," ",BIN8 Array(2), CR 'Display the bytes in binary format
LOOP
I display the expected data. However, if I use:
SERIN 0,16468, [Array(0),Array(1),Array(2)]
or
SERIN 0,16468, [Array(0)]
SERIN 0,16468, [Array(1)]
SERIN 0,16468, [Array(2)]
to read the input, I get the first byte correct, but the second two bytes are wrong. The second example gives different wrong bytes than the third example.
Is this just a timing issue, or am I missing something fundamental about how arrays or SERIN work?
Thanks!
I'm just starting out with the BS2 and am wondering about serial behavior. I am reading input from a serial device that communicates with 3-byte commands at 9600 baud. If I read the input according to the following:
Array VAR BYTE(3)
DO
SERIN 0,16468, [STR Array \3] 'Wait for 3 bytes on Pin 0
DEBUG BIN8 Array(0), " ",BIN8 Array(1)," ",BIN8 Array(2), CR 'Display the bytes in binary format
LOOP
I display the expected data. However, if I use:
SERIN 0,16468, [Array(0),Array(1),Array(2)]
or
SERIN 0,16468, [Array(0)]
SERIN 0,16468, [Array(1)]
SERIN 0,16468, [Array(2)]
to read the input, I get the first byte correct, but the second two bytes are wrong. The second example gives different wrong bytes than the third example.
Is this just a timing issue, or am I missing something fundamental about how arrays or SERIN work?
Thanks!