07-15-2009, 12:50 AM
here is the code written in basic stamp. Does anyone know how to write this code in propeller tool.
Program Code:
LOW Tx 'Initialize transceiver interface
DO
idx = Message 'Point idx to start of message data
DO
strLen = 0 'Set string length to zero
crc = 0 'Start Crc at zero
DO
strLen = strLen + 1
READ idx, char 'Read a character from message data
idx = idx + 1 'Point to next character in message
string(strLen-1) = char 'Put character into string array
cValue = char 'Prepare to add char to Crc value
GOSUB CalcCRC 'Add cValue to Crc value
IF (strLen = 15) OR (char = EOM) THEN EXIT 'Exit loop when ready
LOOP 'Keep reading message characters
' Send packet
PULSOUT Tx,1200 'Send sync pulse to radio
' Send preample "UUUU!", string length, string data, crc
SEROUT Tx, Baud, ["UUUU!", strLen, STR string\strLen,
crc.LOWBYTE, crc.HIGHBYTE]
PAUSE 1000 'Give receiver time to process
LOOP WHILE char <> EOM 'Keep sending until EOM character
LOOP 'Start all over at the beginning
Program Code:
LOW Tx 'Initialize transceiver interface
DO
idx = Message 'Point idx to start of message data
DO
strLen = 0 'Set string length to zero
crc = 0 'Start Crc at zero
DO
strLen = strLen + 1
READ idx, char 'Read a character from message data
idx = idx + 1 'Point to next character in message
string(strLen-1) = char 'Put character into string array
cValue = char 'Prepare to add char to Crc value
GOSUB CalcCRC 'Add cValue to Crc value
IF (strLen = 15) OR (char = EOM) THEN EXIT 'Exit loop when ready
LOOP 'Keep reading message characters
' Send packet
PULSOUT Tx,1200 'Send sync pulse to radio
' Send preample "UUUU!", string length, string data, crc
SEROUT Tx, Baud, ["UUUU!", strLen, STR string\strLen,
crc.LOWBYTE, crc.HIGHBYTE]
PAUSE 1000 'Give receiver time to process
LOOP WHILE char <> EOM 'Keep sending until EOM character
LOOP 'Start all over at the beginning