Quote Originally Posted by Charles Linquis View Post
It depends a lot on whether or not your program is going to wait around for
the input, or if it needs to do something else while waiting. Or whether or not your input will come from a keyboard (time between characters) or all at once.

One way would be to -

Code:
LookForStart:
 
 
FoundStart = 0  
 
 
HSERIN 1000,NoData,[WAIT ("start")] : FoundStart=1
 
 
Return
 
 
 
 
 
NoData:
 
 
Return
FoundStart will = 1 if the "start" was received after waiting for 1 second.
I use this :

Code:
DEFINE OSC 40      
DEFINE LCD_DREG PORTD
DEFINE LCD_EREG PORTB
DEFINE LCD_RSREG PORTB
DEFINE LCD_EBIT 6
DEFINE LCD_RSBIT 7
DEFINE ADC_BITS 10
DEFINE HSER_RCSTA 90h 
DEFINE HSER_TXSTA 20h 
DEFINE HSER_BAUD 9600
DEFINE HSER_SPBRG 64


char var WORD
foundstart var bit


pause 1000
HIGH PORTE.2
LCDOUT $fe,1
Hserout ["Program has started."] 
pause 1000


LookForStart:
  
FoundStart = 0  
  
HSERIN 5000,noData,[WAIT ("start")] : FoundStart=1
 
Return
 
  
nodata:
 
if FoundStart=1 then 
   HIGH PORTD.4
   Lcdout $fe,2,"Backlight ON."
ENDIF
 
Return
And it doesn't work, every 5 seconds I receive "Program has started".
Now I'm using Terminal v1.9b by Bray, it's far better because I can send a word at once. So no time between characters.

And yeah, my program have a lot things to do (interrupts, etc.) during this time. Here I'm using a very simple program to get started.