Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

can not tx out txt mesage...

Status
Not open for further replies.

hhhsssmmm

New Member
hello

i can not get the text message receive on my cell phone or any other network via the program coding below.

it simply desinged so that to send sms only .... not receive

i can get all other command resposnes back from the gsm modem and display on my LCD....so i know that the hardware is working correctly and that my below code snippet is wrong somewhere.

plz can someone look at my code below and tell me what is wrong and why i can not receive text mesage on my cell phone.


my setup involves the following...

PIC18F4220 @ 20MHz C18
MAX202CPE
GSM Modem Siemens Model TC35


thank you

haseeb


Code:
void main(void)
{

putUSARTcustom( "AT+CMGF=" ); //write the 'SMS Format Selection' AT command syntax
   
    TXREG = 1;  //SMS format in TEXT mode   
    while(TXSTAbits.TRMT==0); //wait until transmition is complete       

    TXREG = 0x0D;  //write CR     
    while(TXSTAbits.TRMT==0); //wait until transmition is complete       
   
    while(1) //loop for 'OK' reply from modem
    {   

        while(PIR1bits.RCIF == 0); //wait for data reply from GSM Modem
   
        GSM_Byte_1 = RCREG; //reading RCREG clears RCIF
   
        while(PIR1bits.RCIF == 0); //wait for data reply from GSM Modem
   
        GSM_Byte_2 = RCREG; //reading RCREG clears RCIF           
       
        if(GSM_Byte_1 == 'O' && GSM_Byte_2 == 'K') //break from while loop when u get 'OK'       
   
            break;            

    }   
   
    putUSARTcustom( "AT+CMGS=xxxxxxxxxxx" ); //enter in the desired number to send SMS via AT command

    TXREG = 0x0D;  //write CR     
    while(TXSTAbits.TRMT==0); //wait until transmition is complete       

    while(1) //loop for '>' reply from modem
    {   

        while(PIR1bits.RCIF == 0); //wait for data reply from GSM Modem
   
        GSM_Byte_1 = RCREG; //reading RCREG clears RCIF       
       
        if(GSM_Byte_1 == '>') //break from while loop when u get '>'       
   
            break;            

    }

    putUSARTcustom( "PIC" ); //enter desird text to be sent       

    TXREG = 0x1B;  //write ESC to finish sending text message
    while(TXSTAbits.TRMT==0); //wait until transmition is complete

    TXREG = 0x0D;  //write CR     
    while(TXSTAbits.TRMT==0); //wait until transmition is complete
   


    while(1); //end program

}//end of main()

void putUSARTcustom(const rom char *data)
{

    char c;
 
      while ((c = *data++))
      {
       
           TXREG = c; //Transmit a byte

        while(TXSTAbits.TRMT==0); //wait until transmition is complete     

      }

} //end of putUSARTcustom()
 
Just looking at your code, why have you seperated your values from the command string?

For example, why not just write:
Code:
putUSARTcustom( "AT+CMGF=1\r" ); //write the 'SMS Format Selection' AT command syntax
Just a thought.

Have you put in a check to see if the code section completes?

For example, when you send the first command, have something written to the LCD to say it has completed, and the same with the AT+CMGS command.

I suppose you have tried this with Hyperterminal or TerraTerm to make sure it will actually send correctly?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top