You are currently viewing How to Interface ARM9 Stick with GPS SIM39E 20×4 LCD

How to Interface ARM9 Stick with GPS SIM39E 20×4 LCD

Spread the love

ARM9-LPC2929 STICK BOARD

The is specifically designed to help students to master the required skills in the area of embedded systems. The board is designed in such way that all the possible features of the microcontroller will be easily used by the students. The board supports Keil µVision 4 compilers with Keil ULink2.

NXP Microcontroller,ARM9-LPC2929 stick boardis proposed to smooth the progress of developing and debugging of various designs encompassing of speed 32-bit Microcontrollers. It integrates CAN, LIN, UART, ADC, PWM, I2C, SPI, Timer, Interrupt etc., to create a stand-alone versatile test platform.

ARM9 Stick Board having more no of I/O line for user access able. Its consists of 64 GPIO pins, CAN0/1, LIN1, I2C0/1, UART0/1, SPI0/1, USB, ADC0/1/2, PWM, Timer and more features. Users can easily access the controller and develop more application by using

ARM9 Stick Board.

PROJECT DESCRIPTION

Connecting wires:

The connecting wires are both sides having female type, because ARM9 stick, GPS and LCD models are having male type connector for interfacing.

Mode of GPS Interfacing:

☞Serial Interface UART

Output of GPS Module:

The output of GPS SIM39E module was taken from 20×4 LCD. Its display the latitude, longitude and Time (UTC) values of our GPS module where placed.

The Program receiving GPS data through UART and display that latitude and longitude values in 20×4 LCD has been downloading to ARM9 stick board.

Hardware’s:

  • ARM9 Stick Board
  • ULink2 for Download program
  • Base Board with GPS SIM39E module
  • USB Micro cable (for Stick board Power)
  • USB Mini cable (for ULink2)
  • 20 Pin FRC Cable (for interface Stick board and ULink)
  • LCD 20×4
  • Connecting Wires.

Software’s:

  • Keil UVision4

Note:

For easy interfacing purpose only we have to use the base board (PS-XBEE-PRJ Board) for GPS module. So without that base board, we can implement this project.

Functional Pin Diagram of ARM9 Stick Board

Front view of GPS SIM39EA Module

Note:

The GPS SIM39EA module will take 3 minutes time for to give a received GPS data. So wait till LED ‘D1’ become ON (glow), and then only we got the correct GPS data.

Pin Details of GPS SIM39EA Module

  • Pin 1 — VCC (3.3V)
  • Pin 2 — TXD (Connect to ARM9 RXD_UART0/1 in J2)
  • Pin10 — GND

Circuit for ARM9 Stick Interface with GPS Module

Real view of ARM9 Stick Interface with GPS Module

Output of received GPS Data

Latitude – — Latitude value of GPS module

Longitude – — Longitude value of GPS module

Values: ‘N’ North Pole 012 degree 57.8268’

         ‘E’ East Pole 080 degree 14.9697’

Time – — HH:MM:SS UTC (Coordinated Universal Time)

Some Tips about this project

1. The 20×4 LCD working in 4 bit mode. Its Anode (A), Cathode (K) and Contrast (CST) lines are configure as I/O lines and Set high as ‘A’, Set Low as ‘K’ & ‘CST’ by using program.

2. The GPS module have internal patch antenna. So no need any external antenna.

3. The GPS module will get the GPS values and transmit the GPS data’s through TXD line in UART protocol.

4. ARM9 stick board will receive the GPS data’s through RXD line in UART protocol.

5. Display the latitude and longitude values in LCD.

6. The ULink2 board was used only for downloading program to ARM9_LPC2929 stick board.

Downloading the Project file into Stick Board using Keil4

C Program for Interfacing GPS Module with ARM9 Stick Board

Title: Program ARM9

