speedEC
Full Member level 6
- Joined
- Apr 1, 2011
- Messages
- 337
- Helped
- 23
- Reputation
- 46
- Reaction score
- 21
- Trophy points
- 1,298
- Activity points
- 4,324
GSM Modem SIM300 and PIC16F877A +AT+CLCC Command problem
I am new to PIC world and also I am moderate on C/C++. I have already communicated GSM Modem (SIMCOM300) using MS VB6.0 from PC successfully. Now I tried to communicate GSM Modem from PIC16F877A. I can able to send and receive sms, ring tone from/to GSM Modem SIM300 and PIC16F877A. All SMS commands works fine. But, when I issue "AT+CLCC" Command, it also works and also the commands followed by are also executed well, but it didn't come out from the loop. I have to switch-off the power and restart. Then only PIC process the command. Can you pl help me to locate the issue and guide me to solve this problem. I will be very humble and thankful to you if anyone provide help to solve this issue.
PIC16F877A
HI-TECH C PRO Compiler (MPLAB v8.63)
SIMCOM300 GSM Modem
LCD JHD 162A
I am new to PIC world and also I am moderate on C/C++. I have already communicated GSM Modem (SIMCOM300) using MS VB6.0 from PC successfully. Now I tried to communicate GSM Modem from PIC16F877A. I can able to send and receive sms, ring tone from/to GSM Modem SIM300 and PIC16F877A. All SMS commands works fine. But, when I issue "AT+CLCC" Command, it also works and also the commands followed by are also executed well, but it didn't come out from the loop. I have to switch-off the power and restart. Then only PIC process the command. Can you pl help me to locate the issue and guide me to solve this problem. I will be very humble and thankful to you if anyone provide help to solve this issue.
PIC16F877A
HI-TECH C PRO Compiler (MPLAB v8.63)
SIMCOM300 GSM Modem
LCD JHD 162A
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 Code: #include <stdio.h> #include <htc.h> #include "usart.h" #include "lcd.h" #include "string.h" __CONFIG(HS & WDTDIS & UNPROTECT & LVPDIS); unsigned char gsmInput[60]; unsigned int i=0; unsigned int lenOfGSMInput = 0; bit OK; bit Error; bit Ring; void showGSM_DATA(char GSM_DATA[]){ //to show the GSM OUTPUT after eliminating the chars '\r' and '\n' if (strcmp(GSM_DATA, "OK") == 0){ OK = 1; } else if (strcmp(GSM_DATA, "ERROR") == 0){ Error = 1; } else if (strcmp(GSM_DATA, "RING") == 0){ Ring = 1; GSM_DATA[0] = '\x00'; puts("AT+CLCC"); putch(0x0D); } else{ lcd_clear(); lcd_goto(0); lcd_puts(GSM_DATA); } GSM_DATA[0] = '\x00'; } // end function showGSM_DATA void main(int argc, char* argv[]){ unsigned char input; INTCON=0; // purpose of disabling the interrupts. lcd_init(); // initiate LCD init_comms(); // set up the USART - settings defined in usart.h puts("ATE0"); putch(0X0D); puts("AT+CMGF=1"); putch(0X0D); while(1){ input = getch(); // read a response from the GSM switch(input){ case '\x0A': // if line feed detected in the GSM output i.e. '\n' break; case '\x0D': // if carriage return detected i.e. '\r' gsmInput[i] = '\x00'; lenOfGSMInput = strlen(gsmInput); if (lenOfGSMInput > 0){ i = 0; lenOfGSMInput = 0; showGSM_DATA(gsmInput); } break; case '\x3E': // if greater-sign (in order to send SMS) break; default: // if characters received gsmInput[i] = input; i++; break; }//end brace for switch } //end brace for while loop }//end brace for main
Last edited: