Discussion in "Embedded GSM Development" started by    waterineyes    Apr 22, 2013.
Tue Apr 23 2013, 10:04 pm
#11
Hey, I have checked that link @kirangowle..

That link is not working for me, can you tell me something about that code??

Why there is written:

sfr port = 0xB0; ??

What is this representing??

And do I have to write "port" there or some other port like P0, P1, P2 or P3 I have to mention there??
Wed Apr 24 2013, 08:56 pm
#12
I guess i am not using port in the code. dont use this code, that was just for testing.
In some page you can find GSM_LCD_msg19.zip(something like) you can use that as reference.
Wed Apr 24 2013, 11:21 pm
#13
You are using 'port' there..
Wow!
You don't remember your own code!
Strange enough..
Thu Apr 25 2013, 10:26 am
#14
@Kirangowle, Did we upload your GSM notice board project? If not then please email me.

You are using 'port' there..
Wow!
You don't remember your own code!
Strange enough..

waterineyes


Strange things happen when try to do multiple things at once to make just one thing work dont be surprised. A coder sometimes have multiple version of code when working on a project and picks the one that works and moves ahead.


[ Edited Thu Apr 25 2013, 10:26 am ]
 mohansaini like this.
Thu Apr 25 2013, 04:26 pm
#15
@Ajay, saying "I am not sure" or "but I will confirm it", is far better than saying I have not used "port" there...

Anyways, can I see the code for gsm notice board..??


See, I am in a bit hurry, because tomorrow is last day for it, and I want to make the code.. Only coding part remains for me..
Frankly, what I know about it I tell you..

See, I know how to code for LCD Display, for that, I have written code and that is working fine for me and LCD is displaying what I want to display..

The only and Important part is that I don't ABC of GSM SIM 300 coding..

How to code it, where to code it, I need this urgently today...

Hope someone will post the coding part for me..
Fri Apr 26 2013, 11:15 am
#16
There are many threads that talk about using GSM. Just go through them once. GSM modems use uart for communication. and works on AT commands. You can get AT command manual for SIM300 from simcom's website. read some of the important commands related to sms e.g.

AT+CMGR = read sms
AT+CMGS = send sms
AT+CMGF = set sms format (text/pdu)
Sat Apr 27 2013, 12:58 pm
#17
Can someone please tell me what is the problem in this code??

I am getting "SYSTEM INSTALING" and "GSM BASED MSG DISPLAY" displayed on my LCD but after it nothing is happening..

Can someone check this code by using your SIM300 Modem and 16X2 LCD with 89S52 Microcontroller..

My Full Code is:

#include <REGX52.H>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define OP_PORT P0
#define ON 1
#define OFF 0

//lcd
sbit rs = P2^5;
sbit rw = P2^7;
sbit en = P2^6;
sbit buzzer = P1^7;


// DELAYS
void del_30ms (void);
void del_1ms (void);
void del_1s (void); //delay of 1 second
void del_3ms (void);
void MS_delay (const unsigned short);

// SERIAL COMMUNICATION
void serial_init (void); //initialise serial communication
unsigned char recv_byte (void); //recieves th ASCII value
void send_byte (unsigned char); //sends ASCII value to PC
void sendString (unsigned char *str);

// MODEM ROUTINES
void modem_init (void);
unsigned char recv_sms_no(void);
void read_sms (unsigned char );
void delete_sms (unsigned char);
void enter (void);
void beep (void);
//void check (unsigned char);

//LCD
void lcdinit(void);
void write_inst(unsigned char);
void write_text(unsigned char);
void write(unsigned char);
void setadress(unsigned char);
void dat_lcd(unsigned char );
void printlcd1(unsigned char * );
void printlcd2(unsigned char * );
void cleardisplay();
void scrolling(unsigned char *);


// GLOBAL
unsigned char volatile no;
unsigned char volatile data com[50];
unsigned int volatile FLAG=0,count=0;

void extint0(void)interrupt 0
{

FLAG = 1;
START :if(IE0 == 1)
{
count++;
MS_delay(30);
}
goto START;

if(count >= 9 )
count = 1;
}

void main(void)
{
unsigned char volatile no;

lcdinit();
serial_init();

FLAG = 0;
cleardisplay();
printlcd1("SYSTEM INSTALING");
del_1s();
// modem_init();
beep();
del_1s();
while(1)
{
setadress(0x01);
setadress(0x80);
printlcd1(" GSM BASED");
printlcd2(" MESSAGE DISPLAY");
del_1s();
while(!FLAG);
if(FLAG)
{

read_sms(count);
del_1ms();
FLAG = 0;
count = 0;
}

no = recv_sms_no();
if(no >= 1 && no != 0)
{
cleardisplay();
printlcd2("sms recieved");
del_1s();
read_sms(no);
cleardisplay();
printlcd2(com);
scrolling(com);
del_1s();
//check(no);
del_1s();
}
else
{
setadress(0x01);
printlcd2("INVALID DIGIT");
del_1s();
delete_sms(no);
del_1s();

}
}
}



