+ Post New Thread
Results 1 to 2 of 2
  1. #1
    Newbie level 4
    Points: 55, Level: 1

    Join Date
    Jun 2015
    Posts
    6
    Helped
    0 / 0
    Points
    55
    Level
    1

    sim 300 gsm modem interfacing with PIC controller

    hi
    we are interfacing sim 300 with PIC18f. ,using ccs compiler
    if i m sending at commands from microcontroller to modem , it is working perfect. we monitor via hyperterminal.
    but if i m checking for 'OK' after each at command, it receives only for 1st at command.
    here is my code
    Code:
    void main()
    {
    char c;
    int8 i;
    
    
     for(i=0;i<10;i++)
      delay_ms( 1000 );
      while(True)
      {
      
    printf("AT");
    printf("\r");
         
    do
    {
    c=getc();
    
    if ( c== 'E')
    {
       printf("AT");
       delay_ms( 10 );
       printf("\r");
       delay_ms( 10 );
      // c=getc();
    }
    
    
    }while(c != 'K');  
    
    
    
    
    
      delay_ms( 1000 );
     
     printf("AT+CMGF=1");
    printf("\r");
    do
    {
    c=getc();
    
    if ( c== 'E')
    {
       printf("AT");
       delay_ms( 10 );
       printf("\r");
       delay_ms( 10 );
      // c=getc();
    }
    
    
    }while(c != 'K');  
    
    
      
       delay_ms( 1000 ); 
    
     }
    }

    for 'AT', it is receiving OK and reading 'K'. and execution goes to next step.
    but for AT+CMGF=1, it is receiving OK. but controller couldnot read K.
    expected output was



    controller stuck with this instruction
    c=getc();

    it is getting OK command. but not reading' K'.
    is it the delay problem? may be OK reply coming fast?

    we r connecting max323 rx to gsm tx and vice versa, just for monitoring purpose only.

    please help us....

    •   AltAdvertisment

        
       

  2. #2
    Banned
    Points: 12,436, Level: 26

    Join Date
    Apr 2013
    Posts
    2,528
    Helped
    538 / 538
    Points
    12,436
    Level
    26

    Re: sim 300 gsm modem interfacing with PIC controller

    Use Serial receive interrupt to receive the responses.



--[[ ]]--