Discussion in "Embedded GSM Development" started by    kirangowle    Nov 20, 2010.
Thu Jan 13 2011, 05:56 pm
#81
I have made little change in the code. I have kept test strings to check where the program is flowing.

while(1)
{
while(key!=1)
{
if(flag==0)
{
lcdcmd(0x80);
lcdstr("MSG Sent");
SMSString("AT+CMGS=\"9845xxxxxx\"\r");
delay(1);
SMSString("This is a test msg \r");
tx0(0x1A);
flag=1;
}
}
 lcdcmd(0x80);
lcdstr("MSG Not sent");
flag=0;
}



I think tx0(0x1A) ctrl+z line is not working properly.

Fri Jan 14 2011, 09:29 pm
#82
delay(1); means how much?
Fri Jan 14 2011, 10:26 pm
#83
try in this manner

SMSString("AT+CMGS=\"9845xxxxxx\"\r");
tx0(0x1A);
SMSString("This is a test msg \r");


here 9845xxxxxx ru use xxxxx or any number
use number
Fri Jan 14 2011, 11:43 pm
#84
that is wrong majoka.. it will not work that way...

ctrl-z should be sent after data only not command.
Sat Jan 15 2011, 12:18 am
#85
hi ajay
AT+CMGS is a command
is 9845xxxxxx is a command or it is data ?
Sat Jan 15 2011, 10:02 am
#86
@ Mojaka
9845xxxxx is a data(mob no.)
After this msg along with ctrl+z has to be sent. then only msg will be sent.

@ Ajay,
Just a small delay i m giving.
void delay(unsigned int i)
{
        unsigned int k, l;
        for(k=0;k<i;k++)
                for(l=0;l<1000;l++);
}



I think in SMSString(" This is the test msg\r");

\r should not be used.
 majoka like this.
Sun Jan 16 2011, 12:01 am
#87
i guess that delay is too less.. what else you can do is.. wait for '>'

coz after you send AT+CMGS="mobnum" modem reply with a prompt '>' so you can wait for this prompt and then send your data.

@majoka, anything starting with AT is a command.
 majoka like this.
Sun Jan 16 2011, 11:27 am
#88
Thanks Guys..

Its working..
I removed \r from the test msg.
Sun Jan 16 2011, 11:55 pm
#89
glad to hear it
best of luck
Fri Jul 15 2011, 09:45 am
#90
Hi

I want to store the msg content(i.e msg, mob no, date/time) into the eeprom(24C256-256K). the below code works fine for 24C04/02 chips but didnt worked for
24C256. Is there is any addressing different from 24C04?

void main()
{
	unsigned char i[16],l,k;
	unsigned char c[16];
lcd_ini();
k=0x60;// Ascii values storing in array
for(l=0;l<=15;l++)
{
c[l]=k;
k++;
}
c[l]='\0';
//writing that array into eeprom
write_string_eprom(0x00,c);//starting addr, array[]
lcd_command(0x80);
//read the stored data
for(l=0;l<=15;l++)
{
i[l]=read_e2prom(0xA0,l);// device addr, starting addr.
aknowledge();
lcd_data(i[l]);// display same on LCD
} 
while(1);
}

void write_string_eprom(unsigned char addr, unsigned char *text)
{
	while(*text)
	{
		write_e2prom(0xA0,addr,*text++);
		addr++;
	}
}
void write_e2prom(unsigned char device_id,unsigned char location,unsigned char c)
{
	do
	{
		start();      //starts i2c bus
		send_byte(device_id); //select slave device
		aknowledge();
		if(slave_ack==1)  //if acknowledge not received, stop i2c bus
			stop();
	}while(slave_ack==1); //loop until acknowledge is received
send_byte(location); //send address location
aknowledge();
send_byte(c); //send data to i2c bus
aknowledge();
stop(); //stop i2c bus
delay(1);
}       

//reads one byte of data(c) from slave device(device_id) at given address(location)
unsigned char read_e2prom(unsigned char device_id,unsigned char location)
{
unsigned char c;
	do
	{
		start();      //starts i2c bus
		send_byte(device_id); //select slave device
		aknowledge();
		if(slave_ack==1)  //if acknowledge not received, stop i2c bus
			stop();
	}while(slave_ack==1); //loop until acknowledge is received
send_byte(location);  //send address location    
aknowledge();  
stop(); //stop i2c bus
start(); //starts i2c bus   
send_byte(device_id+1); //select slave device in read mode
aknowledge();
c=read_byte(); //receive data from i2c bus
aknowledge();
stop(); //stop i2c bus
return c;
}

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Astorne
Tue Apr 16 2024, 08:52 pm
Williamjaf
Tue Apr 16 2024, 12:25 pm
best_yyPa
Tue Apr 16 2024, 09:42 am
ErnestoExpop
Tue Apr 16 2024, 02:57 am
Jamesclepe
Mon Apr 15 2024, 11:10 am
Aliciaelora
Mon Apr 15 2024, 07:59 am
btaletvpcu
Mon Apr 15 2024, 04:36 am
UbvpwcTib
Mon Apr 15 2024, 03:13 am