c code for mobile interfacing with 8051

Status
Not open for further replies.

aliraza786

Full Member level 4
Joined
Nov 10, 2009
Messages
210
Helped
14
Reputation
28
Reaction score
14
Trophy points
1,298
Location
Lahore, Pakistan, Pakistan
Activity points
2,914
hi anyone can help me out...plz tell me is this code is right for sending "AT" to mobile and the check wht the mobile reply and if the mobile reply "ok"....led on some port will light up...plz check my code....thnks in advance.
___________________________________________________________

#include<reg51.h>
unsigned char at[]="AT";
unsigned char dt[]="ATDT 03134495084" ;

sbit sw=P1^1; unsigned char dta[2];
char y,l;
sbit led=P2^0;

void main()
{
TMOD=0x20;
TH1=-3;
SCON=0x50;
TR1=1;

if(sw==0)
{
for (y=0;y<2;y++)
{
SBUF=at[y];
while(T1==0)
T1=0;

}
for(l=0;l<2;l++)
{
while(RI==0)

dta[l]=SBUF;
RI=0;

}

if(dta[0]=='o' && dta[1]=='k')

{ led=0; }

}

}
 

Put semicolons as shown below:

{
SBUF=at[y];
while(T1==0);
T1=0;
}

Also
{
while(RI==0);
dta[l]=SBUF;
RI=0;

}

Rest seems fine.. although u might wanna provide a very small delay between transmitting two characters.
Also I think the command to connect the call is 'ATD' and not 'ATDT'
 
Check the code section of this project : **broken link removed**
It shows how to transmit the AT command to GSM modem.
 
Reactions: nikhil_jain

    nikhil_jain

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
thnku very much nikhil and sumit.......i have another problem wht baud rate i set to comunicate with mobile phone like we set 9600 bps mostly while comunicating with computer through hyperterminal.....
 

the baudrate of controller board and modem should be 9600, if the baud rate set in hyperterminal is 9600.. its not only the baud rate but the setting should be same for 8data bits, 1 stop bit, No parity,..............
 
Reactions: MRAMA

    MRAMA

    Points: 2
    Helpful Answer Positive Rating
thnku very much nikhil and sumit.......i have another problem wht baud rate i set to comunicate with mobile phone like we set 9600 bps mostly while comunicating with computer through hyperterminal.....

9600 is mostly used baudrate.. what is the baudrate of your modem? the baudrate of your modem and 8051 must match each other

---------- Post added at 09:11 ---------- Previous post was at 09:09 ----------

the given link of sumit_sharma is nice to read.. try
 
Reactions: MRAMA

    MRAMA

    Points: 2
    Helpful Answer Positive Rating
thnks to ALL....but the problem is i am using nokia 6230i and i dnt know what is the baud rate at which the mobile will prpoerly comunicate with controller.....and in the hardware circuit i simple join the Tx and Rx pins of controller to the Tx and Rx pins of Mobile Phone....i use volatge trnasltor becuse mobile work at 3.7 and controller work at 5 volts. is it correct.....
 
Last edited:

have you tried communicating through hyper terminal with your phone? I don't think you can use AT commands of that phone because it looks like the phone uses Fbus protocol..



---------- Post added at 20:27 ---------- Previous post was at 20:26 ----------







it does not support serial communication
Nokia N60, N70, N90, N91, 3155i, 3230, 3300, 6155, 6170, 6230, 6230i, 6235, 6236i, 6255, 6256i, 6260, 6620, 6630, 6650, 6651, 6670, 6680, 6681, 7270, 7600, 7610, 7700, 7710, 9300, 9500 pop-port DKU-2 usb cable schematic Cable Pinout - AllPinouts

---------- Post added at 20:30 ---------- Previous post was at 20:27 ----------

use phone that supports serial com
 
thnks for your timely reply.....i am new to microcontroler......ya you are right that this phone supports the Fbus protocol.....can u tell me what is the diffrenc between the Fbus protocol and serial protocol...bcuz in serial comunication we also use three pins tx,rx, and gnd...and in some disscuion on edaboard i see that some one conect phone to mcu with conecting tx and rx pins of phone to mcu tx rx pins...check pic on that link.....**broken link removed** what about 8250 nokia mobile it support the serial comunication or not..???
someone tell me this in case of nokia 8250 ...haedware u can see in the pic and he said read the datasheet of 8051 and learn how ro cnfigure the Uart of the 8051 to send 8 bit data no pairty one stop bit...after that write serial output and input routine(i couldnt understand what he said). yes i practise At comands on my 6600 mobile by using hyperterminal.
 
I haven't tried dealing with FBUS protocol.. just do some research about it.. I don't encourage you to go with FBUS because it's not easy to work with..

Im not sure but 8250 is using MBUS protocol..

I tried before serial communication using SE t290i phone.. it worked
 

check this....... we had some discussion long back on FBUS...


https://www.edaboard.com/threads/213321/

---------- Post added at 17:10 ---------- Previous post was at 17:09 ----------

FBUS does not support AT commands.......
 
I found something about that phone.

**broken link removed**

if you have doubts about the phone support you can google it for the pinouts. it's available everywhere ...
 

i found its pinouts but i coudnt understand the comunication is serial or again it is fbus becuse bothe comunication shows pins name TX RX and GND..........
look at this link......https://obrazki.elektroda.pl/34_1312902241.png
 


**broken link removed**

I cannot find any documentation about that phone

but base on the cable it uses USB and it will not work to your MCU unless you use USB protocol which is hard.

---------- Post added at 17:59 ---------- Previous post was at 17:54 ----------

There is a good explanation here in UART.

**broken link removed**

This is the code I am using to send and receive from UART

void serial_send(unsigned char dat){
while(!TI);
TI = 0;
SBUF = dat;
}


unsigned char serial_read(){
while(!RI);
RI = 0;
return SBUF;
}
 
there are also many phones supports at commands but I haven't remember it all.. just do google search if what phone you have there in your place
 

the command is AT+CKPD

Description:
Emulates phone keypad by setting each keystroke as a character in a
string <keys>.

Execution
command:

AT+CKPD=<keys>[,<time>[,<pause>]]


Test command:

AT+CKPD=? Shows if the command is supported.


---------- Post added at 08:57 ---------- Previous post was at 08:53 ----------

<time>:

<time> Description
0-255 0-25.5 seconds


<pause>:

<pause> Description
0-255 0-25.5 seconds


hope this helps.
thanks
 

how to recieve a string of data in 8051...i am not able in doing this..plz help..actua;;y working on GSM
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…