Shop OBEX P1 Docs P2 Docs Learn Events
pin state into byte variable - serial... — Parallax Forums

pin state into byte variable - serial...

FORDFORD Posts: 221
edited 2007-04-26 13:08 in General Discussion
Hi All,
Am just wondering if I am going about this the right way, in SXBasic.
I have serial data coming into an SX pin, and want to shift that data into a byte variable.
I'm just not sure if its working correctly...

string is a byte variable.
RA.0 is the serial input pin

immediately after I detect the start bit it goes something like this...

· pauseus 417················ 'align the first data bit to the middle of the bit, correct for 1200bps
· startbit = RA.0············· 'get start bit
· pauseus·833················ 'pause 1 bit period
for counter = 0 to 7········ 'loop for 8 bits of data
· string.7 = RA.0············· 'get the serial input pin state and put it into bit 7 of 'string' variable
· string = string SHR 1····· 'shift bits right
· pauseus 833················
next
··parity = RA.0··············· 'get parity bit
· pauseus 833
· stopbit = RA.0············· 'get stop bit
· pauseus 833

Is there a problem with getting a pin state into a variable this way ?
I mean can you just put any bit of a byte variable directly onto a pin ?

I cant use the serin command, because its E81 comms.


Cheers,
Chris, Weastern Australia.

Comments

Sign In or Register to comment.