- Tue Nov 17, 2009 5:51 pm
The simplest thing is to poll U0LSR (or U1LSR, depending which UART you are using) to see if there are any characters waiting, then pull them into a buffer, e.g.:
int count = 0;
while ((U0LSR & 1) && (count < 256))
buf[count] = U0RBR;
count += 1;
Then scan through the buffer until you find a '$' character. Throw away everything before this character. Then scan until you find a '*' followed by two more characters and <CR><LF>. This delimits a complete sentence. If you don't have a complete sentence in the buffer, go back and wait for more characters to arrive. If you do have a complete sentence, compute and verify the checksum. If the checksum is correct, process the sentence. If the checksum is incorrect, throw the sentence away and look for the next sentence in the buffer.
Because you have a reliable communications channel (direct connection between the GPS module and the LPC2148 UART), it is probably unnecessary to check the checksum.