You are on page 1of 206

Interfacing a GPS to an LCD using a Microcontroller

A. HENRICHSEN

Interfacing a GPS to an LCD using a Microcontroller


27/10/1998

Interfacing a GPS to an LCD using a Microcontroller


Prepared by: Arne Henrichsen, fourth-year student in the Department of Electrical Engineering at the University of Cape Town Prepared for: The Department of Electrical Engineering University of Cape Town

27/10/1998
This thesis is prepared in partial fulfillment of the requirements for the degree of BSc. in Electrical Engineering.

Acknowledgements
I would like to give my thanks to the following people for all their help and advice. Mr G. Tattersfield, Department of Electrical Engineering, for his guidance as my thesis supervisor. Mr J. Pinto, MSc. Student at the University of Cape Town, for his help with the Atmel Microcontroller. Mr J. Salzwedel, Student at the University of Cape Town, for being a co-operative partner in sharing the GPS receiver, implementing the principles of the GPS and the construction of the final GPS container. And finally to the people at `Avnet Kopp', for lending us their copy of the Motorola GPS manual, and for donating the Motorola voltage regulator and Atmel microcontroller free of charge.

Declaration
The work was my own, although this project could not have been accomplished without the help of the people mentioned in the Acknowledgements. The breakdown

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (1 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

of work on various aspects of the thesis is as follows: Circuit Implementation I received substantial help in the design of the external RAM for the microcontroller from Mr J. Pinto. I was responsible for the PCB layout using the program Tango PCB and the testing of the circuit. The boards were produced by the `Electronics Supermarket' in Cape Town. Design of the GPS box The design and construction of the plastic box for the GPS circuitry was done by `Mr Plastic' from Montague Gardens. Software Implementation The C++ and assembly programs are my own, except for the help I received from Mr J. Pinto with the setting up of the RAM and ROM areas of the microcontroller. Voltage Regulator The voltage regulator used in the circuit was suggested by Mr N. Ballard from `Avnet Kopp'. The incorporation of the regulator into the circuit is entirely my own. System Analysis The final analysis of the GPS system is my own, as are the conlusions drawn.

Terms Of Reference
This Thesis was proposed by Mr G. Tattersfield, Programme Co-ordinator of Electro-Mechanical Engineering at the University of Cape Town. The briefing was given on the 25 June 1998 and work commenced on the 13 July 1998. Mr Tattersfield's specific instructions were: 1. To develop a hand-held GPS system using the following: r The Motorola GPS Oncore Receiver r A Liquid Crystal Display (LCD) 2. To investigate different microcontrollers and choose the most appropriate device to interface the GPS and LCD. 3. The system should be controlled by a small keyboard. 4. The GPS should be powered by a battery. 5. The hand-in date for the thesis is the 28 October 1998.

Synopsis

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (2 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

This thesis describes the investigation undertaken in implementing a hand-held Global Positioning System (GPS). The objectives of this thesis were to use the Motorola Oncore GPS Receiver (Serial No. R3111G1111) in an embedded application and to build a user-friendly GPS system, which would display all basic features of the GPS on a Liquid Crystal Display (LCD). A software based program would be controlled using a certain number of keys, which would in turn operate and control the LCD and GPS. The project was approached by first interfacing the GPS receiver to the PC via the serial port and the LCD to the PC via the parallel port. By studying the protocols of the GPS and LCD, a program was implemented in C++. The next step in the design was to replace the PC using a suitable microcontroller. This microcontroller was chosen to be the Atmel 89C55, as it had the necessary program memory and ports to substitute the PC. In order to program the Atmel chip, the already implemented C++ code was converted into assembly language using a cross compiler. The final circuit was designed around the Atmel 89C55 chip. In order to make the system more versatile, the user is able to switch between the microcontroller and the PC. This was achieved by providing an RS-232 connector, which lets the GPS communicate with any computer. Power is provided by either a car battery or a `Gel' cell battery. The major conclusions that could be drawn from the investigation are: 1. Most functions (position, status, data) could be implemented with the GPS and displayed on the LCD. 2. The use of the Atmel 89C55 microcontroller made the implementation of software and hardware easy as much help was available. 3. The system was succesfully tested and the layout of the keyboard and LCD made the system easy to use. A GPS system was succesfully built and demonstrated. Since time was limited, some functions were not able to be implemented. Thus the following recommendations can be made to improve the system: 1. 2. 3. 4. 5. Display the data obtained from the GPS graphically using the existing LCD, instead of using text as at present. Implement the NMEA format for GPS data output using the RS-232 serial port. Add non-volatile memory in order to store data from the GPS to be used later. Display maps and plot the current position using a bigger colour screen/LCD. Implement Differential GPS to get better position accuracies.

