CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to initialize GPS?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

How to initialize GPS?
PostPosted: Thu May 06, 2010 1:44 pm     Reply with quote

Hello,

I am trying to send a string to the GPS module connected to the UART of the 18F2550.

UART interrupt for receiving works fine, I can display the incoming data on the LCD connected to the same PIC.

What I am trying to do is to send a $PMTK string to the GPS to send me only the relevant GGA and RMC strings only.

I tried this:
Code:

void initgps(){
   disable_interrupts(INT_RDA);
   delay_ms(100);
   printf("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,*28");
   delay_ms(100);
   enable_interrupts(INT_RDA);
}

but I am not getting the desired effect, all other NMEA strings still coming in.

What am I dong wrong?

Thank you.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 06, 2010 1:50 pm     Reply with quote

All NMEA sentences are supposed to end with a CRLF pair (0x0D, 0x0A).
In a CCS printf statement, it would be this sequence: "\r\n"
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Thu May 06, 2010 2:42 pm     Reply with quote

Thank you,

so that woud be the following:

Code:

void initgps(){
   disable_interrupts(INT_RDA);
   delay_ms(100);
   printf("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,*28\r\n");
   delay_ms(100);
   enable_interrupts(INT_RDA);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Fri May 07, 2010 3:51 am     Reply with quote

Except, 'why disable INT_RDA'?.
The modem _will_ send a reply. This needs to be at the very least removed from the hardware serial buffer. Even if 'errors' is selected, which will prevent the UART from becoming 'hung' because of the unhandled reply, there will still be two characters waiting to be read.
Leave the interrupt enabled, and then have a simple routine to empty the serial buffer, assuming you don't actually want to check the characters returned.

So (assuming a serial routine like EX_SISR), something like:
Code:

void initgps(){
   delay_ms(100);
   printf("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,*28\r\n");
   delay_ms(100);
   while (bkbhit) bgetc(); //Throw away reply.
}


Best Wishes
Jiewy



Joined: 27 Apr 2010
Posts: 8
Location: Penang Malaysia

View user's profile Send private message MSN Messenger

PostPosted: Wed May 12, 2010 3:40 am     Reply with quote

Hie there, i am trying to receive nmea data through uart to make sure that i am receiving it properly before parsing it. But so far, no luck. Can u pls share ur experience with me?

This is my coding but i am not sure if its correct.

Because when i applied it to the hardware, when i start up, my lcd gives me giberish straight away and when i on the gps, the giberish changes but still giberish. Can u pls help me in this matter?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group