|
|
View previous topic :: View next topic |
Author |
Message |
oxxyfx
Joined: 24 May 2007 Posts: 97
|
How to initialize GPS? |
Posted: Thu May 06, 2010 1:44 pm |
|
|
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
|
|
Posted: Thu May 06, 2010 1:50 pm |
|
|
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
|
|
Posted: Thu May 06, 2010 2:42 pm |
|
|
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: 19498
|
|
Posted: Fri May 07, 2010 3:51 am |
|
|
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
|
|
Posted: Wed May 12, 2010 3:40 am |
|
|
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? |
|
|
|
|
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
|