Pa moj kod gore i sadrzi te dve linije! pogledaj!
Nego, evo detaljnog objasnjenja sta se dogadja!
a evo i koda:
isto je iz primera MikroC-a, nista nisam dirao!
/******************************************************************************\
* G P S D e c o d e r *
* Tested on 18F4550 @ 8MHz *
* Program by Umut Erkal on April 9th, 2009 *
* *
* Revision: 1.02 *
* *
* Dev. Board.......: EasyPIC 5 with GLCD 128x64 *
* Dev. Environment.: mikroC PRO for PIC 2009 *
* MCU / Osc........: PIC18F4550 / 8Mhz. *
* GPS Hardware.....: SmartGPS HW. Rev 1.01 on PortC *
* GPS Configuration: High Message Set (J6D, J7D, J8E) *
* *
* GPS Decoder application parses the NMEA sentence to extract: *
* 1. # of Satellites being tracked *
* 2. Clock (HH:MM SS) at fix taken (UTC) *
* 3. Latitude *
* 4. Longitude *
* 5. Altitude above mean sea level *
* 6. Height of geoid above WGS84 ellipsoid *
* *
* It only parses GPGGA data since it is essential fix data which *
* provide 3D location and accuracy data. *
* *
* If you have any questions, please don't hesitate to contact me *
* at
[email protected] *
* *
\******************************************************************************/
// GLCD module connections
char GLCD_DataPort at PORTD;
sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS at RB2_bit;
sbit GLCD_RW at RB3_bit;
sbit GLCD_EN at RB4_bit;
sbit GLCD_RST at RB5_bit;
sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;
// GEnd LCD module connections
// Variables
int received = 0;
char DataType[] = "GPXXX";
char NMEA[] = "$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char receive;
// End Variables
void main() {
Glcd_Init(); // Initialize LCD
Glcd_Fill(0); // Clear display
UART1_Init(4800); // Initialize UART for GPS board connectivity
// LCD Stuff
Glcd_Rectangle(0, 3, 127, 60, 1);
Glcd_Dot(126, 59, 1);
Glcd_Dot(125, 59, 1);
Glcd_Dot(126, 58, 1);
Glcd_Write_Text("GPS Decoder", 30, 0, 1);
Glcd_Write_Text("Time :", 7, 1, 1);
Glcd_Write_Text("Sats", 7, 2, 1);
Glcd_Write_Text("Lat", 7, 3, 1);
Glcd_Write_Text("Lon", 7, 4, 1);
Glcd_Write_Text("Alt", 7, 5, 1);
Glcd_Write_Text("HGeo", 7, 6, 1);
while(1) {
if (UART1_Data_Ready() == 1) {
receive = UART1_Read();
if (receive == '$') // Check if sentence begins.
{
received = 0;
do{
if (UART1_Data_Ready() == 1)
{
UART1_Read_Text(DataType, ",", 10); // Capture GPXXX word
received = 1;
}
} while(received == 0);
// If it is GPGGA Data, then acquire it.
if ((DataType[2] == 'G') && (DataType[3] == 'G') && (DataType[4] == 'A'))
{
received = 0;
do{
if (UART1_Data_Ready() == 1)
{
UART1_Read_Text(NMEA, "*", 100); // Stop at *XX checksum data
received = 1;
}
} while(received == 0);
// Fill GLCD with relevant data
// Number of satellites being tracked
Glcd_Write_Char(NMEA[39], 36, 2, 1);
Glcd_Write_Char(NMEA[40], 42, 2, 1);
// Time Fix Taken (UTC)
Glcd_Write_Char(NMEA[0], 36, 1, 1);
Glcd_Write_Char(NMEA[1], 42, 1, 1);
Glcd_Write_Char(NMEA[2], 54, 1, 1);
Glcd_Write_Char(NMEA[3], 60, 1, 1);
Glcd_Write_Char(NMEA[4], 72, 1, 1);
Glcd_Write_Char(NMEA[5], 78, 1, 1);
// Latitude
Glcd_Write_Char(NMEA[10], 42, 3, 1);
Glcd_Write_Char(NMEA[11], 48, 3, 1);
Glcd_Write_Char(NMEA[12], 60, 3, 1);
Glcd_Write_Char(NMEA[13], 66, 3, 1);
Glcd_Write_Char(NMEA[15], 78, 3, 1);
Glcd_Write_Char(NMEA[16], 84, 3, 1);
Glcd_Write_Char(NMEA[17], 90, 3, 1);
Glcd_Write_Char(NMEA[18], 96, 3, 1);
Glcd_Write_Char(NMEA[19], 102, 3, 1);
Glcd_Write_Char(NMEA[21], 114, 3, 1);
// Longitude
Glcd_Write_Char(NMEA[23], 36, 4, 1);
Glcd_Write_Char(NMEA[24], 42, 4, 1);
Glcd_Write_Char(NMEA[25], 48, 4, 1);
Glcd_Write_Char(NMEA[26], 60, 4, 1);
Glcd_Write_Char(NMEA[27], 66, 4, 1);
Glcd_Write_Char(NMEA[29], 78, 4, 1);
Glcd_Write_Char(NMEA[30], 84, 4, 1);
Glcd_Write_Char(NMEA[31], 90, 4, 1);
Glcd_Write_Char(NMEA[32], 96, 4, 1);
Glcd_Write_Char(NMEA[33], 102, 4, 1);
Glcd_Write_Char(NMEA[35], 114, 4, 1);
// Altitude, Meters, above mean sea level
Glcd_Write_Char(NMEA[47], 36, 5, 1);
Glcd_Write_Char(NMEA[48], 42, 5, 1);
Glcd_Write_Char(NMEA[49], 48, 5, 1);
Glcd_Write_Char(NMEA[50], 54, 5, 1);
Glcd_Write_Char(NMEA[52], 60, 5, 1);
// Height of geoid (mean sea level) above WGS84 ellipsoid
Glcd_Write_Char(NMEA[54], 36, 6, 1);
Glcd_Write_Char(NMEA[55], 42, 6, 1);
Glcd_Write_Char(NMEA[56], 48, 6, 1);
Glcd_Write_Char(NMEA[57], 54, 6, 1);
Glcd_Write_Char(NMEA[59], 60, 6, 1);
}
receive = "x";
}
}
}
}
I KAO STO VIDITE OPET ISTI PROBLEMI SA GRAFICKIM LCD-OM... LINIJE PREKO DISPLEJA I BUSY FLAG IS SET...
kako da ispravim ovo???