SEROUT and word variables
aa200orion
Posts: 10
I am trying to send a word variable using SEROUT.· Below is the code.· Is there a better way to send a word variable instead of breaking it up as shown below?· Is there a way to break a word into upper and lower bytes?
· SEND_CHARTCODE_TO_AP:
··· eyechartcode = $4164·' 64 = "d"· and 41 = "A" ' test data
···· SEROUT·RB.1,·N9600, eyeChartcode
···· eyeChartcode = eyeChartcode SHR 8
···· SEROUT·RB.1,·N9600, eyechartcode
···· PAUSE 1000
·RETURN
It works, just looks awkward.
Thanks,
Jimmy
· SEND_CHARTCODE_TO_AP:
··· eyechartcode = $4164·' 64 = "d"· and 41 = "A" ' test data
···· SEROUT·RB.1,·N9600, eyeChartcode
···· eyeChartcode = eyeChartcode SHR 8
···· SEROUT·RB.1,·N9600, eyechartcode
···· PAUSE 1000
·RETURN
It works, just looks awkward.
Thanks,
Jimmy
Comments
And, of course, it's good practice to define your serial output pin using the PIN declaration, and your baud rate as a constant (see the SX/B help file). Now you can do this:
This assumes that you've defined the variable using Word; the compiler will create the _LSB and _MSB [noparse][[/noparse]byte] variables automatically.
Thanks