|
我从网上找到了这个实例,编译后写入芯片,无法显示GPS数据。试过很多实例都没办法。
由于我使用的是ATMEGA8L-8PU,实例是m8-16pu做的,不知道会不会有影响,请教高手帮忙了!
$regfile = "M8def.dat"
$crystal = 11059200
$baud = 9600 'by the GPS module output baud rate
'------------- LCD connection, key definitions ------------------------------- ---------
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portc.3 , E = Portc.2 , Rs = Portd.2
Config Lcd = 16 * 2
Config Lcdmode = Port
'* -----------------------------------------
'* Name: GPS_Monitor
'* Author: Joop Kuijntjes PA2JOK (C)
'* Date: March 25 2010
'* Versie; 1.2
'*
' NMEA signals:
'
'-> $GPGGA,1233525150.4464,N,00457.0858,E,1,09,1.01,3.9,M,47.2,M,,*74
' $GPGLL,5141.6192,N,00752.0280,E,072344.187,A*3B
' $GPGSA,A,3,13,23,11,17,04,20,,,,,,,2.6,1.6,2.1*31
' $GPGSV,3,1,10,23,78,167,47,20,55,091,36,13,50,213,45,04,41,300,32*7D
' $GPGSV,3,2,10,17,22,237,44,31,21,042,00,11,14,157,46,01,10,049,00*77
' $GPGSV,3,3,10,25,09,173,00,02,08,314,00*7F
' $GPRMC,072344.187,A,5141.6192,N,00752.0280,E,0.04,342.98,070707,,*0B
' $GPVTG,342.98,T,,M,0.04,N,0.1,K*61
' $GPMSS,0,0,0.000000,200,*5A
'
'-> : Only this line is used
'
'* -----------------------------------------
'
'* -----------------------------------------
'* Setting RS232
'* -----------------------------------------
On Urxc Onrxd 'Init Interrupt-Routine
Enable Urxc
Dim S8 As String * 8
Dim B1 As Byte
Dim B2 As Byte
Dim B3 As Byte
Dim B4 As Byte
Dim B5 As Byte
Dim A1(3) As String * 1
Dim Arr(13) As String * 11
Dim Sl As String * 1
Dim S2 As String * 2
Dim Ser_buf As String * 82 'max. 82 characters from GPS
'Sreg.7 = 1 'Enable Interrupts
Enable Interrupts
'* -----------------------------------------
'* Main program
'* -----------------------------------------
Config Pinb.0 = Input 'Port B.0 as input, to change time U, W, Z
Ddrb.1 = 1 'Port B.1 as output LED on when lock
Config Pind.7 = Input 'Port d.7 as input Backlight on switch
Ddrb.2 = 1 'Port B.2 as output Backlight
Cls
Cursor Off Noblink
Portb.1 = 1 'LED on
Portb.2 = 1 'Backlight on
B2 = 0
B3 = 0
B4 = 255
B5 = 0
A1(1) = "U"
A1(2) = "W"
A1(3) = "Z"
Lcd "Wachten op GPS."; 'text: Wait for GPS
Locate 2 , 1
Lcd "(c) PA2JOK V 1.2";
'Locate 3 , 1
'Lcd "25.03.2010";
Wait 2
Do
S8 = Left(ser_buf , 5)
Loop Until S8 = "GPGGA"
Locate 2 , 1
Lcd "GPS gevonden! "; 'text: Found GPS
'Locate 3 , 1
'Lcd "Wachten op een lock."; 'text: Waiting for a lock
'Locate 4 , 1
'Lcd "Nog geen lock!!. " ; 'text: No lock yet
Wait 1
Do
' Format: $GPGGA,123352,5150.4464,N,00457.0858,E,1,09,1.01,3.9,M,47.2,M,,*74
'1 = GPGGA
'2 = UTC of Position
'3 = Latitude
'4 = N or S
'5 = Longitude
'6 = E or W
'7 = GPS quality indicator (0=invalid; 1=GPS fix; 2=Diff. GPS fix)
'8 = Number of satellites in use [not those in view]
'9 = Horizontal dilution of position
'10 = Antenna altitude above/below mean sea level (geoid)
'11 = Meters (Antenna height unit)
'12 = Geoidal separation (Diff. between WGS-84 earth ellipsoid and
' mean sea level. -=geoid is below WGS-84 ellipsoid)
'13 = Meters (Units of geoidal separation)
'14 = Age in seconds since last update from diff. reference station
'15 = Diff. reference station ID#
'16 = Checksum
' Buf = Ser_buf
If Left(ser_buf , 5) = "GPGGA" Then
B1 = Split(ser_buf , Arr(1) , ",")
If Arr(7) = "1" Then
Arr(2) = Left(arr(2) , 6) ' Time in UTC
S2 = Left(arr(2) , 2)
B3 = Val(s2) + B2
If B3 >= 24 Then
B3 = B3 - 24
End If
S2 = Str(b3)
S8 = Format(s2 , "00") + ":" + Mid(arr(2) , 3 , 2) + ":" + Mid(arr(2) , 5 , 2)
B5 = B2 + 1
'Locate 1 , 1
'Lcd "Tijd : " ; S8 ; " " ; A1(b5);
'Locate 2 , 1
'Lcd "Sats : " ; Arr(8) ; " "; 'Number of sats
Portb.1 = 1 'LED on
Locate 1 , 1
Lcd "Breedte: " ; Arr(3) ; " " ; Arr(4) ; 'Lattitude
Locate 2 , 1
Arr(5) = Right(arr(5) , 8)
If Arr(6) = "E" Then
Sl = "O"
Else
Sl = "Z"
End If
Lcd "Lengte : " ; Arr(5) ; " " ; Sl; 'Logitude
If B4 <> 0 Then
B4 = B4 - 1
End If
If B4 = 0 Then
Portb.2 = 0 'Backlight off
End If
Else
B4 = 255
Portb.1 = 1 'LED on
Waitms 500
Portb.1 = 0 'LED off
Waitms 500
Locate 4 , 1
Lcd "Nog geen lock!!. " ;
End If
End If
If Pinb.0 = 0 Then 'Switch between U(TC), W(inter) and (Z)omer
B2 = B2 + 1
If B2 > 2 Then
B2 = 0
End If
End If
If Pind.7 = 0 Then 'Switch backlight on
B4 = 255
Portb.2 = 1 'Backlight on
End If
Loop
End
'--------------RS232-INT---------------------
Dim Udr_buf As Byte
Onrxd:
Udr_buf = Udr 'Read Byte from UART
Select Case Udr_buf
Case 13 :
Case 10 :
Case "$" : Ser_buf = ""
Case Else
If Len(ser_buf) < 82 Then
Ser_buf = Ser_buf + Chr(udr_buf)
End If
End Select
Return |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|