SERIN\SEROUT were originally made to be compatible with the older BASIC Stamp 1 syntax.
The BASIC Stamp 1 was very limited in what it could do, and these commands are also very
limited. I.E. they do not support the list of modifiers shown in the PBP manual for SERIN2 or
SEROUT2, DEBUG, HSERIN, HSEROUT, etc,,.
To use T2400 you would need to insert include "MODEDEFS.BAS" in the beginning
section of your code to use the serial MODE names.
Or create a CONstant like T2400 CON 0, or SYMBOL T2400 = 0.
SERIN2\SEROUT2 were made to be compatible with the higher-end BASIC Stamp2. How they
work & the difference between these commands is shown in the PBP manual.
The back section of the manual shows SERIN2\SEROUT2 MODE examples.
This should work with SERIN2\SEROUT2;
Code:
DEFINE OSC 20
Char VAR BYTE[20] ' 20 byte array for serial data
CR CON 13 ' constant value of a carriage return
Main:
' receive up to 20 characters, optionally terminated by CR
SERIN2 PORTC.7,396,[STR Char\20\CR]
' echo back the received string of characters
SEROUT2 PORTC.6,396,[STR Char,13,10]
' clear the string
CLEAR
GOTO Main
END
Since you're already using the hardware USART pins, you might want to consider using
HSERIN & HSEROUT.
This should work with HSERIN\HSEROUT;
Code:
DEFINE OSC 20
DEFINE HSER_CLROERR 1
Char VAR BYTE[20] ' 20 byte array for serial data
CR CON 13 ' constant value of a carriage return
Main:
' receive up to 20 characters, optionally terminated by CR
HSERIN [STR Char\20\CR]
' echo back the received string of characters
HSEROUT [STR Char,13,10]
' clear the string
CLEAR
GOTO Main
END
DEBUG and DEBUGIN are also options.
Bookmarks