EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Trying to run this code but cant go through it. needs help!!!

Trying to run this code but cant go through it. needs help!!!

|

Microcontroller › 8051 › Trying to run this code but cant go through it. needs help!!!

  • This topic has 1 reply, 2 voices, and was last updated 11 years, 1 month ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • May 18, 2014 at 8:10 am #3088
    fadi
    Participant
    #include<reg51.h>

    #define port2 P2

    sbit rs = P1^0;

    sbit rw = P1^1;

    sbit e = P1^2;

    char info[70];

    char test[6]={“$GPGGA”};

    char comma_position[15];

    unsigned int check=0,i;

    unsigned char a;

    void receive_data();

    void lcd_latitude();

    void lcd_longitude();

     

    //DELAY FUNCTION

    void delay(unsigned int msec)

    {

    int i,j ;

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

    for(j=0;j<1275;j++); 

    }

     

    // LCD COMMAND SENDING FUNCTION

    void lcd_cmd(unsigned char item)

    {

    port2 = item;

    rs= 0;

    rw=0;

    e=1;

    delay(1);

    e=0;

    return;

    } 

     

    // LCD DATA SENDING FUNCTION

    void lcd_data(unsigned char item)

    {

    port2 = item;

    rs= 1;

    rw=0;

    e=1;

    delay(1);

    e=0;    

    return;

    }

     

     // LCD STRING SENDING FUNCTION 

    void lcd_string(unsigned char *str)

    {

    int i=0;

    while(str!=’’)

    {

            lcd_data(str);

            i++;

            delay(10);

       }

            return;

    }

     

    // SERIAL PORT SETTING

    void serial()

    {

    TMOD=0x20;      //MODE=2

    TH1=0xfa;     // 4800 BAUD

    SCON=0x50  ;    // SERIAL MODE 1 ,8- BIT DATA ,1 STOP BIT ,1 START BIT , RECEIVING ON

    TR1=1;         //TIMER START

    }

     

    void find_comma()

    {

    unsigned int i,count=0;

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

    {

    if(info==’,’)

    {

    comma_position[count++]=i;

    }

        }

    }

    void compare()

    {  

    IE=0x00;       //Interrupt disable 

    find_comma();   //Function to detect position of comma in the string

    lcd_latitude();   //Function to show Latitude

    lcd_longitude(); //Function to show Longitude

    check=0;

    IE=0x90;   //Interrupt enable

    }

    void receive_data()   interrupt 4  

    {

    info[check++]=SBUF;  //Read SBUF

    if(check<7)         //Condition to check the required data

        {

    if(info[check-1]!=test[check-1])

    check=0;

        }

    RI=0;

    }

    void lcd_shape()      //Function to create shape of degree

    {

    lcd_cmd(64);

    lcd_data(10);

    lcd_data(17);

    lcd_data(17);

    lcd_data(10);

    lcd_data(0);

    lcd_data(0);

    lcd_data(0);

    lcd_data(0);

    }

     

    void lcd_latitude() //Function to display Latitude

    {

    unsigned int c2=comma_position[1]; //Position of second comma

    lcd_shape();

    lcd_cmd(0x01);         // Clear LCD display

    lcd_cmd(0x84);         //Move cursor to position 6 of line 1

    lcd_string(“LATITUDE”); //Showing Latitude

    lcd_cmd(0xC0); //Beginning of second line  

    lcd_data(info[c2+1]);

    lcd_data(info[c2+2]);

    lcd_data(0); //Degree symbol

    lcd_data(info[c2+3]);

    lcd_data(info[c2+4]);

    lcd_data(info[c2+5]);

    lcd_data(info[c2+6]);

    lcd_data(info[c2+7]);

    lcd_data(info[c2+8]);

    lcd_data(info[c2+9]);

    lcd_data(0x27);          //ASCII of minute sign(‘)

    lcd_data(info[c2+10]);

    lcd_data(info[c2+11]);

    delay(250);

    } 

     

    void lcd_longitude()

    {

    unsigned int c4=comma_position[3];

    lcd_cmd(0x01);            //Clear LCD display

    lcd_cmd(0x84);            //Move cursor to position 4 of line 1

    lcd_string(“LONGITUDE”); //Showing Longitude

    lcd_cmd(0xC0);    //Begining of second line  

    lcd_data(info[c4+1]);

    lcd_data(info[c4+2]);

    lcd_data(info[c4+3]);

    lcd_data(0);

    lcd_data(info[c4+4]);

    lcd_data(info[c4+5]);

    lcd_data(info[c4+6]);

    lcd_data(info[c4+7]);

    lcd_data(info[c4+8]);

    lcd_data(info[c4+9]);

    lcd_data(info[c4+10]);

    lcd_data(0x27);               //ASCII of minute sign(‘)

    lcd_data(info[c4+11]);

    lcd_data(info[c4+12]);

    delay(250);

    }

    void main()

    {

    serial();

    lcd_cmd(0x38);        //2 LINE, 5X7 MATRIX

    lcd_cmd(0x0e);         //DISPLAY ON, CURSOR BLINKING

    IE=0x90;

    while(1)

    {

    if(check==69)

    compare();

    }

    }
    May 18, 2014 at 12:02 pm #11741
    Ashutosh Bhatt
    Participant

    r u trying to display GPS data on LCD?

    what is the problem u r gattine?

    is ur GPS working fine?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Raise your hand if your car had one of these: July 8, 2025
  • Simple LED Analog Clock Idea July 8, 2025
  • Kawai KDP 80 Electronic Piano Dead July 8, 2025
  • Tektronix 2235 channel 1 trace unstable July 8, 2025
  • How to make string LEDs? July 8, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise