You might want to try this instead:
Code: Select all
dim location as byte
dim msgb0 as byte
dim msgb1 as byte
dim w as word
USART.SetBaudrate(br9600)
ISRRX.Initialize()
while (true)
// check for usart overrun. it'll stop data if not cleared
if (ISRRX.Overrun) then
ISRRX.Reset()
// maybe display a message.
endif
// now, to receive a message from the PICAXE you must always read three bytes
// get first byte (location index)
while (ISRRX.DataAvailable = false)
end while
location = ISRRX.ReadByte()
// get second byte - lowbyte of parameter (LSB)
while (ISRRX.DataAvailable = false)
end while
msgb0 = ISRRX.ReadByte()
// get third byte - highbyte of parameter (MSB)
while (ISRRX.DataAvailable = false)
end while
msgb1 = ISRRX.ReadByte()
// display the two message bytes based on the location
select (location)
case 23, 24, 25, 26 // parameter is already ascii text
GLCD.WriteAt(10, 10, msgb0, msgb1)
else // parameter is binary data...
// write data as two bytes (LSB, MSB)
GLCD.WriteAt(10, 10, dectostr(msgb0), ", ", dectostr(msgb1))
// or write data as a single 16-bit value
w.byte1 = msgb1
w.byte0 = msgb0
GLCD.WriteAt(10, 10, dectostr(w))
end select
end while