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 / Replies / Please find the code

Please find the code

|

Microcontroller › PIC › PIC18F2550 with GTPA010 › Please find the code

December 18, 2013 at 6:55 am #10743
sampoornam
Participant

Please find the code attached. It doesn’t display any. I am using mikroPRO C. Kindly help

– regards

 -samp

 

//

// Program to Interface GPS GTPA010 with PIC18F2550 Microcontroller
 
 
//LCD Control pins
#define rs LATB.F4
#define en LATB.F5
 
//LCD Data pins
#define lcdport LATB
 
void lcd_ini();
void dis_cmd(unsigned char);
void dis_data(unsigned char);
void lcdcmd(unsigned char);
void lcddata(unsigned char);
 
unsigned char rx_data();
 
unsigned char longi_data[12];
unsigned char lati_data[12];
unsigned char data1,value=0;
unsigned int i=0,pos;
 
void main()
{
        TRISB=0;                        // Set Port B as output port
        LATB=0;
        TRISA=0;
        LATA=0;
 
        UART1_init(9600);
        
        Delay_ms(100);
 
 
   //     RCSTA.SPEN=1;                        // To activate serial port (Tx and Rx pins)
    //    RCSTA.CREN=1;                        // To enable continuous reception
 
        lcd_ini();
        while(1)
        {
                data1=rx_data();                     // Check the string ‘$GPGGA,’
                if(data1==’$’)
                {
                        data1=rx_data();
                        if(data1==’G’)
                        {
                                data1=rx_data();
                                if(data1==’P’);
                                {
                                        data1=rx_data();
                                        if(data1==’G’);
                                        {
                                                data1=rx_data();
                                                if(data1==’G’)
                                                {
                                                data1=rx_data();
                                                if(data1==’A’)
                                                {
                                                data1=rx_data();
                                                if(data1==’,’)
                                                {
                                                data1=rx_data();
                                                while(data1!=’,’)
                                                data1=rx_data();
                                                for(i=0;data1!=’N’;i++)
                                                data1=rx_data();
                                                lati_data=data1;  // Store the Latitude data
                                                }
                                                data1=rx_data();
                                                if(data1==’,’)
                                                {
                                                for(i=0;data1!=’E’;i++)
                                                {
                                                data1=rx_data();
                                                longi_data=data1;  // Store the Longitude data
                                                }
                                                }
                                                i=0;
                                                dis_cmd(0x80);
                                                while(i<11)
                                                {
                                                dis_data(lati_data);        // Print the Latitude data
                                                i++;
                                                }
                                                i=0;
                                                dis_cmd(0xC0);
                                                while(i<12)
                                                {
                                                dis_data(longi_data);          // Print the Longitude data
                                                i++;
                                                }
                                                }
                                                }
                                                }
                                        }
                                }
                     //}
                }
                Delay_ms(1000);
                for(i=0;i<12;i++)
                {
                        data1=0;
                        lati_data=0;
                        longi_data=0;
                }
        }
}
 
unsigned char rx_data(void)
{
        while(PIR1.RCIF==0);                // Wait until RCIF gets low
        return RCREG;                        // Store data in Reception register
}
 
void lcd_ini()
{
        dis_cmd(0x02);                // To initialize LCD in 4-bit mode.
        dis_cmd(0x28);                // To initialize LCD in 2 lines, 5×7 dots and 4bit mode.
        dis_cmd(0x0C);                 // 0x01 – clear screen, 0x02, return home, 0x046- increment cursor , 0x04- decrement cursor
        dis_cmd(0x06);                 // 0x0E – Display On, Cursor ON, 0x80-force sursor to begining of 1st line
        dis_cmd(0x80);                 //0xC0 – Force cursor to beginning of third line, 0x94 beginning of second line 0xd4, beginning of 4th line
}
 
void dis_cmd(unsigned char cmd_value)
{
        unsigned char cmd_value1;
        cmd_value1 = ((cmd_value>>4)&0x0F);        // Shift 4-bit and mask
        lcdcmd(cmd_value1);                               // Send to LCD
        cmd_value1 = (cmd_value & 0x0F);        // Mask lower nibble because RB4-RB7 pins are being used
        lcdcmd(cmd_value1);                        // Send to LCD
}
 
 
void dis_data(unsigned char data_value)
{
        unsigned char data_value1;
        data_value1=((data_value>>4)&0x0F);
        lcddata(data_value1);
        data_value1=(data_value&0x0F);
        lcddata(data_value1);
}
 
void lcdcmd(unsigned char cmdout)
{
        lcdport=cmdout;                //Send command to lcdport=PORTB
        rs=0;
        en=1;
        Delay_ms(10);
        en=0;
}
 
void lcddata(unsigned char dataout)
{
        lcdport=dataout;        //Send data to lcdport=PORTB
        rs=1;
        en=1;
        Delay_ms(10);
        en=0;
}

RSS Recent Posts

  • going out on a limb and praying the schematic is correct May 24, 2025
  • Easy PC Demo version Schem and Layout program questions May 24, 2025
  • Actin group needed for effective PCB software tutorials May 24, 2025
  • Back to the old BASIC days May 24, 2025
  • Fluke 123 scopemeter not reading ANY voltage, please help May 24, 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