Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Issue successfully resolved

???
02/27/04 15:03
Read: times


 
#65628 - re: hyperterminal
Hi,
I was wondering if someone could help me.I am trying to send a sms messge from a 8051 to a mobile phone.
I am testing it first by using the hyperterminal and the AT commands are coming out(SEE CODE), when I press the switch on the board to send the message's it does not send it.It totally ignores the switch.It only sends the messages when I turn on/off the power supply.Can you please help as I have tried everything.Below is the code for this.
Thank you




#pragma small //default to small memory model
#include<reg52.h> //include header file

void serialInit(); //function prototype
void sendATCommand(); //function prototype

sbit SWT = P3^2; //the port pin is assigned using sbit

/*****************************************************************/
/*The unsigned char arrays are set up,containing the following */
/*AT commands */
/*****************************************************************/
code unsigned char AT1[] = "AT&K[0] *"; //resets the modem and sets the factory defaults
code unsigned char AT2[] = "AT *";
code unsigned char AT3[] = "AT + CMGF =1*";
code unsigned char AT4[] = "AT + CSCA = +353868002000 *";
code unsigned char AT5[] = "AT + CMGS = +353877835815 *";
code unsigned char AT6[] = "FIRE ALERT *";

/****************************************************************/
/*Global variables declared and initialised */
/****************************************************************/
unsigned char *ptr0;
unsigned char sendData = 0;
unsigned char cmdOver = 0;

void main() //execution of main
{

serialInit(); //function prototype
sendData = 1; //send data is initialised to 1

while( 1 ){ //while true keep running
while( !SWT ) //not switch
{} // Wait till switch goes high
sendATCommand(); //function prototype
SWT = 0; //switch is initialised
}
}

/*********************************************************************/
/*void sendATCommand() */
/*pointer (ptr)= address of each AT array starting off in each do */
/*while loop, if the end of the AT command is not encountered */
/*and not TI keep sending the data and incrementing the pointer */
/*otherwise cmdOver(AT command sentence)=1.It does this for array AT2*/
/*to AT4. */
/*********************************************************************/
void sendATCommand()
{
ptr0 = &AT1; // pointer assigned to the address of AT1
do
{
if( *ptr0 != '*' ) //if not the end of the line
{
SBUF = *ptr0;
while( !TI )
{}
TI = 0; // Send data
ptr0++; //increment the pointer
} //end the if statement
else //otherwisecmdOver=1
cmdOver = 1;
}
while( cmdOver == 0 ); //starts the AT command at position 0

ptr0 = &AT2; //pointer is the address of array AT2
cmdOver = 0; //starts array AT2 at position 0
do //do the following
{
if( *ptr0 != '*' ) //if not the end of the line
{
SBUF = *ptr0;
while( !TI )
{}
TI = 0; // Send data
ptr0++;
}

else
cmdOver = 1;
}
while( cmdOver == 0 ); //starts the AT command at position 0

ptr0 = &AT3;
cmdOver = 0;
do
{
if( *ptr0 != '*' ) //if not the end of the line
{
SBUF = *ptr0;
while( !TI )
{}
TI = 0; // Send data
ptr0++;
}

else
cmdOver = 1;
}
while( cmdOver == 0 ); //starts the AT command at position 0

ptr0 = &AT4; //pointer is the address of array AT4
cmdOver = 0;
do //do the following
{
if( *ptr0 != '*' ) //if not the end of the line
{
SBUF = *ptr0;
while( !TI )
{}
TI = 0; // Send data
ptr0++; //increment the pointer to write all words out
}

else
cmdOver = 1;
}
while( cmdOver == 0 ); //starts the AT command at position 0

ptr0 = &AT5; // pointer assigned to the address of AT1
cmdOver = 0;
do
{
if( *ptr0 != '*' ) //if not the end of the line
{
SBUF = *ptr0;
while( !TI )
{}
TI = 0; // Send data
ptr0++; //increment the pointer
} //end the if statement
else //otherwisecmdOver=1
cmdOver = 1;
}
while( cmdOver == 0 ); //starts the AT command at position 0

ptr0 = &AT6; // pointer assigned to the address of AT1
cmdOver = 0;
do
{
if( *ptr0 != '*' ) //if not the end of the line
{
SBUF = *ptr0;
while( !TI )
{}
TI = 0; // Send data
ptr0++; //increment the pointer
} //end the if statement
else //otherwisecmdOver=1
cmdOver = 1;
}
while( cmdOver == 0 ); //starts the AT command at position 0


}

/*****************************************************************/
/*void serialInit() */
/*Initialises Timer1 */
/*****************************************************************/

void serialInit()
{
TMOD = 0x20; // Timer1 as 16-bit
TH1 = 0x0E8; // Baud rate of 1200
TL1 = 0x0E8;
SCON = 0x50; // Set serial mode( mode 1 )
TR1 = 1; // Start baud rate

}


List of 43 messages in thread
TopicAuthorDate
re: hyperterminal            01/01/70 00:00      
   re: hyperterminal            01/01/70 00:00      
      re: hyperterminal            01/01/70 00:00      
         re: hyperterminal            01/01/70 00:00      
            re: hyperterminal            01/01/70 00:00      
            re: hyperterminal            01/01/70 00:00      
   re: hyperterminal            01/01/70 00:00      
   re: hyperterminal            01/01/70 00:00      
      re: hyperterminal            01/01/70 00:00      
         re: hyperterminal            01/01/70 00:00      
         re: hyperterminal            01/01/70 00:00      
            re: hyperterminal            01/01/70 00:00      
               re: hyperterminal            01/01/70 00:00      
            About internal pull-ups            01/01/70 00:00      
               RE: About internal pull-ups            01/01/70 00:00      
                  RE: About internal pull-ups            01/01/70 00:00      
                     RE: About internal pull-ups            01/01/70 00:00      
               RE: About internal pull-ups            01/01/70 00:00      
                  I apologize Joseph Hébert!            01/01/70 00:00      
                     RE: I apologize Joseph Hébert!            01/01/70 00:00      
                        RE: I apologize Joseph Hébert!            01/01/70 00:00      
                           RE: I apologize Joseph Hébert!            01/01/70 00:00      
                              RE: I apologize Joseph Hébert!            01/01/70 00:00      
                                 RE: Continuing furrrrrrrrrther off topic            01/01/70 00:00      
                                    RE: Continuing furrrrrrrrrther off topic            01/01/70 00:00      
                                       RE: Continuing furrrrrrrrrther off topic            01/01/70 00:00      
                                          RE: Continuing furrrrrrrrrther off topic            01/01/70 00:00      
                                 RE:hyperterminal            01/01/70 00:00      
                                    RE: RE:hyperterminal            01/01/70 00:00      
                                    RE: RE:hyperterminal            01/01/70 00:00      
                                       RE: RE:hyperterminal            01/01/70 00:00      
                                          Alternate Windows Comm Program            01/01/70 00:00      
                                             RE: Alternate Windows Comm Program            01/01/70 00:00      
                                                RE: TeraTermPro            01/01/70 00:00      
                                                   TeraTermPro hime page (I think)            01/01/70 00:00      
                                             RE: Alternate Windows Comm Program            01/01/70 00:00      
                                                RE: Alternate Windows Comm Program            01/01/70 00:00      
                                                   RE: Alternate Windows Comm Program            01/01/70 00:00      
   AT commands and baudrate            01/01/70 00:00      
      RE: AT commands and baudrate            01/01/70 00:00      
      RE: baudrate            01/01/70 00:00      
         RE:            01/01/70 00:00      
            RE: RE:            01/01/70 00:00      

Back to Subject List