Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with code for GPS with 8051 that turns on/off a LED

Status
Not open for further replies.

fatima_just

Junior Member level 1
Joined
Sep 13, 2008
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,419
help me this code for gps to make led on then off(in loop on ---> off ) if ($) receive from gps but the code make led on always
(curcuit is 8051 connected with max232 an gps pathfinder pocket )(crystal frequncy is 11.0592)
#include<Reg51.H>
#include<string.h>
unsigned char i;
sbit led1=P1^0;
void delay(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
for(j=0;j<1275;j++);
}
void SerialInit()

{ //initialization
TMOD = 0x20; // timer 1 (8 bit auto-reloed)
TH1 = 0xFA; //to obtain 4800 baud rate
TR1 = 1; //start timer
SCON = 0x50;


return;
}
void make_on()
{
while(1)
{
led1=!led1;
delay(500);
}

}
unsigned char SerialRecvChar()
{


while(!RI); //waits till a byte is recieved
RI = 0;
return (SBUF);
}


//---------------------------------------------------------------


//-----------------------------------------------------
void GPS_data()//GPS format:$GGA,hhmmss.ss,ddmm.mmmm,n,dddmm.mmmm,e//ddmm.mmmm,n:the date recived of latitude //dddmm.mmmm,e:the date recived of longitude
{

unsigned char j;
SerialInit();

i = 0x24;


while(1)
{
if(SerialRecvChar() == '$' )
make_on();
}


}
void main()
{
GPS_data();
}
 

Re: gps + 8051 problem

first make sure that your 8051 receives data from GPS ..
most of GPS devices output 0-5V ASCII string(s) and MAX232 will not recognize it as a valid RS-232 signal ..
if this is the case all what you need to do is just to invert the signal from GPS using a gate or a single transistor inverter ..

rgds,
ianp
 

Re: gps + 8051 problem

thanks for reply I solve the problem by check connection for max but Know I need code In C for gsm device which connected to 8051
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top