Hi, I am interfacing GSM modem with 8051 mc. I am able to send message from gsm modem by giving command through microcontroller. but i am not able to read message from gsm modem and cannot display it on LCD. I donot want to use computer in between. Please help me.
"My car is not working - don't you dare looking under the hood!!! - help me!"
Whining baby!
OK, so you've worked out how to use CAPS LOCK properly: http://www.keil.com/forum/18229
Now you need to actually supply some useful information to enable people to help!
"I am able to send message from gsm modem by giving command through microcontroller"
So you must be able to send AT Commands to the modem, and receive & interpret the response?
"i am not able to read message from gsm modem"
Why not? What is preventing you?
As already noted, that's like saying, "my car doesn't work - what's wrong with it?"
"and cannot display it on LCD"
That is an entirely separate issue!
"I donot want to use computer in between"
What do you mean by that?
Note that using a GSM modem - or any other modem - with a microcontroller is a very common project indeed. There are very many examples on the web - have you searched...?
i hav searched but i didn't get even one sample. this is my code: #include<reg51.h> #include<stdio.h> #include<string.h> void MSdelay(unsigned int); void serial_init(void); void trans(unsigned char); void trans_string(char *); void gsm(); void lcdinit(unsigned char[]); void lcddata(unsigned char); unsigned int i,j; sbit rs = P2^0; sbit rw = P2^1; sbit en = P2^2; unsigned char mydata[]={0x38,0x0E,0x01,0x06};
void main() { IE=0X90; P1=0x00; lcdinit(mydata); serial_init(); gsm(); while(1); } void serial_init(void) { TMOD=0X20; TH1=0XFD; SCON=0X50; TR1=1;
} void lcdinit(unsigned char cmd[]) { unsigned int i; for(i=0;i<4;i++) { P1=cmd[i]; rs=0; rw=0; en=1; MSdelay(5); en=0; MSdelay(5); } } void lcddata(unsigned char a) { P1=a; rs=1; rw=0; en=1; MSdelay(5); en=0; MSdelay(5); } void MSdelay(unsigned int itime) { for(i=0;i<itime;i++) for(j=0;j<1275;j++); }
void gsm() { trans_string("AT\r"); MSdelay(5); trans_string("AT+CMGF=0"); trans_string("\r"); MSdelay(5); // trans_string("AT+CMGS=""+918983513833"); // trans_string("\r"); // MSdelay(5); // trans_string("Santa ne apni car k niche kutte ko leta hua dekha,to kutte ko ek dum se kheecha or kaha- bahar nikal saale, bada aaya mechenical engineer banne."); // trans(0x1A); trans_string ("AT+CMGR=1"); trans_string("\r"); MSdelay(5); }
void trans_string(char *p) { while(*p!='\0') { SBUF = *p ; IE=0x00; while (TI==0); TI=0; IE=0X90; p++; } }
void serial0() interrupt 4 { unsigned char a; if(TI == 1) { TI=0; } else { a=SBUF; lcddata(a); RI=0; } } /*void trans(unsigned char a) { SBUF=a; IE=0x00; while(TI==0); TI=0; IE=0x90; } */
this is my code:
code???
code is formatted and commented
Erik
Obviously your search was as thorough as your attention to the instructions on how to post source code:
www.danlhenry.com/.../keil_code.png