Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to store data coming on RX of 89c51

Status
Not open for further replies.

bilalayub

Newbie level 3
Newbie level 3
Joined
Feb 14, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,308
i have to compare the data coming on RX of 89c51 from GSM MODEM with "ON"/"OFF"/"1"/"2"/"3"/"4"/"5" and set/reset other pins. but when i request the masage from the GSM MODEM it replies with all information of the masage, i.e sender number etc + masage contents. So how do i get the masage contents only from the masage? please help me any one.
 

You can store them in arrays if you are using C Language for Programming purpose.

Then compare those arrays with the expected results and send command based on that to your gsm modem.

If you are new to array search arrays in C Language and also read Character Arrays i.e String in C Language
 

but which string i want is in the middle somewhere of the replied string. and i want just that string. so what i do?
 

Short answer, the SMS content starts after a <CR><LF> sequence and can be easily identified.

Longer answer, you'll most likely want to decode the "originating address" field to identify legal senders. Some message format details can vary according to network likings, you should be prepared for it. Refer to the AT command manual of your modem or GSM/3GPP specifications (downlaodable at etsi.org) for a complete description.
 

the one problem is also this that when i recieve the data from the gsm modem, it replies along with my own commands too, i.e
AT sent through TX line is also shown on RX line along with OK, and i want to check the OK only. so i will also add a treatment in program for this too?????
 

thanks Arun sharma,
and i also have problem with recieving the data, i did it in asembly program so i recieved 'OK', when i skipped 5 recieved values. @echo on
but it is not recieving when i create a c program. it always gives me empty or enter. @echo on here too. please help with giving commands for recieving.
 

i am interfacing gsm modem sim300 with micrcontroller p89v51rd2. i want to send 'at' and the reply'ok' i want to display on the lcd. but i don't know whr am i going wrong . following is the code


#include<p89v51rx2.h.txt>
#include<string.h>
sfr lcd_data_pin=0xA0; // data port P2
sbit rs=P3^0; // Register select pin
sbit rw=P3^1; // Read write pin
sbit en=P3^2; // Enable pin
sbit D7 = P2^7;
unsigned char msg[20];
unsigned char a,i,z,j;

void delay(unsigned int msec) //delay function
{
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void checkbusy()
{
D7=1;
rs=0;
rw=1;
while(D7!=0)
{
en=0;
delay(1);
en=1;
}
}

void lcd_command(unsigned char comm) // function to send command to LCD
{
checkbusy();
lcd_data_pin=comm;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
}

void lcd_data(unsigned char show) // function to send data on LCD
{
checkbusy();
lcd_data_pin=show;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
}

void lcd_dataa(unsigned char disp[]) // function to send string to LCD
{
unsigned char x;
for(x=0;disp[x]!=0;x++)
{
if(disp[x]=='O'||disp[x]=='K')
lcd_data(disp[x]);
}
}

void lcd_ini() //Function to inisialize the LCD
{
lcd_command(0x38);
delay(5);
lcd_command(0x0F);
delay(5);
lcd_command(0x80);
delay(5);
}
void init_serial(void)
{
a,i=0;
TH1=0xFD; // 9600 baud
TMOD=0x20; // Mode=2
SCON=0x50; // Serial mode=1 ,8-Bit data,1 Stop bit ,1 Start bit , Receiving on
TR1=1; //start timer
IEN0=0x90;
for(z=0;z<20;z++)
msg[z]=0;
}
void string(unsigned char text[])
{
while(text)
{
EA=0;
SBUF=text;
while(TI==0);
TI=0;
i++;
EA=1;
}
}
void receive() interrupt 4
{
msg[a]=SBUF;
RI=0;
a++;
}
/*void lcdstr(unsigned char *s)
{
unsigned char l,i;
l = strlen(s); // get the length of string
for(i=1;i<=l;i++)
{
lcddata(*s); // write every char one by one
s++;
}
}*/

void main()
{
delay(5);
lcd_ini(); //to initialise lcd
lcd_dataa("READY"); //TO DISPLAY AN INITIAL MSG ON LCD
delay(10);
string("AT\r"); // AT commands to initialize gsm modem
delay(50);
lcd_dataa(msg);
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top