// ROUTINES FOR GSM
void enter()
{
send_byte(0x0d); // <CR>
send_byte(0x0a); // <LF>
}

// ROUTINE FOR INITIALIZATION OF MODEM
void modem_init()
{
unsigned char volatile ch[10],i=0;
//checking for at command
cleardisplay();
setadress(0x80);
send_byte('A');
dat_lcd(recv_byte());
del_1ms();
send_byte('T');
dat_lcd(recv_byte());
del_1ms();

enter();
i=0;
while(i<6)
ch[i]=recv_byte();
printlcd1(&ch);
cleardisplay();
if(strncmp(ch,"ok",2))
printlcd1("AT OK");

else
{
printlcd2("OK ERROR");
modem_init();
}
del_1s();

//removing echo char
cleardisplay();
setadress(0x80);
sendString("ATE0");
enter();

i=0;
while ((ch[i] = recv_byte()) < 6);
if(strncmp(ch,"ok",2))
printlcd1("ECHO OK");


else
{
printlcd2("ECHO ERROR");
modem_init();
}
del_1s();
//AT+CSMS=1 SELECT MESSAGE SERVICE //SMS AT command Phase 2 +
cleardisplay();
setadress(0x80);
sendString("AT+CSMS=0");
enter();
i=0;
while ((ch[i] = recv_byte()) < 10);
if(strncmp(ch,"ok",2))
printlcd1("PHASE OK");


else
{
printlcd2("PHASE ERROR");
modem_init();
}
del_1s();

//setting the text command
cleardisplay();
setadress(0x80);
sendString("AT+CMGF=1");
enter();
i=0;
while ((ch[i] = recv_byte()) < 6);
if(strncmp(ch,"ok",2))
printlcd1("TEXT OK");

else
{
printlcd2("TEXT ERROR");
modem_init();
}
del_1s();

//new message indication
cleardisplay();
setadress(0x80);
sendString("AT+CNMI=2,1,0,0,0");
enter();
i=0;
while ((ch[i] = recv_byte()) < 6);
if(strncmp(ch,"ok",2))
printlcd1(" MODEM SET ");

else
{
printlcd2(" MODEM NOT SET ");
modem_init();
}

}

//SERIAL ROUTINES
void serial_init()
{
SCON = 0x50; //mode 1 serial communication
TMOD = 0x20; //timer 1 auto reload mode
TH1 = 0xfd; //9600 baudrate at 11.0592 MHz
TR1 = 1;
EA = 1;
EX0 = 1;
IT0 = 1;
IP = 0x10;
}

unsigned char recv_byte()
{
unsigned char c;
while(!RI);
RI = 0; //waits till a byte is recieved
c = SBUF;
return(c);
}

void send_byte(unsigned char ch)
{
TI = 0;
SBUF = ch;
while(!TI);
del_1ms();
}

void sendString(unsigned char *str)
{
while(*str != '\0')
send_byte(*str++);
}

void lcdinit()
{
setadress(0x01);
setadress(0x38);
setadress(0x0E);
}



void write_inst(unsigned char a)
{

rs = 0;
rw = 0;
a = (a>>4);
write(a);
}

void write_text(unsigned char a)
{

rs = 1;
rw = 0;
a = (a>>4);
write(a);
}

void write(unsigned char a)
{


OP_PORT = a;
rs = 1;
rw = 0;
en = 1; //enable
del_30ms();
en = 0; //disable
del_30ms();del_30ms();


}

void setadress(unsigned char a)
{
OP_PORT = a;
rs = 0;
rw = 0;
en = 1; //enable
del_30ms();
en = 0; //disable
del_30ms();

}

void dat_lcd(unsigned char a)
{
OP_PORT = a;
rs = 1;
rw = 0;
en = 1; //enable
del_30ms();
en = 0; //disable
del_30ms();del_30ms();
}
void printlcd1(unsigned char * str)
{
int len,i;
len = strlen(str); // finding length of the string
setadress(0x80); // seting cursor to 0x80 address
for(i=0;i<len;i++)
{
dat_lcd(*str); // displaying each character
str++;
}
}

