This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

regarding GSM 300

i am able to send msg from gsm to the mobile phone but am not able to receive data from the GSM.
eg..in this code when i send AT to the gsm , i get garbage value on the LCD instead of OK..but with the hyperterminal, the communication is proper with both the 8051 and GSM.
and please talk politely . you guys talk very roughly if any one asks question...that is my request to you...

#include<stdio.h>
#include<at89x51.h>
#define port P1
#define dataport P2 // Data port for LCD
sbit rs = port^2;
sbit rw = port^3;
sbit en = port^4; int p; unsigned char msg[20];
//generates delay in milli seconds
void delay_ms(unsigned int i)
{ unsigned int j; while(i-->0) { for(j=0;j<500;j++) { ; } }
}

void command(unsigned char dost) { dataport=dost; //put the value on pin rs=0; rw=0; en=1; //strobe the enable pin delay_ms(5); en=0; }

void lcddisplay(unsigned char word) { dataport=word; //put the value on pin rs=1; rw=0; en=1; //strobe the enable pin delay_ms(5); en=0; }

void lcd_data_string(unsigned char *str) // Function to display string on LCD
{ int i=0; while(str[i]!='\0') { lcddisplay(str[i]); i++; delay_ms(1); } return;
}

//Function to initialize RS232 Serial Port
void serial_init()
{ SCON=0x50; //setup for 8-bit data TMOD=0x20; //setup timer 1 for auto-reload TH1=0xfd; //Baud Rate 9600 TL1=0xfd; TR1=1; //turn on timer 1 TI=1; //indicate ready to transmit
}

//This function displays a null-terminated string on the RS232 port
void send_serial(unsigned char *s)
{ while(*s!=0x0)
{ SBUF=*s;
while(!TI)
{ }
TI=0;
s++;
} }

int i;

void tx0(unsigned char x) //send data to serial port 0
{ EA=0;
SBUF=x;
while(TI==0);
TI=0;
EA=1;
} void lcd()
{ command(0x38); // For using 8-bit 2 row LCD delay_ms(1); command(0x0F); // For display on cursor blinking delay_ms(1); command(0x80); // Set the cursor on first position of LCD delay_ms(1);
} char receive(void) { // unsigned char m; while (RI != 1) {;} //wait to receive data

msg[++p]=SBUF; // save value of data RI=0; return (msg[p]);

}

void main()
{ p=(-1);
delay_ms(80);
lcd();
delay_ms(50);
serial_init(); //Initialize Serial port.

while(1)
{ int m;
send_serial(" AT");
tx0(0x0D);

m=receive();
command(0x06);
lcddisplay(m);

}
}

Parents
  • and please talk politely . you guys talk very roughly if any one asks question...that is my request to you

    before adding 'rules' why do you not follow those that already exist (When posting messages, use the following HTML tags to make your message easier to read and understand. ...) displayed over the entry window

    Erik

Reply
  • and please talk politely . you guys talk very roughly if any one asks question...that is my request to you

    before adding 'rules' why do you not follow those that already exist (When posting messages, use the following HTML tags to make your message easier to read and understand. ...) displayed over the entry window

    Erik

Children
No data