Interfacing GPS with LPC2148 ARM

Objective

A global positioning system (GPS) receiver is used to get precise geographical location by receiving information from satellites. It not only gives information about location but also information like time, date, height and speed. It is so useful that most smartphones are embedded with it.

Block Diagram

The GPS module continuously transmits serial data in the form of sentences according to NMEA standards. The latitude and longitude values of the location are contained in the GPGGA sentence.To communicate over UART or USART, we just need three basic signals which are, namely, RXD (receive), TXD (transmit), GND (common ground).

Circuit Diagram

Working Principle

We need to receive data from the satellite to the LPC2148 Primer Board by using a GPS module through UART0. The serial data is taken from the GPS module through MAX232 into the SBUF register of the LPC2148 microcontroller. The serial data from the GPS receiver is taken by using the Serial Interrupt of the controller. This data consists of a sequence of NMEA sentences from which GPGGA sentences are identified and processed.The first six bytes of the data received are compared with the pre-stored string and if matched then only data is further accounted for; otherwise the process is repeated again. From the comma delimited GPGGA sentence, latitude and longitude positions are extracted by finding the respective comma positions and extracting the data.

Pin Assignment with LPC2148

Program

#define CR     0x0D
#include <LPC21xx.H>
void init_serial (void);
int putchar (int ch);
int getchar (void);
unsigned char test;
int main(void)
{
    char *Ptr = "*** UART0 Demo ***\n\n\rType Characters to be echoed!!\n\n\r";
    VPBDIV = 0x02;   // Divide Pclk by two
    init_serial();
    while(1) 
    {
        while (*Ptr)
        {
            putchar(*Ptr++);
        }
        putchar(getchar());  // Echo terminal
    }
}

void init_serial (void)
{
    PINSEL0  = 0x00000005; // Enable RxD0 and TxD0
    U0LCR    = 0x00000083;   //8 bits, no Parity, 1 Stop bit
    U0DLL    = 0x000000C3; //9600 Baud Rate @ 30MHz VPB Clock
    U0LCR    = 0x00000003;
}

int putchar (int ch)
{
    if (ch == '\n')
    {
        while (!(U0LSR & 0x20));
        U0THR = CR;
    }
    while (!(U0LSR & 0x20));
    return (U0THR = ch);
}
int getchar (void)
{
    while (!(U0LSR & 0x01));
    return (U0RBR);
}

Conclusion

GPS is used in many fields such as Agriculture, Aviation, Marine, Public Safety, Rail, Roads & Highways, Space, Surveying & Mapping.Since the GPS system gets calibrated on its own, anyone can use it.As GPS follows trilateration which means data from three satellites uses to locate a specific point on the earth , so its user friendly.

Authors