Dear sir,
I used PIC18F452 to communicate with SIMCOMM300 Gsm Modem. I done everything OK. It works fine for all AT Commands except "AT+CMGR". This command also processed successfully but not come out from the loop. I tried my level best to correct the issue. But still I didn't find success. Anyone can provide help to correct the issue.
GSM Modem Initialized with:
Serial Port settings (as mentioned in sample program provided along with mplab c18 compiler).
If Message received "+CMTI : SM", <msg number>, it process and split the msg number and displayed correctly.
Read SMS also works fine. Reading Msg and split the incoming SMS Phone number and displayed correctly. Here the compiler hangs. It didn't process further. I have to restart the PIC.
The split function is:
All others AT Commands work fine. It correctly parse the incoming Phone number if call received and interrupts also works fine.
I am facing problem only in "AT+CMGR" Command. Really I was so tired in finding the bug. Please help me.
I used PIC18F452 to communicate with SIMCOMM300 Gsm Modem. I done everything OK. It works fine for all AT Commands except "AT+CMGR". This command also processed successfully but not come out from the loop. I tried my level best to correct the issue. But still I didn't find success. Anyone can provide help to correct the issue.
Code:
IDE: MPLAB v8.63
Compiler: MPLAB C18v3.37
PIC18F452
SIMCOMM300 GSM Modem
Code:
ATE0 - OK //echo-off
AT+CMGF = 1 - OK // SMS Text mode
AT+CLIP = 1 - OK // To extract incoming phone number
Code:
OpenUSART (USART_TX_INT_OFF & //Set and Open Serial Port
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH, 25);
If Message received "+CMTI : SM", <msg number>, it process and split the msg number and displayed correctly.
Code:
if(strcmp(strBuff, SMS_CMTI) == 0){
*strBuff = 0;
split(gsmOutput_s);
*gsmOutput_s = 0;
//memset(gsmOutput_s, 0, sizeof(gsmOutput_s));
while(BusyUSART());
putrsUSART((const far rom char*)"AT+CMGR=");
putsUSART(SMS_SPLIT[1].SMS_Rec); //received message number
while(BusyUSART());
putcUSART(0x0D);
}
Code:
if(strcmp(strBuff, SMS_CMGR) == 0){
strBuff = 0;
split(gsmOutput_s);
pch = strstr(SMS_SPLIT[1].SMS_Rec, AdminPhNum);
memset(strBuff_IncomingPhNum, 0, sizeof(strBuff_IncomingPhNum));
strncpy(strBuff_IncomingPhNum, pch, 10);
WriteCmdXLCD(CLR_LCD);
while(BusyXLCD());
WriteCmdXLCD(HOME_LCD);
while(BusyXLCD());
if (strcmp(strBuff_IncomingPhNum, AdminPhNum) == 0){
putrsXLCD("Admin SMS");
}
else{
putrsXLCD("Anonymous SMS");
}
}
Code:
void split(char input[]){
char *output[7];
int loop;
output[0] = strtokpgmram(input, (const far rom char*)",");
if(output[0]==NULL)
{
return;
}
for(loop=1;loop<strlen(input);loop++)
{
output[loop]=strtokpgmram(NULL, (const far rom char*)",");
if(output[loop]==NULL)
break;
}
for(loop=0;loop<strlen(input);loop++)
{
if(output[loop]==NULL)
break;
strcpy(SMS_SPLIT[loop].SMS_Rec, output[loop]);
}
}
I am facing problem only in "AT+CMGR" Command. Really I was so tired in finding the bug. Please help me.