$regfile = "m16def.dat"
$crystal = 8000000
$baud = 19200
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Const False = 0
Const True = 1
' Variables
Dim Char As Byte
Dim I As Byte
Dim Message As String * 20
Dim Buffer As String * 20
Dim Received As Bit
Message = ""
Received = False
'program starts here
Cls
Cursor Off
Lcd "AVR Data"
On Urxc Priem
Enable Interrupts
Enable Urxc
Do
Loop
End
Priem:
Cls
Char = Inkey() 'see if there is a character
If Char > 0 Then 'if there is
If Char = 13 Then 'if its a Carriage return
Nop 'ignore it
Elseif Char = 10 Then 'if Linefeed (signals end of message)
Message = Buffer 'copy to output
Buffer = "" 'release the buffer
Received = True 'signal we have the complete string
Else
Buffer = Buffer + Chr(char)
Incr I 'add new char to buffer
End If
End If
If Received = True Then
'display the incoming message on the LCD
Locate 1 , 1
Lcd Message
Locate 2 , 1
Lcd I
End If
Return