Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help required .... (C function does not return)

Status
Not open for further replies.
@AtomSoft
i have cheacked your code but same problem it only gets 1st time latt/long
here is code of uc2 which contineously sends these sentences.
 

Attachments

  • gps_mc1.c
    803 bytes · Views: 119
Ok that helps somewhat...

Are you trying to print each one on the LCD or just the $GPGLL line ?

Look at the 3rd line of printf

Code:
printf("GPAPB,A,A,0.0,L,N,,,358.1,M,SIM002,358.0,M,,,*20 ");

are you missing a $ ?
 
Last edited:
while(1)
{

serial();
set_tris_c(0b10000000);
set_tris_D(0x00);
set_tris_b(0x00);
lcd_init();
delay_ms(20);
led=1;///-----------------------------------------------------to cheack weather main program is executing
delay_ms(50);
led=0;
delay_ms(50);

lcd_gotoxy(1,1);
printf(lcd_putc,"LAT=%c%c%c%c%c%c%c%c%c%c%c \n",cmd[1],cmd[2],cmd[3],cmd[4],cmd[5],cmd[6],cmd[7],cmd[8],cmd[9],cmd[10],cmd[11]);
lcd_gotoxy(1,2);
printf(lcd_putc,"LON=%d%c%c%c%c%c%c%c%c%c%c%c%c",loop,cmd[13],cmd[14],cmd[15],cmd[16],cmd[17],cmd[18],cmd[19],cmd[20],cmd[21],cmd[22],cmd[23],cmd[24]);
delay_ms(100);
loop++;


}
the led only turn on and off once so when second time main calls serial() it does not return to main()
 
If you are using old loop like first post it will not return to main

Ah ok ill get back to you in a minute with thoughts
 
Last edited:
Still unclear, sorry im no GPS expert...

from this latt line what is the actual data you want to get?

"$GPGLL,%ld.%ld,N,01959.8130,E,135944.703,A*30"

Is the actual data just the %ld/%ld or do you need the entire thing ?
 
%ld.%ld,N,01959.8130,E


i want to extract that in array and the array again and again takes this and print on lcd
 
Thanks ill check it out now... for now check and see if this is understandable ?

Code:
char commaCount = 0;
char data[20] ;
char done = 0;
char count=0;
char LL;

for(LL=0;LL<2;LL++)     //Loop 2 times for Longitude and Latitude strings
{
  while( != '$');       //Wait until beginning of new printf
  while(getch() != ',');//wait until we get out first comma

  while(commaCount < 4) // This is the amount of data we need... 4 commas worth
  {
    count=0;            //count variable for placing data in loop
    while(1)            //loop getting all data possible
    {
      data[count] = getch(); //place data into variable
      count++;               //Increase count

      if(data = ',')         //if data is a command break the loop
        break;
    }
    commaCount++;            //Loop is broken so increase the comma count
  }
}
 
dude this is crazy! it wont even breakpoint repeatedly. Im sure its a simulation issue... do you have the MCUs to test this on?

Im sure i can code it in C18 and not have this issue
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top