my c code for testing AT command

Status
Not open for further replies.

abbas1707

Full Member level 4
Joined
May 3, 2007
Messages
216
Helped
20
Reputation
40
Reaction score
8
Trophy points
1,298
Activity points
2,371
i want to test dat if my cellphone is responding to AT commands sent by AT89c51
i have writen a c program and before wirting this code to controller i want 2 confirm if this code ok???? or i must correct it?? im just sending AT and cheking wether OK recieved and if so turning led on!!! can any1 help me out??:?:
********************************
#include <reg51.h>
sbit led=P1^0;
void init()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
void transmit(unsigned char *a)
{
while(*a!='\0')
{
SBUF=*a;
while(TI==0);
TI=0;
a++;
}
}
unsigned char rcv()
{
while(RI==0);
return SBUF;
}
void main()
{
unsigned char ok[2];
unsigned char j;
led=0;
init();
transmit("AT");
transmit(0x0d);
for(j=0;j<2;j++)
ok[j]=rcv();
if(ok[0]=='O'&&ok[1]=='K')
led=1;

}
 

Only a comment:

I think that the transmition rutine is OK, but the reception is better to do by interruptions.
 

Could you refer from link below it should be to help you coding.

**broken link removed**
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…