void cleardisplay()
{
unsigned char a;
a=0x00;
write_inst(a);
// del_3ms();
a=0x10;
write_inst(a);
del_3ms();
}

void printlcd2(unsigned char * str)
{
int len,i;
len = strlen(str); // finding length of the string
setadress(0xc0); // seting cursor to 0x80 address
for(i=0;i<len;i++)
{
dat_lcd(*str); // displaying each character
str++;
}
}

//DELAY Routines

void del_3ms(void)
{
unsigned char i,j;
for(i=0;i<15;i++)
for(j=0;j<98;j++);
}

void del_30ms()
{
unsigned char j;
for(j=0;j<10;j++)
del_3ms();
}

void del_1s()
{
unsigned char i;
for(i=0;i < 60;i++)
del_30ms();
}

void del_1ms(void)
{
unsigned char j;
for(j=0;j<100;j++);
}

void MS_delay(unsigned short MS)
{
unsigned int x,y;
for(x=0;x<=MS;x++)
for(y=0;y<=120;y++);

}


//READING THE MESSAGE FROM MODEM
void read_sms(unsigned char sms) //CMTI:"SM",1
{

unsigned char data i=0,j=0;

sendString("AT+CMGR=");
del_1ms();
send_byte(sms);
enter();

do
{
j=recv_byte();

}while(j != '*');

i=0;
while(j !='#' && i<50)
{
j=recv_byte();
com[i]=j;
i++;
}
com[i]='\0';
cleardisplay();
printlcd1("MESSAGE READ ");
del_1s();
}

unsigned char recv_sms_no()
{
unsigned char volatile ch[14],i;
do
{
i = recv_byte();

}while(i != '+');

for(i=0;i<13;i++)
{
ch[i]=recv_byte();
}
cleardisplay();
printlcd1("SMS RECEIVED ");
beep();
return(ch[11]);


}

//ROUTINE FOR DELETING THE MESSAGE
void delete_sms(unsigned char msg)
{
unsigned char volatile temp[7],i=0;

cleardisplay();
printlcd1("Deleting message");
del_3ms();
sendString("AT+CMGD=");
del_1ms();
send_byte(msg);
enter();
cleardisplay();
printlcd1("DEL COMM SENT ");
for(i=0; i<6 ;i++)
{
temp[i]=recv_byte();
}
temp[i]='\0';


cleardisplay();
if(strncmp(temp,"ok",2))
{
printlcd1("SMS DELETED... ");
beep();
del_1s();
RI=0;
}
else
{
printlcd2("NOT DELETED... ");
del_1s();

}
}
/*void check(unsigned char num)
{
if(num >= LAST)
{
cleardisplay();
printlcd1("MEMORY FULL");
del_1s();
cleardisplay();
printlcd2("DELETE UNWANTED");
del_1s();

}

} */

void beep()
{
buzzer = ON;
del_30ms();
del_30ms();
buzzer = OFF;
}

void scrolling(unsigned char *str1)
{
unsigned char len=0,i;
//len = strlen(str1);
for(i=1;com[i] != '\0';i++)
len += 1;
setadress(0xc0);
for(i=0;i<len-1;i++)
{
dat_lcd(*str1);
str1++;
del_30ms();
del_30ms();
del_30ms();
del_30ms();
del_30ms();
}
for(i=0;i<len+1;i++)
{
setadress(0x18);
del_30ms();
del_30ms();
del_30ms();
del_30ms();
del_30ms();
del_30ms();
del_30ms();
del_30ms();
}
}

Need your help urgently..


[ Edited Sat Apr 27 2013, 01:07 pm ]
Sun Apr 28 2013, 10:31 am
#18
Can anyone help with the working of this program??

Need your help urgently..

GSM is not going in the FLAG condition..
Mon Apr 29 2013, 10:21 am
#19
I do not understand this part of code
void extint0(void)interrupt 0
{

FLAG = 1;
START :if(IE0 == 1)
{
count++;
MS_delay(30);
}
goto START;

if(count >
= 9 )
count = 1;
}


and I do not see anywhere IE0 getting enabled. so there is no way FLAG will become 1.
 waterineyes like this.
Mon Apr 29 2013, 05:52 pm
#20
Can you make me understand how to enable IE0 and where to enable it??

Also, can you modify this code that you are not getting so that Flag can be set, so that program will move in the while(1) part??

Thanks for your reply Ajay..

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm
Robertgurse
Wed Apr 24 2024, 02:43 pm
Richardedils
Wed Apr 24 2024, 04:07 am
Malcolmaccek
Wed Apr 24 2024, 01:21 am