??? 07/09/10 11:56 Read: times |
#177176 - Problems with GPS Receiver and the 8051 |
I am planning to interface the EM406A GPS receiver with the 8051, parse the NMEA data sentences and display the Latitude and Longitude on a 16 x 2 LCD module..
So far, I have managed to interface the EM406A module to the serial port of my PC and display the NMEA sentences on the hyperterminal(with is mostly just plug and play) The module works at 4800 baud and follows the 8n1 format. I next interfaced the module to my P89V51RD2 controller,in the following manner GPS TX ==> 8051 RX GPS RX ==> 8051 TX (COMMON GND) Next, I burnt the following code into my controller(this code is mainly to check the customary dollar "$" sign that initiates every NMEA sentence) sbit check=P3^7; //making P3.7 a flag void serial_init(); char serial_rec(); void serial_init() // initializing the controller for 4800 baud {RI=0; TMOD=0x20; TH1=0xFA; // 4800 baud rate SCON=0x50; TR1=1; return; } char serial_rec() //receiving data into SBUF by polling { while(RI==0); RI=0; return(SBUF); } void main() { unsigned char ch; check=0; // making "check" flag zero serial_init(); while(1) { ch=serial_rec(); if(ch==0x24) //HEX equivalent of ASCII'$' sign is 0x24 {check=1; //if '$' sign , make "check" HIGH for(;;); // and infinite loop } else check=0; // else, "check" stays LOW. } } No errors,no warnings,but the check flag never goes high when I test pin 3^7 with a voltmeter(although RI does go to a HIGH indicating that data is coming into the SBUF) I tried a lot of other things( like displaying the incoming data on the LCD) , but no results. I'm sure there's some problem with my code that I've overlooked , or my interfacing might be faulty. What could be the problem here? Thanks! |