Glossary
BMP - Bitmap Image CG RAM - Character Generator Random Access Memory GPS

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (3 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

- Global Positioning System LCD - Liquid Crystal Display NMEA - National Marine Electronics Association PC - Personal Computer

Contents
1 Introduction 2 The Motorola Oncore GPS 2.1 Brief Description of GPS 2.2 Antenna Information 2.3 GPS Oncore Information 2.3.1 Electrical Specifications 2.3.2 The Serial Interface 2.4 Interface Protocol 2.4.1 Motorola Binary Format 2.4.2 Details of some Commands 2.5 NMEA Interface Standard 2.5.1 Brief Description of NMEA 2.5.2 Outline of Command Structure 3 The Graphics Liquid Crystal Display 3.1 Module Pin-out 3.2 Status Check 3.3 Setting the Cursor and Address Pointer 3.4 Generating User Defined Characters 3.5 Displaying Graphics 4 The Atmel 89C55 Microcontroller 4.1 External RAM 4.2 The Serial Port 4.3 The Keypad 4.4 Other Microcontroller Connections 5 Software Development

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (4 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

5.1 PC application 5.2 Microcontroller application 6 Description of Power Supply 6.1 Switching between the Microcontroller and PC 7 System Analysis and Errors 7.1 Keypad Scanning Routine 7.2 Microcontroller serial port 7.3 GPS Differential Mode 7.4 External RAM 7.5 LCD Contrast Voltage 8 Conclusion 9 Recommendations 10 Bibliography A GPS Oncore Commands B Almanac Parameters C LCD Controller Notes D Circuit Diagrams E C++ Code F Assembly Code G Included Disc

List of Figures
2.1 Oncore GPS Receiver (from the `GT PLUS ONCORE RECEIVER' pamphlet, available from Motorola). 3.1 User defined character of the degree sign 3.2 Bitmap Image displayed on LCD 3.3 Graphics Data Format 4.1 External RAM taken and modified from [Atmel,1997] 4.2 Keypad used in this thesis 5.1 Program Flow Diagram B.1 Details of Subframe 5 C.1 Character Code Map from the T6963C D.1 Circuit Diagram for External RAM D.2 Interface Diagram for LCD

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (5 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

D.3 D.4 D.5 D.6 D.7

Microcontroller and PC to GPS Keypad Connections Power Supply and Contrast Voltage PCB Circuit Design PCB Circuit Keyboard Design

List of Tables
2.1 Oncore Power - Data Connector Pin Assignments [Motorola, 1996]. 2.2 Oncore Interface Protocol [Motorola, 1996] 3.1 Relationship between CG RAM and Offset register 5.1 Virtual KeyBoard A.1 Commands from GPS used for Thesis A.2 NMEA Commands A.3 Format Commands B.1 Parameters of Subframe 4 and 5

Chapter 1 Introduction
This thesis sets out the results of the design and construction of a hand-held GPS receiver system. The NAVigation Satellite and Ranging (NAVSTAR) GPS is an all weather, radio based, satellite navigation system that enables users to accurately determine 3dimensional position, velocity and time worldwide. The GPS system has been developed by the US Department of Defense and the service it provides is free to an unlimited number of users [Motorola, 1996]. Receivers like the Motorola Oncore are inexpensive and easily obtainable and allow the inclusion of the receiver in embedded applications. This gives the designer the freedom of designing a system suitable to a wide range of people [Motorola, 1996]. The Objectives of this thesis was to build a GPS system with the following aspects: 1. Must be hand-held. 2. Must be able to display all relevant information on a Graphics LCD. 3. The interfacing must be done using a microcontroller.

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (6 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

The thesis is restricted to the objectives outlined above due to the limited time that was available. It is up to the recommendations to provide details of other aspects that could be included in a GPS system. This thesis will first investigate the protocols associated with the Motorola Oncore GPS Receiver and the functions to be included in the project. Based on this information and the visual requirements needed to display all necessary data, the graphics LCD screen is discussed. The method of displaying a bitmap image is outlined here in detail. The choice of the Atmel 89C55 microcontroller will be discussed next, focusing on the suitability as an interface between the GPS and LCD. Following this, there will be certain sections describing software development and the final circuit will be described with the chosen power supply. The whole system will be analysed and discussed. Finally, conclusions are made about the design and effectiveness of the GPS system and recommendations are made about further improvements that could be implemented.

Chapter 2 The Motorola Oncore GPS


As the GPS receiver forms the central part of this thesis, the first thing to do was to get a good understanding of the functions and requirements this particular GPS receiver can provide. This was done using the Motorola GT/UT Oncore User's Guide [Motorola, 1996].

2.1 Brief Description of GPS


The overall Global Positioning System consists of three major segments: the space segment, the ground segment, and the user segment. These are detailed below from the Motorola Oncore User's Guide [Motorola, 1996]. Space Segment: This consists of the 24 satellites that make up the GPS. These satellites are found in 6 orbital planes and are equally spaced about the equator and inclined at 55 degrees. The satellites are found at an altitude of 20 183km. Ground Control Segment: This segment consist of a master control center and a number of monitoring stations. This network of stations tracks the satellites and precisely determines their orbits. At certain intervals they will update the almanac ephemeris and other system data which the satellites transmit to the users. User Segment: The user segment consists of all the GPS receivers. The GPS receiver's position is determined by the geometric intersection of several simultaneously observed ranges (satellite to receiver distance) from the satellites with known co-ordinates in space. The receiver measures the time required for a satellite signal to reach the receiver. This transmission time is determined using code correlation techniques. This means that each satellite has a unique code sequence that is identical to a code sequence generated by the receiver. The receiver code is shifted until maximum correlation between the 2 codes exist. This time shift is multiplied by the speed of light and gives the distance to each satellite. Factors like satellite and receiver clock errors and propagation delays are included in that signal. A minimum of 4 satellites need to be tracked in order to solve for 4 unknown parameters (i.e. latitude, longitude, altitude

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (7 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

and clock offset). If one of these parameters is known and fixed, one only needs to track 3 satellites.

2.2 Antenna Information


The major components included in the antenna is a microstrip patch antenna, a ceramic RF filter and a signal preamplifier. This antenna is designed to collect the L1 band signals transmitted from GPS satellites at a frequency of 1575.42 MHz. The signals are then amplified and relayed to the receiver. The signal is first preamplified within the antenna and this is made possible by the external power supply supplied by the Oncore receiver. The antenna module draws 22 mA of current at 5 Vdc, directly from the antenna connector. The Oncore receiver is capable of detecting the presence of an antenna. An antenna sense circuit can detect under current (open circuit), over current (shorted or exceeding maximum receiver limits), or a valid antenna connection [Motorola, 1996]. The above information is available through 2 I/O messages, namely the `Position/Status/Data' and `Self-Test' message.

2.3 GPS Oncore Information


The Motorola Oncore Receiver is a compact and lightweight module, especially designed to be used in embedded applications. It has 8 channels which enables it to track 8 satellites simultaneously. A RF signal processing circuit converts the RF signal received from the antenna to an intermediate frequency (IF) which is passed on to an analog-to-digital converter which digitizes the signal. This digitized IF signal is routed to the 8 channels for code correlation, carrier tracking and filtering. A microprocessor decodes and processes satellite data and computes position, velocity and time [Motorola, 1996].

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (8 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure 2.1: Oncore GPS Receiver (from the `GT PLUS ONCORE RECEIVER' pamphlet, available from Motorola).

2.3.1 Electrical Specifications


The Oncore receiver operates on a +5 Vdc regulated power source. The power source chosen for this thesis will be described in detail later. The data I/O serial port interface is inverted TTL (5 V logic). The receiver has a 10-pin, power/data connector and a miniature RF connector for the antenna connection [Motorola, 1996]. The following table lists the assigned signal connections of the Oncore receiver: Pin No. Signal Name Description 1 Battery Externally applied backup power ( + 5 Vdc)

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (9 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

2 3 4 5 6 7 8 9 10

+5 Power Ground Vpp

+5Vdc regulated main power Ground (receiver) Flash memory programming voltage

RTCM Input Differential correction input pin 1 PPS 1 PPS RTN TTL TXD TTL RXD TTL RTN 1 Pulse per second signal 1 pulse per second return Transmit 5V logic Receive 5V logic Transmit / Receive return

Table 2.1: Oncore Power - Data Connector Pin Assignments [Motorola, 1996]. 5V PWR: 4.75 Vdc to 5.25 Vdc Battery or Backup PWR: 2.5 Vdc to 5.25 Vdc

2.3.2 The Serial Interface


To connect the GPS Oncore receiver to a PC, the TTL signal levels of the receiver have to be converted to RS-232 signal levels (i.e. TTL: 0V to be converted to +3 to +25Volts and TTL: 5V to -3V to -25Volts) To achieve this, the MAX232 driver ( or LT1032 ) is placed in the circuit which operates from a +5V power supply and uses a charge pump to generate the negative supply needed.

2.4 Interface Protocol


The folowing table lists the interface protocol parameters: Format: Motorola Type: Binary Baud Rate: 9600bps Data Bits: 8 bits

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (10 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Start/Stop: 1/1 Parity: none Table 2.2: Oncore Interface Protocol [Motorola, 1996] The I/O port on the receiver operates under interrupt control. The incoming data is stored in a buffer that is serviced by the Oncore every 1.0 seconds.

2.4.1 Motorola Binary Format


The Oncore Receiver uses binary data messages consisting of a number of binary characters. A data message can be divided into the following sections [Motorola, 1996]: Message Start: @@ - (2 x 40hex) denotes the start of the binary message Message ID: (A..Z)(a..z, A..Z) - ASCII upper-case letter, followed by an ASCII lower-case or upper-case letter. These 2 characters together identify the message type and imply the correct message length and format. Binary Data Sequence: This consists of a variable number of bytes of binary data dependent on the command type. Checksum: C - This is the exculsive-or of all bytes after the @@ and prior to the checksum. Message Terminator: <CR> <LF> - carriage return and line feed characters denoting the end of the binary message. A list of all commands used in this thesis are found in Appendix A. Every Oncore receiver input command has a corresponding response message to determine if the command has been accepted or rejected. If a correct command has been received, the receiver will perform the requested function. A binary message is considered received if the following checks out:
q q q

the message started with @@ and is terminated with a carriage return and line feed character. the message is the correct length for its type the checksum validates.

[Motorola, 1996]

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (11 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

The data field contains binary data which can either be integer or floating point data. Negative numbers are stored as two's complement numbers. The Oncore receiver will reject the entire command if one of its input parameters is out of range. For example, to change the GMT offset, the range of hours to be changed is between -23 and +23. If a command is send requesting to change the GMT offset to 24 hours, the entire command is rejected and the original setting is kept. Response messages are identified in the same way as the Oncore receiver decodes the commands.

2.4.2 Details of some Commands


As describing each of the commands will take up many pages, only some commands will be descibed in more detail. These are taken from [Motorola, 1996]. 1. The structure of the `Latitude'command is highlighted. All other commands follow the same structure but may be of different lengths. Input Command: Poll current Latitude: @@AdxxxxC<CR><LF> where xxxx = 4 out of range bytes (99hex99hex99hex99hex) Message length is 11 bytes. Change current Latitude: @@AdddddC<CR><LF> where dddd = latitude in milliarcseconds (mas) (-324 000 000 .. 324 000 000) (-90o .. 90o) Response Message: @@AdddddC<CR><LF> To convert milliarcseconds to degrees, the following relationship is used: 1o = 3 600 000 mas 2. The `Position/Status/Data' command combines nearly all other commands. The response message contains the date, time, position, velocity, geometry, the satellite visibility and tracking status, and the status of each of the 8 channels. The message length is 76 bytes. It is possible to poll the receiver once or to request a updated message at certain intervals. 3. The Almanac data output message contains satellite data. This almanac data is loaded into the onboard RAM of the Oncore receiver and takes about 15 minutes after power-up to be broadcast from the satellites. As there are 34 satellites, there are 34 response messages. Almanac data is transmitted in words 310 of subframe 5 (pages 1-25), and words 3-10 of subframe 4 (pages 2-5, 7-10, and 25) of the satellite broadcast message. Appendix B shows the format of the parameters that are situated in words 3-10 [GPS ICD-200]. As this message requires a big buffer (1122 bytes at least) to store the values in, this command has only been implemented on the PC and not on the

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (12 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

microcontroller.

2.5 NMEA Interface Standard


The Oncore receiver supports the National Marine Electronics Associatian (NMEA) 0183 format for GPS data output [NMEA,1997]. Using the `Switch to NMEA' command makes it possible to change the serial data format of the serial port. The baud rate is switched from 9600 to 4800 and the input commands are only recognized in NMEA format. Due to time limitations, this format was not implemented. It is, however, compared to the Motorola Binary Format.

2.5.1 Brief Description of NMEA


The National Marine Electronics Association (NMEA) developed this standard to allow a satisfactory direct data interface between electronic marine instruments, navigation equipment and communications equipment. This standard defines electrical signal requirements, data transmission protocol and timing for a 4800-baud serial data bus. The intended application for this standard is between a single TALKER to one or many LISTENERS in one-way serial data transmission. The data and commands are in the form of ASCII characters and as in the Motorola binary format, certain sequences of ASCII characters convey information about the position, altitude etc. Each ASCII character has 8 data bits with the most significant bit always set to zero. Valid characters are the ASCII characters from 20h to 7Eh except some characters defined as reserved characters [NMEA,1997].

2.5.2 Outline of Command Structure


The following gives an outline of the reply message the Oncore receiver will send to an electronic navigation instrument [NMEA,1997]: Start of sentence: This is the ASCII character `$'= 24h [Adress field:] This field consists of 5 characters. The first 2 characters identify the TALKER. In the case of the GPS, this code consists of the 2 ASCII characters `GP'. The last 3 characters are the sentence formatter or message ID. Field delimiter: The character `,' = 2Ch starts each field except the address and checksum fiels. If it is followed by a null field, it indicates that no data is present. Data Sentence block: This consists of a series of data fields containing all the data that is transmitted. The sequence is identified by the sentence formatter. Checksum Delimiter: The character `*' = 2Ah follows the last data field and indicates that a 2 byte hex value follows from the checksum. Checksum field: This is the same as in the Motorola Binary format: all data between the `$' and the `*' are exclusive-or'ed together. Terminates the sentence:

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (13 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

<CR> = 0Dh and <LF> = 0Ah. To request such a message from the Oncore, the following command needs to be sent [Motorola, 1996]: Start of command: $PMOTG, where the P identifies the message as Proprietary format; MOT stands for Motorola and G for GPS. [Command field:] This field consists of 3 characters and corresponds to the sentence formatter of the address field above. The Oncore receiver has 7 NMEA commands which are outlined in Appendix A. Update Rate: 4 bytes instruct the receiver to output the message once or continuously. The command also includes field delimiters, a checksum field and the 2 terminating characters. As can be seen above, the NMEA format is similar to the Motorola Binary Format. The NMEA Format makes it easier for an electronic navigation instrument that supports NMEA to communicate with the GPS. As the information from NMEA commands can also be requested through the Motorola Binary Format, the NMEA Format was not implemented. The project could have been expanded to include an electronic navigation instrument that communicates with the GPS.

Chapter 3 The Graphics Liquid Crystal Display


One of the requirements for this thesis was to display all information from the GPS on a LCD. A Graphics display was chosen as the biggest text display only had 40 characters by 4 lines. The display used is a 240 X 64 pixel graphics display from Varitronix (MGL(S)-24064-G-LED03). This was the biggest display the budget could afford. With a 6 X 8 character font, text of 40 characters by 8 lines could be displayed which is sufficient for this thesis. This chapter will describe the LCD controller from Toshiba (T6963C) and how to display a uncompressed black and white bitmap image on the screen.

3.1 Module Pin-out


This section will describe some of the pins from the LCD. 1. The supply voltage is +5 Volts with a negative contrast voltage of about -10 Volts. This contrast voltage depends on the display type and temperature. In the

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (14 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

final circuit a charge pump (LT1054) is included to generate the required negative voltage. As its input +12 Volts is used (directly from Car battery or `Gel' cell battery) which is inverted to -12 Volts. A potentiometer is included in the circuit to enable a variable negative contrast voltage. 2. There are 4 control pins: /WR (Write), /RD (Read), /CE (Chip enable) and C\/D (data/command register). These pins are used to write data or commands, or to read the status byte [Toshiba,1997]. Write data: The data to be written should be set on D0-7 and C/\D taken low /WR taken low (/RD should be high) /CE must be pulsed low for greater than 80ns Write command: The command should be set on D0-7 and C/\D taken high /WR taken low (/RD should be high) /CE must be pulsed low for greater than 80ns Read Status: To check the status of the controller: C/\D taken high /RD taken low (/WR should be high) /CE must be pulsed After approximately 150ns the data can be read from D0-7 /CE taken high 3. This LCD enables the user to choose the font size of the text characters. The fonts available are either 8x8 or 6x8 pixels. A 6x8 font was chosen in order to increase the number of characters per row to 40. Only 30 characters are available per row with an 8x8 font.

3.2 Status Check


Before data or commands are read or written, a status read must be performed. This means checking that Status bit 0 (STA0) and Status bit 1 (STA1) are set to 1. If they are set to zero, the controller is still busy executing a command or an internal read/write is taking place [Toshiba,1997]. It was only possible to interface to the parallel port of the PC if the port was bidirectional. As some PC's only have an output port, a delay of 1ms was inserted before writing the data. As the Atmel microcontroller has bidirectional ports, this was not needed as the status byte can be read directly.

3.3 Setting the Cursor and Address Pointer


On initialisation, the text and graphics home address have to be defined. The address can be anywhere in the RAM area available (8k). The text home address was chosen to be 0000h and the graphics home address to be 0200h. In this way, text and graphics data will not interfere with one another.

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (15 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

The user can choose between either graphics or text mode. In text mode there are certain cursor functions: a 1-8 line cursor, blinking or on/off. The cursor is moved according to the following equation: address = TextBASE + (y * BYTES PER ROW) + x where y = [0,8], x = [0,63] and BYTES PER ROW = 40 with a 6X8 font FromJohn P. Beale's program (May 3-4, 1997, beale@best.com) The cursor pointer is not automatically moved with each write. Only the address pointer is incremented / decremented to the next position. The address pointer is also set up according to the above equation.

3.4 Generating User Defined Characters


Appendix C shows the character map available to this LCD controller. The character codes are different from ASCII codes. To display an ASCII number means subtracting 20h which will be then the correct index into the character map. As this character map does not contain all ASCII characters, it was necessary to generate one's own character. The degree sign character was defined in the following way: 1. The `Offset Register' command is used to determine the external character CG RAM area. As seen in Appendix C, characters are already defined from 00h to 7Fh. User defined characters can be from 80h to FFh in CG RAM. The following table will help chosing the nescessary Offset register data [Toshiba,1997]: Offset Register data CG RAM area 00000 00001 00010 00011 ... 11110 11111 0000 to 07FFh 0800 to 0FFFh 1000 to 17FFh 1800 to 1FFFh ... ... F000 to F7FFh F800 to FFFFh

Table 3.1: Relationship between CG RAM and Offset register

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (16 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

As this LCD only has 8k of RAM available, only the first 4 offset data numbers are usable. The CG RAM area used was from 1800 to 1FFFh, so that character 80h will take up locations 1C00 to 1C07h (1800h + 80h*8 lines). This meant using an offset register number of 3h. 2. Then to set character number 80h to a user defined character:

Figure 3.1: User defined character of the degree sign To store this character in RAM, the address pointer has to be set to 1C00h and the 8 bytes from Figure 3.1 written to it. Setting then the address pointer to 80h will display the degree sign on the LCD.

3.5 Displaying Graphics


To display an image on the LCD involves a number of steps: 1. To create an image in black and white the Microsoft Paint Program was used. A canvas exactly the same size, in pixels, as the LCD was set up in the paint program.

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (17 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure 3.2: Bitmap Image displayed on LCD 2. This image was saved in uncompressed `Tiff' format, now stored in negative mode. A black pixel is thus stored as a logical `0' and a white pixel as a logical `1'. As the LCD is in positive mode, the image will be inverted. To remedy this, the bits were inverted when writing to the LCD. 3. To convert the image into hexadecimal form, a freeware program called bin2hex.exe was used. It is available from the following website: http://www.hantronix.com. This program creates a text file which can be edited to the user's needs. The bytes of the image are listed in the following way: 00 15 12 32 ac ... 4. A `Hantronix' Application Note [Hantronix] says that one must delete the first 25 bytes from that text file, as these bytes are part of the `Tiff' header. This was found not to be true. The text file in question consisted of 2260 bytes. To subtract 25 would give 2235 bytes. The LCD only needs 1920 bytes (30 bytes in a row by 64 pixels (rows)). Thus the `Tiff' header which should be subtracted is 340 bytes long. 5. When reformatting the text file (using a simple text editor) to be included in an assembly program, the bytes will look like the following (see also page 122): db 000h 015h 012h 032h 0ach ... 6. The data is formatted as shown below: This applies to the 240X64 Pixel Display.

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (18 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure 3.3: Graphics Data Format 7. The graphics area in RAM needs to be set up to how many bytes later one wants the next line to start at. This can be the same number of bytes to fill one line of the screen for most efficient use of the RAM. If one would set the number of bytes in RAM less than the number of bytes per row the image gets corrupted as certain bits / bytes get overwritten. With an 8X8 font there are 30 bytes in a row as in the `Tiff' file. But as a 6X8 font is used, the RAM had to be set up to 40 bytes per row. The following equation which sets the address for each of the bytes in the text file on the LCD is taken from John P. Beale's program (May 3-4, 1997, beale@best.com): address = GraphicsBASE + (row * BYTES PER ROW) + (column / 6) where row = [0,63], column = [0,239] and BYTES PER ROW = 40 with a 6X8 font To set the bits on the LCD the `Set bit within byte' command is used. 8. As mentioned above, the image consists of 1920 bytes. Most of the pixels on the image were not set. To compress the same image the number of interstitial `zero' bytes were counted and replaced with a number representing the number of `zero' bytes.

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (19 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

For example: The following sequence of bytes: 0aah 0deh 000h 000h 000h 000h 0ffh would be converted to this: 0aah 0deh 4 0ffh In this way the image was compressed to 1000 bytes. The display routine simply jumps over the number and offsets the address by the required number of bytes. (The code which displays the image on the LCD is found on page 89-90.)

Chapter 4 The Atmel 89C55 Microcontroller


After interfacing the GPS and the LCD to the PC and implemeting the code in C++, it became evident that the microcontroller to be used had to have at least 16 kbytes of Onboard ROM. This came from the fact that the image and the C-code would take up much memory. The microcontroller also needed approximately 512 bytes of RAM, half of it used for the buffer to store the GPS data in and the rest for program variables. A UART serial port was also needed. Two microcontrollers were considered: the XC68HC705C9A from Motorola and the 89C55 from Atmel. As the Motorola microcontroller was not available, the Atmel microcontroller was chosen as it has 20 kbytes of Flash, 256 bytes of RAM and a UART serial port. Another interesting fact was that the Flash Memory was electronically and not UV erasable and made debugging and program development faster. The only drawback was that not enough Onboard RAM was available.

4.1 External RAM


As the program needed another 256 bytes of RAM, a small RAM array was inserted in the circuit. The following figure shows the hardware configuration for accessing up to 2 kbytes of external RAM (see also Figure D.1):

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (20 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure 4.1: External RAM taken and modified from [Atmel,1997] The 3 lines from Port 2 were strapped to +5V as they were not needed. Port 0 supplied the address and data and only 256 bytes could be accessed, which gave an overall total of 512 bytes of RAM. In order to access the external RAM, the `movx' instruction was used instead of the normal `mov' instruction. The address is placed on Port 0 and is latched with the `ALE' pin after which the data is read or written from RAM.

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (21 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

The Atmel 89C55 makes use of 4 register banks. Only register bank `zero' was used during program execution which meant that the other 3 register banks were used as additional 21 bytes of RAM.

4.2 The Serial Port


The serial port was used in Mode `1' with 8 data bits and 1 start and 1 stop bit. The onboard timer/counter1 was used to generate the nescessary baud rate of 9600. With an oscillator frequency of 11.059MHz the following equation was used to determine the reload value for TH1 (the timer/counter high byte 1): TH1 = 256 - [(Oscillator Frequency)/( 384 Baud Rate)] = 253 [Atmel,1997] The serial port was setup so that it could generate an interrupt whenever it received an character, in this case from the Oncore GPS receiver. The characters are read from the microcontroller serial buffer (SBUF) and stored in a temporary circular buffer.

4.3 The Keypad


The program required 7 keys to control the LCD and GPS. The following concept on scanning a keypad is taken and modified from: [Yeralan S and Ahluwalia A, 1995]. The keys were arranged in the following way (see also Figure D.4):

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (22 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure 4.2: Keypad used in this thesis Each pushbutton has 2 terminals with one connected to a column rail and the other to a row rail. The row and column rails are then connected to the microcontroller Port 1. The columns are then driven low by the port and the rows are read in. If no key has been pressed, the rows read `1'. When a row is detected to be `0', it indicates that a key has been pressed. To detect which key has been pressed, the microcontroller loops through each column, driving 1 column at a time low and inspects the row. The row will be grounded when the column in which the key resides is driven low. In this way the keys can be identified. Each key has a number associated with it and this number is stored in the global variable `key'. This particular keypad is implemented to invoke an interrupt. The 2 rows are combined into an AND gate. As the rows are normally at a logic level `1' , the output

http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (23 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

of the AND gate is also a `1'. When a key is pressed, the `1' to `0' transition at the AND gate will trigger the interrupt. A debouncing scheme has also been implemented. After the pressed key has been identified, the rows are checked until the key has been released. Only then does the program continue. (The code which implements the keypad scanning is found on page 78.)

4.4 Other Microcontroller Connections


It was decided that the LCD's data pins should be connected to Port `0' of the microcontroller(see figure D.2). To drive the LCD, pull-up resistors had to be inserted. These pull-up resistors do not interfere with the external RAM. Accessing external RAM also does not have any effect on the LCD as the LCD control lines (on Port `2') are inactive.

Chapter 5 Software Development


Two types of programs were implemented. A program was written in C++ for the PC and another was written in assembly language for the microcontroller. Both programs are identical: they implement the same routines in different languages.

5.1 PC application
In order to get a better understanding of both the GPS and LCD, the thesis was first implemented on the PC. The GPS Oncore was connected to the PC via the serial port and the LCD was connected to the PC via the parallel port. The program was developed using Borland C++ for DOS, as the author has had previous experience with it. The following diagram shows the program flow of the main routines:

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (24 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (25 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure 5.1: Program Flow Diagram If a key has been pressed, the program will decide which Menu to display and which command to send to the GPS. The GPS will then send information back. As the serial port was interrupt driven, every time the GPS Oncore send back data, an interrupt service routine would store the incomming characters in an ringbuffer (see code on page 57).The main program would then check to see if the headpointer and tailpointer of the ringbuffer are equal or not. If not equal, then the ringbuffer received new data and a routine had to decide which command had been send back. A command is identified by the 3rd and 4th character of each sequence (see Appendix A). For each command from the GPS Oncore there is a display function which operates on the data in the ringbuffer and displays it in the best possible way (see code in Appendix E).

5.2 Microcontroller application


The microcontroller had to use the same routines as the PC. The only difference is the implementation of the keypad. The PC has the whole keyboard available to input strings of numbers. It was decided to use only seven keys with the microcontroller. These are the Up and Down Keys, Left and Right Keys, Enter Key, Escape Key and a Menu Key. This meant that a virtual keyboard had to be implemented on the LCD. The four `arrow' keys were used to scroll through the virtual keyboard and the `Enter' key used to select a number. The XY coordinates on the LCD display were used as an index into a Look-up Table to get the correct number selected. The number was then stored in an array. To leave the virtual keyboard, the user has to select the `*' character. The `arrow' keys were used in the same way as outlined above to scroll through the different LCD menus. 0123 *456 789 Table 5.1: Virtual KeyBoard The program flow is exactly the same as for the PC. A cross-compiler was used to change the C++ code to assembler. As the Engineering Departement did not have a cross-compiler, a demo cross-compiler was used. This cross-compiler (HI-TECH C compiler for the 8051) only generated 500 lines of assembly code. Therefore it was nescessary to break up the C++ code into smaller pieces and cross-compile these sections individually. It was then nescessary to edit the assembly code and insert the names of the allocated variables in RAM, as the cross-compiler did not do so.

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (26 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Assembly code was not generated for all functions. The cross-compiler left it to the user to generate code for 32-bit division and displaying strings. 32-bit division was implemented by means of successive subtraction [Yeralan S and Ahluwalia A, 1995]. To display strings of characters the following code was used: lcall lcdprint db "The Oncore Receiver.",0 If a subroutine is called, the return address is pushed onto the stack. On entering this subroutine (lcdprint), the return address is popped again from the stack into the data pointer. This data pointer will now point to the first character of the string, `T'. The data pointer is incremented after each character is displayed. If the data pointer points to a `0', the routine returns to the calling program. As the return address was already popped from the stack, a `jump' is made to the address pointed to by the data pointer, which points now to the instruction after the `0' (see code on page 86). As the LCD character generator RAM only displays one character at a time, a number consisting of several characters had to be split up into its individual characters. For example, the number `125' had to be split up into `1', `2', and `5'. This was achieved by dividing the number by `10', storing the remainder in an array and later displaying the variables in the array. To show how this works the above number is used: 125 / 10 = 12 with a remainder of `5' 12 / 10 = 1 with a remainder of `2' 1 / 10 = 0 with a remainder of `1' The remainder numbers are stored in an array and then displayed individually (see code on page 106).

Chapter 6 Description of Power Supply


A prerequisite for this thesis was to make the GPS portable. This meant running the GPS of batteries. It was decided to use a `Gel' cell battery and as another alternative a car battery. The `Gel' cell battery was chosen as it was small enough and is rechargeable. It supplies 12 Volts with 2.2Ah. As the GPS, LCD and microcontroller need a +5 Volt supply, a voltage regulator was needed. The voltage regulator chosen initially was the LM340. This regulator is designed to change only 10 Volts to the required 5 Volts by dissipating the extra power. Using the `Gel' cell battery with the LM340 wasn't so desirable as the power regulator had to dissipate an extra 2 Volts. As the car battery supplies 14 Volts when the car is running and the `Gel' cell battery supplies 12 Volts, the regulator finally chosen was the MC34167 from Motorola. This is a fixed frequency power-switching regulator which changes any voltage ranging from 7-35 Volts to 5 Volts (see figure D.5). The box which houses the GPS circuitry has an extra compartment to hold the `Gel' cell battery. In order to prevent connecting the car battery to the circuit while the

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (27 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

`Gel' cell battery is still in the compartment, the connector can only be plugged in inside the compartment with the `Gel' cell battery removed.

6.1 Switching between the Microcontroller and PC


To switch between the microcontroller and the PC a Quad Bilateral Switch (HCF4066) was used. Using a `double throw, double pole' switch the bilateral switch and the power to the microcontroller and LCD was controlled (See Figure D.3).

Chapter 7 System Analysis and Errors


The following sections will describe some areas in the GPS system where errors occur or where the design is not very efficient. The errors are mostly timing related, as in the keypad scanning routine. Another factor which will be discussed is the expanding of the external RAM from 256 bytes to 2 kbytes.

7.1 Keypad Scanning Routine


A major problem is that the keys do not respond sometimes when pressed. This is due to other routines still running and setting the `key' variable back to zero, which indicates that no key was pressed. The user then has to press the key a couple of times before the program will function in the normal way again. The key debouncing routine is very efficient, although sometimes the keys react to fast by `jumping' over certain functions in the program. This could be due to the fact that the microcontroller is too fast and already `sees' the next key being pressed. This is minimal though and does not really affect the program.

7.2 Microcontroller serial port


Incoming data from the GPS receiver via the serial port is slow (9600 bps) in comparison to the program execution of the microcontroller (at a frequency of 11.059 MHz). The incoming data is stored in a circular buffer, but at the same time data can be read from it. To prevent the tailpointer from `catching' the headpointer in the circular buffer, every time data is read from the buffer a delay is inserted in the program. The length of the delay was determined by trial and error and is about 50ms. This gives the serial interrupt routine time to store all incoming characters in the buffer.

7.3 GPS Differential Mode


The GPS receiver is only accurate to 100m in the horizontal position and 156m in the vertical position. Only military users have access to the more accurate

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (28 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

satellite code to give them accuracies of centimetres or millimetres. A civilian user could get an accuracy of 1-5 meters by using the GPS Oncore receiver in differential mode (DGPS). This means that a link between a base station, of which the exact position is known and fixed, and a GPS receiver exist so that the GPS receiver can receive correction messages from the base station. A base station can be a GPS receiver being at a fixed location sending its correction messages to another receiver. The GPS GT Oncore receiver, like the one used in this project, is capable of accepting these messages through one of its pins (Pin 5). But as only one GPS receiver was available, the differential mode could not have been implemented. The GPS receiver also has to be capable of generating these correction messages. The VP Oncore receiver from Motorola is capable of generating these correction messages. In South Africa there are some base stations where these correction messages are available. The user has to buy `airtime' from them in order to receive these. A possible way of using the Oncore receiver in differential mode would be to have a cell-phone link between the base staion and the GPS receiver in order to receive these correction messages.

7.4 External RAM


Only 256 bytes of external RAM was used, but the chip can provide up to 2 kbytes of memory. Being able to access this amount of memory, the 2 functions `Almanac data' and `Visible Satellites' could also be implemented with the microcontroller, as these functions need a bigger circular buffer to store data in. Due to time limitations this was not done, but it could be easily implemented by using the 3 unused address lines provided on the RAM chip. These address lines are tied to +5 Volts, but could be connected to the unused pins of port 2 of the microcontroller. The extra address has to be then placed onto the port 2 pins before a `write' or `read' is to be done to external RAM.

7.5 LCD Contrast Voltage


Switching from the `Gel' cell battery to the car battery and vice versa means adjusting the LCD contrast voltage every time using the provided potentiometer. Initially the design provided only the use of one battery and only later included the use of the car battery. As this is not an ideal situation, this contrast voltage should be made battery (voltage) independent. This could be done by adding another voltage inverter and by routing the 2 batteries separately to the 2 voltage inverters.

Chapter 8 Conclusion
The project undertaken to design and build a GPS system was succesfully completed. The final system is hand-held, user-friendly and reliable. From the implementation process and work carried out on the GPS, the following conclusions can be drawn: 1. Microcontroller. The use of the Atmel 8051 microcontroller made the implementation of software and hardware very easy, as much help was available in form of literature and cross-compilers. 2. Battery. The `Gel' cell battery is well suited for hand-held applications, and as it is rechargeable it can be used many times.

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (29 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

3. Method of Operation. The lay-out of the keyboard and LCD as well as the integration of the battery into a separate compartment made the system easy to use. Making use of a virtual keyboard reduces the number of keys on the box but does not reduce the functionability. 4. Cost. The cost of this GPS system is R2000.00 which is initially more expensive than commercially available GPS systems that can be obtained nowadays for less and are much smaller. But having a clear understanding of the Motorola Oncore GPS receiver means that more functions can be implemented at a later stage to the user's preferences.

Chapter 9 Recommendations
As time was limited, many functions of the Oncore receiver could not be implemented. Therefore the following recommendations can be made: 1. 2. 3. 4. 5. Implement the NMEA protocol and use an electronic navigation system to communicate with the GPS. Use the LCD more extensively by displaying the position of the GPS receiver or satellites graphically, instead of only using text. Add non-volatile external memory to record data (i.e. position) in order to recall it later, or use it with the PC together to plot co-ordinates on a map. Display a map and plot the current position on it, using a bigger colour screen. Implement Differential GPS using the existing GPS receiver to get better position accuracies.

Bibliography
[Atmel,1997] Atmel Corporation Microcontroller Data Book, San Jose California, 1997. [GPS ICD-200] GPS Interface Control Document: p86,p123-130 [Hantronix] A simple way to create Bitmap Images for Graphics LCD's [Motorola, 1996] Motorola, GT/UT Oncore User's Guide, p2.1-2.3, 3.2-3.3, 3.7, 5.1-5.3, 6.1-6.45. [NMEA,1997] National Marine Electronics Association, NMEA 0183, Standard for Interfacing Marine Electronic Devices, Version 2.20, January1, 1997. [Toshiba,1997] Toshiba T6963C Data Sheet, Toshiba Corporation, 07/04/1997 [Yeralan S and Ahluwalia A, 1995] Programming and Interfacing the 8051 Microcontroller, Addison-Wesley Publishing Comapany, Massachusetts: p75-111, p176-181, p185-195.

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (30 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Appendix A GPS Oncore Commands


Function Description Time Time Time Time of day GMT Offset Date Binary Command @@Aa @@Ab @@Ac @@Ad @@Ae @@Af @@Ag @@Aq @@Aw @@Bb @@Be @@Bj @@Cf @@Cj @@Ea @@Fa

Position Latitude Position Longitude Position Height Position Satellite Mask Angle Receiver Atmosphere Correction Mode Time Time Mode

Receiver Visible Satellite Status message Almanac Almanac Data Output Time Leap Second Pending Status

Receiver Set-to-Defaults Receiver Receiver ID Position Position/Status/Data Receiver Self-Test

Table A.1: Commands from GPS used for Thesis Command name Description GPGGA GPGLL GPGSA Global Positioning System Fix Data Geographic Position - Latitude/Longitude GPS DOP and Active Satellites

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (31 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

GPGSV GPRMC GPVTG GPZDA

GPS Satellites in View Recommended Minimum Specific GPS / Transit Data Course over Ground and Ground Speed Time and Date

Table A.2: NMEA Commands The following 2 commands are used with the NMEA data format: Command name Description @@Ci Switch to NMEA Format

$PMOTG,FOR, Switch to Motorola Binary Format

Table A.3: Format Commands

Appendix B Almanac Parameters


Parameters No. of Bits Scale Factor e toa i** Omegadot (A)1/2 (Omega)0 16 8 16* 16* 24 24* 24* 2-21 212 2-19 2-38 2-11 2-23 2-23 Units dimensionless seconds semi-circles semi-circles/second meters1/2 semi-circles semi-circles

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (32 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

M0 af0 af1

24* 11* 11*

2-23 2-20 2-38

semi-circles seconds sec/sec

Table B.1: Parameters of Subframe 4 and 5 * These parameters are represented in 2's Complement with the sign bit in the MSB. ** Relative to 0.3 semi-circles.

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (33 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure B.1: Details of Subframe 5 The following pages of subframe 4 have the same format as above: 2-5, 7-10.

Appendix C LCD Controller Notes


takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (34 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure C.1: Character Code Map from the T6963C

Appendix D Circuit Diagrams

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (35 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (36 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure D.1: Circuit Diagram for External RAM

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (37 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (38 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure D.2: Interface Diagram for LCD

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (39 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (40 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure D.3: Microcontroller and PC to GPS

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (41 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (42 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure D.4: Keypad Connections

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (43 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (44 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure D.5: Power Supply and Contrast Voltage

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (45 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (46 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (47 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Figure D.6: PCB Circuit Design

Figure D.7: PCB Circuit Keyboard Design

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (48 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Appendix E C++ Code


The following files make up the 'GPS' program in C++ code: [Writegps.cpp (p50):] Includes the main program from which commands are send to the GPS and messages from the GPS are decoded. Gps.h (p54): Contains the function which sends characters to the GPS and reads characters from the ringbuffer. Lcd.h (p56): Contains lcd routines to display characters on the LCD. Disp.h (p60): Contains routines which format the data received from the GPS and display it. Pic.h (p72): Contains the array holding the bytes for the picture displayed on the LCD. These files are also included on the attached disc. FILE: WRITEGPS.CPP
#include #include #include #include #include #include #include #include #include <conio.h> <dos.h> <math.h> <string.h> <bios.h> "pic.h" "lcd.h" "gps.h" "disp.h"

void main(void) { int num1, num2, num3; int hours, minutes, sign, time, atmos, sat, fix, angle; char index1, index2; char s; int flag = 1, tag = 1, check = 1, count = 0; //make sure control lines are at correct levels lcd_setup(); //initialize LCD memory and display modes lcd_init();

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (49 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

outp(PORT + 1, 0);

//Turn off interrupts

//Save old interrupt vector for later recovery oldport1isr = getvect(INTVECT); setvect(INTVECT, PORTINT);//Set interrupt vector entry //COM1 - 0x0C //COM2 - 0x0B outp(PORT + 3, 0x80); //Set Dlab on //Set Baud rate - Divisor Latch Low Byte outp(PORT + 0, 0x0C); //0x03 = 38 400 BPS - default //0x01 = 115 200 BPS //0x02 = 56 700 BPS //0x0C = 9 600 BPS //0x18 = 4 800 BPS //0x30 = 2 400 BPS //Set Baud rate - Divisor Latch High Byte outp(PORT + 1, 0x00); //8 bits, no parity, 1 stop bit outp(PORT + 3, 0x03); outp(PORT + 2, 0xC7); //FIFO control register outp(PORT + 4, 0x0B); //Turn on DTR, RTS, and OUT2 outp(0x21,(inp(0x21) & 0xEF)); //Set programmable interrupt //controller //COM1 (IRQ4) - 0xEF //COM2 (IRQ3) - 0xF7

outp(PORT + 1, 0x01);

//Interrupt when data received

Disp_Pic(); //Display opening picture: hit any key to get to //main menu do { while(bufferin != bufferout) { index1 = Buffer(); index2 = Buffer(); index1 = Buffer(); index2 = Buffer(); tag = 1; switch(index1) { case 'A': switch(index2) { case 'a': Disp_Aa(0);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (50 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

break; case 'b': Disp_Ab(); break; case 'c': Disp_Ac(0); break; case 'd': Disp_Ad(0); break; case 'e': Disp_Ae(0); break; case 'f': Disp_Af(0); break; case 'g': Disp_Ag(); break; case 'q': Disp_Aq(); break; case 'w': Disp_Aw(); break; } break; case 'B': switch(index2) { case 'b': Disp_Bb(); break; case 'j': Disp_Bj(); break; } break; case 'C': switch(index2) { case 'b': Disp_Cb(); break; case 'f': Disp_Same(0); break; case 'j': Disp_Cj(); break; } break; case 'E': switch(index2) { case 'a':

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (51 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

flag = Disp_Ea(flag); break; } break; case 'F': switch(index2) { case 'a': Disp_Fa(); break; } break; case 'S': switch(index2) { case 'z': Disp_Same(1); break; } break; } }

if(kbhit()) { if(tag == 1) { num1 = 0; tag = 0; } ////////////////UNDO INTERRUPTS AGAIN////////////////// else num1 = Key_Press_0(); switch(num1) { ///////////////////////////////////////////////////////// case MAIN_MENU: Main_Menu(); break; case POS_STA_DAT: Sub_Menu1(); num2 = Key_Press_1(); if((check == 0) && (num2 != 1)) { lcd_clear_text(); //write spaces cput(0x94); //Graphics OFF & Text ON, cursor blinking lcd_xy(0,3); //first character, 3 line lcd_print("Disable first polling command!!!!"); num2 = 10; }

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (52 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

switch(num2) { case POS_STATUS_DATA: Pos_Menu(check); num3 = Key_Press_3(); switch(num3) { case POS_1: Data_To_Gps(pos_status_data, if(count == 1) { flag = 1; count = 0; } if(flag == 0) { flag = 2; count = 1; } check = 1; break; case POS_2: Data_To_Gps(pos_status_data, if(count == 1) count = 0; flag = 0; check = 0; break; case POS_3: Data_To_Gps(pos_status_data, if(count == 1) count = 0; flag = 0; check = 0; break; case POS_4: Data_To_Gps(pos_status_data, if(count == 1) count = 0; flag = 0; check = 0; break; } break;

4, 1, 0, 0, 0);

4, 1, 10, 0, 0);

4, 1, 20, 0, 0);

4, 1, 30, 0, 0);

case LATTITUDE: Data_To_Gps(lattitude, 8, 0, 0, 0, 0); break; case LONGITUDE: Data_To_Gps(longitude, 8, 0, 0, 0, 0); break;

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (53 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

case HEIGHT: Data_To_Gps(height, 9, 0, 0, 0, 0); break; case DATE: Data_To_Gps(date, 8, 0, 0, 0, 0); break; case TIME_OF_DAY: Data_To_Gps(time_of_day, 7, 0, 0, 0, 0); break; case SATELLITES: Data_To_Gps(satellites, 5, 0, 0, 0, 0); break; case ALMANAC: Data_To_Gps(almanac, 5, 0, 0, 0, 0); break; } break; //////////////////////////////////////////////// case GPS_MODES: Sub_Menu2(); num2 = Key_Press_2(); if(check == 0) { lcd_clear_text(); //write spaces cput(0x94);//Graphics OFF & Text ON, cursor blinking lcd_xy(0,3); //first character, 3 line lcd_print("Disable first polling command!!!!"); num2 = 10; } switch(num2) { case GMT: Gmt_Menu(); num3 = Key_Press_4(); switch(num3) { case GMT_POLL: Data_To_Gps(gmt_poll, 7, 0, 0, 0, 0); break; case GMT_CHANGE: lcd_clear_text(); //write spaces cput(0x97);//Graphics OFF & Text ON, cursor blinking

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (54 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcd_xy(4,0); //first character, 3 line lcd_print("Enter offset in hours(-23 .. 23):"); Numbers( 0 ); s = Key_Press_5(); Numbers( 1 ); hours = Key_Press_6(); lcd_clear_text(); //write spaces cput(0x97); //Graphics OFF & Text ON, cursor blinking lcd_xy(4,0); //first character, 3 line lcd_print("Enter offset in minutes(0 .. 59):"); Numbers( 1 ); minutes = Key_Press_6(); if(s == '-') sign = 0xFF; else if(s == '+') sign = 0; Data_To_Gps(gmt_change, 4, 3, sign, hours, minutes); break; } break; case TIME_MODE: Time_Menu(); num3 = Key_Press_4(); switch(num3) { case TIME_MODE_POLL: Data_To_Gps(time_mode_poll, 5, 0, 0, 0, 0); break; case TIME_MODE_CHANGE: Time_Change(); time = Key_Press_4() - 1; Data_To_Gps(time_mode_change, 4, 1, time, 0, 0); break; } break; case LEAP_SECOND: Data_To_Gps(leap_second, 5, 0, 0, 0, 0); break; case ATMOSPHERE: Atmos_Menu(); num3 = Key_Press_4();

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (55 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

switch(num3) { case ATMOSPHERE_POLL: Data_To_Gps(atmosphere_poll, 5, 0, 0, 0, 0); break; case ATMOSPHERE_CHANGE: Atmos_Sub_Menu(); atmos = Key_Press_3() - 1; Data_To_Gps(atmosphere_change, 4, 1, atmos, 0, 0); break; } break; case SATELLITE_MASK: Mask_Menu(); num3 = Key_Press_4(); switch(num3) { case MASK_POLL: Data_To_Gps(mask_poll, 5, 0, 0, 0, 0); break; case MASK_CHANGE: Mask_Sub_Menu(); Numbers( 1 ); angle = Key_Press_6(); Data_To_Gps(mask_change, 4, 1, angle, 0, 0); break; } break; } break; /////////////////////////////////////////////////////////// case RECEIVER_FUNC: Sub_Menu3(); num2 = Key_Press_0(); if(check == 0) { lcd_clear_text(); //write spaces cput(0x94); //Graphics OFF & Text ON, cursor blinking lcd_xy(0,3); //first character, 3 line lcd_print("Disable first polling command!!!!"); num2 = 10; } switch(num2)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (56 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

{ case GPS_ID: Data_To_Gps(gps_id, 4, 0, 0, 0, 0); break; case GPS_SELFTEST: Data_To_Gps(gps_selftest, 4, 0, 0, 0, 0); break; case GPS_SET_DEFAULTS: Data_To_Gps(gps_set_defaults, 4, 0, 0, 0, 0); break; } break; } } } while(num1 != 4); cput(0x98); // Graphics ON, Text OFF, display stored picture outp(PORT + 1, 0); outp(0x21, (inp(0x21) | 0x10)); //Turn //Mask //COM1 //COM2 off interrupts IRQ using PIC (IRQ4) - 0x10 (IRQ3) - 0x08

setvect(INTVECT, oldport1isr); }

//Restore old interrupt vector

FILE: GPS.H
#define PORT #define INTVECT #define DATA_READY 0x3F8 0x0C 1 //COM1 = 0x3F8 //COM2 = 0x2F8 //Com Port's IRQ here

#ifdef __cplusplus #define __CPPARGS ... #else #define __CPPARGS #endif int bufferin = 0; int bufferout = 0; int buffer[2049]; char pos_status_data[4] = { '@', '@', 'E', 'a' }; char lattitude[8] = { '@', '@', 'A', 'd', 0x99, 0x99, 0x99, 0x99 }; char longitude[8] = { '@', '@', 'A', 'e', 0x99, 0x99, 0x99, 0x99 }; char height[9]

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (57 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

= { '@', '@', 'A', 'f', char date[8] = { '@', '@', 'A', 'c', char time_of_day[7] = { '@', '@', 'A', 'a', char satellites[5] = char almanac[5] =

0x99, 0x99, 0x99, 0x99, 0x99 }; 0xFF, 0xFF, 0xFF, 0xFF }; 0xFF, 0xFF, 0xFF }; { '@', '@', 'B', 'b', 0 }; { '@', '@', 'B', 'e', 0 };

char gmt_poll[7] = { '@', '@', 'A', 'b', 0xFF, 0xFF, 0xFF }; char gmt_change[4] = { '@', '@', 'A', 'b' }; char time_mode_poll[5]= { '@', '@', 'A', 'w', 0xFF }; char time_mode_change[4] = { '@', '@', 'A', 'w' }; char leap_second[5] = { '@', '@', 'B', 'j', 0 }; char atmosphere_poll[5] = { '@', '@', 'A', 'q', 0xFF }; char atmosphere_change[4] = { '@', '@', 'A', 'q' }; char mask_poll[5] = { '@', '@', 'A', 'g', 0xFF }; char mask_change[4] = { '@', '@', 'A', 'g' }; char gps_id[4] char gps_selftest[4] char gps_set_defaults[4] = { '@', '@', 'C', 'j' }; = { '@', '@', 'F', 'a' }; = { '@', '@', 'C', 'f' };

void interrupt (*oldport1isr)(__CPPARGS); //Interrupt servive routine (ISR) void interrupt PORTINT(__CPPARGS) //for PORT (COM1) { int status; do { status = inp(PORT + 5); if (status & DATA_READY) { buffer[bufferin] = inp(PORT); bufferin++; if(bufferin == 2048) bufferin = 0; } } while(status & DATA_READY); outp(0x20,0x20); } void Data_To_Gps(char data[], int max, int flag, int var1, int var2, int var3) { int i, checksum = data[2]; for(i = 0; i < max; i++) { outp(PORT, data[i]); delay(1);

//send char to serial port

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (58 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

if(i > 2) checksum ^= data[i]; } checksum ^= var1 ^ var2 ^ var3; if(flag == 1) { outp(PORT, var1); delay(1); } else if(flag == 2) { outp(PORT, var1); delay(1); outp(PORT, var2); delay(1); } else if(flag == 3) { outp(PORT, var1); delay(1); outp(PORT, var2); delay(1); outp(PORT, var3); delay(1); } outp(PORT, checksum); delay(1); outp(PORT, 0x0D); delay(1); outp(PORT, 0x0A); delay(1); } int Buffer() { int ch; ch = buffer[bufferout]; delay(2); bufferout++; if(bufferout == 2048) bufferout = 0; return ch; } long Bytes(int num) { long b; int i; for(i = 0; i < num; i++) { if(i == 0) b = Buffer(); b <<= 8;

//send char to serial port

//send char to serial port //send char to serial port

//send char to serial port //send char to serial port //send char to serial port

//send char to serial port //send <CR> to serial port //send <LF> to serial port

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (59 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

b = b | Buffer(); } return b; } void End() { int byte; byte = Buffer(); byte = Buffer(); byte = Buffer(); }

FILE: LCD.H
////////////////////////////////////////////////////// //Program to control a T6963C-based 240x64 pixel LCD display //////////////////////////////////////////////////////// #define CEHI outp(pcont, (inp(pcont) & 0xfe))//take PC 1 HI #define CELO outp(pcont, (inp(pcont) | 0x01))//take PC 1 LO #define RDHI outp(pcont, (inp(pcont) & 0xfd))//take PC 14 HI #define RDLO outp(pcont, (inp(pcont) | 0x02))//take PC 14 LO #define WRHI outp(pcont, (inp(pcont) | 0x04))//take PC 16 HI #define WRLO outp(pcont, (inp(pcont) & 0xfb))//take PC 16 LO #define CDHI outp(pcont, (inp(pcont) & 0xf7))//take PC 17 HI #define CDLO outp(pcont, (inp(pcont) | 0x08))//take PC 17 LO /* ---- Definitions concerning LCD internal memory #define G_BASE 0x0200 #define T_BASE 0x0000 #define BYTES_PER_ROW 40 --- */

//base address of graphics memory //base address of text memory //how many bytes per row on screen

//This will be 30 with 8x8 font, 40 with 6x8 font, //for both Text & Graphics modes. Font selection by //FS pin on LCD module: //FS=High: 6x8 font. FS=Low: 8x8 font. void dput(int byte); //write data byte to LCD module int sget(void); //check LCD display status pbrt void cput(int byte); //write command byte to LCD module //make sure control lines are at correct levels void lcd_setup(); void lcd_init(); //initialize LCD memory and display modes //send string of characters to LCD void lcd_print(char *string); void lcd_clear_graph(); //clear graphics memory of LCD void lcd_clear_text(); //clear text memory of LCD

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (60 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

//set memory pointer to (x,y) position (text) void lcd_xy(int x, int y); //set single pixel in 240x64 array void lcd_setpixel(int column, int row); void Disp_Pic(); int array[15]; #define BASE 0x378 //base address for parallel port LPT1: int pdata = BASE; //par.port data register int pcont = BASE+2;//par.port control register //////////////////////////////////////////////////////////// void lcd_clear_graph() //clear graphics memory of LCD { int i; dput(G_BASE%256); dput(G_BASE>>8); cput(0x24);

//addrptr at address G_BASE

for (i = 0; i < 2560; i++) { dput(0); //write data cput(0xc0); //inc ptr } //end for(i) } //end lcd_clear_graph()

void lcd_clear_text() { int i; dput(T_BASE%256); dput(T_BASE>>8); cput(0x24); //set low address //set high address //addrptr at address T_BASE

for (i = 0; i < 320; i++)//40 chars in a line * 8 lines { dput(0); //write space cput(0xc0); //inc ptr } //end for(i) } //lcd_clear_text() //send string of characters to LCD void lcd_print(char *string) { int i; int c; for (i = 0; i < strlen(string); i++) { c = string[i] - 0x20; //convert ASCII to LCD char address if (c<0) c=0;

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (61 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

dput(c); cput(0xc0); } //end for } //end lcd_print

//write character //increment memory ptr.

//send string of characters to LCD void lcd_print_num(long num, int f) { long c; int temp; int count = 0, i; temp = num; while(1) { c = num % 10; array[count] = char(c);//convert ASCII to LCD char address count++; num = num / 10; if(num == 0) break; } if((f == 1) && (temp > 0) && (temp < 10)) { array[count] = char(0); count++; } for(i = count - 1; i >= 0 ; i--) { c = array[i] | 0x10; if (c<0) c=0; dput(c); //write character cput(0xc0); //increment memory ptr. } } //end lcd_print_num //send string of characters to LCD void lcd_print_float(float num) { long c, n; int count1 = 0, count2 = 0, count3 = 0, i; int temp; if((num > 0) && (num < 1)) { while(1) { num = num * 10; count1++; if(num >= 1) break; }

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (62 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

} temp = count1; while(1) { n = num; if((n < num) || (n > num)) { num = num * 10; count1++; } else if(n == num) break; } n = num; while(1) { c = n % 10; array[count2] = char(c);//convert ASCII to LCD char address count2++; n = n / 10; if(n == 0) break; } if(count2 > count1) { for(i = (count2 - 1); i >= 0 ; i--) { if(((count2 - count1) == count3) && (count1 != 0)) lcd_print("."); c = array[i] | 0x10; count3++; if (c<0) c=0; dput(c); cput(0xc0);

//write character //increment memory ptr.

} } else if(count2 <= count1) { c = 0x10; dput(c); //write character cput(0xc0); //increment memory ptr. lcd_print("."); count1--; for(i = (count2 - 1); i >= 0 ; i--) { while((temp - 1) > count3) { c = 0x10;

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (63 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

dput(c); cput(0xc0); count3++; } c = array[i] | 0x10; if (c<0) c=0; dput(c); cput(0xc0); } } } //end lcd_print_float

//write character //increment memory ptr.

//write character //increment memory ptr.

//set single pixel in 240x64 array void lcd_setpixel(int column, int row) { int addr; //memory address of byte containing pixel to write addr = G_BASE + (row * BYTES_PER_ROW) + (column / 6); dput(addr%256); dput(addr>>8); cput(0x24); //set LCD addr. pointer //set bit-within-byte command cput(0xf8 | (5 - (column % 6)) ); } //end lcd_setpixel() //set memory pointer to (x,y) position (text) void lcd_xy(int x, int y) { int addr; addr = T_BASE + (y * BYTES_PER_ROW) + x; dput(addr%256); dput(addr>>8); cput(0x24); //set LCD addr. pointer } //lcd_xy() /* =================================================== * Low-level I/O routines to interface to LCD display * based on four routines: * * dput(): write data byte * cput(): write control byte * sget(): read status * =================================================== */ //make sure control lines are at correct levels void lcd_setup() { CEHI; //disable chip RDHI; //disable reading from LCD WRHI; //disable writing to LCD CDHI; //command/status mode

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (64 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

} //end lcd_setup()

void lcd_init() //initialize LCD memory and display modes { dput(G_BASE%256); dput(G_BASE>>8); cput(0x42); //set graphics memory to address G_BASE dput(BYTES_PER_ROW%256); dput(BYTES_PER_ROW>>8); cput(0x43); //n bytes per graphics line dput(T_BASE%256); dput(T_BASE>>8); cput(0x40);

//text memory at address T_BASE

dput(BYTES_PER_ROW%256); dput(BYTES_PER_ROW>>8); cput(0x41); //n bytes per text line cput(0x80); cput(0xA7); dput(0x00); dput(0x00); cput(0x21); //mode set: Graphics OR Text, ROM CGen //cursor is 8 lines high

//put cursor at (x,y) location

//define own char(degree sign) dput(0x03); dput(0x00); cput(0x22); //offset register set / set CG RAM dput(0x00); dput(0x1C); cput(0x24); //set address pointer dput(0x1C); cput(0xC0); dput(0x14); cput(0xC0); dput(0x1C); cput(0xC0); dput(0x00); cput(0xC0); dput(0x00); cput(0xC0); dput(0x00); cput(0xC0); dput(0x00); cput(0xC0); dput(0x00); cput(0xC0);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (65 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

} //end lcd_init() int sget(void) { int lcd_status; //get LCD display status byte

RDLO; //bring LCD /RD line low (read active) WRHI; //make sure WRITE mode is inactive CELO; //bring LCD /CE line low (chip-enable active) CDHI; //bring LCD C/D line high (read status byte) delay(1); lcd_status = inp(pdata); //read LCD status byte CEHI; //bring LCD /CE line high, disabling it RDHI; //deactivate LCD read mode return(lcd_status); } //sget() //write data byte to LCD module over par. port void dput(int byte) //assume PC port in data OUTPUT mode { //wait until display ready do {} while ((0x03 & sget()) != 0x03); outp(pdata, byte); //write value to data port CDLO; WRLO; //activate LCD's write mode RDHI; //make sure LCD read mode is off CELO; //pulse enable LOW > 80 ns (hah!) delay(1); CEHI; //return enable HIGH WRHI; //restore Write mode to inactive } //end dput() void cput(int byte) { //wait until display ready do {} while ((0x03 & sget()) != 0x03); outp(pdata, byte); CDHI; RDHI; WRLO; CELO; delay(1); CEHI; WRHI; } //cput() //present data to LCD on PC's port pins //write command byte to LCD module //assumes port is in data OUTPUT mode

//control/status mode //make sure LCD read mode is off //activate LCD write mode //pulse ChipEnable LOW, > 80 ns, enables LCD I/O //disable LCD I/O //deactivate write mode

void Disp_Pic() { int i = 0, j = 0, k; int num, no;

//generic counter

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (66 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

int counter = 0; lcd_clear_graph(); cput(0x98); //fill graphics memory with 0x00 // Graphics ON, Text OFF

while(1) { num = Gps_pic_less[counter]; if(num > 1000) { for(k = 1000; k < num ; k++) { j += 8; if(j == 240) { j = 0; i++; if(i == 64) break; } } } else { for(k = 0; k < 8; k++) { no = num & 0x80; num <<= 1; if(no == 0x80) lcd_setpixel(j + k, i); } j += 8; if(j == 240) { j = 0; i++; if(i == 64) break; } } counter++; } }

// draw pixel on LCD screen

FILE: DISP.H
#define #define #define #define #define #define MAIN_MENU POS_STA_DAT GPS_MODES RECEIVER_FUNC POS_STATUS_DATA LATTITUDE 0 1 2 3 1 2

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (67 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

#define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define

LONGITUDE HEIGHT DATE TIME_OF_DAY SATELLITES ALMANAC GMT TIME_MODE LEAP_SECOND ATMOSPHERE SATELLITE_MASK GPS_ID GPS_SELFTEST GPS_SET_DEFAULTS POS_1 POS_2 POS_3 POS_4 GMT_POLL GMT_CHANGE TIME_MODE_POLL TIME_MODE_CHANGE ATMOSPHERE_POLL ATMOSPHERE_CHANGE MASK_POLL MASK_CHANGE

3 4 5 6 7 8 1 2 3 4 5 1 2 3 1 2 3 4 1 2 1 2 1 2 1 2

int lines; int chars; int key; long byte; char pole[2]; char *messages[16] = { "Channel 1 Correlation Test "Channel 2 Correlation Test "Channel 3 Correlation Test "Channel 4 Correlation Test "Channel 5 Correlation Test "Channel 6 Correlation Test "Channel 7 Correlation Test "Channel 8 Correlation Test "1 kHz Presence", "ROM Fail", "RAM Fail", "Ignore", "Temperature Sensor Fail", Fail!!!", Fail!!!", Fail!!!", Fail!!!", Fail!!!", Fail!!!", Fail!!!", Fail!!!",

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (68 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

"RTC Comm & Time Fail", "Antenna Overcurrent:", "Antenna Undercurrent:" }; char *channel[9] = { " " " " " " " " " }; code search.", code acquire.", AGC set.", preq acquire.", bit sync detect.", message sync detect.", satellite time available.", ephemeris acquire.", available for position."

char *ch_status[8] = { " "", "", " " " " " }; char *re_status[8] = { " " "", " " " " " };

parity error.",

satellite satellite satellite satellite using for

reported inaccurate(>16m).", reported unhealthy.", anti_spoof flag set.", momentum alert flag.", position fix."

bad almanac.", insufficient visible satellites(< 3).", acquiring satellites.", 2D fix.", 3D fix.", poor geometry (DOP > 12)." position propagate mode."

int nums[3][10] = { { 0, 0, 0, 1, 0, 0, 2, 0, 0, 3}, { 0, 0, 0, 4, 0, 0, 5, 0, 0, 6}, { 0, 0, 0, 7, 0, 0, 8, 0, 0, 9} }; void Init_Text( int f ) { lcd_clear_text(); //write spaces if(f == 0) cput(0x97); //Graphics OFF & Text ON, cursor blinking else if(f == 1) cput(0x94); //Graphics OFF & Text ON, cursor off } void Cursor_Pos(int l, int c) { if(l == -1) lines--; else if(l == 10) lines++;

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (69 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

else lines = l; chars = c; dput(chars); dput(lines); cput(0x21); }

//put cursor at (x,y) location

void Numbers( int f ) { Cursor_Pos(5, 13); lcd_xy(13,4); //first character, 5 line lcd_print("0 1 2 3"); lcd_xy(13,5); //first character, 6 line if(f == 0) lcd_print("- 4 5 6"); else if(f == 1) lcd_print("* 4 5 6"); lcd_xy(13,6); //first character, 7 line if(f == 0) lcd_print("+ 7 8 9"); else if(f == 1) lcd_print(" 7 8 9"); }

int Key_Press_0() { while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x11B) { lines = 6; break; } else if(key == 0x1C0D) break; else if(key == 0x4800) { if(lines > 3) Cursor_Pos(-1, chars); else if(lines == 3) Cursor_Pos(5, chars); } else if(key == 0x5000) { if(lines < 5) Cursor_Pos(10, chars); else if(lines == 5)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (70 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Cursor_Pos(3, chars); } } return (lines - 2); } int Key_Press_1() { while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x11B) { lines = 9; break; } else if(key == 0x1C0D) break; else if(key == 0x4800) { if(lines > 0) Cursor_Pos(-1, chars); else if(lines == 0) Cursor_Pos(7, chars); } else if(key == 0x5000) { if(lines < 7) Cursor_Pos(10, chars); else if(lines == 7) Cursor_Pos(0, chars); } } return (lines + 1); } int Key_Press_2() { while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x11B) { lines = 6; break; } else if(key == 0x1C0D) break; else if(key == 0x4800) { if(lines > 1) Cursor_Pos(-1, chars); else if(lines == 1)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (71 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Cursor_Pos(5, chars); } else if(key == 0x5000) { if(lines < 5) Cursor_Pos(10, chars); else if(lines == 5) Cursor_Pos(1, chars); } } return lines; }

int Key_Press_3() { while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x11B) { lines = 6; break; } else if(key == 0x1C0D) break; else if(key == 0x4800) { if(lines > 1) Cursor_Pos(-1, chars); else if(lines == 1) Cursor_Pos(4, chars); } else if(key == 0x5000) { if(lines < 4) Cursor_Pos(10, chars); else if(lines == 4) Cursor_Pos(1, chars); } } return lines; } int Key_Press_4() { while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x11B) { lines = 6; break;

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (72 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

} else if(key == 0x1C0D) break; else if(key == 0x4800) { if(lines > 3) Cursor_Pos(-1, chars); else if(lines == 3) Cursor_Pos(4, chars); } else if(key == 0x5000) { if(lines < 4) Cursor_Pos(10, chars); else if(lines == 4) Cursor_Pos(3, chars); } } return (lines - 2); } char Key_Press_5() { char sign; while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x11B) { sign = '+'; break; } else if(key == 0x1C0D) break; else if((key == 0x4800) && (chars == 13)) { if(lines > 5) Cursor_Pos(-1, chars); else if(lines == 5) Cursor_Pos(6, chars); } else if((key == 0x5000) && (chars == 13)) { if(lines < 6) Cursor_Pos(10, chars); else if(lines == 6) Cursor_Pos(5, chars); } } if(lines == 5) sign = '-'; else if(lines == 6) sign = '+';

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (73 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

return sign; } int Key_Press_6() { int num = 0, i, count = 0; int yebo[5]; while(1) { while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x11B) { num = 0; break; } else if(key == 0x1C0D) break; else if((key == 0x4800) && (chars != 13)) { if(lines > 4) Cursor_Pos(-1, chars); else if(lines == 4) Cursor_Pos(6, chars); } else if((key == 0x5000) && (chars != 13)) { if(lines < 6) Cursor_Pos(10, chars); else if(lines == 6) Cursor_Pos(4, chars); } else if((key == 0x4800) && (chars == 13)) { if(lines > 4) Cursor_Pos(-1, chars); else if(lines == 4) Cursor_Pos(5, chars); } else if((key == 0x5000) && (chars == 13)) { if(lines < 5) Cursor_Pos(10, chars); else if(lines == 5) Cursor_Pos(4, chars); } else if((key == 0x4B00) && ((lines == 4) || (lines == 5))) { if(chars > 13) Cursor_Pos(lines, chars - 3);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (74 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

else if(chars == 13) Cursor_Pos(lines, 22); } else if((key == 0x4D00) && ((lines == 4) || (lines == 5))) { if(chars < 22) Cursor_Pos(lines, chars + 3); else if(chars == 22) Cursor_Pos(lines, 13); } else if((key == 0x4B00) && (lines == 6)) { if(chars > 16) Cursor_Pos(lines, chars - 3); else if(chars == 16) Cursor_Pos(lines, 22); } else if((key == 0x4D00) && (lines == 6)) { if(chars < 22) Cursor_Pos(lines, chars + 3); else if(chars == 22) Cursor_Pos(lines, 16); } } if(key == 0x11B) { num = 0; break; } else if(key == 0x1C0D) { if((lines == 5) && (chars == 13)) { for(i = 1; i <= count; i++) num = num + yebo[i - 1] * pow(10,count - i); break; } else { count++; yebo[count - 1] = nums[lines - 4][chars - 13]; lcd_xy(14 + count,2); lcd_print_num(yebo[count - 1],0); } } } return num; } void Main_Menu() { Init_Text(0); Cursor_Pos(3, 7); lcd_xy(0,0); //write text from upper left corner

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (75 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcd_print("Main Menu to operate the GPS Oncore."); lcd_xy(0,1); //first character, 2 line lcd_print("Press ESC to quit!!"); lcd_xy(8,3); //first character, 4 line lcd_print("POSITION/STATUS/DATA:"); lcd_xy(8,4); //first character, 5 line lcd_print("GPS MODES:"); lcd_xy(8,5); //first character, 6 line lcd_print("RECEIVER FUNCTIONS:"); } void Sub_Menu1() { Init_Text(0); Cursor_Pos(0, 7); lcd_xy(8,0); //write text from upper left corner lcd_print("POS/STATUS/DATA:"); lcd_xy(8,1); //first character, 2 line lcd_print("LATTITUDE:"); lcd_xy(8,2); //first character, 3 line lcd_print("LONGITUDE:"); lcd_xy(8,3); //first character, 4 line lcd_print("HEIGHT:"); lcd_xy(8,4); //first character, 5 line lcd_print("DATE:"); lcd_xy(8,5); //first character, 6 line lcd_print("TIME OF DAY:"); lcd_xy(8,6); //first character, 7 line lcd_print("VISIBLE SATELLITES:"); lcd_xy(8,7); //first character, 8 line lcd_print("ALMANAC DATA OUTPUT:"); } void Sub_Menu2() { Init_Text(0); Cursor_Pos(1, 7); lcd_xy(8,1); //first character, 2 line lcd_print("GMT OFFSET:"); lcd_xy(8,2); //first character, 3 line lcd_print("TIME MODE:"); lcd_xy(8,3); //first character, 4 line lcd_print("LEAP SECOND PENDING STATUS:"); lcd_xy(8,4); //first character, 5 line lcd_print("ATMOSPHERIC CORRECTION MODE:"); lcd_xy(8,5); //first character, 6 line lcd_print("SATELLITE MASK ANGLE:"); } void Sub_Menu3() { Init_Text(0); Cursor_Pos(3, 11);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (76 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcd_xy(12,3); //first character, 3 line lcd_print("RECEIVER ID:"); lcd_xy(12,4); //first character, 4 line lcd_print("GPS SELFTEST:"); lcd_xy(12,5); //first character, 5 line lcd_print("SET TO DEFAULTS:"); } void Pos_Menu(int flag) { Init_Text(0); Cursor_Pos(1, 1); lcd_xy(2,1); //first character, 2 line if(flag == 0) lcd_print("Disable Polling:"); else if(flag == 1) lcd_print("Poll Position/Status/Data once:"); lcd_xy(2,2); //first character, 3 line lcd_print("Poll Position once every 10 seconds:"); lcd_xy(2,3); //first character, 4 line lcd_print("Poll Position once every 20 seconds:"); lcd_xy(2,4); //first character, 5 line lcd_print("Poll Position once every 30 seconds:"); } void Gmt_Menu() { Init_Text(0); Cursor_Pos(3, 1); lcd_xy(2,3); //first character, 3 line lcd_print("Poll current GMT Offset:"); lcd_xy(2,4); //first character, 4 line lcd_print("Change current GMT Offset:"); } void Time_Menu() { Init_Text(0); Cursor_Pos(3, 1); lcd_xy(2,3); //first character, 3 line lcd_print("Poll current Time Mode:"); lcd_xy(2,4); //first character, 4 line lcd_print("Change current Time Mode:"); } void Time_Change() { Init_Text(0); Cursor_Pos(3, 1);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (77 of 206) [30/05/2004 08:31:22 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcd_xy(2,3); //first character, 3 line lcd_print("GPS Time:"); lcd_xy(2,4); //first character, 4 line lcd_print("UTC Time:"); } void Atmos_Menu() { Init_Text(0); Cursor_Pos(3, 1); lcd_xy(2,3); //first character, 4 line lcd_print("Poll Atmosphere Correction Mode:"); lcd_xy(2,4); //first character, 4 line lcd_print("Change Atmosphere Correction Mode:"); } void Atmos_Sub_Menu() { Init_Text(0); Cursor_Pos(1, 1); lcd_xy(2,1); //first character, 2 line lcd_print("Ionosperic Model disabled:"); lcd_xy(2,2); //first character, 3 line lcd_print("Ionosperic Model only enabled:"); lcd_xy(2,3); //first character, 4 line lcd_print("Tropospheric Model only enabled:"); lcd_xy(2,4); //first character, 5 line lcd_print("Both Models enabled:"); } void Mask_Menu() { Init_Text(0); Cursor_Pos(3, 1); lcd_xy(2,3); //first character, 3 line lcd_print("Poll current Satellite Mask Angle:"); lcd_xy(2,4); //first character, 4 line lcd_print("Change current Satellite Mask Angle:"); } void Mask_Sub_Menu() { Init_Text(0); lcd_xy(2,0); //write text from upper left corner lcd_print("Enter angle in degrees( 0 - 89 ): "); } void Disp_Aa(int flag) {

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (78 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

if(flag == 0) { Init_Text(1); lcd_xy(0,3); //first character, 3 line lcd_print("Current Time: "); } if(flag == 1) { lcd_xy(17,0); lcd_print("/ Time: "); } lcd_print_num(Buffer(),1); lcd_print(":"); lcd_print_num(Buffer(),1); lcd_print(":"); lcd_print_num(Buffer(),1); lcd_print(" hours"); if(flag == 0) End(); } void Disp_Ab() { Init_Text(1); lcd_xy(0,3); //first character, 3 line lcd_print("GMT offset: "); byte = Buffer(); if(byte == 0) lcd_print("+"); else lcd_print("-"); lcd_print_num(Buffer(),0); lcd_print(":"); lcd_print_num(Buffer(),0); lcd_print(" hours"); End(); } void Disp_Ac(int flag) { if(flag == 0) { Init_Text(1); lcd_xy(0,3); //first character, 3 line lcd_print("Current Date(dd/mm/yyyy): "); } else if(flag == 1) { lcd_xy(0,0); lcd_print("Date: ");

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (79 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

} byte = Buffer(); lcd_print_num(Buffer(),1); lcd_print("/"); lcd_print_num(byte,1); lcd_print("/"); lcd_print_num(Bytes(1),0); if(flag == 0) End(); } void Disp_Ad(int flag) { long temp; float minutes; strcpy(pole, "N");

if(flag == 0) { Init_Text(1); lcd_xy(0,1); //first character, 1 line lcd_print("Lattitude(milliarcseconds or mas): "); } byte = Bytes(3); if(flag == 0) { lcd_xy(5,2); if(byte > 0) { lcd_print("+"); temp = byte; } else { lcd_print("-"); temp = -byte; } lcd_print_num(temp,0); lcd_print("mas"); lcd_xy(0,3); //first character, 5 line lcd_print("Lattitude(degrees/min.sec): "); } else if(flag == 1) { lcd_xy(0,1); //first character, 3 line lcd_print("Position: "); } minutes = byte; if(minutes < 0)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (80 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

minutes = -minutes; byte = byte / 3600000; if(byte < 0) { byte = -byte; strcpy(pole, "S"); } if(flag == 0) lcd_xy(5,4); lcd_print_num(byte,0); dput(0x80); //write character(degree sign) cput(0xc0); //increment memory ptr. minutes = ( (minutes/3600000) - byte) * 60; lcd_print_float(minutes); lcd_print(" "); lcd_print(pole); if(flag == 0) End(); } void Disp_Ae(int flag) { long temp; float minutes; strcpy(pole, "E"); if(flag == 0) { Init_Text(1); lcd_xy(0,1); //first character, 1 line lcd_print("Longitude(milliarcseconds or mas): "); } byte = Bytes(3); if(flag == 0) { lcd_xy(5,2); if(byte > 0) { lcd_print("+"); temp = byte; } else { lcd_print("-"); temp = -byte; } lcd_print_num(temp,0); lcd_print("mas"); lcd_xy(0,3); //first character, 5 line lcd_print("Longitude(degrees/min.sec): ");

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (81 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

} else if(flag == 1) { lcd_xy(23,1); lcd_print("/ "); } minutes = byte; if(minutes < 0) minutes = -minutes;

//first character, 3 line

byte = byte / 3600000; if(byte < 0) { byte = -byte; strcpy(pole, "W"); } if(flag == 0) lcd_xy(5,4); lcd_print_num(byte,0); dput(0x80); //write character(degree sign) cput(0xc0); //increment memory ptr. minutes = ( (minutes/3600000) - byte) * 60; lcd_print_float(minutes); lcd_print(" "); lcd_print(pole); if(flag == 0) End(); } void Disp_Af(int flag) { float height; if(flag == 0) { Init_Text(1); lcd_xy(0,1); //first character, 1 line lcd_print("Height(ellipsoid height in meters): "); lcd_xy(5,2); } else if(flag == 1) { lcd_xy(7,2); //first character, 1 line lcd_print("Height (m): "); } byte = Bytes(3); height = byte; lcd_print_float(height/100); lcd_print("m"); if(flag == 0) End();

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (82 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

} void Disp_Ag() { Init_Text(1); lcd_xy(0,3); //first character, 1 line lcd_print("Satellite Mask Angle(degrees): "); lcd_print_num(Buffer(),0); dput(0x80); //write character(degree sign) cput(0xc0); //increment memory ptr. End(); } void Disp_Aq() { Init_Text(1); lcd_xy(0,3); lcd_print("Atmospheric Correction Mode: "); byte = Buffer(); lcd_xy(2,4); if(byte == 0) lcd_print("'0' = Ionosphere model disabled."); else if(byte == 1) lcd_print("'1' = Ionosphere model only enabled."); else if(byte == 2) lcd_print("'2' = Troposphreric model only enabled."); else if(byte == 3) lcd_print("'3' = Both models enabled."); End(); } void Disp_Aw() { Init_Text(1); lcd_xy(0,3); lcd_print("Current Time Mode: "); byte = Buffer(); lcd_xy(2,4); if(byte == 0) lcd_print("'0' = GPS Time."); else if(byte == 1) lcd_print("'1' = UTC Time."); End(); } void Disp_Bb() { int num, i, key;

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (83 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Init_Text(1); lcd_xy(3,3); lcd_print("Current Visible Satellites: "); num = Buffer(); lcd_print_num(num,0); lcd_xy(10,7); lcd_print("...press enter for next page."); while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x1C0D) break; } for(i = 0; i < num; i++) { Init_Text(1); lcd_xy(0,1); lcd_print("Satellite "); lcd_print_num(i + 1,0); lcd_print(": PN code ID: "); lcd_print_num(Buffer(),0); lcd_xy(0,2); lcd_print("Doppler freq: "); lcd_print_num(Bytes(1),0); lcd_print("Hz"); lcd_xy(0,3); lcd_print("Elevation: "); lcd_print_num(Buffer(),0); dput(0x80); //write character(degree sign) cput(0xc0); //increment memory ptr. lcd_xy(0,4); lcd_print("Azimuth: "); lcd_print_num(Bytes(1),0); dput(0x80); //write character(degree sign) cput(0xc0); //increment memory ptr. byte = Buffer(); lcd_xy(0,5); lcd_print("Satellite is "); if(byte == 0) lcd_print("healthy & not removed."); else if(byte == 1) lcd_print("healthy & removed."); else if(byte == 2) lcd_print("unhealthy & not removed."); else if(byte == 3) lcd_print("unhealthy & removed."); lcd_xy(35,7);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (84 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcd_print("....."); while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x1C0D) break; } } num = (12 - num) * 7; for(i = 0; i < num; i++) byte = Buffer(); End(); } void Disp_Bj() { Init_Text(1); lcd_xy(0,3); lcd_print("Leap Second Pending Status: "); byte = Buffer(); lcd_xy(2,4); if(byte == 0) lcd_print("'0' = No leap second pending."); else if(byte == 1) lcd_print("'1' = Addition of one second pending."); else if(byte == 2) lcd_print("'2' = Subtraction of one second pending."); End(); } void Disp_Cb() { int data_id, sv_id, frame, page; int af0, af1; int i; float number; char pm[2]; strcpy(pm, " "); Init_Text(1); frame = Buffer(); page = Buffer(); byte = Buffer(); data_id = ((byte & 0xC0) >> 6); sv_id = (byte & 0x3F); cout << "\n\tData ID: " << data_id; if( (page == 25) || (data_id == 2) || (sv_id > 32) ) { for(i = 0; i < 23; i++) byte = Buffer();

//

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (85 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

End(); } else { lcd_xy(0,0); lcd_print("SUBFRAME: "); lcd_print_num(frame,0); lcd_print(" / PAGE: "); lcd_print_num(page,0); lcd_xy(0,1); lcd_print("SV ID: "); lcd_print_num(sv_id,0); number = Bytes(1) * pow(2, -21); lcd_xy(0,2); lcd_print("Eccentricity: "); lcd_print_float(number); number = Buffer() * pow(2, 12); lcd_xy(0,3); lcd_print("Time of Applicability (s): "); lcd_print_float(number); byte = Bytes(1); if((byte >> 15) & 1 == 1) { number = ((~byte + 1) * pow(2, -19) * M_PI) + (0.3 * M_PI); number = -number; strcpy(pm, "-"); } else number = (byte * pow(2, -19) * M_PI) + (0.3 * M_PI); lcd_xy(0,4); lcd_print("Orbital Inclination(rad): "); lcd_print(pm); lcd_print_float(number); strcpy(pm, " "); byte = Bytes(1); if((byte >> 15) & 1 == 1) { number = (~byte + 1) * pow(2, -38)* M_PI; number = -number; strcpy(pm, "-"); } else number = byte * pow(2, -38)* M_PI; lcd_xy(0,5); lcd_print("Rate of Right Ascen(r/s): "); lcd_print(pm); lcd_print_float(number); strcpy(pm, " "); lcd_xy(11,1); lcd_print("/ Health: "); lcd_print_num(Buffer(),0);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (86 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

number = Bytes(2) * pow(2, -11); lcd_xy(0,6); lcd_print("SQRT(A) (m^1/2): "); lcd_print_float(number); lcd_xy(35,7); lcd_print("....."); while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x1C0D) break; } Init_Text(1); byte = Bytes(2); if((byte >> 23) & 1 == 1) { number = (~byte + 1) * pow(2, -23)* M_PI; number = -number; strcpy(pm, "-"); } else number = byte * pow(2, -23)* M_PI; lcd_xy(0,1); lcd_print("Right Ascen at TOA(rad): "); lcd_print(pm); lcd_print_float(number); strcpy(pm, " ");

byte = Bytes(2); if((byte >> 23) & 1 == 1) { number = (~byte + 1) * pow(2, -23)* M_PI; number = -number; strcpy(pm, "-"); } else number = byte * pow(2, -23)* M_PI; lcd_xy(0,2); lcd_print("Argument of Perigee(rad): "); lcd_print(pm); lcd_print_float(number); strcpy(pm, " "); byte = Bytes(2); if((byte >> 23) & 1 == 1) {

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (87 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

number = (~byte + 1) * pow(2, -23)* M_PI; number = -number; strcpy(pm, "-"); } else number = byte * pow(2, -23)* M_PI; lcd_xy(0,3); lcd_print("Mean Anom(rad): "); lcd_print(pm); lcd_print_float(number); strcpy(pm, " "); af0 = Buffer(); //only get 8MSB's of Af0 af1 = Bytes(1); byte = (af1 >> 2) & 0x0007; af0 = ((af0 << 3) | byte); if((af0 >> 10) & 0x01 == 1) { number = (~af0 + 1) * pow(2, -20); number = -number; strcpy(pm, "-"); } else number = af0 * pow(2, -20); lcd_xy(0,4); lcd_print("Af0 (s): "); lcd_print(pm); lcd_print_float(number); strcpy(pm, " "); af1 >>= 5; if((af1 >> 10) & 0x01 == 1) { number = (~af0 + 1) * pow(2, -20); number = -number; strcpy(pm, "-"); } else number = af1 * pow(2, -38); lcd_xy(0,5); lcd_print("Af1 (s/s): "); lcd_print(pm); lcd_print_float(number); strcpy(pm, " "); End(); lcd_xy(35,7); lcd_print("....."); while(1) { key = _bios_keybrd(_KEYBRD_READ);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (88 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

if(key == 0x1C0D) break; } } }

void Disp_Cj() { int count = 0; char array[2]; Init_Text(1); lcd_xy(0,0); while(bufferin != bufferout) { array[0] = char(Buffer()); if(count == 0) { if(array[0] == 0x0D) {} else if(array[0] == 0x0A) { count++; } } else { if(array[0] == 0x0D) {} else if(array[0] == 0x0A) { if(count == 3) { lcd_xy(17,count - 1); lcd_print(" / "); count++; } else if(count < 3) { lcd_xy(0,count); count++; } else { lcd_xy(0,count - 1); count++; } } else lcd_print(array); } } }

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (89 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

int Disp_Ea(int flag) { int i, j, num; int count = 0; float velocity, heading, dop; int key; Init_Text(1); //data Disp_Ac(1); //time Disp_Aa(1); for(i = 0; i < 4; i++) byte = Buffer(); //lattitude Disp_Ad(1); //longitude Disp_Ae(1); //height Disp_Af(1); for(i = 0; i < 4; i++) byte = Buffer(); //velocity velocity = Bytes(1); lcd_xy(7,3); //first character, 1 line lcd_print("Velocity (m/s): "); lcd_print_float(velocity / 100); heading = Bytes(1); lcd_xy(7,4); //first character, 1 line lcd_print("Current Heading: "); lcd_print_float(heading / 100); dput(0x80); //write character(degree sign) cput(0xc0); //increment memory ptr. //geometry dop = Bytes(1); if(dop == 0) { lcd_xy(6,5); //first character, 1 line lcd_print("Current DOP not computable."); } else { lcd_xy(7,5); //first character, 1 line lcd_print("Current DOP: "); lcd_print_float(dop / 10); } byte = Buffer(); lcd_xy(4,6); //first character, 1 line if(byte == 0) lcd_print("DOP Type: PDOP(3D)/Antenna Ok.");

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (90 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

else if(byte == 1) lcd_print("DOP Type: else if(byte == 64) lcd_print("DOP Type: else if(byte == 65) lcd_print("DOP Type: else if(byte == 128) lcd_print("DOP Type: else if(byte == 129) lcd_print("DOP Type: else if(byte == 192) lcd_print("DOP Type: else if(byte == 193) lcd_print("DOP Type:

HDOP(2D)/Antenna Ok."); PDOP(3D)/Antenna shorted."); HDOP(3D)/Antenna shorted."); PDOP(3D)/Antenna open."); PDOP(3D)/Antenna open."); PDOP(3D)/Antenna shorted."); PDOP(3D)/Antenna shorted.");

if(flag == 1) { lcd_xy(35,7); lcd_print("....."); while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x1C0D) break; } //Satellite visibility Init_Text(1); lcd_xy(5,2); lcd_print("Num of visible satellites: "); lcd_print_num(Buffer(),0); lcd_xy(5,3); lcd_print("Num of satellites tracked: "); lcd_print_num(Buffer(),0); lcd_xy(35,7); lcd_print("....."); while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x1C0D) break; } for(i = 0; i < 8; i++) { Init_Text(1); lcd_xy(3,0); lcd_print("Channel "); lcd_print_num(i + 1,0); lcd_print(" / Satellite ID: "); lcd_print_num(Buffer(),0);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (91 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

byte = Buffer(); lcd_xy(0,1); lcd_print("Channel Tracking Mode: "); lcd_xy(3,2); lcd_print(channel[byte]); lcd_xy(0,3); lcd_print("Carrier to Noise Density Ratio: "); lcd_print_num(Buffer(),0); lcd_print("dB-Hz"); byte = Buffer(); lcd_xy(0,4); lcd_print("Channel Status Flag: "); for(j = 0; j < 8; j++) { num = (byte >> j) & 0x01; if(num == 1) { if(j == 1 || j == 2); else { lcd_xy(1,5 + count); lcd_print(ch_status[j]); count++; } } } if(count == 0) lcd_print("0"); count = 0; while(1) { key = _bios_keybrd(_KEYBRD_READ); if(key == 0x1C0D) break; } } //Receiver status flag Init_Text(1); lcd_xy(5,2); lcd_print("Receiver status flag: "); byte = Buffer(); count = 0; for(j = 0; j < 8; j++) { num = (byte >> j) & 0x01; if(num == 1 && j != 2) { lcd_xy(6,3 + count);

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (92 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcd_print(re_status[j]); count++; } } byte = 1; }//end of flag == 1 else if((flag == 0) || (flag == 2)) { for(i = 0; i < 35; i++) byte = Buffer(); byte = 0; } End(); return byte; }

void Disp_Fa() { int i, num, count = 0; int bit14 = 0, bit15 = 0; Init_Text(1); lcd_xy(7,1); //first character, 1 line lcd_print("GPS Selftest Results: "); byte = Bytes(1); for(i = 0; i < 16; i++) { num = (byte >> i) & 0x01; if(num == 1) { lcd_xy(7,3); lcd_print(messages[i]); } else if(num == 0) count++; if(num == 1 bit14 = else if(num bit15 = && i == 14) 1; == 1 && i == 15) 1;

} if((bit14 == 1 && bit15 == 1) || (bit14 == 1 && bit15 == 0)) { lcd_xy(7,4); lcd_print("Antenna causes a short!!!"); } else if(bit14 == 0 && bit15 == 1) { lcd_xy(7,4); lcd_print("Antenna not connected!!!"); }

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (93 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

if(count == 16) { lcd_xy(7,3); lcd_print("Selftest Passed!!!"); } End(); } void Disp_Same( int f ) { Init_Text(1); lcd_xy(7,3); //first character, 1 line if(f == 0) lcd_print("GPS Receiver Reset!!!"); else if(f == 1) lcd_print("System Power_On Failure!!!"); End(); }

FILE: PIC.H
//Picture for GPS startup (compressed)// int Gps_pic_less[963] = 1054, 0x1f, 0x80, 0x07, 0xf8, 0x03, 0xc0, 1006, 0xf8, 1009, 0x7e, 0x00, 0x7f, 0xff, 0x00, 0x03, 0xff, 1008, 0x0f, 0xc0, 0x80, 1004, 0x01, 0xff, 0xff, 0xe0, 0x01, 0xff, 1003, 0x03, 0x81, 0xc0, 0xe0, 0x03, 0xff, 0xff, 0xc0, 1007, 0x30, 0x00, 0xc0, 1004, 0x07, 0xf8, 0xff, 0xf8, 0x03, 0xf0, 0xe3, 0xe0, 0x3f, 0xfe, 0x0f, 0xc0, 0x01, 0xf8, 0x07, 0xc0, 0x03, 0xf0, 0x7f, 0xfe, 0x00, 0x0c, 0xf8, 0x03, 0xc0, 0x00, 0xf0, 1006, 0x06, 0x1f, 0x86, 0x1c, 1004, 0x1e, 0x00, 0x3e, 0x0f, 1002, 0x18, 0x01, 0xfe, 0x03, 1002, 0x3c, 0x03, 0xc0, 0x78, 1006, 0x18, 0x03, 0xc1, 0x87, 1004, 0x3c, 0x00, 0x1e, 0x0f, 1002, 0xff, 0xff, 0xff, 0xff, { 0x80, 0x0f, 0x07, 0xff, 0x00, 0xff, 0xff, 1004, 0xf0, 0x0f, 0x07, 0x0f, 0x00, 0x03, 1006, 0x38, 0x7c, 0xc0, 1002, 0xf8, 0x83, 0x00, 0xff, 1002, 0x78, 0xc1,

1025, 0xf8, 0xe3, 0xff, 0x01, 0xc0, 0x80, 0x03, 0x03, 0x00, 0xf0, 0xe0, 0x78, 0xc0, 0x03, 1004, 0x0f, 0xff, 0x7c, 1006, 0x0e, 0x1e, 0xff, 0x3c, 1006, 0xc3,

0x01, 1006, 0x7c, 1002, 0xfe, 0x03, 1007, 0xff, 0xff, 0x01, 0x03, 1006, 0xf0, 0x00, 0x07, 0x1f, 0x80, 0xfe, 0x03, 0x0c, 1004, 0x0f, 0xff, 0x03, 0x30, 0x80,

0xff 0x0f 1006 0x7f 0x1f 0xff 0x18 0xff 0xff 0xc1 0xff 0x01 1004 0xfc 0xe0 1002 0x00 0x03 0xc0 0x1e 0x3e 1002 0xff 0xc0 0x03 1003

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (94 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

0x78, 1009, 0xf1, 0x1e, 0xff, 0x03, 0xc0, 0xc0, 0x07, 0xff, 0x03, 0x03, 0xfc, 0x7c, 0x07, 0xf0, 0xff, 0xff, 0xfe, 0xc0, 0xff, 0xfe, 0xe0, 0xf2, 0xff, 0xff, 1003, 1003, 0xff, 0x1e, 0xe0, 1002, 0xff, 0x78, 0x3c, 0xd9, 1002, 0x00, 0x1e, 0x0f, 0x3e, 0x3c, 0x18, 0x0f, 0x07, 0x7e, 1005, 0x06, 0xc0, 0x00, 0x60, 1002, 0x0f, 1003, 0x01, 0xe0,

1002, 0x60, 0x80, 0x0f, 0xff, 0xc0, 0xfc, 1003, 0xf8, 0xff, 0xc0, 0x00, 0x60, 0x01, 0xff, 1003, 1006, 0xff, 0x03, 1005, 0xff, 0x03, 1007, 0x38, 0xff, 0xff, 0xf0, 0x03, 0xff, 0x03, 0x1f, 0x1e, 0xe0, 1002, 1007, 0x18, 0x1e, 0x3f, 0x03, 0xff, 1002, 1007, 1003, 0x80, 0xf1, 0x03, 0x02, 0x30, 1002, 0x0f, 1003, 0x03, 0xf0, 0x03, 0xff, 0x00,

0x18, 0x3f, 1003, 0x80, 0xff, 0x00, 0xe7, 0xf0, 1007, 0xff, 0x00, 0x31, 1003, 0xff, 0xff, 0x03, 0x02, 0xfc, 0xff, 0x02, 0xfa, 0xff, 0xff, 1003, 0xc0, 0xff, 0x00, 0xf8, 0xff, 0xc0, 0xff, 0x03, 0x0f, 0x1e, 0x7f, 1003, 1002, 0xff, 0xc0, 1002, 0x1e, 0x0f, 0x1e, 0x00, 0x82, 0xc0, 0x00, 1003, 0x07, 0xf0, 0x07, 0xf8, 0x00, 0xff, 0xff, 0x01,

0x03, 0xff, 0x78, 1008, 0xf0, 0x1e, 0xff, 1003, 0x01, 0xf8, 0x3c, 0xc3, 0xf0, 0xf8, 0xff, 0xc0, 0x00, 0x30, 0xff, 0x00, 0x38, 0xff, 0xff, 0xf0, 1002, 0xff, 0x7f, 1006, 0xc3, 1005, 0xff, 0xc0, 0xff, 0x03, 0xff, 0x78, 0x3c, 0x93, 1002, 0x1f, 0x03, 0xf8, 1002, 0x7c, 0x30, 1002, 0x0f, 0x0f, 0xe0, 0x00, 0xf8, 0x07, 0x01, 0xff, 0xe0, 0x83,

0xc0, 0xff, 1003, 0xc0, 0xc0, 0x07, 0xff, 0x03, 0x80, 0xe0, 0x03, 0xff, 1003, 1006, 0xff, 0x01, 0x3f, 1003, 0xf8, 0x7f, 1003, 0xf0, 0xff, 0x00, 0x3f, 0xff, 0xfe, 0x01, 0x18, 0xf8, 0xc1, 1005, 0xff, 0xc0, 0xe0, 1002, 1007, 0x18, 0x1f, 0xff, 0xc0, 1002, 0x1e, 1007, 1003, 0x0f, 0xf0, 0xc0, 0x01, 0x01, 0x07, 0xf0, 0x83, 0xf0, 1005, 0xe0,

0x00, 0xff, 0x03, 0x7c, 1003, 0xc0, 0xff, 0xc0, 0x79, 1003, 0xff, 0xff, 0x03, 0x02, 0xfc, 0xf8, 0x8f, 0xf0, 0x00, 0xff, 0xf0, 0x00, 0xff, 0x7f, 0xf0, 0xff, 0x03, 0xff, 1003, 1007, 0x18, 0x7c, 0xc1, 1002, 0x0f, 0x1e, 0x1f, 1003, 1002, 0x03, 1002, 0x07, 0x03, 0x0f, 0x1f, 0xc0, 1002, 0x00, 0xf8, 0x81, 0xfc, 1005, 0xc0, 0x03, 0x01, 0x18,

0x1e, 0xff, 0xc0, 0x6f, 0x78, 1007, 0xff, 0x00, 0xc3, 0xf0, 0x80, 0xff, 0xc0, 0x00, 0x70, 0x00, 0xff, 0x00, 0x1f, 0xff, 0x00, 0x03, 0xff, 0xfe, 1006, 0xf3, 0xff, 0xff, 0xf0, 0xff, 1003, 1007, 0x18, 0x1e, 0xff, 0x03, 0xff, 0x3c, 0x3c, 0x18, 0x0f, 0xfc, 0xc0, 0xf8, 0x80, 0x00, 0x80, 0xfe, 1005, 0x8f, 0x03, 0x01, 0x0c, 0xc0, 0x80, 0xe0,

0x0f 0xff 0x00 0xff 1003 0x01 0xf8 0x1e 0xff 1003 1006 0xff 0x00 0x1c 1003 0xff 0xff 0x7f 0xff 0xff 0x7f 0xff 0xff 0x03 0x01 0x38 0xff 0xcf 1002 0xff 0x78 0xff 1003 1002 0xff 0xc0 0xc0 1002 1007 1003 1002 0x82 1002 1002 0x00 0x78 0x0f 0x03 0x03 0x04 0xc0 0x00 0x60 1002 0x0f 1004

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (95 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

0xff, 0xc0, 1004, 0xff, 0xc0, 0x40, 0x80, 0x80, 0x1f, 0x03, 0xf0, 0xc0, 0xc0, 0xf0, 0x0e, 0x8a, 0x1c, 0x08, 1005, 1005, 0x24, 0x0f, 0x90, 0xc9, 0x7f, 0x00, 1006, 0x90, 0x08, 0xf0, 0x10, 0x0f, 0x10, 0x1f, 1028, 1027, 1027, 0xff, 0x00,

0xff, 1006, 0x7f, 1007, 1004, 1006, 1021, 1021, 1022, 0xff, 1003, 1002, 1004, 1002, 0x1e, 0x09, 0x0f, 0x10, 0x03, 0x80, 0x24, 0xff, 0x21, 0x13, 0xe0, 0x11, 0x01, 0x90, 0x08, 1006, 0x44, 1008, 0x23, 0xc0, 0x1f, 0x01, 0x1f, 0xe0, 0x00,

0xe0, 0x03, 0xc0, 0x07, 0xff, 0x80, 0xc0, 0x07, 0x07, 0xfc, 0x61, 0x80, 0x3f, 1003, 0x1f, 0xf8, 0x07, 0xfc, 0xe0, 1003, 0x60, 0xe0, 0x08, 1008, 0x41, 1005, 0x03, 0x83, 0x2c, 0xf0, 0xe2, 0xc0, 1005, 0x80, 0x24, 0x24, 0xc0, 0xff, 0x90, 0x90, 0x08, 0x49, 0xff, 0x01, 0x21, 0xf8, 0xf2, 1006, 1005, 0x80, 0x04, 0x04, 0xfc, 0x00, 0x21, 0x21, 0xa2, 0x02, 0x41, 0x10, 0x24, 0x48, 0x3e, 0x10, 0xc3, 0x87, 1028, 0x1f, 0xc0, 1028, 0xff, 0xfc, 0xff, 0xff, 1025, 0x01, 0x00 }

0xc0, 0x80, 0x03, 1003, 1006, 1021, 0x01, 1002, 1004, 0x3c, 1004, 0x3f, 0x10, 0x80, 0x10, 1005, 0x98, 0x48, 0x80, 0x21, 0x12, 0xf0, 0x1f, 0x3f, 0x90, 0x08, 0x07, 0x00, 1007, 0x91, 0x48, 0x8e, 0x88, 0xc0, 0x0f, 1027, 0x80, 0xff,

1003, 1004, 0xc0, 0x60, 0x07, 0x60, 0x30, 0x01, 0x06, 0x78, 0x3e, 0xf0, 0x20, 1004, 0x23, 0x03, 0x91, 0x4a, 0x07, 0x21, 0x12, 1005, 0xc7, 0xc0, 0x90, 0x08, 0xf8, 0x10, 0x3f, 0x21, 0x42, 0x1e, 0x41, 1028, 1029, 0x03, 1026, 0xff,

0xff, 0x10, 1003, 0x00, 0xfc, 1006, 0x01, 0x10, 0x3c, 1023, 1005, 1003, 1011, 0x80, 0xc3, 0xf8, 0x21, 0x0a, 0xf0, 0x08, 1006, 0x80, 0xe4, 0x1f, 0x21, 0xa2, 1006, 0x84, 0xff, 0x21, 0x12, 0x20, 0xe2, 0x1f, 0x7f, 0xff, 0x3f, 0xff,

0xff 0xc0 0x3f 0x70 1007 0xc1 0xc3 0x03 1022 0x7f 0x1f 0xc1 0x1f 0x97 0x87 1002 0x31 0x13 0x7c 0x10 0x70 0x90 0x0f 0x80 0x21 0x02 0x80 0x04 0xff 0x08 1008 0xf0 1008 0xc0 0xf0 0xfc 0xff 0xfc

Appendix F Assembly Code

The assembly code consists of only one file: 'Oncore.as'. The assembly code implements exactly the same functions as the C++ code. Only the 'Almanac' and 'Vissible Satellite' commands are ommitted. This file is also included on the attached disc. FILE: ONCORE.H
;Data Segment dseg at 0008h

;data segment in Ram from 03h

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (96 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

org X0 X1 X2 X3 Y0 Y1 Y2 Y3 Z0 Z1 Z2 Z3 Z4 Z5 Z6 Z7 PR0 PR1 PR2 PR3 equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ org ds

08h 08h 09h 0ah 0bh 0ch 0dh 0eh 0fh 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 1ah 1bh 0030h 0020h ;stack from 030h to 04fh ;32 bytes of stack

Stack:

;now the rest of the Ram from 050h to 07fh is available org 50h i row column address x y l car f lines chars flag tag check count index1 index2 num1 num2 num3 checksum var1 var2 var3 fl fla data data data data data data data data data data data data data data data data data data data data data data data data data data 50h 52h 53h 54h 56h 58h 5ah 5bh 5ch 5dh 5eh 5fh 60h 61h 62h 63h 64h 65h 66h 67h 68h 69h 6ah 6bh 6ch 6dh ;vars for lcd routines

;vars for main function

;vars for data_to_gps function

;var for Numbers function

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (97 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

s hours minutes sign time atmos angle j num lb ch bufferin bufferout key univ ALE

data data data data data data data data data data data data data data data equ

6eh ;vars for main function 6fh 70h 71h 72h 73h 74h 75h ;var for data_to_gps function 76h ;vars for Bytes function 77h 7bh 7ch 7dh 7eh 7fh 8eh

;///////////////////////////////// ;Xdata Segment xseg at 00h ;switch to XDATA segment at address 0 org ringbuffer: ds yebo: ds array: ds aid1 aid2 xdata xdata 00h

230 5 15 0fbh 0fdh

;gives 230 bytes

;//////////////////////////// ;Code Segment cseg at 0000h ;code segment in Rom from 0000h org jmp 0000h Start ;on reset the PC->00h ;skip interrupt routines and go to main prog.

;Interrupt locations and code ;each section has 8 bytes available to it. org jmp org reti org reti org 0003h ;external interrupt 0 Pushbutton 000Bh ;timer 0 interrupt

0013h

;external interrupt 1

001Bh

;timer 1 interrupt

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (98 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

reti org jmp org reti 0023h serial 002Bh ;serial port interrupt

;timer 2 interrupt

;////////////////////////////////////// ;Code starts here: org 0050h ;////////////////////////////////////// ;Interrupt service routine serial serial: push jnb clr serial1: jnb mov clr mov add mov mov movx inc mov cjne mov serialdone: pop reti RI,serialdone ;done if no receive interrupt b,SBUF RI ;clear serial status bit a,bufferin ;buffer[bufferin] = SBUF a,#ringbuffer r0,a a,b @r0,a bufferin ;bufferin++ a,bufferin ;if(bufferin == 230) a,#230,serialdone bufferin,#0 ;bufferin = 0 acc acc TI,serial1 TI ;ignore transmit interrupts

;///////////////////////////////////////////// ;Interrupt service routine Pushbutton Pushbutton: lcall mov jnc jmp GetColumn: lcall swap orl mov jnc jmp

FindRow b,a GetColumn Nothing

FindColumn a a,b b,a ReportKey Nothing

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (99 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

ReportKey: mov jmp Nothing: reti StillKey: lcall jc mov clr reti

key,b StillKey

KeyRelease StillKey P1,#0fh EX0

;waiting for release

;/////////////////////////////////////////////// ;Function FindRow FindRow: mov mov TryNextRow: rrc jnc djnz setb ret RowFound: mov subb clr ret a,P1 r0,#4 ;rows in port 1 ;counter

a RowFound r0,TryNextRow C

a,#4 a,r0 C

;/////////////////////////////////////////////////// ;Function FindColumn FindColumn: mov mov push TryNextColumn: pop mov rl push mov orl cpl jnz djnz pop setb

r0,#4 a,#0efh acc acc P1,a a acc a,P1 a,#0f0h a ColumnFound r0,TryNextColumn acc C

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (100 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov ret ColumnFound: pop mov clr subb clr mov ret

P1,#0fh

acc a,#4 C a,r0 C P1,#0fh

;///////////////////////////////////////////////// ;Function KeyRelease KeyRelease: mov mov orl cpl jz setb ret NoKey: clr ret

P1,#0fh a,P1 a,#0f0h a NoKey C

;/////////////////////////////////////////////// org 01a0h Start: using 0 ;using bank of registers 0 Initilisation: ;sets up stack pointer to 5fh as required. mov SP,#(Stack-1) mov IE,#00h ;disable all interrupts mov P0,#00h ;P0: low, configured as output ;P1: columns low and rows high for keyboard routine mov P1,#0fh mov P2,#0f0h ;P2: low byte output ;initiate serial port anl PCON,#7fh mov TMOD,#20h ;set Timer 1 for auto reload - Mode 2 mov TCON,#41h ;run Timer 1 and set edge trig ints ;set Timer 1 for 9600 baud with xtal = 11.059Mhz mov TH1,#0fdh mov SCON,#50h ;set mode 1 and 8 data bits mov IE,#91h ;enable ES,EX0 and global interrupt ;Disable ALE; only active during movx instruction orl ALE,#01h ;///////////////////////////////////////////// ;Function Main: calls Gps and receives info back ;from Gps and displays it on LCD

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (101 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

main: clr clr mov mov mov mov mov mov mov mov mov mov lcall lcall lcall DoWhile: jmp BeginSwitch: lcall lcall lcall mov lcall mov mov jmp BigA: jmp Case_Aa: mov lcall jmp Case_Ab: lcall jmp Case_Ac: mov lcall jmp Case_Ad: mov lcall jmp Case_Ae: r4,#0 Disp_Ad EndA r4,#0 Disp_Ac EndA Disp_Ab EndA r4,#0 Disp_Aa EndA Switch_A EndSwitch Buffer Buffer Buffer index1,r3 Buffer index2,r3 tag,#1 Main_Switch ;switch(index1) ;case 'A': ;switch(index2) ;case 'a': ;Disp_Aa(0) ;break; ;case 'b': ;Disp_Ab() ;break ;case 'c': ;Disp_Ac(0); ;break ;case 'd': ;Disp_Ad(0) ;break ;case 'e': TI RI flag,#1 tag,#1 check,#1 count,#0 bufferin,#0 bufferout,#0 key,#0 num1,#0 num2,#0 num3,#0 lcd_setup lcd_init Disp_Pic ;do ;while(bufferin != bufferout) ;index1 = Buffer() ;index2 = Buffer() ;index1 = Buffer() ;index2 = Buffer()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (102 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall jmp Case_Af: mov lcall jmp Case_Ag: lcall jmp Case_Aq: lcall jmp Case_Aw: lcall jmp Switch_A: mov add jz dec jz dec jz dec jz dec jz dec jz dec jz add jz add jz jmp EndA: jmp BigB: jmp Case_Bj: lcall jmp Switch_B:

r4,#0 Disp_Ae EndA

;Disp_Ae(0) ;break ;case 'f':

r4,#0 Disp_Af EndA

;Disp_Af(0) ;break ;case 'g': ;Disp_Ag() ;break ;case 'q': ;Disp_Aq() ;break ;case 'w': ;Disp_Aw() ;break

Disp_Ag EndA

Disp_Aq EndA

Disp_Aw EndA

a,index2 a,#159 Case_Aa a Case_Ab a Case_Ac a Case_Ad a Case_Ae a Case_Af a Case_Ag a,#246 Case_Aq a,#250 Case_Aw EndA

EndSwitch

;break ;case 'B': ;switch(index2) ;case 'j': ;Disp_Bj() ;break

Switch_B

Disp_Bj EndB

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (103 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov add jz jmp EndB: jmp

a,index2 a,#150 Case_Bj EndB

EndSwitch

;break

BigC: jmp Case_Cf: mov lcall jmp Switch_C: mov add jz jmp EndC: jmp EndSwitch r4,#0 Disp_Same EndC Switch_C

;case 'C': ;switch(index2) ;case 'f': ;Disp_Same(0) ;break

a,index2 a,#154 Case_Cf EndC

;break

BigE: jmp Case_Ea: lcall jmp Switch_E: mov add jz jmp EndE: jmp EndSwitch Disp_Ea EndE Switch_E

;case 'E': ;switch(index2) ;case 'a': ;flag = Disp_Ea(flag) ;break

a,index2 a,#159 Case_Ea EndE

;break

BigF: jmp Case_Fa: lcall jmp Switch_F: Disp_Fa EndF Switch_F

;case 'F': ;switch(index2) ;case 'a': ;Disp_Fa() ;break

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (104 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov add jz jmp EndF: jmp

a,index2 a,#159 Case_Fa EndF

EndSwitch

;break

BigS: jmp Case_Sz: mov lcall jmp Switch_S: mov add jz jmp EndS: jmp Main_Switch: mov add jz jmp F1: jmp F2: dec jz jmp F3: jmp F4: dec jz add jz dec jz add jz jmp EndSwitch: mov cjne jmp Back: EndSwitch r4,#1 Disp_Same EndS Switch_S

;case 'S': ;switch(index2) ;case 'z': ;Disp_Same(1) ;break

a,index2 a,#134 Case_Sz EndS

;break

a,index1 a,#191 F1 F2 BigA a F3 F4 BigB a BigC a,#254 BigE a BigF a,#243 BigS EndSwitch

a,bufferin a,bufferout,Back Next

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (105 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp

BeginSwitch

;//////////////////////////////////////// Next: mov a,key jz F5 ;if(key != 0) jmp F6 F5: setb EX0 jmp EndCommand F6: mov a,tag cjne a,#1,Fail1 ;if(tag == 1) mov a,key cjne a,#23h,Fail1 mov key,#0 mov num1,#0 ;num1 = 0 mov tag,#0 ;tag = 0 jmp GoToCommands ;else if(tag == 0) Fail1: mov jnz lcall mov setb jmp Fail2: setb mov GoToCommands: jmp MainMenu: lcall jmp Pos_Sta_Dat: lcall lcall mov mov jnz jmp U2: mov cjne jmp U3: jmp U1: jmp U5 U4 a,num2 a,#1,U3 U1 EX0 num1,#5 ;num1 = 5 //else do nothing a,tag Fail2 Key_Press_0 num1,r3 EX0 GoToCommands

;num1 = Key_Press_0()

MainS

;switch(num1) ;case 0: ;Main_Menu() ;break ;case 1: ;Sub_Menu1() ;num2 = Key_Press_1()

Main_Menu EndCommand

Sub_Menu1 Key_Press_1 num2,r3 a,check U1 U2

;if((check == 0) && (num2 != 1))

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (106 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

U5: jmp U4: lcall mov lcall mov mov mov mov lcall lcall db lcd_clear_text r7,#148 cput r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy ;lcd_clear_text() Switch_1

;cput(0x94)

;lcd_xy(0,3)

lcd_print ;lcd_print() "Disable first polling command!!!!",0

mov Switch_1: jmp

num2,#10

;num2 = 10 ;switch(num2)

SwitchSub1 ;case 1: ;Pos_Menu(check)

Pos_Status_Data: lcall Pos_Menu

lcall mov jmp Pos_1: mov mov mov mov mov lcall mov cjne jmp U6: jmp U7: mov mov U8: mov jnz mov mov

Key_Press_3 num3,r3 Pos

;num3 = Key_Press_3() ;switch(num3) ;case 1:

var3,#0 var2,#0 var1,#0 fl,#1 r5,#1 Data_To_Gps a,count a,#1,U6 U7 U8 flag,#1 count,#0

;Data_To_Gps() ;if(count == 1)

;flag = 1 ;count = 0 ;if(flag == 0)

a,flag U9 flag,#2 count,#1 ;flag = 2 ;count = 1

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (107 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

U9: mov jmp Pos_2: mov mov mov mov mov lcall U10: mov cjne jmp U11: jmp U12: mov U13: mov mov jmp Pos_3: mov mov mov mov mov lcall jmp Pos_4: mov mov mov mov mov lcall jmp Pos: mov dec jz jmp F7: jmp F8: dec jz dec a Pos_2 a Pos_1 a,num3 a F7 F8 var3,#0 var2,#0 var1,#30 fl,#1 r5,#1 Data_To_Gps U10 var3,#0 var2,#0 var1,#20 fl,#1 r5,#1 Data_To_Gps U10 flag,#0 check,#0 EndPos ;flag = 0 ;check = 0 ;break ;case 3: count,#0 ;count = 0 U13 a,count a,#1,U11 U12 ;if(count == 1) var3,#0 var2,#0 var1,#10 fl,#1 r5,#1 Data_To_Gps check,#1 EndPos ;check = 1 ;break ;case 2:

;Data_To_Gps()

;Data_To_Gps()

;case 4:

;Data_To_Gps()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (108 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jz dec jz EndPos: jmp Lattitude: mov mov mov mov mov lcall jmp Longitude: mov mov mov mov mov lcall jmp Height: mov mov mov mov mov lcall jmp Date: mov mov mov mov mov lcall jmp Time_Of_Day: mov mov mov mov mov lcall jmp SwitchSub1: mov dec jz

Pos_3 a Pos_4 EndPosition ;break ;case 2: var3,#0 var2,#0 var1,#0 fl,#0 r5,#2 Data_To_Gps EndPosition

;Data_To_Gps() ;break ;case 3:

var3,#0 var2,#0 var1,#0 fl,#0 r5,#3 Data_To_Gps EndPosition

;Data_To_Gps() ;break ;case 4:

var3,#0 var2,#0 var1,#0 fl,#0 r5,#4 Data_To_Gps EndPosition

;Data_To_Gps() ;break ;case 5:

var3,#0 var2,#0 var1,#0 fl,#0 r5,#5 Data_To_Gps EndPosition

;Data_To_Gps() ;break ;case 6:

var3,#0 var2,#0 var1,#0 fl,#0 r5,#6 Data_To_Gps EndPosition

;Data_To_Gps() ;break

a,num2 a F9

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (109 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp F9: jmp F10: dec jz dec jz dec jz dec jz dec jz EndPosition: jmp Gps_Modes: lcall lcall mov mov jnz lcall mov lcall

F10 Pos_Status_Data a Lattitude a Longitude a Height a Date a Time_Of_Day EndCommand ;break ;case 2: ;Sub_Menu2() ;num2 = Key_Press_2()

Sub_Menu2 Key_Press_2 num2,r3 a,check U18 lcd_clear_text r7,#148 cput

;if(check == 0)

;lcd_clear_text()

;cput(0x94)

mov mov mov mov lcall

r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy

;lcd_xy(0,3)

lcall db mov U18: jmp Gmt: lcall lcall mov jmp

lcd_print ;lcd_print() "Disable first polling command!!!!",0 num2,#10 ;num2 = 10 ;switch(num2) SwitchSub2 ;case 1: ;Gmt_Menu() ;num3 = Key_Press_4()

Gmt_Menu Key_Press_4 num3,r3 GmtFind

;switch(num3)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (110 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Gmt_Poll: mov mov mov mov mov lcall jmp Gmt_Change: lcall mov lcall mov mov mov mov lcall lcall db mov lcall lcall mov lcall lcall mov lcall mov lcall mov mov mov mov lcall lcall db mov lcall

;case 1: var3,#0 var2,#0 var1,#0 fl,#0 r5,#7 Data_To_Gps EndGmt

;Data_To_Gps() ;break ;case 2: ;lcd_clear_text()

lcd_clear_text r7,#151 cput r2,#high (0) r3,#low (0) r4,#high (4) r5,#low (4) lcd_xy

;cput(0x97)

;lcd_xy(4,0)

lcd_print ;lcd_print() "Enter offset in hours(-23 .. 23):",0 fla,#0 Numbers Key_Press_5 fla,#1 Numbers Key_Press_6 hours,r3 lcd_clear_text r7,#151 cput r2,#high (0) r3,#low (0) r4,#high (4) r5,#low (4) lcd_xy

;Numbers( 0 ) ;s = Key_Press_5()

;Numbers( 1 ) ;hours = Key_Press_6()

;lcd_clear_text()

;cput(0x97)

;lcd_xy(4,0)

lcd_print ;lcd_print() "Enter offset in minutes(0 .. 59):",0 fla,#1 Numbers

;Numbers( 1 )

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (111 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall mov mov cjne mov jmp U19: mov cjne clr mov U20: mov mov mov mov mov lcall jmp GmtFind: mov dec jz jmp F11: jmp F12: dec jz jmp F13: jmp EndGmt: jmp Time_Mode: lcall lcall mov jmp Time_Mode_Poll: mov mov mov mov mov

Key_Press_6 minutes,r3 a,s a,#(45),U19 sign,#0ffh U20 a,s a,#(43),U20 a sign,a

;minutes = Key_Press_6()

;if(s == '-')

;sign = 0xFF ;else if(s == '+')

;sign = 0

var3,minutes var2,hours var1,sign fl,#3 r5,#8 Data_To_Gps EndGmt

;Data_To_Gps() ;break

a,num3 a F11 F12 Gmt_Poll a F13 EndGmt Gmt_Change EndModes ;break ;case 2: ;Time_Menu() ;num3 = Key_Press_4()

Time_Menu Key_Press_4 num3,r3 TimeFind

;switch(num3) ;case 1:

var3,#0 var2,#0 var1,#0 fl,#0 r5,#9

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (112 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall jmp

Data_To_Gps EndTime

;Data_To_Gps() ;break

Time_Mode_Change: ;case 2: lcall Time_Change ;Time_Change() lcall mov clr subb mov mov mov mov mov mov lcall jmp TimeFind: mov dec jz dec jz EndTime: jmp Key_Press_4 a,r3 c a,#01h time,a var3,#0 var2,#0 var1,time fl,#1 r5,#10 Data_To_Gps EndTime ;time = Key_Press_4() - 1

;Data_To_Gps() ;break

a,num3 a Time_Mode_Poll a Time_Mode_Change EndModes ;break

Leap_Second: mov mov mov mov mov lcall jmp Atmosphere: lcall lcall mov jmp

;case 3: var3,#0 var2,#0 var1,#0 fl,#1 r5,#11 Data_To_Gps EndModes

;Data_To_Gps() ;break ;case 4: ;Atmos_Menu() ;num3 = Key_Press_4()

Atmos_Menu Key_Press_4 num3,r3 AtmosFind

;switch(num3)

Atmosphere_Poll: ;case 1: mov var3,#0 mov var2,#0 mov var1,#0 mov fl,#0 mov r5,#12 lcall Data_To_Gps ;Data_To_Gps()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (113 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp

EndAtmos

;break

Atmosphere_Change: ;case 2: lcall Atmos_Sub_Menu ;Atmos_Sub_Menu() lcall mov clr subb mov mov mov mov mov mov lcall jmp AtmosFind: mov dec jz dec jz EndAtmos: jmp Key_Press_3 a,r3 c a,#01h atmos,a var3,#0 var2,#0 var1,atmos fl,#1 r5,#13 Data_To_Gps EndAtmos ;atmos = Key_Press_3() - 1

;Data_To_Gps() ;break

a,num3 a Atmosphere_Poll a Atmosphere_Change EndModes ;break ;case 5: ;Mask_Menu() ;num3 = Key_Press_4()

Satellite_Mask: lcall Mask_Menu lcall mov jmp Mask_Poll: mov mov mov mov mov lcall jmp Mask_Change: lcall mov lcall lcall mov Key_Press_4 num3,r3 Sat_Find

;switch(num3) ;case 1:

var3,#0 var2,#0 var1,#0 fl,#0 r5,#14 Data_To_Gps EndMask

;Data_To_Gps() ;break

;case 2: Mask_Sub_Menu ;Mask_Sub_Menu() fla,#1 Numbers Key_Press_6 angle,r3

;Numbers( 1 ) ;angle = Key_Press_6()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (114 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov mov lcall jmp Sat_Find: mov dec jz dec jz EndMask: jmp SwitchSub2: mov dec jz jmp F15: jmp F16: dec jz jmp F17: jmp F18: dec jz jmp F19: jmp F20: dec jz jmp F21: jmp F22: dec jz jmp F23: jmp F24: EndModes: jmp

var3,#0 var2,#0 var1,angle fl,#1 r5,#15 Data_To_Gps EndMask

;Data_To_Gps() ;break

a,num3 a Mask_Poll a Mask_Change EndModes ;break

a,num2 a F15 F16 Gmt a F17 F18 Time_Mode a F19 F20 Leap_Second a F21 F22 Atmosphere a F23 F24 Satellite_Mask

EndCommand

;break

Receiver_Func:

;case 3:

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (115 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall lcall mov mov jnz lcall mov lcall mov mov mov mov lcall lcall db mov U31: jmp Gps_Selftest: mov mov mov mov mov lcall jmp

Sub_Menu3 Key_Press_4 num2,r3 a,check U31

;Sub_Menu3() ;num2 = Key_Press_0()

;if(check == 0)

lcd_clear_text ;lcd_clear_text() r7,#148 cput r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy

;cput(0x94)

;lcd_xy(0,3)

lcd_print ;lcd_print() "Disable first polling command!!!!",0 num2,#10 ;num2 = 10 ;switch(num2) SwitchSub3 ;case 2: var3,#0 var2,#0 var1,#0 fl,#0 r5,#16 Data_To_Gps EndFunc

;Data_To_Gps() ;break

Gps_Set_Defaults: ;case 3: mov var3,#0 mov var2,#0 mov var1,#0 mov fl,#0 mov r5,#17 lcall Data_To_Gps ;Data_To_Gps() jmp EndFunc ;break SwitchSub3: mov dec jz dec jz EndFunc: jmp

a,num2 a Gps_Selftest a Gps_Set_Defaults EndCommand ;break

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (116 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

MainS: mov jz jmp F25: jmp F26: dec jz jmp F27: jmp F28: dec jz jmp F29: jmp F30: dec jz jmp F31: jmp F32: EndCommand: mov mov mov cjne jmp StartAgain: jmp EndMain: mov lcall jmp Receiver_Func a F31 F32 Gps_Modes a F29 F30 Pos_Sta_Dat a F27 F28 MainMenu a,num1 F25 F26

P1,#0fh key,#0 a,num1 a,#4,StartAgain ;while(num1 != 4) EndMain DoWhile r7,#152 cput Final

;cput(0x98)

;////////////////////////////////////////////// ;Functions for Control signals WRHI: setb ret WRLO: clr ret RDHI: setb ret RDLO: clr p2.1 p2.1 p2.0 p2.0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (117 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

ret CEHI: setb ret CELO: clr ret CDHI: setb ret CDLO: clr ret p2.3 p2.3 p2.2 p2.2

;///////////////////////////////////////////////// ;Function lcd_clear_test lcd_clear_text: mov r7,#0d lcall dput mov lcall mov lcall clr mov mov jmp Loop: mov lcall mov lcall inc mov jnz inc Bypass: Test: mov add mov xrl addc jnc a,i+1 a,#low -(320) a,i+0 a,#80h a,#(high -(320))xor 80h Loop r7,#0d dput r7,#192d cput i+1 a,i+1 Bypass i+0 r7,#0d dput r7,#36d cput a i+0,a i+1,a Test

;clear i

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (118 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

ret ;//////////////////////////////////////////////// ;Function lcd_print lcd_print: prtLCD: pop pop prtNext: clr movc cjne sjmp chrOK: subb mov lcall inc ljmp retPrtLCD: mov jmp a,#20h r7, a wrLCDdata dptr prtNext a, #1h @a+dptr a ; set offset = 0 a,@a+dptr ; get chr from code memory a,#0, chrOK ; if chr = 0 then return retPrtLCD dph dpl ; pop return address into dptr

; send character ; point at next character ; loop till end of string ; point to instruction after string ; return with a jump instruction

;//////////////////////////////////////////// lcd_print1: clr a ; set offset = 0 movc a,@a+dptr ; get chr from code memory mov univ,a mov a,#1 ; set offset = 0 movc a,@a+dptr ; get chr from code memory mov dpl,a mov a,univ mov dph,a printNext: clr a ; set offset = 0 movc a,@a+dptr ; get chr from code memory cjne a,#0, char_is_OK ; if chr = 0 then return sjmp returnPrtLCD char_is_OK: subb a,#20h mov r7, a lcall wrLCDdata ; send character inc dptr ; point at next character ljmp printNext ; loop till end of string returnPrtLCD: ret ;////////////////////////////////////////////////// ;Function wrLCDdata: prints out characters wrLCDdata: lcall

dput

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (119 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall ret

r7,#192d cput

;////////////////////////////////////////////// ;Function lcd_xy: place cursor at x/y position lcd_xy: mov mov mov mov mov mov mov mov lcall mov add mov mov addc mov mov mov anl anl mov lcall mov mov mov lcall mov lcall ret y,r2 y+1,r3 x,r4 x+1,r5 r4,#high (40) r5,#low (40) r2,y r3,y+1 mult8_8 a,r3 a,x+1 address+1,a a,r2 a,x address,a r4,address r5,address+1 4+0,#high (0FFh) 5+0,#low (0FFh) r7,1+4+0 dput r5,address r4,#0 r7,1+4+0 dput r7,#36d cput ;y == 0

;x == 0 ;Bytes_Per_Row = 40

;/////////////////////////////////////////////// ;Function lcd_setup lcd_setup: lcall lcall lcall lcall ret

CEHI RDHI WRHI CDHI

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (120 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;//////////////////////////////////////////////// ;Function lcd_init lcd_init: mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov

r7,#0d dput r7,#2d dput r7,#66d cput r7,#40d dput r7,#0d dput r7,#67d cput r7,#0d dput r7,#0d dput r7,#64d cput r7,#40d dput r7,#0d dput r7,#65d cput r7,#128d cput r7,#167d cput r7,#0d dput r7,#0d dput r7,#33d

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (121 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall

cput

;define own char(degree sign) at 80h mov r7,#3d lcall dput mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall r7,#0d dput r7,#34d cput r7,#0d dput r7,#28d dput r7,#36d cput r7,#28d dput r7,#192d cput r7,#20d dput r7,#192d cput r7,#28d dput r7,#192d cput r7,#0d dput r7,#192d cput r7,#0d dput r7,#192d cput r7,#0d dput

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (122 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall mov lcall mov lcall mov lcall mov lcall

r7,#192d cput r7,#0d dput r7,#192d cput r7,#0d dput r7,#192d cput

;define own char(" ' " sign) at 80h mov r7,#3d lcall dput mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall r7,#0d dput r7,#34d cput r7,#08h dput r7,#1ch dput r7,#36d cput r7,#10h dput r7,#192d cput r7,#10h dput r7,#192d cput r7,#10h dput r7,#192d cput

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (123 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall mov lcall ret

r7,#0 dput r7,#192d cput r7,#0d dput r7,#192d cput r7,#0d dput r7,#192d cput r7,#0d dput r7,#192d cput r7,#0d dput r7,#192d cput

;////////////////////////////////////////////////////// ;Function sget sget: mov P0,#0ffh lcall CDHI lcall RDLO lcall CELO mov a,P0 lcall CEHI lcall RDHI ret ;///////////////////////////////////////////////// ;Function dput dput: lcall sget anl a,#03h cjne a,#03h,dput mov P0,r7 lcall CDLO

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (124 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall lcall lcall lcall lcall ret

WRLO RDHI CELO CEHI WRHI

;///////////////////////////////////////////////// ;Function cput cput: lcall sget anl a,#03h cjne a,#03h,cput mov P0,r7 lcall CDHI lcall RDHI lcall WRLO lcall CELO lcall CEHI lcall WRHI ret ;////////////////////////////////////////// ;Function lcd_clear_graph lcd_clear_graph: mov r7,#0 lcall dput mov lcall mov lcall clr mov mov jmp CC2: mov lcall mov lcall inc mov jnz inc CC1: mov add a,i+1 a,#low -(2560) r7,#0 dput r7,#192 cput i+1 a,i+1 CC1 i ;dput(0) r7,#2 dput r7,#36 cput a i,a i+1,a CC1

; dput(0x0200%256)

;dput(0x0200>>8)

;cput(0x24) ;for (i = 0; i < 2560; i++)

;cput(0xc0)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (125 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov xrl addc jnc ret

a,i a,#80h a,#(high -(2560))xor 80h CC2

;///////////////////////////////////////// ;Function lcd_setpixel ;param column assigned to r4 on entry ;param row assigned to r2 on entry lcd_setpixel: mov mov mov mov mov mov lcall mov add mov mov addc mov mov mov mov mov mov mov mov mov lcall mov mov add mov mov addc mov mov mov anl anl mov mov lcall

row,r2 ;address = 0x0200 + (row * 40) + (column / 6) column,r4 r4,#high (40);Bytes_Per_Row = 40 r5,#low (40) r2,#0 r3,row mult8_8 a,r3 a,#low(512) address+1,a a,r2 a,#high(512) address,a X3,#0 X2,#0 X1,#0 X0,column Y0,#6 Y1,#0 Y2,#0 Y3,#0 DIV32 ;Z4-Qlow - Z7-Qhigh / Z0-rem(low) column,Z0 a,Z4 a,address+1 address+1,a a,Z5 a,address address,a r4,address r5,address+1 4+0,#high (0FFh) 5+0,#low (0FFh) a,r5 r7,a dput ;dput(addr%256)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (126 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall mov lcall mov clr subb mov orl lcall ret

r7,address dput ; dput(addr>>8) r7,#36 cput

;cput(0x24)

a,#05h c a,column r7,a 7,#0f8h cput ;cput(0xf8 | (5 - (column % 6)) )

;////////////////////////////////////////////// ;Function Disp_Pic ;no - > index1 ;num -> x ;counter -> y ;j -> time ;i -> index2 ;k -> i Disp_Pic: mov mov mov mov lcall mov lcall jmp CC4: mov add mov mov addc mov lcall clr movc mov inc lcall clr movc mov a,y+1 a,y+1 r2,a a,y a,y r3,a ADD16 a a,@a+dptr x,a r2 ADD16 a a,@a+dptr x+1,a ;num = Gps_pic_less[counter]

index2,#0 time,#0 y,#0 y+1,#0 lcd_clear_graph ;lcd_clear_graph() r7,#152 cput CC3

;cput(0x98) ;while(1)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (127 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov add mov xrl addc jnc mov mov jmp CC7: mov add mov mov cjne jmp CC8: jmp CC9: mov inc mov cjne jmp CC11: jmp CC12: jmp CC10: inc mov jnz inc CC6: clr mov subb mov xrl mov xrl subb jc CC13: jmp CC5: mov mov jmp CC15: mov

a,x+1 ;if(num > 1000) a,#low -(1001) a,x a,#80h a,#(high -(1001))xor 80h CC5 i,#high(1000) ;for(k = 1000; k < num ; k++) i+1,#low(1000) CC6 ;for(k = 1000; k < num ; k++ a,time a,#08h time,a a,time a,#240,CC8 CC9 CC10 time,#0 index2 a,index2 a,#64,CC11 CC12 CC10 CC13 i+1 a,i+1 CC6 i c a,i+1 a,x+1 b,x b,#80h a,i a,#80h a,b CC7 CC22 i,#0 i+1,#0 CC14 a,x+1 ;else ;for(k = 0; k < 8; k++) ;break ;j = 0 ;i++ ;if(i == 64)

;j += 8 ;if(j == 240)

;no = num & 0x80

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (128 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

anl mov mov mov mov add mov mov addc mov mov mov mov cjne jmp CC16: jmp CC17: mov mov add mov lcall CC18: inc mov jnz inc CC14: mov add mov xrl addc jnc CC19: mov add mov mov cjne jmp CC20: jmp CC21: mov inc mov cjne jmp CC23: jmp CC24: jmp

a,#080h index1,a r0,x r1,x+1 a,r1 a,r1 r1,a a,r0 a,r0 r0,a x,r0 x+1,r1 a,index1 a,#128,CC16 CC17 CC18 r2,index2 a,time a,i+1 r4,a lcd_setpixel i+1 a,i+1 CC14 i

;num <<= 1

;if(no == 0x80)

;lcd_setpixel(j + k, i)

a,i+1 a,#low -(8) a,i a,#80h a,#(high -(8))xor 80h CC15 a,time a,#08h time,a a,time a,#240,CC20 CC21 CC22 time,#0 index2 a,index2 a,#64,CC23 CC24 CC22 CC25 ;break ;j = 0 ;i++ ;if(i == 64) ;j += 8

;if(j == 240)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (129 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

CC22: inc mov jnz inc CC3: jmp CC25: ret CC4 y+1 a,y+1 CC3 y ;counter++

;////////////////////////////////////////////// ;Function Init_Text Init_Text: lcall mov jnz mov lcall jmp middle: mov lcall q: ret ;///////////////////////////////////////////////// ;Function Cursor_Pos Cursor_Pos: mov cjne jmp aa: jmp bb: mov add mov jmp cc: mov cjne jmp ee: jmp ff: inc jmp lines dd ;lines++ ;else gg a,l a,#10d,ee ff a,lines a,#-01h lines,a dd ;lines-cc a,l ;if(l == -1) a,#high (-1),aa ;jump if l != -1 bb ;jump if l == -1 r7,#148 cput

lcd_clear_text a,f middle r7,#151 cput q ;if(f == 0) ;jump to c if accumulator is not zero

;jump to end of function ;else if(f == 1)

;else if(l == 10)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (130 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

gg: mov dd: mov mov lcall mov lcall mov lcall ret ;///////////////////////////////////////////// ;Function Main_Menu Main_Menu: mov lcall mov mov lcall mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db chars,car r7,chars dput r7,lines dput r7,#33 cput lines,l

f,#0 Init_Text car,#7 l,#3 Cursor_Pos r2,#high (0) r3,#low (0) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Main Menu to operate the GPS Oncore.",0 r2,#high (1) r3,#low (1) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Press ESC to quit!!",0 r2,#high (3) r3,#low (3) r4,#high (8) r5,#low (8) lcd_xy lcd_print "POSITION/STATUS/DATA:",0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (131 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db ret

r2,#high (4) r3,#low (4) r4,#high (8) r5,#low (8) lcd_xy lcd_print "GPS MODES:",0 r2,#high (5) r3,#low (5) r4,#high (8) r5,#low (8) lcd_xy lcd_print "RECEIVER FUNCTIONS:",0

;////////////////////////////////////////////////// ;Function Sub_Menu1 Sub_Menu1: mov lcall mov mov lcall mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall

f,#0 Init_Text car,#7 l,#1 Cursor_Pos r2,#high (1) r3,#low (1) r4,#high (8) r5,#low (8) lcd_xy lcd_print "POS/STATUS/DATA:",0 r2,#high (2) r3,#low (2) r4,#high (8) r5,#low (8) lcd_xy lcd_print "LATTITUDE:",0 r2,#high (3) r3,#low (3) r4,#high (8) r5,#low (8) lcd_xy

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (132 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db ret

lcd_print "LONGITUDE:",0 r2,#high (4) r3,#low (4) r4,#high (8) r5,#low (8) lcd_xy lcd_print "HEIGHT:",0 r2,#high (5) r3,#low (5) r4,#high (8) r5,#low (8) lcd_xy lcd_print "DATE:",0 r2,#high (6) r3,#low (6) r4,#high (8) r5,#low (8) lcd_xy lcd_print "TIME OF DAY:",0

;////////////////////////////////////////////////// ;Function Sub_Menu2 Sub_Menu2: mov lcall mov mov lcall mov mov mov mov lcall lcall db mov

f,#0 Init_Text car,#7 l,#1 Cursor_Pos r2,#high (1) r3,#low (1) r4,#high (8) r5,#low (8) lcd_xy lcd_print "GMT OFFSET:",0 r2,#high (2)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (133 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db ret

r3,#low (2) r4,#high (8) r5,#low (8) lcd_xy lcd_print "TIME MODE:",0 r2,#high (3) r3,#low (3) r4,#high (8) r5,#low (8) lcd_xy lcd_print "LEAP SECOND PENDING STATUS:",0 r2,#high (4) r3,#low (4) r4,#high (8) r5,#low (8) lcd_xy lcd_print "ATMOSPHERE CORRECTION MODE:",0 r2,#high (5) r3,#low (5) r4,#high (8) r5,#low (8) lcd_xy lcd_print "SATELLITE MASK ANGLE:",0

;////////////////////////////////////////////////////// ;Function Sub_Menu3 Sub_Menu3: lcall lcall db lcall lcall db ret

Same_XY1 lcd_print "GPS SELFTEST:",0 Same_XY2 lcd_print "SET TO DEFAULTS:",0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (134 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;///////////////////////////////////////////////////// ;Function Pos_Menu Pos_Menu: mov lcall mov mov lcall mov mov mov mov lcall mov jnz lcall db jmp yy0: lcall db yy1: mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db ret r2,#high (2) r3,#low (2) r4,#high (2) r5,#low (2) lcd_xy lcd_print "Poll Position once every 10 seconds: ",0 r2,#high (3) r3,#low (3) r4,#high (2) r5,#low (2) lcd_xy lcd_print "Poll Position once every 20 seconds: ",0 r2,#high (4) r3,#low (4) r4,#high (2) r5,#low (2) lcd_xy lcd_print "Poll Position once every 30 seconds: ",0 lcd_print "Poll Position/Status/Data once:",0

f,#0 Init_Text car,#1 l,#1 Cursor_Pos r2,#high (1) r3,#low (1) r4,#high (2) r5,#low (2) lcd_xy a,check yy0 lcd_print "Disable Polling:",0 yy1 ;if(flag == 1)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (135 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;//////////////////////////////////////////////////// ;Function Same_XY1 Same_XY1: mov f,#0 lcall Init_Text mov mov lcall mov mov mov mov lcall ret ;////////////////////////////////////////////////////// ;Function Same_XY2 Same_XY2: mov r2,#high (4) mov r3,#low (4) mov r4,#high (2) mov r5,#low (2) lcall lcd_xy ret ;///////////////////////////////////////////////////////// ;Function Gmt_Menu Gmt_Menu: lcall lcall db lcall lcall db ret ;////////////////////////////////////////////////////// ;Function Time_Menu Time_Menu: lcall lcall db car,#1 l,#3 Cursor_Pos r2,#high (3) r3,#low (3) r4,#high (2) r5,#low (2) lcd_xy

Same_XY1 lcd_print "Poll current GMT Offset:",0 Same_XY2 lcd_print "Change current GMT Offset:",0

Same_XY1 lcd_print "Poll current Time Mode:",0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (136 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall lcall db ret

Same_XY2 lcd_print "Change current Time Mode:",0

;///////////////////////////////////////////////////// ;Function Time_Change Time_Change: lcall lcall db lcall lcall db ret ;///////////////////////////////////////////////////// ;Function Atmos_Menu Atmos_Menu: lcall lcall db lcall lcall db

Same_XY1 lcd_print "GPS Time:",0 Same_XY2 lcd_print "UTC Time:",0

Same_XY1 lcd_print "Poll Atmosphere Correction Mode:",0 Same_XY2 lcd_print "Change Atmosphere Correction Mode:",0

ret ;/////////////////////////////////////////////////////////// ;Function Atmos_Sub_Menu Atmos_Sub_Menu: mov f,#0 lcall Init_Text mov mov lcall mov mov mov car,#1 l,#1 Cursor_Pos r2,#high (1) r3,#low (1) r4,#high (2)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (137 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db ret

r5,#low (2) lcd_xy lcd_print "Ionospheric Model disabled:",0 r2,#high (2) r3,#low (2) r4,#high (2) r5,#low (2) lcd_xy lcd_print "Ionospheric Model only enabled:",0 r2,#high (3) r3,#low (3) r4,#high (2) r5,#low (2) lcd_xy lcd_print "Tropospheric Model only enabled:",0 r2,#high (4) r3,#low (4) r4,#high (2) r5,#low (2) lcd_xy lcd_print "Both Models enabled:",0

;//////////////////////////////////////////////////////////// ;Function Mask_Menu Mask_Menu: lcall lcall db lcall lcall db ret ;//////////////////////////////////////////////////////// ;Function Mask_Sub_Menu

Same_XY1 lcd_print "Poll current Satellite Mask Angle:",0 Same_XY2 lcd_print "Change current Satellite Mask Angle:",0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (138 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Mask_Sub_Menu: mov lcall mov mov mov mov lcall lcall db ret

f,#0 Init_Text r2,#high (0) r3,#low (0) r4,#high (2) r5,#low (2) lcd_xy lcd_print "Enter angle in degrees( 0 - 89 ):",0

;///////////////////////////////////////////////////// ; ==================================================== ; subroutine mdelay - millisecond delay ; delays for 998 microseconds - 2 microseconds are ; reserved for the call to this routine. ; input : none ; output : none ; destroys : nothing - uses a ; ---------------------------------------------------; 100h-a6h=5ah=(90)decimal ; 90 * 11 = 990 ; plus 8 gives 998 microseconds ; ; microseconds (cycles) ; ----------------------mdelay: push acc mov a, #0a6h md_olp: inc nop nop nop nop nop nop nop nop jnz nop pop ret a ; ; ; ; ; ; ; ; ; ; ; ; ; 1 1 1 1 1 1 1 1 1 2 1 2 2 \ | | | | |- 11 | | | / ; ; 2 1

cycles

md_olp

acc

;//////////////////////////////////////////////////// ;Function Gps_Chars

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (139 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Gps_Chars: sendGPS: pop pop mov sendNext: clr movc cjne sjmp charOK: mov lcall inc inc mov dec jz dec jz dec jz jmp D1: ljmp D2: mov ljmp D3: mov xrl ljmp retsendGPS: mov jmp a,r0 checksum,a sendNext checksum,r0 sendNext ; loop till end of string sendNext ; loop till end of string dph dpl j,#0 ;pop return address into dptr

a a,@a+dptr a,#0,charOK retsendGPS r0,a sendGPSdata dptr j a,j a D1 a D1 a D2 D3

; set offset = 0 ; get chr from code memory ; if chr = 0 then return

; send character ; point at next character

; loop till end of string

a, #1h @a+dptr

; point to instruction after string ;return with a jump instruction

;//////////////////////////////////////////////////// ;Function sendGPSdata: sends out characters sendGPSdata: clr TI mov SBUF,r0 lcall mdelay ret ;///////////////////////////////////////////////// ;Function Data_To_Gps Data_To_Gps:

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (140 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov dec jz jmp C1: jmp C2: dec jz jmp C3: jmp C4: dec jz jmp C5: jmp C6: dec jz jmp C7: jmp C8: dec jz jmp C9: jmp C10: dec jz jmp C11: jmp C12: dec jz jmp C13: jmp C14: dec jz jmp C15: jmp C16: dec jz jmp C17: jmp C18: dec

a,r5 a C1 C2 Possi a C3 C4 Lat a C5 C6 Lon a C7 C8 Hei a C9 C10 Datum a C11 C12 Tim a C13 C14 GmtP a C15 C16 GmtC a C17 C18 TPoll a

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (141 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jz jmp C19: jmp C20: dec jz jmp C21: jmp C22: dec jz jmp C23: jmp C24: dec jz jmp C25: jmp C26: dec jz jmp C27: jmp C28: dec jz jmp C29: jmp C30: dec jz jmp C31: jmp C32: dec jz jmp C33: jmp C34: jmp

C19 C20 TChange a C21 C22 LeapS a C23 C24 AtmosP a C25 C26 AtmosC a C27 C28 MaskP a C29 C30 MaskC a C31 C32 Self a C33 C34 Defa lastchars

Possi: lcall db jmp Gps_Chars "@@Ea",0 lastchars

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (142 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Lat: lcall db jmp Lon: lcall db jmp Hei: lcall db jmp Datum: lcall db jmp Tim: lcall db jmp GmtP: lcall db jmp GmtC: lcall db jmp TPoll: lcall db jmp TChange: lcall db jmp LeapS: lcall db jmp AtmosP: lcall db jmp Gps_Chars "@@Aq",0ffh,0 lastchars Gps_Chars "@@Bj",0 lastchars Gps_Chars "@@Aw",0 lastchars Gps_Chars "@@Aw",0ffh,0 lastchars Gps_Chars "@@Ab",0 lastchars Gps_Chars "@@Ab",0ffh,0ffh,0ffh,0 lastchars Gps_Chars "@@Aa",0ffh,0ffh,0ffh,0 lastchars Gps_Chars "@@Ac",0ffh,0ffh,0ffh,0ffh,0 lastchars Gps_Chars "@@Af",99h,99h,99h,99h,99h,0 lastchars Gps_Chars "@@Ae",99h,99h,99h,99h,0 lastchars Gps_Chars "@@Ad",99h,99h,99h,99h,0 lastchars

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (143 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

AtmosC: lcall db jmp MaskP: lcall db jmp MaskC: lcall db jmp Self: lcall db jmp Defa: lcall db jmp Gps_Chars "@@Cf",0 lastchars Gps_Chars "@@Fa",0 lastchars Gps_Chars "@@Ag",0 lastchars Gps_Chars "@@Ag",0ffh,0 lastchars Gps_Chars "@@Aq",0 lastchars

lastchars: mov xrl mov xrl mov xrl mov cjne jmp D4: jmp D5: mov lcall jmp D6: mov cjne jmp D8: jmp D9: mov lcall

a,var1 checksum,a a,var2 checksum,a a,var3 checksum,a a,fl a,#1,D4 D5 D6

;checksum ^= var1 ^ var2 ^ var3

;if(fl == 1)

r0,var1 ;SBUF = var1 sendGPSdata D7 a,fl a,#2,D8 D9 D10 r0,var1 ;SBUF = var1 sendGPSdata ;else if(fl == 2)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (144 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall jmp D10: mov cjne jmp D11: jmp D12: mov lcall mov lcall mov lcall D7: mov lcall mov lcall mov lcall der: ret

r0,var2 ;SBUF = var2 sendGPSdata D7 ;else if(fl == 3) a,fl a,#3,D11 D12 D7 r0,var1 ;SBUF = var1 sendGPSdata r0,var2 ;SBUF = var2 sendGPSdata r0,var3 ;SBUF = var3 sendGPSdata ;SBUF = checksum r0,checksum sendGPSdata r0,#13 ;SBUF = 0x0D sendGPSdata r0,#10 ;SBUF = 0x0A sendGPSdata

;//////////////////////////////////////////////////////////// ;Function Buffer Buffer: clr mov add mov movx mov mov loooop: lcall djnz inc mov cjne clr mov D16: mov setb ret mdelay r6,loooop ;mdelay() EX0 a,bufferout ;ch = buffer[bufferout] a,#ringbuffer r1,a a,@r1 ch,a r6,#50

bufferout ;bufferout = bufferout + 1 a,bufferout ;if(bufferout == 230) a,#230,D16 a ;bufferout = 0 bufferout,a ;return ch r3,ch EX0

;///////////////////////////////////////////////////

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (145 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;Function Bytes Bytes: clr mov mov mov mov mov jmp D18: mov jnz lcall mov mov D19: mov mov mov mov mov D20: mov add mov mov addc mov mov addc mov mov addc mov djnz mov mov mov mov lcall mov mov inc mov D17: cjne mov mov a,num,D18 r2,lb r3,lb+1 ;return b a,r3 a,r3 r3,a a,r2 a,r2 r2,a a,r1 a,r1 r1,a a,r0 a,r0 r0,a r5,D20 lb,r0 lb+1,r1 lb+2,r2 lb+3,r3 Buffer a,r3 lb+3,a i a,i ;lb = lb | Buffer() r5,#8 r0,lb r1,lb+1 r2,lb+2 r3,lb+3 a,i D19 Buffer a,r3 lb+3,a ;if(i == 0) a lb,a lb+1,a lb+2,a lb+3,a i,a D17

;for(i = 0; i < num; i++)

;lb = Buffer()

;lb <<= 8

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (146 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov ret

r4,lb+2 r5,lb+3

;/////////////////////////////////////////////////////// ;Function EndDisps EndDisps: lcall lcall lcall ret

Buffer Buffer Buffer

;Buffer() ;Buffer() ;Buffer()

;//////////////////////////////////////////////////////// ;Function Numbers Numbers: mov mov lcall mov mov mov mov lcall car,#13 l,#5 Cursor_Pos r2,#high (4) r3,#low (4) r4,#high (13) r5,#low (13) lcd_xy ;lcd_xy(13,4)

lcall db mov mov mov mov lcall mov jnz lcall db jmp ZZ1: lcall db ZZ2: mov mov mov mov lcall

lcd_print ;lcd_print() "0 1 2 3",0 r2,#high (5) r3,#low (5) r4,#high (13) r5,#low (13) lcd_xy ;lcd_xy(13,5) a,fla ZZ1 ;if(fla == 0)

lcd_print ;lcd_print() "- 4 5 6",0 ZZ2 ;else if(f == 1)

lcd_print ;lcd_print() "* 4 5 6",0 r2,#high (6) r3,#low (6) r4,#high (13) r5,#low (13) lcd_xy ;lcd_xy(13,6)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (147 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov jnz lcall db jmp ZZ3: lcall db ZZ4: ret

a,fla ZZ3

;if(f == 0)

lcd_print ;lcd_print() "+ 7 8 9",0 ZZ4 ;else if(f == 1)

lcd_print ;lcd_print() " 7 8 9",0

;/////////////////////////////////////////////////////// ;Function Key_Press_0 Key_Press_0: M2: ;while(1) mov a,key ;if(key == 0x03) cjne a,#3,M3 jmp M4 M3: jmp M5 M4: mov lines,#6 ;lines = 6 jmp M6 ;break ;--------------------------------------M5: ;else if(key == 0x13) mov a,key cjne a,#19,M7 jmp M8 M7: jmp M9 M8: jmp M6 ;break ;-------------------------------------------------------------------M9: ;else if(key == 0x22) mov a,key cjne a,#34,M10 jmp M11 M10: jmp M12 M11: mov key,#0 mov a,lines ;if(lines > 3) cjne a,#3,M13 jmp M14 M13: mov car,chars mov l,#-1 lcall Cursor_Pos ;Cursor_Pos(-1, chars) jmp M15 M14: mov ;else if(lines == 3) car,chars

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (148 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall M15:

l,#5 Cursor_Pos

;Cursor_Pos(5, chars)

jmp M16 ;------------------------------------------M12: ;else if(key == 0x32) mov a,key cjne a,#50,M17 jmp M18 M17: jmp M16 M18: mov key,#0 mov a,lines ;if(lines < 5) cjne a,#5,M19 jmp M20 M19: car,chars l,#10 Cursor_Pos ;Cursor_Pos(10, chars) M16 M20: ;else if(lines == 5) mov car,chars mov l,#3 lcall Cursor_Pos ;Cursor_Pos(3, chars) ;-------------------------------------------M16: setb EX0 jmp M2 ;back to while(1) M6: mov clr subb mov mov setb ret a,lines c a,#02h r3,a key,#0 EX0 ;return (lines - 2) mov mov lcall jmp

;/////////////////////////////////////////////////// ;Function Key_Press_1 Key_Press_1: N2: ;while(1) mov a,key ;if(key == 0x03) cjne a,#3,N3 jmp N4 N3: jmp N5 N4: mov lines,#10 ;lines = 6 jmp N6 ;break ;----------------------------------------------N5: ;else if(key == 0x13)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (149 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov cjne jmp N7: jmp N8:

a,key a,#19,N7 N8 N9

jmp N6 ;break ;---------------------------------------------N9: ;else if(key == 0x22) mov a,key cjne a,#34,N10 jmp N11 N10: jmp N12 N11: mov key,#0 mov a,lines ;if(lines > 1) cjne a,#1,N13 jmp N14 N13: mov car,chars mov l,#-1 lcall Cursor_Pos ;Cursor_Pos(-1, chars) jmp N15 N14: mov mov lcall N15: jmp N16 ;-------------------------------------------------N12: ;else if(key == 0x32) mov a,key cjne a,#50,N17 jmp N18 N17: jmp N16 N18: mov key,#0 mov a,lines ;if(lines < 6) cjne a,#6,N19 jmp N20 N19: car,chars l,#10 Cursor_Pos ;Cursor_Pos(10, chars) N16 N20: ;else if(lines == 6) mov car,chars mov l,#1 lcall Cursor_Pos ;Cursor_Pos(1, chars) ;------------------------------------------------N16: setb EX0 mov mov lcall jmp ;else if(lines == 1) car,chars l,#6 Cursor_Pos ;Cursor_Pos(6, chars)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (150 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp N6: mov mov setb ret

N2

;back to while(1)

r3,lines key,#0 EX0

;return (lines)

;////////////////////////////////////////////////// ;Function Key_Press_2 Key_Press_2: ;while(1) mov cjne jmp O3: jmp O4: mov lines,#6 ;lines = 6 jmp O6 ;break ;---------------------------------------------O5: ;else if(key == 0x13) mov a,key cjne a,#19,O7 jmp O8 O7: jmp O9 O8: jmp O6 ;break ;----------------------------------------------O9: ;else if(key == 0x22) mov a,key cjne a,#34,O10 jmp O11 O10: jmp O12 O11: mov key,#0 mov a,lines ;if(lines > 1) cjne a,#1,O13 jmp O14 O13: mov car,chars mov l,#-1 lcall Cursor_Pos ;Cursor_Pos(-1, chars) jmp O15 O14: mov mov lcall O15: jmp O16 ;-----------------------------------------------car,chars l,#5 Cursor_Pos ;else if(lines == 1) O5 a,key a,#3,O3 O4 ;if(key == 0x03)

;Cursor_Pos(5, chars)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (151 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

O12: mov cjne jmp O17: jmp O18: mov mov cjne jmp O19: mov mov lcall jmp O20: car,chars l,#10 Cursor_Pos O16 key,#0 a,lines a,#5,O19 O20 O16 a,key a,#50,O17 O18

;else if(key == 0x32)

;if(lines < 5)

;Cursor_Pos(10, chars)

;else if(lines == 5) mov car,chars mov l,#1 lcall Cursor_Pos ;Cursor_Pos(1, chars) ;------------------------------------------------O16: setb EX0 jmp O2 ;back to while(1) O6: mov mov setb ret r3,lines key,#0 EX0 ;return (lines)

;////////////////////////////////////////////////////////// ;Function Key_Press_3 Key_Press_3: YY2: ;while(1) mov a,key ;if(key == 0x03) cjne a,#3,YY3 jmp YY4 YY3: jmp YY5 YY4: mov lines,#6 ;lines = 6 jmp Y6 ;break ;--------------------------------------------------YY5: ;else if(key == 0x13) mov a,key cjne a,#19,Y7 jmp Y8 Y7: jmp Y9 Y8: jmp Y6 ;break ;-------------------------------------------------

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (152 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

Y9: mov cjne jmp Y10: jmp Y11: mov mov cjne jmp Y13: mov mov lcall jmp Y14: mov mov lcall Y15: car,chars l,#4 Cursor_Pos car,chars l,#-1 Cursor_Pos Y15 key,#0 a,lines a,#1,Y13 Y14 Y12 a,key a,#34,Y10 Y11

;else if(key == 0x22)

;if(lines > 1)

;Cursor_Pos(-1, chars)

;else if(lines == 1)

;Cursor_Pos(4, chars)

jmp Y16 ;-----------------------------------------------------Y12: ;else if(key == 0x32) mov a,key cjne a,#50,Y17 jmp Y18 Y17: jmp Y16 Y18: mov key,#0 mov a,lines ;if(lines < 4) cjne a,#4,Y19 jmp Y20 Y19: mov mov lcall jmp Y20: car,chars l,#10 Cursor_Pos Y16

;Cursor_Pos(10, chars)

;else if(lines == 4) mov car,chars mov l,#1 lcall Cursor_Pos ;Cursor_Pos(1, chars) ;-----------------------------------------------Y16: setb EX0 jmp YY2 ;back to while(1) Y6: mov mov setb ret r3,lines key,#0 EX0 ;return (lines)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (153 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;///////////////////////////////////////////////////// ;Function Key_Press_4 Key_Press_4: Q2: ;while(1) mov a,key ;if(key == 0x03) cjne a,#3,Q3 jmp Q4 Q3: jmp Q5 Q4: mov lines,#6 ;lines = 6 jmp Q6 ;break ;----------------------------------------------Q5: ;else if(key == 0x13) mov a,key cjne a,#19,Q7 jmp Q8 Q7: jmp Q9 Q8: jmp Q6 ;break ;-----------------------------------------------Q9: ;else if(key == 0x22) mov a,key cjne a,#34,Q10 jmp Q11 Q10: jmp Q12 Q11: mov key,#0 mov a,lines ;if(lines > 3) cjne a,#3,Q13 jmp Q14 Q13: mov car,chars mov l,#-1 lcall Cursor_Pos ;Cursor_Pos(-1, chars) jmp Q15 Q14: mov mov lcall Q15: jmp Q16 ;----------------------------------------------------Q12: ;else if(key == 0x32) mov a,key cjne a,#50,Q17 jmp Q18 Q17: jmp Q16 Q18: car,chars l,#4 Cursor_Pos ;else if(lines == 3)

;Cursor_Pos(4, chars)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (154 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov cjne jmp Q19:

key,#0 a,lines a,#4,Q19 Q20

;if(lines < 4)

mov car,chars mov l,#10 lcall Cursor_Pos ;Cursor_Pos(10, chars) jmp Q16 ;else if(lines == 4) mov car,chars mov l,#3 lcall Cursor_Pos ;Cursor_Pos(3, chars) ;-----------------------------------------------Q16: setb EX0 jmp Q2 ;back to while(1) Q6: mov a,lines ;return (lines - 2) clr c subb a,#02h mov r3,a mov key,#0 setb EX0 ret ;/////////////////////////////////////////////// ;Function Key_Press_5 Key_Press_5: ZZ5: mov a,key ;if(key == 0x03) cjne a,#3,ZZ6 jmp ZZ7 ZZ6: jmp Z8 ZZ7: mov s,#43 ;sign = '+' jmp Z9 ;break ;---------------------------------------------Z8: ;else if(key == 0x13) mov a,key cjne a,#19,Z10 jmp Z11 Z10: jmp Z12 Z11: jmp Z9 ;break ;-----------------------------------------------Z12: ;else if((key == 0x22) && (chars == 13)) mov a,key cjne a,#34,Z13 jmp Z14 Z14: mov a,chars

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (155 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

cjne jmp Z15: jmp Z13: jmp Z16: mov mov cjne jmp Z18: mov mov lcall jmp Z19: mov mov lcall Z20:

a,#13,Z13 Z15 Z16 Z17 key,#0 a,lines a,#5,Z18 Z19

;if(lines > 5)

car,chars l,#-1 Cursor_Pos ;Cursor_Pos(-1, chars) Z20 ;else if(lines == 5) car,chars l,#6 Cursor_Pos ;Cursor_Pos(6, chars)

jmp Z21 ;------------------------------------------------Z17: ;else if((key == 0x32) && (chars == 13)) mov a,key cjne a,#50,Z22 jmp Z23 Z23: mov a,chars cjne a,#13,Z22 jmp Z24 Z24: jmp Z25 Z22: jmp Z21 Z25: mov key,#0 mov a,lines ;if(lines < 6) cjne a,#6,Z26 jmp Z27 Z26: mov car,chars mov l,#10 lcall Cursor_Pos ;Cursor_Pos(10, chars) jmp Z21 Z27: ;else if(lines == 6) mov car,chars mov l,#5 lcall Cursor_Pos ;Cursor_Pos(5, chars) Z21: setb jmp Z9: mov cjne a,lines a,#5,Z28 ;if(lines == 5) EX0 ZZ5

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (156 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp Z28: jmp Z29: mov jmp Z30: mov cjne jmp Z32: jmp Z33: mov Z31: mov setb ret

Z29 Z30 s,#45 Z31 ;s = '-'

;else if(lines == 6) a,lines a,#6,Z32 Z33 Z31 s,#43 key,#0 EX0 ;s = '+'

;///////////////////////////////////////////////// ;Function Key_Press_6 ;use var1, var2, checksum Key_Press_6: mov var1,#0 mov var2,#0 mov checksum,#0 Z34: ;while(1) Z35: ;while(1) mov a,key ;if(key == 0x03) cjne a,#3,Z36 jmp Z37 Z36: jmp Z38 Z37: mov var1,#0 ;var1 = 0 jmp Z39 ;break ;---------------------------------------------Z38: ;else if(key == 0x13) mov a,key cjne a,#19,Z40 jmp Z41 Z40: jmp Z42 Z41: jmp Z39 ;break ;-------------------------------------------------Z42: ;else if((key == 0x22) && (chars != 13)) mov a,key cjne a,#34,Z43 jmp Z44 Z44: mov a,chars cjne a,#13,Z45 jmp Z43 Z45:

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (157 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp Z43: jmp Z46: mov mov cjne jmp Z48: mov mov lcall jmp Z49: mov mov lcall Z50:

Z46 Z47 key,#0 a,lines a,#4,Z48 Z49 car,chars l,#-1 Cursor_Pos Z50 car,chars l,#6 Cursor_Pos

;if(lines > 4)

;Cursor_Pos(-1, chars) ;else if(lines == 4)

;Cursor_Pos(6, chars)

jmp Z51 ;-----------------------------------------------Z47: ;else if((key == 0x32) && (chars != 13)) mov a,key cjne a,#50,Z52 mov a,chars cjne a,#13,Z53 jmp Z52 Z53: jmp Z54 Z52: jmp Z55 Z54: mov key,#0 mov a,lines ;if(lines < 6) cjne a,#6,Z56 jmp Z57 Z56: mov car,chars mov l,#10 lcall Cursor_Pos ;Cursor_Pos(10, chars) jmp Z58 Z57: ;else if(lines == 6) mov car,chars mov l,#4 lcall Cursor_Pos ;Cursor_Pos(4, chars) Z58: jmp Z51 ;------------------------------------------------Z55: ;else if((key == 0x22) && (chars == 13)) mov a,key cjne a,#34,Z59 mov a,chars cjne a,#13,Z59 jmp Z60 Z59: jmp Z61 Z60:

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (158 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov cjne jmp Z62: mov mov lcall jmp Z63: mov mov lcall Z64:

key,#0 a,lines a,#4,Z62 Z63 car,chars l,#-1 Cursor_Pos Z64 car,chars l,#5 Cursor_Pos

;if(lines > 4)

;Cursor_Pos(-1, chars) ;else if(lines == 4)

;Cursor_Pos(5, chars)

jmp Z51 ;-------------------------------------------------Z61: ;else if((key == 0x32) && (chars == 13)) mov a,key cjne a,#50,Z65 mov a,chars cjne a,#13,Z65 jmp Z66 Z65: jmp Z67 Z66: mov key,#0 mov a,lines ;if(lines < 5) cjne a,#5,Z68 jmp Z69 Z68: mov car,chars mov l,#10 lcall Cursor_Pos ;Cursor_Pos(10, chars) jmp Z70 Z69: ;else if(lines == 5) mov car,chars mov l,#4 lcall Cursor_Pos ;Cursor_Pos(4, chars) Z70: jmp Z51 ;------------------------------------------------Z67: ;else if((key == 0x02) && ((lines == 4) || (lines == 5))) mov a,key cjne a,#2,Z71 mov a,lines cjne a,#4,Z72 jmp Z73 Z72: mov a,lines cjne a,#5,Z71 Z73: jmp Z74 Z71: jmp Z75 Z74: mov key,#0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (159 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov cjne jmp Z76: mov clr subb mov mov lcall jmp Z77: mov mov lcall Z78:

a,chars a,#13,Z76 Z77 a,chars c a,#03h car,a l,lines Cursor_Pos Z78 car,#22 l,lines Cursor_Pos

;if(chars > 13)

;Cursor_Pos(lines, chars - 3) ;else if(chars == 13)

;Cursor_Pos(lines, 22)

jmp Z51 ;--------------------------------------------------Z75: ;else if((key == 0x12) && ((lines == 4) || (lines == 5))) mov a,key cjne a,#18,Z79 mov a,lines cjne a,#4,Z80 jmp Z81 Z80: mov a,lines cjne a,#5,Z79 Z81: jmp Z82 Z79: jmp Z83 Z82: mov key,#0 mov a,chars ;if(chars < 22) cjne a,#22,Z84 jmp Z85 Z84: mov a,chars add a,#03h mov car,a mov l,lines lcall Cursor_Pos ;Cursor_Pos(lines, chars + 3) jmp Z86 Z85: ;else if(chars == 22) mov car,#13 mov l,lines lcall Cursor_Pos ;Cursor_Pos(lines, 13) Z86: jmp Z51 ;-----------------------------------------------Z83: ;else if((key == 0x02) && (lines == 6)) mov a,key cjne a,#2,Z87 mov a,lines cjne a,#6,Z87

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (160 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp Z87: jmp Z88: mov mov cjne jmp Z90: mov clr subb mov mov lcall jmp Z91: mov mov lcall Z92:

Z88 Z89 key,#0 a,chars a,#16,Z90 Z91 a,chars c a,#03h car,a l,lines Cursor_Pos Z92 car,#22 l,lines Cursor_Pos

;if(chars > 16)

;Cursor_Pos(lines, chars - 3) ;else if(chars == 16)

;Cursor_Pos(lines, 22)

jmp Z51 ;----------------------------------------------------Z89: ;else if((key == 0x12) && (lines == 6)) mov a,key cjne a,#18,Z93 mov a,lines cjne a,#6,Z93 jmp Z94 Z93: jmp Z51 Z94: mov key,#0 mov a,chars ;if(chars < 22) cjne a,#22,Z96 jmp Z97 Z96: mov a,chars add a,#03h mov car,a mov l,lines lcall Cursor_Pos ;Cursor_Pos(lines, chars + 3) jmp Z51 Z97: ;else if(chars == 22) mov car,#16 mov l,lines lcall Cursor_Pos ;Cursor_Pos(lines, 16) Z51: setb EX0 jmp Z35 ;-------------------------------------------------------Z39: mov a,key ;if(key == 0x03) cjne a,#3,Z99 jmp Z100 Z99:

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (161 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp Z100:

Z101

mov var1,a ;var1 = 0 jmp Z102 ;break ;-------------------------------------------------------Z101: ;else if(key == 0x13) mov a,key cjne a,#19,Z103 jmp Z104 Z103: jmp Z105 Z104: mov a,lines ;if((lines == 5) && (chars == 13)) cjne a,#5,Z106 mov a,chars cjne a,#13,Z106 jmp Z107 Z106: jmp Z108 Z107: mov var2,#1 ;for(i = 1; i <= count; i++) jmp Z109 Z110: ;var1 = var1 + yebo[i - 1] * pow(10,count - i) mov a,checksum clr c subb a,var2 mov r5,a jz Z111 mov a,#1 Z111: mov mul cjne jmp Gogo1: djnz Gogo2: jz mov jmp Power: inc mov Correct: clr mov subb mov mov add mov movx mov c a,var2 a,#01h r3,a a,#yebo a,r3 r1,a a,@r1 4+0,a a fl,a Power fl,a Correct r5,Z111 b,#10d ab r5,#0,Gogo1 Gogo2 ;pow operation (value will never be ;greater then 100)

;r4 contains now value from array

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (162 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mul add mov inc Z109: clr mov subb add jnz jmp Z108: inc ;yebo[count mov clr subb mov mul mov clr mov subb add mov mov clr subb mov mov add mov lcall movx mov mov mov mov add mov mov lcall mov mov mov

a,r4 b,fl ab a,var1 var1,a var2 c a,checksum a,var2 a,#1 Z110 Z102 ;else checksum ;var3++ - 1] = nums[lines - 4][chars - 13] a,lines c a,#04h b,#10 ab r2,a c a,chars a,#0dh a,r2 r2,a a,checksum c a,#01h r1,a a,#yebo a,r1 r1,a GetVal @r1,a fl,a r2,#high (2) r3,#low (2) a,checksum a,#0Eh r4,#0 r5,a lcd_xy ;lcd_xy(14 + count,2) r1,#0 r2,#high (0) r3,#low (0)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (163 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov lcall Z105: setb mov jmp Z102: mov mov setb ret

r4,high(fl) r5,low(fl) lcd_print_num

;lcd_print_num(yebo[count - 1],0)

EX0 key,#0 Z34 r3,var1 key,#0 EX0 ;return var1

;//////////////////////////////////////////////// ;Function GetVal GetVal: mov inc movc ret nums: db db db db db db db db db db db db db db db db db db db db db db db db db db db db db db 0 0 0 1 0 0 2 0 0 3 0 0 0 4 0 0 5 0 0 6 0 0 0 7 0 0 8 0 0 9 a,r2 a a,@a+pc

;////////////////////////////////////////////

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (164 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;Function lcd_print_num ;count - num ;temp - x ;i - l ;f - car lcd_print_num: mov mov mov mov mov mov K1: mov mov mov mov mov mov mov mov lcall mov add mov mov add mov movx inc mov mov mov mov mov jnz jmp K2: jmp K1 K3: ;if((f == 1) && (temp > 0) && (temp < 10)) mov a,car cjne a,#1,K4 mov a,x+1 add a,#low -(1) mov a,x xrl a,#80h addc a,#(high -(1))xor 80h jnc K4 X3,r2 X2,r3 X1,r4 X0,r5 Y0,#10 Y1,#0 Y2,#0 Y3,#0 DIV32 a,#array a,num r1,a a,Z0 a,#16 Z0,a @r1,a num r2,Z7 r3,Z6 r4,Z5 r5,Z4 a,Z4 K2 K3

num,#0 y,r2 y+1,r3 x,r4 x+1,r5 car,r1 ;highest byte ;temp = r2, r3, r4 and r5 ;save car(flag) ;while(1) ;num % 10

;high 16 bits of Y is 0 ;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;array[num] = Z0 + 16

;rem is in R4 ;num++

;num = num / 10

;if(a == 0) ;break

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (165 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp K4: jmp K5: mov add mov xrl addc jc jmp K6: jmp K7: mov add mov mov movx inc K8: mov clr subb mov jmp K10: mov mov mov add mov movx jnb clr K11: mov lcall mov lcall mov clr subb mov K9: mov add jnz ret

K5 K6 a,x+1 a,#low -(10) a,x a,#80h a,#(high -(10))xor 80h K6 K7 K8 a,#array a,num r1,a a,#16 @r1,a num ;array[num] = 16

;num++ ;for(i = count - 1; i >= 0 ; i--)

a,num c a,#01h l,a K9 a,l r3,a a,#array a,r3 r1,a a,@r1 acc.7, K11 a

;a = array[i]

;if (a<0) ;a=0

r7,a dput r7,#192 cput a,l c a,#01h l,a a,l a,#1 K10

;dput(a)

;cput(0xc0)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (166 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;/////////////////////////////////////////////////// ;================================================= ; subroutine DIV32 ; 32-Bit Unsigned Division ;================================================= DIV32: mov a,Y3 ;get divisor high byte orl a,Y2 orl a,Y1 orl a,Y0 ;OR with low bytes jnz div32_OK ;divisor OK if not 0 setb OV ;else, overflow ret div32_OK: mov PR3,X3 ;store dividend mov PR2,X2 mov PR1,X1 mov PR0,X0 mov X3,#0 ;clear partial remainder mov X2,#0 mov X1,#0 mov X0,#0 mov r6,#0 mov r5,#0 mov r4,#0 mov r3,#0 ;clear partial quotient mov r7,#32 ;set loop count div32_loop: clr mov rlc mov mov rlc mov mov rlc mov mov rlc mov mov rlc mov mov rlc mov mov rlc mov mov

C a,PR0 a PR0,a a,PR1 a PR1,a a,PR2 a PR2,a a,PR3 a PR3,a a,X0 a X0,a a,X1 a X1,a a,X2 a X2,a a,X3

;clear carry flag ;shift the highest bit of the dividend... ;... into...

;... the lowest bit of the partial ... ;... remainder

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (167 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

rlc mov lcall

a X3,a SUB32 ;attempt to subtract to see if the... ;... partial remainder is as large or... ;... larger than the divisor. ;get subtraction external barrow ;complement external barrow

mov cpl jnc mov mov mov mov div32_1: mov rlc mov mov rlc mov mov rlc mov mov rlc mov djnz mov mov mov mov mov mov mov mov clr ret

C,OV C div32_1 X3,Z3 X2,Z2 X1,Z1 X0,Z0 a,r3 a r3,a a,r4 a r4,a a,r5 a r5,a a,r6 a r6,a r7,div32_loop Z7,r6 Z6,r5 Z5,r4 Z4,r3 Z0,X0 Z1,X1 Z2,X2 Z3,X3 OV

;add result bit to partial quotient

;put quotient in Z4 - Z7

;get remainder, saved before the... ;last subtraction

;divisor is not 0 ;done

;////////////////////////////////////////////////// ;================================================== ; subroutine SUB32 ; 32-Bit Unsigned subtraction ;================================================== SUB32: mov a,X0 ;load X low byte into accumulator clr C ;clear carry flag subb a,Y0 ;subract Y low byte mov Z0,a ;put result in Z low byte mov a,X1 ;repeat with other bytes... subb a,Y1 mov Z1,a mov a,X2

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (168 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

subb mov mov subb mov mov ret

a,Y2 Z2,a a,X3 a,Y3 Z3,a OV,C

;set ZOV id an external barrow is produced ;done

;//////////////////////////////////////////////////// ;=================================================== ; subroutine ADD16 ; 16-Bit Unsigned Addition ;=================================================== ADD16: mov a,#low(Gps_pic_less); load X low byte into accumulator add a,r2 ; add Y low byte mov dpl,a ; put result in Z low byte mov a,#high(Gps_pic_less); load X high byte into accumulator addc a,r3 ; add Y high byte with the carry from low ... ; ... byte operation mov dph,a ; save result in Z high byte mov OV,C ; set OV if external carry ret ; done ;///////////////////////////////////////////////// ;Function mult8_8: multiplies 2 8bit numbers mult8_8: mov mov mul mov push mov mov mul pop add mov ret a,r5 b,r3 ab r3,a b a,r5 b,r2 ab 0 a,r0 r2,a

;////////////////////////////////////////////// Disp_Aa: mov univ,r4 mov a,r4 cjne a,#0,ww mov lcall mov mov mov mov f,#1 Init_Text r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (169 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall lcall db jmp ww: mov mov mov mov lcall lcall db ww1: lcall mov mov mov mov mov mov lcall lcall db lcall mov mov mov mov mov mov lcall lcall db lcall mov mov mov mov mov mov lcall lcall db

lcd_xy lcd_print "Current Time: ",0 ww1

r2,#high (0) r3,#low (0) r4,#high (17) r5,#low (17) lcd_xy lcd_print " / Time: ",0 Buffer fl,r3 r1,#1 r2,#high (0) r3,#low (0) r4,high(fl) r5,low(fl) lcd_print_num lcd_print ":",0 Buffer fl,r3 r1,#1 r2,#high (0) r3,#low (0) r4,high(fl) r5,low(fl) lcd_print_num lcd_print ":",0 Buffer fl,r3 r1,#1 r2,#high (0) r3,#low (0) r4,high(fl) r5,low(fl) lcd_print_num lcd_print " hours",0

;lcd_print_num()

;lcd_print_num()

;lcd_print_num()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (170 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov cjne lcall ww2: ret

a,univ a,#0,ww2 EndDisps

;////////////////////////////////////////////////// Disp_Ab: mov f,#1 lcall Init_Text mov mov mov mov lcall lcall db lcall mov cjne lcall db jmp ww3: lcall db ww4: lcall mov mov mov mov mov mov lcall lcall db lcall mov mov mov mov mov mov lcall Buffer fl,r3 r1,#0 r2,#high (0) r3,#low (0) r4,high(fl) r5,low(fl) lcd_print_num lcd_print ":",0 Buffer fl,r3 r1,#0 r2,#high (0) r3,#low (0) r4,high(fl) r5,low(fl) lcd_print_num lcd_print "-",0 r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "GMT Offset: ",0 Buffer a,r3 a,#0,ww3 lcd_print "+",0 ww4

;lcd_print_num()

;lcd_print_num()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (171 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall db lcall ret

lcd_print "hours",0 EndDisps

;/////////////////////////////////////////////////// Disp_Ac: mov univ,r4 mov a,r4 cjne a,#0,ww5 mov lcall mov mov mov mov lcall lcall db jmp ww5: mov mov mov mov lcall lcall db ww6: lcall mov lcall mov mov mov mov mov mov lcall lcall db mov mov Buffer angle,r3 Buffer fl,r3 r1,#1 r2,#high (0) r3,#low (0) r4,high(fl) r5,low(fl) lcd_print_num lcd_print "/",0 r1,#1 r2,#high (0) r2,#high (0) r3,#low (0) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Date: ",0 f,#1 Init_Text r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Current Date(dd/mm/yyyy): ",0 ww6

;lcd_print_num()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (172 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov lcall lcall db mov lcall

r3,#low (0) r4,high(angle) r5,low(angle) lcd_print_num lcd_print "/",0 num,#1 Bytes

;lcd_print_num()

;r4 contains high byte ;r5 contains low byte

mov mov mov lcall mov cjne lcall ww7: ret

r1,#0 r2,#high (0) r3,#low (0) lcd_print_num a,univ a,#0,ww7 EndDisps

;lcd_print_num()

;//////////////////////////////////////////////////// Disp_Ad: mov univ,r4 mov a,r4 cjne a,#0,vv1 mov lcall mov mov mov mov lcall lcall db vv1: mov lcall num,#3 Bytes ;r2 contains highest byte ;r3 ;r4 ;r5 contains lowest byte f,#1 Init_Text r2,#high (1) r3,#low (1) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Lattitude(milliarcseconds or mas): ",0

mov mov mov mov mov

lb,r2 lb+1,r3 lb+2,r4 lb+3,r5 a,univ

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (173 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

cjne jmp vv7: jmp vv8: mov mov mov mov lcall mov anl cjne lcall db mov mov cpl add mov mov cpl addc mov mov cpl addc mov mov cpl addc mov jmp vv3: lcall db mov vv4: mov mov mov mov mov lcall lcall db

a,#0,vv7 vv8 vv2 r2,#high (2) r3,#low (2) r4,#high (5) r5,#low (5) lcd_xy a,lb a,#80h a,#80h,vv3 lcd_print "-",0 var1,#0 a,lb+3 a a,#01h lb+3,a a,lb+2 a a,#0 lb+2,a a,lb+1 a a,#0 lb+1,a a,lb a a,#0 lb,a vv4 ;lb = -lb

;test if number is positive

lcd_print "+",0 var1,#1

r1,#0 r2,lb r3,lb+1 r4,lb+2 r5,lb+3 lcd_print_num lcd_print "mas",0

;lcd_print_num()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (174 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov lcall lcall db jmp vv2: mov mov mov mov lcall lcall db vv5: mov cjne mov mov mov mov lcall vv6: mov mov mov mov mov mov mov mov lcall mov mov mov mov mov mov mov mov mov lcall

r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Lattitude(degrees/min/sec): ",0 vv5

r2,#high (1) r3,#low (1) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Position: ",0

a,univ a,#0,vv6 r2,#high (4) r3,#low (4) r4,#high (5) r5,#low (5) lcd_xy X3,lb X2,lb+1 X1,lb+2 X0,lb+3 Y0,#80h Y1,#0eeh Y2,#36h Y3,#00h DIV32 lb,Z3 lb+1,Z2 lb+2,Z1 lb+3,Z0 ;divide milliarcseconds by 3600000

;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;get remainder

r1,#0 ;print angle r2,#high (0) r3,#low (0) r4,high(Z4) r5,low(Z4) lcd_print_num ;lcd_print_num()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (175 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall mov lcall mov mov mov mov mov mov mov mov lcall mov mov mov mov lcall

r7,#80h dput r7,#192 cput X3,lb X2,lb+1 X1,lb+2 X0,lb+3 Y0,#10h Y1,#0eh Y2,#00h Y3,#00h DIV32 r4,#high (6) r5,#low (6) r2,Z5 r3,Z4 mult8_8

;dput(degree sign)

;divide remainder by 3600

;Z4-Qlow - Z7-Qhigh / Z0-rem(low)

mov mov mov mov mov mov mov mov lcall mov mov mov mov mov mov mov mov mov lcall mov lcall mov lcall mov mov mov

X3,#0 X2,#0 X1,r2 X0,r3 Y0,#64h Y1,#00h Y2,#00h Y3,#00h DIV32 lb,Z3 lb+1,Z2 lb+2,Z1 lb+3,Z0

;divide by 100

;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;get remainder

r1,#0 ;print minutes r2,#0 r3,#0 r4,#0 r5,Z4 lcd_print_num ;lcd_print_num() r7,#81h dput r7,#192 cput r4,#high (60) r5,#low (60) r2,lb+2

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (176 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall mov mov mov mov mov mov mov mov lcall mov mov mov mov mov lcall mov lcall mov lcall

r3,lb+3 mult8_8 X3,#0 X2,#0 X1,r2 X0,r3 Y0,#64h Y1,#00h Y2,#00h Y3,#00h DIV32 ;divide by 100

;Z4-Qlow - Z7-Qhigh / Z0-rem(low)

r1,#0 ;print seconds r2,#0 r3,#0 r4,#0 r5,Z4 lcd_print_num ;lcd_print_num() r7,#02h dput r7,#192 cput

mov cjne lcall db jmp wert: lcall db wert1: mov cjne lcall hhhh: ret

a,var1 a,#0,wert lcd_print "S",0 wert1

lcd_print "N",0

a,univ a,#0,hhhh EndDisps

;//////////////////////////////////////////////// Disp_Ae: mov univ,r4 mov a,r4 cjne a,#0,qq1 mov lcall mov f,#1 Init_Text r2,#high (1)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (177 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov lcall lcall db qq1: mov lcall

r3,#low (1) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Longitude(milliarcseconds or mas): ",0

num,#3 Bytes

;r2 contains highest byte ;r3 ;r4 ;r5 contains lowest byte

mov mov mov mov mov cjne jmp qq7: jmp qq8: mov mov mov mov lcall mov anl cjne lcall db mov mov cpl add mov mov cpl addc mov mov cpl addc mov mov cpl

lb,r2 lb+1,r3 lb+2,r4 lb+3,r5 a,univ a,#0,qq7 qq8 qq2 r2,#high (2) r3,#low (2) r4,#high (5) r5,#low (5) lcd_xy a,lb a,#80h a,#80h,qq3 lcd_print "-",0 var1,#0 a,lb+3 a a,#01h lb+3,a a,lb+2 a a,#0 lb+2,a a,lb+1 a a,#0 lb+1,a a,lb a

;test if number is positive

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (178 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

addc mov jmp qq3: lcall db mov qq4: mov mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db jmp qq2: mov mov mov mov lcall lcall db qq5: mov cjne mov mov mov mov lcall qq6: mov mov

a,#0 lb,a ww4

lcd_print "+",0 var1,#1

r1,#0 ;print angle r2,lb r3,lb+1 r4,lb+2 r5,lb+3 lcd_print_num ;lcd_print_num() lcd_print "mas",0 r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Longitude(degrees/min/sec): ",0 qq5

r2,#high (1) r3,#low (1) r4,#high (23) r5,#low (23) lcd_xy lcd_print "/ ",0

a,univ a,#0,qq6 r2,#high (4) r3,#low (4) r4,#high (5) r5,#low (5) lcd_xy X3,lb X2,lb+1 ;divide milliarcseconds by 3600000

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (179 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov mov mov lcall mov mov mov mov mov mov mov mov mov lcall mov lcall mov lcall mov mov mov mov mov mov mov mov lcall mov mov mov mov lcall mov mov mov mov mov mov mov mov lcall mov mov mov

X1,lb+2 X0,lb+3 Y0,#80h Y1,#0eeh Y2,#36h Y3,#00h DIV32 lb,Z3 lb+1,Z2 lb+2,Z1 lb+3,Z0

;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;get remainder

r1,#0 ;print angle r2,#high (0) r3,#low (0) r4,high(Z4) r5,low(Z4) lcd_print_num ;lcd_print_num() r7,#80h dput r7,#192 cput X3,lb X2,lb+1 X1,lb+2 X0,lb+3 Y0,#10h Y1,#0eh Y2,#00h Y3,#00h DIV32 r4,#high (6) r5,#low (6) r2,Z5 r3,Z4 mult8_8 X3,#0 X2,#0 X1,r2 X0,r3 Y0,#64h Y1,#00h Y2,#00h Y3,#00h DIV32 lb,Z3 lb+1,Z2 lb+2,Z1 ;divide by 100 ;divide remainder by 3600

;dput(degree sign)

;Z4-Qlow - Z7-Qhigh / Z0-rem(low)

;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;get remainder

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (180 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov mov mov lcall mov lcall mov lcall mov mov mov mov lcall mov mov mov mov mov mov mov mov lcall mov mov mov mov mov lcall mov lcall mov lcall mov cjne lcall db jmp wert2: lcall db

lb+3,Z0 r1,#0 ;print minutes r2,#0 r3,#0 r4,#0 r5,Z4 lcd_print_num ;lcd_print_num() r7,#81h dput r7,#192 cput r4,#high (60) r5,#low (60) r2,lb+2 r3,lb+3 mult8_8 X3,#0 X2,#0 X1,r2 X0,r3 Y0,#64h Y1,#00h Y2,#00h Y3,#00h DIV32 ;divide by 100

;Z4-Qlow - Z7-Qhigh / Z0-rem(low)

r1,#0 ;print seconds r2,#0 r3,#0 r4,#0 r5,Z4 lcd_print_num ;lcd_print_num() r7,#02h dput r7,#192 cput a,var1 a,#0,wert2 lcd_print "W",0 wert3

lcd_print "E",0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (181 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

wert3: mov cjne lcall gggg: ret ;///////////////////////////////////////////////// Disp_Af: mov univ,r4 mov a,r4 cjne a,#0,qq9 mov lcall mov mov mov mov lcall lcall db mov mov mov mov lcall jmp qq9: mov mov mov mov lcall lcall db qq10: mov lcall num,#3 Bytes ;r2 contains highest byte ;r3 ;r4 ;r5 contains lowest byte lb,r2 lb+1,r3 lb+2,r4 lb+3,r5 r2,#high (2) r3,#low (2) r4,#high (7) r5,#low (7) lcd_xy lcd_print "Height (m): ",0 f,#1 Init_Text r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Height(ellipsoid height in meters): ",0 r2,#high (4) r3,#low (4) r4,#high (5) r5,#low (5) lcd_xy qq10 a,univ a,#0,gggg EndDisps

mov mov mov mov

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (182 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov mov mov mov mov lcall mov mov mov mov mov lcall lcall db mov cjne lcall iiii: ret

X3,r2 ;divide by 100 X2,r3 X1,r4 X0,r5 Y0,#64h Y1,#00h Y2,#00h Y3,#00h DIV32 ;Z4-Qlow - Z7-Qhigh / Z0-rem(low) r1,#0 ;print minutes r2,Z7 r3,Z6 r4,Z5 r5,Z4 lcd_print_num ;lcd_print_num() lcd_print "m",0 a,univ a,#0,iiii EndDisps

;//////////////////////////////////////////////// Disp_Ag: mov f,#1 lcall Init_Text mov mov mov mov lcall lcall db lcall mov mov mov mov mov mov lcall mov lcall mov r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Satellite Mask Angle (degrees): ",0 Buffer fl,r3 r1,#0 r2,#high (0) r3,#low (0) r4,high(fl) r5,low(fl) lcd_print_num r7,#128 dput r7,#192

;lcd_print_num() ;degree sign

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (183 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall lcall ret

cput EndDisps

;/////////////////////////////////////////////// Disp_Aq: mov f,#1 lcall Init_Text mov mov mov mov lcall lcall db lcall mov mov mov mov mov lcall mov cjne lcall db jmp ww8: cjne lcall db jmp ww9: cjne lcall db jmp ww10: cjne lcall db ww11: lcall ret EndDisps a,#3,ww11 lcd_print "'3' = Both models enabled.",0 a,#2,ww10 lcd_print "'2' = Tropospheric model only enabled.",0 ww11 a,#1,ww9 lcd_print "'1' = Ionosphere model only enabled.",0 ww11 r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Atmosphere Correction Mode: ",0 Buffer univ,r3 r2,#high (4) r3,#low (4) r4,#high (2) r5,#low (2) lcd_xy a,univ a,#0,ww8 lcd_print "'0' = Ionosphere model disabled.",0 ww11

;//////////////////////////////////////////////// Disp_Aw:

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (184 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall mov mov mov mov lcall lcall db lcall mov mov mov mov mov lcall mov cjne lcall db jmp ww12: cjne lcall db ww13: lcall ret

f,#1 Init_Text r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Current Time Mode: ",0 Buffer univ,r3 r2,#high (4) r3,#low (4) r4,#high (2) r5,#low (2) lcd_xy a,univ a,#0,ww12 lcd_print "'0' = GPS Time.",0 ww13 a,#1,ww13 lcd_print "'1' = UTC Time.",0 EndDisps

;///////////////////////////////////////////////////// Disp_Bj: mov f,#1 lcall Init_Text mov mov mov mov lcall lcall db lcall mov mov mov mov r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Leap Second Pending Status: ",0 Buffer univ,r3 r2,#high (4) r3,#low (4) r4,#high (2)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (185 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov lcall mov cjne lcall db jmp ww14: cjne lcall db jmp ww15: cjne lcall db ww16: lcall ret

r5,#low (2) lcd_xy a,univ a,#0,ww14 lcd_print "'0' = No leap second pending.",0 ww16 a,#1,ww15 lcd_print "'1' = Addition of one second pending.",0 ww16 a,#2,ww16 lcd_print "'2' = Subtraction of one second pending.",0 EndDisps

;//////////////////////////////////////////////// Disp_Fa: mov var1,#0 mov row,#0 mov column,#0 mov lcall mov mov mov mov lcall lcall db mov lcall mov mov movx inc mov movx clr mov mov jmp f,#1 Init_Text r2,#high (1) r3,#low (1) r4,#high (7) r5,#low (7) lcd_xy lcd_print "GPS Selftest Results: ",0 num,#1 Bytes r0,#aid1 a,r4 @r0,a r0 a,r5 @r0,a a i,a i+1,a ww19

;r4 contains high byte

;for(i = 0; i < 16; i++)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (186 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

ww20: mov mov movx mov inc movx mov cjne jmp ww21: mov clr rrc mov mov rrc mov djnz ww22: mov anl mov inc movx dec mov anl movx a,r3 a,#01h r0,#aid2 r0 @r0,a r0 a,r2 a,#0 @r0,a a,r2 c a r2,a a,r3 a r3,a r5,ww21 r5,i+1 r0,#aid1 a,@r0 r2,a r0 a,@r0 r3,a r5,#0,ww21 ww22 ;num = (byte >> i) & 0x01

mov inc movx cjne dec movx cjne jmp ww23: jmp ww24: mov mov mov mov lcall mov add mov mov addc mov

r0,#aid2 ;if(num == 1) r0 a,@r0 a,#low (1),ww23 r0 a,@r0 a,#high (1),ww23 ww24 ww25

r2,#high (3) r3,#low (3) r4,#high (7) r5,#low (7) lcd_xy a,i+1 a,i+1 r3,a a,i a,i r2,a

;lcd_xy(7,3)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (187 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov add mov mov addc mov lcall jmp ww25: mov inc movx mov dec movx orl jnz inc ww26: mov inc movx cjne dec movx cjne mov cjne mov cjne jmp ww27: jmp ww29: mov jmp ww30: mov inc movx cjne dec movx cjne mov cjne mov cjne jmp ww32:

a,r3 a,#low(messages) dpl,a a,r2 a,#high(messages) dph,a lcd_print1 ;lcd_print(messages[i]) ww26 ;else if(num == 0) r0,#aid2 r0 a,@r0 b,a r0 a,@r0 a,b ww26 var1 ; count++

;if(num == 1 && i == 14) r0,#aid2 r0 a,@r0 a,#low (1),ww27 r0 a,@r0 a,#high (1),ww27 a,i+1 a,#low (14),ww27 a,i a,#high (14),ww27 ww29 ww30 row,#1 ww31 ;bit14 = 1

;else if(num == 1 && i == 15) r0,#aid2 r0 a,@r0 a,#low (1),ww32 r0 a,@r0 a,#high (1),ww32 a,i+1 a,#low (15),ww32 a,i a,#high (15),ww32 ww33

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (188 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp ww33: mov ww34: ww31: inc mov jnz inc ww19: mov add mov xrl addc jnc jmp ww44: jmp

ww34 column,#1 ; bit15 = 1

i+1 a,i+1 ww19 i a,i+1 a,#low -(16) a,i a,#80h a,#(high -(16))xor 80h ww44 ww35 ww20

;if((bit14 == 1 && bit15 == 1) || (bit14 == 1 && bit15 == 0)) ww35: mov a,row cjne a,#1,ww36 mov a,column cjne a,#1,ww36 jmp ww37 ww36: mov a,row cjne a,#1,ww38 mov a,column cjne a,#0,ww38 jmp ww37 ww38: jmp ww41 ww37: jmp ww40 ww40: mov r2,#high (4) mov r3,#low (4) mov r4,#high (7) mov r5,#low (7) lcall lcd_xy ;lcd_xy(7,4) lcall db jmp ww41: mov cjne mov cjne mov a,row a,#0,ww42 a,column a,#1,ww42 r2,#high (4) lcd_print ;lcd_print() "Antenna causes a short!!!",0 ww42 ;else if(bit14 == 0 && bit15 == 1)

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (189 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov lcall lcall db ww42: mov cjne mov mov mov mov lcall lcall db ww43: lcall ret

r3,#low (4) r4,#high (7) r5,#low (7) lcd_xy

;lcd_xy(7,4)

lcd_print ;lcd_print() "Antenna not connected!!!",0 ;if(count == 16) a,var1 a,#16,ww43 r2,#high (3) r3,#low (3) r4,#high (7) r5,#low (7) lcd_xy

;lcd_xy(7,3)

lcd_print ;lcd_print() "Selftest Passed!!!",0 ;End() EndDisps

;//////////////////////////////////////////////// Disp_Ea: mov key,#0 mov var3,#0 mov lcall mov lcall mov lcall mov ll1: lcall djnz mov lcall mov lcall mov lcall mov ll2: lcall Buffer Buffer r0,ll1 r4,#1 Disp_Ad r4,#1 Disp_Ae r4,#1 Disp_Af r0,#4 f,#1 Init_Text r4,#1 Disp_Ac r4,#1 Disp_Aa r0,#4

;date

;time

;lattitude ;longitude ;height

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (190 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

djnz mov lcall

r0,ll2 num,#1 Bytes ;get velocity ;r4 contains high byte ;r5 contains low byte

mov mov mov mov mov mov lcall lcall db mov mov mov mov mov mov mov mov lcall mov mov mov mov mov lcall mov lcall

lb,r4 lb+1,r5 r2,#high (3) r3,#low (3) r4,#high (7) r5,#low (7) lcd_xy lcd_print "Velocity (m/s): ",0 X3,#0 X2,#0 X1,lb X0,lb+1 Y0,#64h Y1,#00h Y2,#00h Y3,#00h DIV32 r1,#0 r2,Z7 r3,Z6 r4,Z5 r5,Z4 lcd_print_num num,#1 Bytes ;divide by 100

;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;print velocity

;lcd_print_num() ;get heading ;r4 contains high byte ;r5 contains low byte

mov mov mov mov mov mov lcall lcall db mov mov mov

lb,r4 lb+1,r5 r2,#high (4) r3,#low (4) r4,#high (7) r5,#low (7) lcd_xy lcd_print "Current Heading: ",0 X3,#0 X2,#0 X1,lb ;divide by 100

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (191 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov mov lcall mov mov mov mov mov lcall mov lcall mov lcall mov lcall

X0,lb+1 Y0,#64h Y1,#00h Y2,#00h Y3,#00h DIV32 r1,#0 r2,Z7 r3,Z6 r4,Z5 r5,Z4 lcd_print_num r7,#80h dput r7,#192 cput num,#1 Bytes

;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;print heading

;lcd_print_num()

;get geometry ;r4 contains high byte ;r5 contains low byte

mov mov mov orl jnz mov mov mov mov lcall lcall db jmp ll3: mov mov mov mov lcall lcall db mov mov mov mov

lb,r4 lb+1,r5 a,r5 a,r4 ll3 r2,#high (5) r3,#low (5) r4,#high (6) r5,#low (6) lcd_xy lcd_print "Current DOP not computable.",0 hello r2,#high (5) r3,#low (5) r4,#high (7) r5,#low (7) lcd_xy lcd_print "Current DOP: ",0 X3,#0 X2,#0 X1,lb X0,lb+1 ;divide by 10

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (192 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov lcall mov mov mov mov mov lcall hello: mov mov mov mov lcall lcall mov cjne lcall db jmp ll4: cjne lcall db jmp ll5: cjne lcall db jmp ll6: cjne lcall db jmp ll7: cjne lcall db jmp ll8: cjne lcall db jmp ll9: cjne lcall db

Y0,#0ah Y1,#00h Y2,#00h Y3,#00h DIV32 r1,#0 r2,Z7 r3,Z6 r4,Z5 r5,Z4 lcd_print_num r2,#high (6) r3,#low (6) r4,#high (4) r5,#low (4) lcd_xy Buffer a,r3

;Z4-Qlow - Z7-Qhigh / Z0-rem(low) ;print dop

;lcd_print_num()

a,#0,ll4 lcd_print "DOP Type: PDOP(3D)/Antenna OK.",0 ll11 a,#1,ll5 lcd_print "DOP Type: HDOP(2D)/Antenna OK.",0 ll11 a,#64,ll6 lcd_print "DOP Type: PDOP(3D)/Antenna shorted.",0 ll11 a,#65,ll7 lcd_print "DOP Type: HDOP(2D)/Antenna shorted.",0 ll11 a,#128,ll8 lcd_print "DOP Type: PDOP(3D)/Antenna open.",0 ll11 a,#129,ll9 lcd_print "DOP Type: HDOP(2D)/Antenna open.",0 ll11 a,#192,ll10 lcd_print "DOP Type: PDOP(3D)/Antenna shorted.",0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (193 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

jmp ll10: cjne lcall db ll11: mov cjne jmp ll12: jmp ll13: mov mov mov mov lcall lcall db ll15: mov jz mov mov lcall mov mov mov mov lcall lcall db lcall mov mov mov mov mov mov lcall mov mov mov mov lcall

ll11 a,#193,ll11 lcd_print "DOP Type: HDOP(2D)/Antenna shorted.",0 a,flag a,#1,ll12 ll13 ;if flag == 1

ll14 r2,#high (7) r3,#low (7) r4,#high (35) r5,#low (35) lcd_xy lcd_print ".....",0 ;wait for key to be pressed a,key ll15 key,#0 f,#1 Init_Text r2,#high (2) r3,#low (2) r4,#high (5) r5,#low (5) lcd_xy lcd_print "Num of visible satellites: ",0 Buffer a,r3 r1,#0 r2,#0 r3,#0 r4,#0 r5,a lcd_print_num r2,#high (3) r3,#low (3) r4,#high (5) r5,#low (5) lcd_xy ;print satellites

;lcd_print_num()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (194 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

lcall db lcall mov mov mov mov mov mov lcall mov mov mov mov lcall lcall db ll16: mov jz mov mov jmp ll18: mov lcall mov mov mov mov lcall lcall db mov add mov mov mov mov mov lcall lcall

lcd_print "Num of satellites tracked: ",0 Buffer a,r3 r1,#0 r2,#0 r3,#0 r4,#0 r5,a lcd_print_num r2,#high (7) r3,#low (7) r4,#high (35) r5,#low (35) lcd_xy lcd_print ".....",0 ;wait for key to be pressed a,key ll16 key,#0 var1,#0 ll17 f,#1 Init_Text r2,#high (0) r3,#low (0) r4,#high (3) r5,#low (3) lcd_xy lcd_print "Channel ",0 a,var1 a,#1 r1,#0 r2,#0 r3,#0 r4,#0 r5,a lcd_print_num lcd_print ;print channel no. ;print satellites

;lcd_print_num()

;lcd_print_num()

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (195 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

db lcall mov mov mov mov mov mov lcall mov mov mov mov lcall lcall db mov mov mov mov lcall lcall mov add mov mov addc mov mov add mov mov addc mov lcall mov mov mov mov lcall lcall db lcall mov

" / Satellite ID: ",0 Buffer a,r3 r1,#0 r2,#0 r3,#0 r4,#0 r5,a lcd_print_num r2,#high (1) r3,#low (1) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Channel Tracking Mode: ",0 r2,#high (2) r3,#low (2) r4,#high (3) r5,#low (3) lcd_xy Buffer a,r3 a,r3 r3,a a,#0 a,#0 r2,a a,r3 a,#low(channel) dpl,a a,r2 a,#high(channel) dph,a lcd_print1 r2,#high (3) r3,#low (3) r4,#high (0) r5,#low (0) lcd_xy lcd_print "Carrier to Noise Density Ratio: ",0 Buffer a,r3 ;print satellite ID

;lcd_print_num()

;lcd_print(channel[byte])

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (196 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov mov mov mov lcall lcall db mov mov mov mov lcall lcall db lcall mov mov jmp ll20: mov mov mov cjne jmp ll21: mov clr rrc mov mov rrc mov djnz ll22: mov anl cjne jmp ll23: jmp ll24: mov cjne jmp ll26: cjne jmp

r1,#0 r2,#0 r3,#0 r4,#0 r5,a lcd_print_num lcd_print "dB-Hz",0 r2,#high (4) r3,#low (4) r4,#high (0) r5,#low (0) lcd_xy

;print carrier to noise density ratio

;lcd_print_num()

lcd_print "Channel Status Flag: ",0 Buffer lb,r3 var2,#0 ll19 r5,var2 r0,#0 r1,lb r5,#0,ll21 ll22 a,r0 c a r0,a a,r1 a r1,a r5,ll21 a,r1 a,#01h a,#1,ll23 ll24 ll25 a,var2 a,#1,ll26 ll25 a,#2,ll27 ll25 ;num = (byte >> i) & 0x01

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (197 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

ll27: mov add mov mov mov mov lcall mov add mov mov addc mov mov add mov mov addc mov lcall inc ll25: inc ll19: mov cjne mov cjne lcall db ll28: mov ll29: mov jz mov inc ll17: mov cjne jmp ll44: jmp ll45: mov lcall mov mov f,#1 Init_Text r2,#high (2) r3,#low (2) ll18 a,var1 a,#8,ll44 ll45 a,key ll29 key,#0 var1 var3,#0 ;wait for key to be pressed a,var2 a,#8,ll20 a,var3 a,#0,ll28 lcd_print "0",0 var2 a,#5 a,var3 r2,#0 r3,a r4,#high (1) r5,#low (1) lcd_xy

;lcd_xy(7,3)

a,var2 a,var2 r3,a a,#0 a,#0 r2,a a,r3 a,#low(ch_status) dpl,a a,r2 a,#high(ch_status) dph,a lcd_print1 ;lcd_print(ch_status[var2]) var3

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (198 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov mov lcall lcall db lcall mov mov jmp ll31: mov mov mov cjne jmp ll32: mov clr rrc mov mov rrc mov djnz ll33: mov anl cjne mov cjne ll34: jmp ll36: mov add mov mov mov mov lcall mov add mov mov addc mov mov add mov

r4,#high (5) r5,#low (5) lcd_xy lcd_print "Receiver status flag: ",0 Buffer lb,r3 var2,#0 ll30 r5,var2 r0,#0 r1,lb r5,#0,ll32 ll33 a,r0 c a r0,a a,r1 a r1,a r5,ll32 a,r1 a,#01h a,#1,ll34 a,var2 a,#2,ll36 ll35 a,#3 a,var3 r2,#0 r3,a r4,#high (6) r5,#low (6) lcd_xy ;if(num == 1) && var2!=2 ;num = (byte >> i) & 0x01

;lcd_xy(7,3)

a,var2 a,var2 r3,a a,#0 a,#0 r2,a a,r3 a,#low(re_status) dpl,a

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (199 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

mov addc mov lcall inc ll35: inc ll30: mov cjne mov jmp ll14: mov ll40: inc mov cjne clr mov wieder: djnz mov ll41: lcall ret

a,r2 a,#high(re_status) dph,a lcd_print1 ;lcd_print(re_status[var2]) var3 var2 a,var2 a,#8,ll31 flag,#1 ll41 r0,#35 bufferout a,bufferout a,#230,wieder a bufferout,a r0,ll40 flag,#0 ;bufferout = bufferout + 1 ;if(bufferout == 230) ;bufferout = 0 ;return value//flag ;end of flag == 1

EndDisps

;//////////////////////////////////////////////////// Disp_Same: mov univ,r4 mov lcall mov mov mov mov lcall mov cjne lcall db jmp ww17: cjne lcall db ww18: lcall ret EndDisps a,#1,ww18 lcd_print "System Power_On Failure!!!",0 f,#1 Init_Text r2,#high (3) r3,#low (3) r4,#high (7) r5,#low (7) lcd_xy a,univ a,#0,ww17 lcd_print "GPS Receiver Reset!!!",0 ww18

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (200 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

;////////////////////////////////////////////// messages: dw 0+kk1 dw 0+kk2 dw 0+kk3 dw 0+kk4 dw 0+kk5 dw 0+kk6 dw 0+kk7 dw 0+kk8 dw 0+kk9 dw 0+kk10 dw 0+kk11 dw 0+kk12 dw 0+kk13 dw 0+kk14 dw 0+kk15 dw 0+kk16

kk16: db kk15: db kk14: db kk13: db kk12: db kk11: db kk10: db kk9: db kk8: db kk7: db kk6: db kk5: db kk4: db kk3: db kk2: db kk1: db "Channel 1 Correlation Test Fail!!!",0 "Channel 2 Correlation Test Fail!!!",0 "Channel 3 Correlation Test Fail!!!",0 "Channel 4 Correlation Test Fail!!!",0 "Channel 5 Correlation Test Fail!!!",0 "Channel 6 Correlation Test Fail!!!",0 "Channel 7 Correlation Test Fail!!!",0 "Channel 8 Correlation Test Fail!!!",0 "1 kHz Presence",0 "ROM Fail",0 "RAM Fail",0 "Ignore",0 "Temperature Sensor Fail",0 "RTC Comm & Time Fail",0 "Antenna Overcurrent:",0 "Antenna Undercurrent:",0

;/////////////////////////////////////////////////

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (201 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

channel: dw dw dw dw dw dw dw dw dw tt9: db tt8: db tt7: db tt6: db tt5: db tt4: db tt3: db tt2: db tt1: db " - code search.",0 " - code acquire.",0 " - AGC set.",0 " - preg acquire.",0 " - bit sync detect.",0 " - message sync detect.",0 " - satellite time available.",0 " - ephemeris acquire.",0 " - available for position.",0 0+tt1 0+tt2 0+tt3 0+tt4 0+tt5 0+tt6 0+tt7 0+tt8 0+tt9

;/////////////////////////////////////////////////// ch_status: dw 0+tt10 dw 0+tt11 dw 0+tt12 dw 0+tt13 dw 0+tt14 dw 0+tt15 dw 0+tt16 dw 0+tt17 tt17: db tt16: db tt15: db tt14: db tt13: db tt12: db tt11: db "",0 "",0 " - satellite reported inaccurate(>16m).",0 " - satellite reported unhealthy.",0 " - satellite anti-spoof flag set.",0 " - satellite momentum alert flag.",0 " - using for position fix.",0

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (202 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

tt10: db " - parity error.",0

;////////////////////////////////////////////////// re_status: dw 0+tt18 dw 0+tt19 dw 0+tt20 dw 0+tt21 dw 0+tt22 dw 0+tt23 dw 0+tt24 dw 0+tt25 tt25: db tt24: db tt23: db tt22: db tt21: db tt20: db tt19: db tt18: db " - poor geometry (DOP > 12).",0 " - position propagate mode.",0

" - 3d fix.",0 " - 2d fix.",0 " - acquring satellites.",0 "",0 " - insufficient visible satellites(< 3).",0 " - bad almanac.",0

;///////////////////////////////////////////////// ;Picture for GPS startup (compressed) Gps_pic_less: dw 1054, 01fh, 080h, 007h, 080h, 1025, 001h, 0ffh dw 0f8h, 003h, 0c0h, 1006, 00fh, 0f8h, 1006 dw 00fh, 0f8h, 1009, 07eh, 000h, 007h, 0e3h, 07ch dw 1006, 07fh, 0ffh, 000h, 003h, 0ffh, 0ffh dw 1002, 07fh, 0ffh, 1008, 00fh, 0c0h, 000h, 001h dw 0feh, 01fh, 080h, 1004, 001h, 0ffh, 0ffh dw 0c0h, 003h, 0ffh, 0ffh, 0e0h, 001h, 0ffh, 0ffh dw 080h, 1007, 018h, 1003, 003h, 081h, 0c0h dw 1004, 003h, 0ffh, 0ffh, 0e0h, 003h, 0ffh, 0ffh dw 0f0h, 003h, 0ffh, 0ffh, 0c0h, 1007, 030h dw 000h, 00fh, 000h, 001h, 0c1h, 0c0h, 1004, 007h dw 0f8h, 007h, 0f0h, 003h, 0ffh, 0ffh, 0f8h dw 003h, 0f0h, 00fh, 0e0h, 1006, 001h, 0e3h, 0e0h dw 03fh, 0feh, 000h, 078h, 0f0h, 1004, 00fh dw 0c0h, 001h, 0f8h, 003h, 0c0h, 000h, 0fch, 007h dw 0c0h, 003h, 0f0h, 1006, 003h, 007h, 0e0h dw 07fh, 0feh, 000h, 00ch, 038h, 1004, 01fh, 1002 dw 0f8h, 003h, 0c0h, 000h, 07ch, 00fh, 080h dw 000h, 0f0h, 1006, 006h, 01fh, 0c0h, 0ffh, 0feh dw 003h, 086h, 01ch, 1004, 01eh, 1002, 07ch dw 003h, 0c0h, 000h, 03eh, 00fh, 1002, 0f8h, 1006

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (203 of 206) [30/05/2004 08:31:23 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw

00ch, 00eh, 01eh, 0ffh, 1002, 1002, 0ffh, 018h, 03fh, 080h, 00fh, 0ffh, 003h, 001h, 0f8h, 000h, 0c3h, 1003, 0ffh, 0ffh, 1003, 0f8h, 0ffh, 003h, 002h, 0ffh, 003h, 0c0h, 0ffh, 07fh, 0ffh, 0ffh, 0feh, 0f0h, 0ffh, 0feh, 001h, 0c3h, 1005, 0ffh, 003h, 0e0h, 1002, 03ch, 0d9h, 0c0h, 0c0h, 03ch, 03ch, 003h, 1002, 1002, 01eh, 07ch, 030h, 0c0h,

01eh, 1004, 00fh, 0ffh, 03ch, 078h, 0c1h, 003h, 0ffh, 1003, 080h, 0ffh, 0c0h, 0c0h, 0c0h, 01eh, 0ffh, 0f0h, 080h, 0ffh, 003h, 1006, 0ffh, 0c0h, 000h, 0fch, 0ffh, 1005, 0ffh, 0feh, 0e0h, 0ffh, 003h, 1006, 0f3h, 003h, 0ffh, 018h, 0f8h, 0ffh, 0c0h, 00fh, 01eh, 1007, 018h, 1002, 000h, 1002, 1007, 018h, 00fh, 007h, 003h, 1007, 1003, 1002,

018h, 03eh, 1002, 0ffh, 003h, 1006, 0c3h, 0c0h, 0ffh, 078h, 1008, 0ffh, 000h, 0fch, 1003, 007h, 0ffh, 1003, 1006, 0ffh, 0c0h, 002h, 0fch, 001h, 03fh, 030h, 0ffh, 002h, 0fah, 003h, 1007, 0f2h, 0ffh, 001h, 038h, 0ffh, 0ffh, 1003, 1007, 0c1h, 1005, 0ffh, 003h, 07fh, 1003, 01eh, 00fh, 01eh, 00fh, 1003, 1002, 0fch, 0c0h, 00fh, 01fh, 00fh,

001h, 1002, 078h, 0ffh, 0c0h, 030h, 080h, 000h, 0ffh, 1003, 0c0h, 0f0h, 01eh, 0e7h, 0f0h, 0f8h, 0ffh, 003h, 003h, 0ffh, 000h, 000h, 070h, 0f8h, 08fh, 1003, 0f8h, 000h, 038h, 0ffh, 0ffh, 038h, 0ffh, 0ffh, 1003, 0ffh, 0cfh, 0f0h, 0ffh, 018h, 07ch, 0ffh, 0c0h, 0ffh, 078h, 1002, 093h, 003h, 0ffh, 03eh, 03ch, 082h, 1002, 0f8h, 080h, 0c0h,

0feh, 03ch, 1006, 0c1h, 000h, 003h, 1003, 01eh, 0ffh, 003h, 07ch, 0c0h, 007h, 0ffh, 1003, 1007, 0ffh, 0c0h, 000h, 0fch, 07ch, 01ch, 1003, 000h, 0ffh, 0f0h, 000h, 07fh, 1003, 0ffh, 0ffh, 1003, 0c0h, 0ffh, 0f0h, 1003, 0ffh, 1002, 0ffh, 1003, 1007, 0c1h, 1002, 0e0h, 1002, 03ch, 018h, 0c0h, 1002, 1002, 1007, 018h, 00fh, 1002, 000h, 000h,

003h, 003h, 018h, 087h, 01eh, 0ffh, 078h, 00fh, 0ffh, 0c0h, 06fh, 1003, 0c0h, 0ffh, 003h, 001h, 0f8h, 000h, 031h, 060h, 001h, 007h, 0f0h, 0ffh, 0ffh, 000h, 01fh, 0ffh, 0f0h, 0f0h, 0ffh, 0f0h, 1002, 0ffh, 000h, 003h, 0ffh, 01eh, 0e0h, 078h, 0ffh, 018h, 01eh, 00fh, 01eh, 1007, 1003 1002, 01fh, 01eh, 00fh, 1003, 080h, 007h, 07eh, 078h,

083h 0c0h, 003h 1004, 00fh 0ffh, 1002 1009, 0f1h 000h, 0ffh 078h, 1007 0ffh, 0c0h 080h, 0e0h 03ch, 0c3h 1003, 0ffh 0ffh, 1003 0ffh, 0ffh 07fh, 0ffh 0ffh, 000h 000h, 0ffh 000h, 03fh 0ffh, 07fh 0f8h, 0ffh 003h, 01fh 1002, 0ffh 1003, 1002 0ffh, 003h 01fh, 01fh, 0ffh 003h, 0f8h 01eh, 000h 0f1h, 003h 1005,

000h 03ch 0ffh 060h 01eh 1003 0ffh 079h 003h 0f0h 0ffh 1006 0feh 0ffh 003h 07fh 0ffh 1006 0c0h 01eh 078h 0ffh 0ffh 1002 0c0h 1002 082h 002h

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (204 of 206) [30/05/2004 08:31:24 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw

000h, 030h, 1002, 000h, 060h, 0c0h, 000h, 00ch, 0c0h, 001h, 018h, 0c0h, 080h, 080h, 007h, 007h, 061h, 1021, 1021, 01fh, 003h, 07fh, 01fh, 1003, 1011, 1004, 023h, 1005, 098h, 024h, 0ffh, 090h, 008h, 0ffh, 021h, 0c9h, 07fh, 021h, 002h, 1006, 084h, 03fh, 021h, 048h, 08eh, 087h, 01fh, 0c0h, 0ffh, 01fh, 0e0h, 000h,

00fh, 1003, 007h, 00fh, 1003, 1002, 00fh, 060h, 1002, 080h, 0e0h, 1003, 1004, 003h, 1003, 0fch, 080h, 03fh, 01fh, 1022, 0ffh, 0f0h, 0c0h, 0c1h, 01fh, 080h, 0c3h, 003h, 091h, 048h, 080h, 090h, 049h, 0ffh, 021h, 013h, 0e0h, 000h, 1006, 080h, 004h, 0ffh, 021h, 042h, 01eh, 088h, 0c0h, 1028, 0fch, 0ffh, 1025, 000h,

0f0h, 00fh, 0e0h, 0f0h, 007h, 003h, 0f0h, 1003, 001h, 00fh, 1004, 0ffh, 010h, 0c0h, 060h, 1006, 1021, 1003, 0f8h, 007h, 0e0h, 1003, 1002, 0c0h, 0f0h, 097h, 087h, 0f8h, 021h, 04ah, 007h, 021h, 012h, 001h, 0f8h, 0f2h, 1005, 011h, 001h, 090h, 008h, 0ffh, 008h, 012h, 020h, 041h, 1028, 00fh, 1027, 0ffh, 001h, 000h

1002, 0c0h, 001h, 000h, 0f8h, 0f8h, 000h, 003h, 0ffh, 0e0h, 0ffh, 0ffh, 0c0h, 1003, 000h, 007h, 060h, 001h, 1002, 0fch, 1003, 060h, 008h, 1004, 1002, 00eh, 08ah, 1002, 031h, 00ah, 0f0h, 021h, 012h, 0f0h, 01fh, 1006, 080h, 004h, 0fch, 090h, 008h, 0f0h, 010h, 1008, 0f0h, 0e2h, 01fh, 1029, 003h, 080h, 0ffh,

080h, 000h, 0f8h, 001h, 007h, 007h, 001h, 0ffh, 0ffh, 000h, 0ffh, 0c0h, 1004, 03fh, 070h, 0fch, 1006, 030h, 001h, 1004, 03ch, 0e0h, 1008, 041h, 003h, 01eh, 009h, 01ch, 008h, 013h, 07ch, 008h, 1006, 1005, 0c7h, 03fh, 090h, 004h, 000h, 021h, 0a2h, 1006, 044h, 00fh, 010h, 1008, 0c0h, 07fh, 0ffh, 1026, 0ffh,

00fh, 0feh, 1005, 081h, 0fch, 0f0h, 083h, 0ffh, 0e0h, 001h, 0e0h, 1006, 07fh, 0ffh, 0c0h, 1007, 0c1h, 001h, 010h, 006h, 078h, 1004, 03fh, 1005, 083h, 02ch, 0e2h, 00fh, 010h, 1005, 1005, 010h, 070h, 080h, 0e4h, 0c0h, 090h, 008h, 007h, 021h, 002h, 041h, 024h, 1008, 023h, 01fh, 1028, 0f0h, 0fch, 03fh, 0ffh,

006h 003h, 003h 08fh, 003h 1005, 0c0h 0f0h, 1005 083h, 003h 0c0h, 0ffh 1007, 1004 040h, 080h 0c3h, 003h 03ch, 1023 03eh, 0f0h 010h, 080h 0f0h, 0c0h 1005, 024h 003h, 080h 024h, 00fh 090h, 00fh 01fh, 021h 008h, 0f8h 000h, 1007 010h, 048h 03eh, 0c3h 0c0h, 01fh 1027, 1027 0ffh, 0fch

0c0h 004h 001h 003h 0e0h 007h 0c0h 1006 080h 1022 1005 020h 010h 080h 0c0h 024h 090h 080h 0a2h 010h 091h 010h 1028 001h 0ffh

;/////////////////////////////////////////////////// Final: jmp Final

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (205 of 206) [30/05/2004 08:31:24 a.m.]

Interfacing a GPS to an LCD using a Microcontroller

end

Appendix G Included Disc

This disc contains 3 directories: gpscomp: This directory contains C++ files to interface the GPS via the serial port to the PC. All information is displayed on the PC. gpslcd: This directory contains C++ files to interface the GPS via the serial port to the PC and the LCD via the parallel port to the PC. asem: This directory contains the assembly program file and a cross-assembler.

File translated from TEX by TTH, version 2.00. On 31 May 1999, 11:49.

takshop.net
http://www.dip.ee.uct.ac.za/~ahenric/oncorhtm.html (206 of 206) [30/05/2004 08:31:24 a.m.]

You might also like