Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
I'm using PIC18F4550 at 115200 baud rate to get GPS information from SIM908. It works fine with commands sent from PC. Also it works fine with commands from MCU. But the problem is, the MCU can not read the GPS data sent from SIM908.
I checked the MCU, it can read data if I send the data from PC UART. But can not read SIM module. It reads some noise or blank space.
Data communication from MCU:
Here you can find that all the communication is ok from MCU's side.
Also here is the data while SIM908 is connected with MCU:
Also the code:
I assumed that it may be the data rate problem with GPS section with MCU as GPS is working at data rate 115200. But unfortunately if I extract data at that rate, it doesn't find any thing rather than a noise.
I'm working at a board with ICD connection. So there is no ISIS simulation file. But I checked it with virtual terminal and its all ok.
If you need the PCB image, I can show it here:
And the real testing circuit image is here:
Now the question is, what is the mistake I've done or what is the problem here. Need your valuable advice. I'm still working on it...
I checked the MCU, it can read data if I send the data from PC UART. But can not read SIM module. It reads some noise or blank space.
Data communication from MCU:
Here you can find that all the communication is ok from MCU's side.
Also here is the data while SIM908 is connected with MCU:
Also the code:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 /******************************************************************************* * Program for 'GPS Position Tracker for Car accident' * * Compiler: MicroC Pro for PIC v.5.6.1 * * Program Written by Engr. Mithun K. Das * * e-mail: [email]mithun060@gmail.com[/email]; 01722448270 * * MCU: PIC18F4550; X-Tal:20MHz * * 25-Jan,2014 * *******************************************************************************/ /* $GPGGA,025526.000,0653.409140,N,07954.150015,E,1,7 ,1.08,22.013,M,-96.608,M,,*4D $GPGLL,0653.409140,N,07954.150015,E,025526.000,A,A *58 $GPGSA,A,3,21,29,18,24,22,25,15,,,,,,1.98,1.08,1.6 7*0F $GPGSV,4,1,14,21,58,020,36,14,56,246,25,29,38,173, 36,18,32,354,36*7E $GPGSV,4,2,14,24,30,071,49,22,25,317,34,06,19,304, 20,25,11,157,33*7E $GPGSV,4,3,14,15,06,035,32,03,04,310,,31,03,205,,3 0,00,240,*78 $GPGSV,4,4,14,42,,,39,50,,,39*7F $GPRMC,025526.000,A,0653.409140,N,07954.150015,E,0 .000,115.0,260313,,,A*6F $GPVTG,115.0,T,,M,0.000,N,0.000,K,A*08 $GPZDA,025526.000,26,03,2013,,*57 */ unsigned char text[64]; int i = 0; short ready = 0; #define LED_ON PORTD = 0xFF #define LED_OFF PORTD = 0x00 void UART_Write_CText(const char *cptr) { char chr; for ( ; chr = *cptr ; ++cptr ) UART1_Write(chr); } void Delay2s() { int d; for(d=0;d<200;d++) { Delay_ms(10); asm CLRWDT; } } void GPS_Int(void); void SMS_Int(void); void GPS_OFF(void); void interrupt() { if (RCIF_bit) { // If interrupt is generated by RCIF text[i] = UART1_Read(); // Read data and store it to txrt string i++; // Increment string index if (i >= 64) { // If index = 768, i = 0; // set it to zero ready = 1; // Ready for parsing GPS data } RCIF_bit = 0; // Set RCIF to 0 } } void main() { TRISD1_bit = 0;//set as output ADCON0 = 0x00; ADCON1 = 0x07;//all digital LED_ON; UART1_Init(115200);//initialize UART at br 9600 bps Delay_ms(1000);// leave some time for UART GIE_bit = 1; // Enable Global interrupt PEIE_bit = 1; // Enable Peripheral interrupt RCIE_bit = 1; // Enable USART Receiver interrupt RCIF_bit = 0;//clear flag LED_OFF; for(i=0;i<2;i++) { GPS_Int(void); } for(i=0;i<64;i++) { text[i] = ' '; } UART_Write_CText("AT+IPR=0\r\n"); while(1) { OERR_bit = 0;// clear Overrun Error bit FERR_bit = 0;//clear Farming Error bit asm CLRWDT; GPS_Int(void); Delay2s(); LED_ON; for(i=0;i<64;i++) { text[i] = ' '; } Delay2s(); UART_Write_CText("AT+CGPSINF=32"); RCIE_bit = 1; // Enable USART Receiver interrupt RCIF_bit = 0;//clear flag for(i=0;i<64;i++) { text[i] = ' '; } Delay2s(); UART_Write_CText("\r\n"); Delay2s(); Delay2s(); RCIE_bit = 0; // Disable USART Receiver interrupt RCIF_bit = 0;//clear flag if(ready == 1) { UART_Write_CText("GPS DATA:"); for(i=0;i<64;i++) { UART1_Write(text[i]); Delay_ms(10); } UART_Write_CText("\n"); for(i=0;i<64;i++) { text[i] = ' '; } ready = 0; } LED_OFF; }//while(1) }//void main void GPS_Int(void) { LED_ON; UART_Write_CText("AT+CGPSPWR=1\r\n");//send AT+CGPSPWR=1 and Enter Delay2s(); LED_OFF; UART_Write_CText("AT+CGPSRST=1\r\n");//select GPS mode, 1 = Autonomous, 0 = Cold Delay2s(); UART_Write_CText("AT+CGPSIPR=115200\r\n");// set data rate Delay2s(); UART_Write_CText("AT&W\r\n");//save recent settings Delay2s(); } void GPS_OFF(void) { UART_Write_CText("AT+CGPSPWR=0\r\n");//send AT+CGPSPWR=1 and Enter Delay2s(); } void SMS_Int(void) { UART_Write_CText("AT+cmgf=1\r\n"); Delay2s(); UART_Write_CText("AT+cmgs="); UART1_Write((char)'"'); UART_Write_CText("01722448270"); UART1_Write((char)'"'); UART1_Write((char)13); UART1_Write((char)10); Delay2s(); } //end of the program
I assumed that it may be the data rate problem with GPS section with MCU as GPS is working at data rate 115200. But unfortunately if I extract data at that rate, it doesn't find any thing rather than a noise.
I'm working at a board with ICD connection. So there is no ISIS simulation file. But I checked it with virtual terminal and its all ok.
If you need the PCB image, I can show it here:
And the real testing circuit image is here:
Now the question is, what is the mistake I've done or what is the problem here. Need your valuable advice. I'm still working on it...