Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Sending SMS Command (AT+CMGR) error on PIC18F452

Status
Not open for further replies.

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
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.


Code C - [expand]
1
2
3
4
IDE: MPLAB v8.63
Compiler: MPLAB C18v3.37
PIC18F452
SIMCOMM300 GSM Modem



GSM Modem Initialized with:


Code C - [expand]
1
2
3
ATE0 - OK         //echo-off
AT+CMGF = 1  - OK  // SMS Text mode
AT+CLIP = 1  - OK // To extract incoming phone number


Serial Port settings (as mentioned in sample program provided along with mplab c18 compiler).

Code C - [expand]
1
2
3
4
5
6
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 C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
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);
}



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.

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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");
    }
}



The split function is:


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
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]);
        
    } 
}


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.
 

Can any one help me?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top