There's a potential stack overflow here
Code:
loop:
RSIn Wait("SLAVE"), value
If value = 0 Then
GoTo loop
Else
GoSub charin ' Get a character from serial input, if any
EndIf
charin:
There's no return in your code to handle it, the only one you have do the PWM, so if the value <>0, yes it will perform the Charin procedure... but you never POP the stack, after 2-3 time, yes indeed, your program may behave in a weird way. Try this...
Code:
loop:
RSIn Wait("SLAVE"), value
If value = 0 Then GoTo loop
charin:
Also, you want to make sure that your Serial dataline is noise free and idle at the right level if both device are disconnected.
Bookmarks