so to start, my problem is that my program runs really slow. it is a basic circuit using an 18f6680 at 20MHz, a matrix orbital serial lcd and a Parallax GPS module.

Im using an old board designed for a different project, so its not possible to use the hardware serial port at this time.

the gps module needs the serout to tell it what data to send, and then it replies with the requested data. then once its returned to the PIC, it gets displayed on the serial LCD.

the "timer" part of the circuit was just so i could tell how often it cycled through the program, and with the clock from the GPS, it takes approximately 5 seconds to run through one loop from Start to start. If i comment out everything except for one piece of data ( such as just getting the number of satallites and displaying it), it still takes close to 1 second for a loop.

is there any way to optimize the code to make it a lot faster? Or do i need to use Hserin and change the gps to use NMEA data?

thanks for the help

<code>

DEFINE OSC 20


'VARIABLES

lcd VAR PORTf.7
gpsin VAR PORTb.3

valid VAR byte
sats var word
hours var byte
minutes var byte
seconds var byte
degreelat var byte
minlat var byte
seclat var word
degreelong var byte
minlong var byte
seclong var word
dirlat var byte
dirlong var byte
decdeglat var byte
decdeglong var byte
baudLCD CON 32
baudgps con 188
speed var byte

degreelong = 0
minlong = 0
seclong = 0
dirlong = 0
degreelat = 0
minlat = 0
seclat = 0
dirlat = 0
speed = 0
valid = 0
sats = 0

timer var byte
timer = 0

'STARTUP PROGRAM

startup:

Pause 800

SerOut2 lcd, baudlcd,[254,"X"] 'clear screen
Pause 200
SerOut2 lcd, baudlcd,[254,"X"] 'clear screen again
pause 200
SerOut2 lcd, baudlcd,[254,"P",140] 'change Contrast
pause 200
SerOut2 lcd, baudlcd,[254,153,0] 'change lcd brightness to 0
Pause 500


SerOut2 lcd, baudlcd,[254,"G",1,1,"V="] 'display V= on screen
serout2 lcd, baudlcd,[254,"G",1,2,"Sat="] 'display Sat= on screen
serout2 lcd, baudlcd,[254,"G",12,2,"Speed="] 'display Speed= on screen

'MAIN PROGRAM

start:
serout2 lcd,baudlcd,[254,"G",7,2,#timer]
timer = timer + 1

SerOut2 gpsin, baudgps,["!GPS", $01] 'checks for valid signal
SerIn2 gpsin, baudgps,3000,no_response,[valid]
SerOut2 lcd, baudlcd,[254,"G",3,1,#valid]

SerOut2 gpsin, baudgps,["!GPS", $02] 'checks number of satellites
SerIn2 gpsin, baudgps,3000,no_response,[sats]
SerOut2 lcd, baudlcd,[254,"G",5,2,#sats]

SerOut2 gpsin, baudgps,["!GPS", $03] 'gets time from satellite
SerIn2 gpsin, baudgps,3000,no_response,[ hours, minutes , seconds]
SerOut2 lcd, baudlcd,[254,"G",10,1, #hours, ":", #minutes, ":", #seconds]

SerOut2 gpsin, baudgps,["!GPS", $05]
SerIn2 gpsin, baudgps,3000,no_response,[degreelat,minlat,seclat,dirlat]
decdeglat = (minlat * 1000 / 6 ) + (seclat / 60 )
SerOut2 lcd, baudlcd,[254,"G",1,3,dec3 degreelat,".",dec4 decdeglat]

SerOut2 gpsin, baudgps,["!GPS", $06]
SerIn2 gpsin, baudgps,3000,no_response,[degreelong,minlong,seclong,dirlong]
decdeglong = (minlong * 1000 / 6 ) + (seclong / 60)
SerOut2 lcd, baudlcd,[254,"G",1,4,dec3 degreelong,".",dec4 decdeglong]

SerOut2 gpsin, baudgps,["!GPS", $08]
SerIn2 gpsin, baudgps,3000,no_response,[speed]
serout2 lcd,baudlcd,[254,"G",18,2,#speed]


GoTo start
no_response:
goto start

end
</code>