Skip to content

Instantly share code, notes, and snippets.

/* Function to send the Data to LCD.
As it is 4bit mode, a byte of data is sent in two 4-bit nibbles */
void Lcd_DataWrite(char dat)
{
LcdDataBus = (dat & 0xF0); //Send higher nibble
LCD_RS = 1; // Send HIGH pulse on RS pin for selecting data register
LCD_RW = 0; // Send LOW pulse on RW pin for Write operation
LCD_EN = 1; // Generate a High-to-low pulse on EN pin
delay(1000);
LCD_EN = 0;
/* Function to send the command to LCD.
As it is 4bit mode, a byte of data is sent in two 4-bit nibbles */
void Lcd_CmdWrite(char cmd)
{
LcdDataBus = (cmd & 0xF0); //Send higher nibble
LCD_RS = 0; // Send LOW pulse on RS pin for selecting Command register
LCD_RW = 0; // Send LOW pulse on RW pin for Write operation
LCD_EN = 1; // Generate a High-to-low pulse on EN pin
delay(1000);
LCD_EN = 0;
/* Configure the data bus and Control bus as per the hardware connection
Databus is connected to P2.4:P2.7 and control bus P2.0:P2.2*/
#define LcdDataBus P2
sbit LCD_RS = P2^0;
sbit LCD_RW = P2^1;
sbit LCD_EN = P2^2;
/***************************************************************************************************
Struct/Enums used
****************************************************************************************************/
/* Time S Lat P Long P Date
$GPRMC,110831.000,A,1304.8763,N,07733.6457,E,0.79,303.84,010116,,,A*68
*/
#define TIME_INDEX 7
#define STATUS_INDEX 18
#define LAT_INTEX 20
#define NS_POLE_INTEX 30
/***************************************************************************************************
ExploreEmbedded Copyright Notice
****************************************************************************************************
* File: main.c
* Version: 16.0
* Author: ExploreEmbedded
* Website: http://www.exploreembedded.com/wiki
* Description: This file contains the sample program to read the GPS data and display it on LCD
This code has been developed and tested on ExploreEmbedded boards.
#include<reg51.h>
#define LEDs P0
unsigned char receivedChar=0;
unsigned char count=0;
unsigned char ti_flag=0;
void ext_int_0() interrupt 0
{
count++;
}
#include<reg51.h>
#define LEDs P0
unsigned char receivedChar=0;
void serial_isr() interrupt 4
{
if(RI == 1)
{
receivedChar = SBUF; // Copy the received char
SBUF = receivedChar; // echo the character back
#include<reg51.h>
#define LEDs P0
unsigned char count=0;
void ext_int_0 () interrupt 0
{
count++;
}
void ext_int_1 () interrupt 2
#include<reg51.h>
sbit LED1 = P0^0; // this will be blinking every 50ms
sbit LED2 = P0^1; // will show switch status(inverted)
sbit SW = P3^2;
void timer0_isr() interrupt 1
{
TH0 = 0X4B; //ReLoad the timer value
TL0 = 0XFD;
LED1 =!LED1; // Toggle the LED pin
#include "glcd.h" //User defined LCD library which contains the lcd routines
#include "delay.h"
/* start the main program */
void main()
{
/* Initialize the glcd before displaying any thing on the lcd */
GLCD_Init();
GLCD_Printf("Interfacing\n\n");