Dear all I am filtering $GPRMC string but i can't able to get any data in the hyperterminal please suggest me my problem in the code.
/*------------------------------------------------------------------------------ Serial.c ------------------------------------------------------------------------------*/ #include <reg52.H> /* special function register declarations */ #include <stdio.h> /* prototype declarations for I/O functions */ sbit mybit=P1^1 ; unsigned char RMC_Pos,GPSReceiveCtr,GPSData,Ctr; unsigned char GPSArray[110]; void main(void) { RMC_Pos=0; SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xFA; /* TH1: reload value for 4800 baud @ 11.0592 MHz */ TR1 = 1; /* TR1: timer 1 run */ ES=1; /* Serial interrupt Enable*/ EA=1; /* global interrupt enable*/ while(1) { if(RMC_Pos==7) { for(Ctr=0;Ctr>GPSReceiveCtr;Ctr++) { SBUF=GPSArray[Ctr]; } } RMC_Pos=0; } } void serial (void) interrupt 4 { mybit=1; if(RI) { RI=0; GPSData = SBUF; if(RMC_Pos!=7) { if( GPSData== '$' && (RMC_Pos == 0) ) RMC_Pos=1; else if( GPSData == 'G' && (RMC_Pos == 1) ) RMC_Pos=2; else if( GPSData == 'P' && (RMC_Pos == 2) ) RMC_Pos=3; else if( GPSData == 'R' && (RMC_Pos == 3) ) RMC_Pos=4; else if( GPSData == 'M' && (RMC_Pos == 4) ) RMC_Pos=5; else if( GPSData == 'C' && (RMC_Pos == 5) ) { RMC_Pos=6; GPSReceiveCtr=0; } else if( GPSData != '*' && (RMC_Pos == 6) ) GPSArray[GPSReceiveCtr++]=GPSData; else if( GPSData == '*' && (RMC_Pos == 6) ) RMC_Pos=7; else RMC_Pos=0; if(GPSReceiveCtr > 100) GPSReceiveCtr=100; mybit=0; } } if(TI)TI=0; }
Please andy,
I know this is cheating but there is no time in my hand, i gothrough your faq and tutorial links, but i can able to understand nothing, i have learned about armature, generators, magnetic flux, ac and dc but i never go through buffer, timers, tI, RI, interrupts, in my life time. My tutors also not well sound for guiding me in coding, They guided my in designing hardware by GODs grace i made it sucessfully. The code logic that i wrote was guided by my senior, but he also can't able to solve this problem. Please slove this problem to me i will be very much thankful to you.
So just don't do it!
Come clean and admit that you cannot complete the assignment. If you bluff this assignment, how will you cope with the next assignment?
"i have learned about armature, generators, magnetic flux, ac and dc but i never go through buffer, timers, tI, RI, interrupts, in my life time."
So why on earth are you doing a project that so totally depends upon it?!
If you really feel that you have followed all the course requirements, and this assignment is totally unrelated to any of the course content, then you need to appeal to your school authorities.
"Please slove this problem to me i will be very much thankful to you."
Actually, you probably won't: If you cheat this assignment, then it will be assumed that you can do this stuff - so you will receive more and harder programming tasks!
Dear all,
Please correct if am going wrong.
/*------------------------------------------------------------------------------ Serial.c ------------------------------------------------------------------------------*/ #include <reg52.H> /* special function register declarations */ #include <stdio.h> /* prototype declarations for I/O functions */ sbit mybit=P1^1 ; unsigned char RMC_Pos,GPSReceiveCtr,GPSData,Ctr; unsigned char GPSArray[80]; void main(void) { RMC_Pos=0; SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xFa; /* TH1: reload value for 4800 baud @ 11.0592 MHz */ TR1 = 1; /* TR1: timer 1 run */ ES=1; /* Serial interrupt Enable*/ EA=1; /* global interrupt enable*/ while(1) { if(RMC_Pos==7) { for(Ctr=0;Ctr<GPSReceiveCtr;Ctr++) { SBUF=GPSArray[Ctr]; while(TI==0); TI=0; } } RMC_Pos=0; } } void serial (void) interrupt 4 { mybit=1; //making P1.1 high for debugging while(RI==0);//if(RI) { // RI=0; GPSData = SBUF; //gps datas are stored in buffer named gpsdata if(RMC_Pos!=7) { if( GPSData== '$' && (RMC_Pos == 0) ) //checks for $ in first character of the string RMC_Pos=1; else if( GPSData == 'G' && (RMC_Pos == 1) ) //checks for G in second character of the string RMC_Pos=2; else if( GPSData == 'P' && (RMC_Pos == 2) ) //checks for P in third character of the string RMC_Pos=3; else if( GPSData == 'R' && (RMC_Pos == 3) ) //checks for R in fourth character of the string RMC_Pos=4; else if( GPSData == 'M' && (RMC_Pos == 4) ) //checks for M in fifth character of the string RMC_Pos=5; else if( GPSData == 'C' && (RMC_Pos == 5) )//checks for C in sixth character of the string // { RMC_Pos=6; //GPSReceiveCtr=0; // } else if( GPSData != '*' && (RMC_Pos == 6) ) //checks for the * { GPSReceiveCtr=0; GPSArray[GPSReceiveCtr++]=GPSData; // } else if( GPSData == '*' && (RMC_Pos == 6) ) // found the whole $gprmc string RMC_Pos=7; else RMC_Pos=0; if(GPSReceiveCtr > 80) { GPSReceiveCtr=80; mybit=0; //making P1.1 low for debugging } } } //if(TI)TI=0; }
Which is easier to read?
This:
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xFa; /* TH1: reload value for 4800 baud @ 11.0592 MHz */ TR1 = 1; /* TR1: timer 1 run */ ES=1; /* Serial interrupt Enable*/ EA=1; /* global interrupt enable*/
Or this:
SCON = 0x50; /* mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; /* timer 1, mode 2, 8-bit reload */ TH1 = 0xFa; /* reload value for 4800 baud @ 11.0592 MHz */ TR1 = 1; /* timer 1 run */ ES = 1; /* Serial interrupt Enable */ EA = 1; /* global interrupt enable */
People are a lot more likely to want to look at your code if you make it "easy on the eye" - it will help you, too.
See: www.8052.com/.../165484