#include  //Register Description Header for LPC2929
#include 
#define RS 0x2 // Register Select
#define RW 0x4 // Read Write Select
#define EN 0x8 // Enable
#define D7 0x800 // Data Line 7
#define D6 0x400 // Data Line 6
#define D5 0x200 // Data Line 5
#define D4 0x100 // Data Line 4
#define A 0x100000 // LCD Anode
#define K 0x080000 // LCD Cathode
#define CST 0x0001 // LCD Contrast
#define CLK 12000000
#define BAUD 9600
#define DLAB_1 0x80
#define DLAB_0 0x7F
void CLOCK_Select(void);
void UART0_Init(void);
unsigned char Receive(void);
void lcd_cmd (char);
void lcd_data (unsigned char);
void lcd_initialize (void);
void lcd_display (void);
void LCD4_Convert(char);
void delay(int);
void gets_USART0(unsigned char *string);
void Get_GPS_USART0(unsigned char *GPS_Str);
void Put_GPS_LCD (unsigned char *gpsval);
void GPS_Time (unsigned int n);
void GPS_Logi (unsigned int n);
void GPS_Lati (unsigned int n);
char cmd[] = {0x33,0x32,0x28,0x0C,0x06,0x01}; // LCD Comments
char msg[] = {" ARM9 GPS SIM39"}; // 1st Line of LCD
char msg1[]= {"Lati:"}; // 2nd Line of LCD
char msg2[]= {"Logi:"}; // 3rd Line of LCD
char msg3[]= {"Time: : : UTC"}; // 4th Line of LCD
unsigned int Fdiv;
unsigned char *ptr,GPS_Rvdata[];
int main(void) // Main Function
{
GPIO3_DR |= 0xFFFF; // P3.0 to P3.15 config as Out Direction
GPIO1_DR |= (A|K); // Anode&Cathode config as Out Direction
GPIO1_OR |= (A); // Set Anode as High
GPIO1_OR &= ~(K); // Set Cathode as Low
GPIO3_OR &= ~(CST); // Set CST as Low
CLOCK_Select();
UART0_Init(); // UART0 Initialize
lcd_initialize(); // LCD Initialize
lcd_display(); // Display Char in LCD
while(1)
{
Get_GPS_USART0(GPS_Rvdata); // Read data from GPS module via UART0
Put_GPS_LCD (GPS_Rvdata); // Write GPS data to LCD
}
}
void delay(int n) // Delay function
{
unsigned int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<100;j++)
{;}
}
}
void CLOCK_Select(void)
{
SYS_CLK_CONF = 0x01000000; //Direct Crystal Frequency = 12Mhz, no PLL
UART_CLK_CONF= 0x01000000; //Direct Crystal Frequency = 12Mhz, no PLL
} 
void UART0_Init(void)
{
SFSP1_22 = 1; //UART0 TXD, Configured as Digital Input without internal pullup
SFSP1_23 = 5; //UART0 RXD, Configured as Digital Input without internal pullup
U0IER = 0x00;
U0FCR = 0;
U0LCR = 0x83; //8 bits, no Parity, 1 Stop bit, DLAB = 1
U0FDR = 0x10; //DivAddVal=0, MulVal=1
Fdiv = ((CLK/16)/BAUD);
U0DLM = Fdiv/256; //Baud rate MSB register
U0DLL = Fdiv%256; //Baud rate LSB register
U0LCR = 0x03; //DLAB = 0
}
void lcd_initialize(void) // LCD Initialize function
{
int k;
for(k=0;k<6;k++)
{
lcd_cmd(cmd[k]);
delay(5);
}
}
void lcd_cmd(char data)
{
GPIO3_OR &= ~RS; // LCD Select as Command mode
GPIO3_OR &= ~RW; // LCD Select as Write mode
LCD4_Convert(data);
} 
void lcd_data (unsigned char data)
{
GPIO3_OR |= RS; // LCD Select as Data mode
GPIO3_OR &= ~RW; // LCD Select as Write mode
LCD4_Convert(data);
}
void lcd_display (void)
{
char i;
lcd_cmd(0x80); // command for LCD first line
delay(20);
for(i=0;msg[i]!='\0';i++)
{
lcd_data(msg[i]);
delay(100);
}
lcd_cmd(0xC0); // command for LCD second line
delay(20);
for(i=0;msg1[i]!='\0';i++)
{
lcd_data(msg1[i]);
delay(100);
}
lcd_cmd(0x94); // command for LCD 3rd line
delay(20);
for(i=0;msg2[i]!='\0';i++)
{
lcd_data(msg2[i]);
delay(100);
}
lcd_cmd(0xD4); // command for LCD 4th line
delay(20);
for(i=0;msg3[i]!='\0';i++)
{
lcd_data(msg3[i]);
delay(100);
}
}
void LCD4_Convert(char c)
{
if(c & 0x80) GPIO3_OR |= D7; else GPIO3_OR &= ~D7; // Set data for Data Line 7
if(c & 0x40) GPIO3_OR |= D6; else GPIO3_OR &= ~D6; // Set data for Data Line 6
if(c & 0x20) GPIO3_OR |= D5; else GPIO3_OR &= ~D5; // Set data for Data Line 5
if(c & 0x10) GPIO3_OR |= D4; else GPIO3_OR &= ~D4; // Set data for Data Line 4
GPIO3_OR |= EN; // Set High as Enable Line
delay(1);
GPIO3_OR &= ~EN; // Set Low as Enable Line

if(c & 0x08) GPIO3_OR |= D7; else GPIO3_OR &= ~D7; // Set data for Data Line 3
if(c & 0x04) GPIO3_OR |= D6; else GPIO3_OR &= ~D6; // Set data for Data Line 2
if(c & 0x02) GPIO3_OR |= D5; else GPIO3_OR &= ~D5; // Set data for Data Line 1
if(c & 0x01) GPIO3_OR |= D4; else GPIO3_OR &= ~D4; // Set data for Data Line 0
GPIO3_OR |= EN; // Set High as Enable Line
delay(1);
GPIO3_OR &= ~EN; // Set Low as Enable Line
}
unsigned char Receive(void)
{
while((U0LSR & 0x01)==0); //Bit0 is used to indicate the status of Receive buffer
return U0RBR; //if it is 1, the U0RBR has data
}
void gets_USART0(unsigned char *string) // Receive a batch of characters via USART0, without interrupting
{
unsigned char i=0,J=0; // The String Must Ended with "Carriage return" ie "Enter key"
do
{
*(string+i)= Receive();
J = *(string+i);
i++;
}
while((J!='\n') && (J!='\r'));
i++;
*(string+i) = '\0';
}
void Get_GPS_USART0(unsigned char *GPS_Str)
{
gets_USART0(GPS_Str);
while(!(strstr(GPS_Str,"GPRMC"))) gets_USART0(GPS_Str);
ptr = strstr(GPS_Str,"GPRMC")+19;
}
void Put_GPS_LCD (unsigned char *gpsval)
{
int j,n;
for(j=0;gpsval[j]!='\0';j++)
{
if( gpsval[j] =='$'&&
gpsval[j+1]=='G'&&
gpsval[j+2]=='P'&&
gpsval[j+3]=='R'&&
gpsval[j+4]=='M'&&
gpsval[j+5]=='C' )
n=j+7;
GPS_Lati (n);
GPS_Logi (n);
GPS_Time (n);
}
}
void GPS_Lati (unsigned int n)
{
lcd_cmd (0xC5);
lcd_data(GPS_Rvdata[n+23]); // Direction (E/W/N/S)
lcd_cmd (0xC7);
lcd_data(0x30);
lcd_data(GPS_Rvdata[n+13]);
lcd_data(GPS_Rvdata[n+14]);
lcd_data(0xDF);
lcd_cmd (0xCC);
lcd_data(GPS_Rvdata[n+15]);
lcd_data(GPS_Rvdata[n+16]);
lcd_data(GPS_Rvdata[n+17]);
lcd_data(GPS_Rvdata[n+18]);
lcd_data(GPS_Rvdata[n+19]);
lcd_data(GPS_Rvdata[n+20]);
lcd_data(GPS_Rvdata[n+21]);
lcd_data(0x27);
}
void GPS_Logi (unsigned int n)
{
lcd_cmd (0x99);
lcd_data(GPS_Rvdata[n+36]); // Direction (E/W/N/S)
lcd_cmd (0x9B);
lcd_data(GPS_Rvdata[n+25]);
lcd_data(GPS_Rvdata[n+26]);
lcd_data(GPS_Rvdata[n+27]);
lcd_data(0xDF);
lcd_cmd (0xA0);
lcd_data(GPS_Rvdata[n+28]);
lcd_data(GPS_Rvdata[n+29]);
lcd_data(GPS_Rvdata[n+30]);
lcd_data(GPS_Rvdata[n+31]);
lcd_data(GPS_Rvdata[n+32]);
lcd_data(GPS_Rvdata[n+33]);
lcd_data(GPS_Rvdata[n+34]);
lcd_data(0x27);
}
void GPS_Time (unsigned int n)
{
lcd_cmd (0xD9);
lcd_data(GPS_Rvdata[n]);
lcd_data(GPS_Rvdata[n+1]);
lcd_cmd (0xDC);
lcd_data(GPS_Rvdata[n+2]);
lcd_data(GPS_Rvdata[n+3]);
lcd_cmd (0xDF);
lcd_data(GPS_Rvdata[n+4]);
lcd_data(GPS_Rvdata[n+5]);
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.