PDA

View Full Version : Using LOOKUP



N6VMO_
- 22nd July 2010, 20:27
My project is to read in a string of 19 characters from a GPS's serial port using HSERIN. Then using
LOOKUP to parse the 10th and 11th characters in the TIME string and act upon the results.

I have the HSERIN working at 9600baud and can display the received string on the LCD. But, I
can't seem to get the LOOKUP syntax correct. Even the examples in the MicroCode Studio and PBP
manual do not compile correctly and it is very frustrating.

Here is my program:

DEFINE HSER_TXSTA 24H
DEFINE HSER_RCSTA 90H
DEFINE HSER_BAUD 9600
DEFINE HSER_SPBRG 25

TIME VAR BYTE(19)

PAUSE 2000 'FOR LCD

LCDOUT $FE,$1 'CLEAR LCD
PAUSE 200

LCDOUT "TEST HSERIN" 'DISPLAY "TEST HSERIN" ON LCD LINE 1
PAUSE 1000

GOSUB CURHOME2 'MOVE LCD CURSOR TO LINE 2

MOREHSER:

HSERIN [WAIT("C708")] ' WAIT FOR "C708"
HSERIN [STR TIME\19]

LOOKUP 10,[TIME],B1 ' FIND 10TH CHARACTER IN THE 'TIME' STRING
LCDOUT B1 ' DISPLAY 10TH CHARACTER ON LCD


LCDOUT STR TIME\19
GOSUB CURHOME2 'LINE 2
GOTO MOREHSER

CURHOME2:
LCDOUT $FE, $C0
RETURN

N6VMO_
- 22nd July 2010, 21:40
My project is to read in a string of 19 characters from a GPS's serial port using HSERIN. Then using
LOOKUP to parse the 10th and 11th characters in the TIME string and act upon the results.

I have the HSERIN working at 9600baud and can display the received string on the LCD. But, I
can't seem to get the LOOKUP syntax correct. Even the examples in the MicroCode Studio and PBP
manual do not compile correctly and it is very frustrating.

Here is my program:
:o
DEFINE HSER_TXSTA 24H
DEFINE HSER_RCSTA 90H
DEFINE HSER_BAUD 9600
DEFINE HSER_SPBRG 25

TIME VAR BYTE(19)

PAUSE 2000 'FOR LCD

LCDOUT $FE,$1 'CLEAR LCD
PAUSE 200

LCDOUT "TEST HSERIN" 'DISPLAY "TEST HSERIN" ON LCD LINE 1
PAUSE 1000

GOSUB CURHOME2 'MOVE LCD CURSOR TO LINE 2

MOREHSER:

HSERIN [WAIT("C708")] ' WAIT FOR "C708"
HSERIN [STR TIME\19]

LOOKUP 10,[TIME],B1 ' FIND 10TH CHARACTER IN THE 'TIME' STRING
LCDOUT B1 ' DISPLAY 10TH CHARACTER ON LCD


LCDOUT STR TIME\19
GOSUB CURHOME2 'LINE 2
GOTO MOREHSER

CURHOME2:
LCDOUT $FE, $C0
RETURN

I just answered my own question by...READING THE BOOK!

LOOKUP can't be used to parse arrays with a variable. ARRAYREAD works better.