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.

[SOLVED] Unable to interface between Sim300 and P89v51RD2

Status
Not open for further replies.

jaysinhp

Newbie level 3
Joined
Apr 15, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,320
I have This board. ->**broken link removed**.
And i have sim300 based board which has onboard db9 with max232 connection.I am connecting boath of them with NULL modem .But unalbe to get interfacing.I use C programming language.And wrtite a code in MCU.I have tested modem as well as MCU with Hyperterminal.It works like charm.But unable to interfacing sim300 with MCU.Kindly help me this is my final year project and just 10 days are left !. :roll:
 

Yes..I have set the baud rate of the modem at 9600 bps. And also initializing serial port at 9600 bps.
 

must be sth wrong with your code ..
post your code here
 

You need to disable echo by ATE0 command, actually, when you are testing with hyper terminal you recieve each and every character you have sent.

When ever SIM300 or SIM900 send back you feedback either it is 'OK' or some thing else, it will always start and end with ASCII Character 10 and 13. For example you will recieve 10,13,O,K,10,13.

You have to download Br@y++ Terminal from **broken link removed** for better checking. Connect SIM300 directly to PC and use above terminal for testing and observing SIM300 response.

For communication between SIM300 and Micro you have to do following;

1. First use disable command by ATE0.
2. Than program you microcontroller for accept 10,13 first than OK and in last 10,13.
 
But i've coded GSM without using this ATE0 command. I used a delay after sending an AT command. It is working without any problems.
 

But i've coded GSM without using this ATE0 command. I used a delay after sending an AT command. It is working without any problems.

Using delay for communication is not recommended, yes it may be working fine, but some time it may give you trouble, do know which microcontroller is present in SIM300/900? Its ARMv7 or ARMv6, some time ARM microcontroller will reponse with some delay, than what your program will do?????
 

Sir this is My Code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<reg52.h>
#include<stdio.h>
sbit a=P0^7; // LED Connected to this port 
unsigned char recive();
void transmit(unsigned char );
void init()
{
TMOD=0x20;
TH1=0xFD;
TL1=0xFD;
SCON=0x50;
TR1=1;
TI=1;
}
void main()
{
unsigned char c[2];
init();
ES=1;
EA=1;
P0=0xFF;
 
 
while(1)
{
transmit('A');
transmit('T');
transmit('\r');
 
c[0]=recive();
c[1]=recive();
 
if((c[0]=='O' && c[1]=='K') || (c[0]=='o' && c[1]=='k'))
{
a=0; // Led is On 
}
}
}
void transmit(unsigned char c)
{
while(!TI);
TI=0;
SBUF=c;
}
unsigned char recive()
{
while(!RI);
RI=0;
return SBUF;
}



---------- Post added at 23:17 ---------- Previous post was at 21:46 ----------

Sir i appreciate your help. I have also downloaded Br@y ++ terminal but i am help less.It is very difficult to use as compared to hyperterminal .Because use with rx and tx pin and no other gnd to get connected with Pc.This works fine with Hypertermianl with gsm modem but unable to get response in br@y ++ terminal.
 
Last edited by a moderator:

Yes. what masterleous said is correct. delay will cause much more problems. Avoid delay at any cost.

I am not aware of MCU that you told.

But, try this (with the assumption that your circuit is correct):

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
main(){
 .
 .
 .
 char GSM_OUTPUT[20];
 
 transmit('A');
 transmit('T');
 transmit('\r');
 
while(1)
 {
  char c = recive();
  switch(c){
       case '0x0A': // if <LF> character received
                break;
       case '0x0D': // if <CR> character received
                      
                      GSM_OUTPUT[i] = '\x00';
                      
                      if (strlen(GSM_OUTPUT) > 1){ // if 2nd <CR> received, then there will be some data
                            if (strcmp(GSM_OUTPUT, "OK") == 0){
                                    led = 0;
                                    i = 0;
                                    strcpy(GSM_OUTPUT, "");
                            }
                      }
                break;
       default:
               if (i < 20){
                 GSM_OUTPUT[i] = c;
                 i++;
               }
               else{
                 i = 0;
               }
             break;
       
      }
}


if you need any more help let me know.
 

There is no problem with calling a delay. I did a project in the same manner. Calling a delay means to mask the ack bits comming from GSM.

---------- Post added at 05:55 ---------- Previous post was at 05:54 ----------

I don't know whether any other bits are coming with "OK". If it is so, then we need to check that also.
 

Hi,

If your modem works with HyperTemrinal and not with your MCU, please check all the other Rs-232 signal, the RTS, DTS and two more.

Sim300 will not reply if this signal not handle correctly, this is called Rs-232 Hand Shaking, if the SIM board as MAX232 chip and all line connected, the it will work on Hyperterminal and not with your MCU.

I use YAT terminal program, it;s open source and far better then HyperTemrinal, it will show the other Rs-232 pin status, so you can understand.

if you connecting to your MCU and only using Rs/TX line then set the other control pins in correct state.

M.Pathma

---------- Post added at 16:43 ---------- Previous post was at 16:42 ----------

Hi,

Also fix the baud rate with AT+IPR=9000, SIMCOM not good at Auto-baud (factory default)

M.Pathma
 

Sir this is My Code:

#include<reg52.h>
#include<stdio.h>
sbit a=P0^7; // LED Connected to this port
unsigned char recive();
void transmit(unsigned char );
void init()
{
TMOD=0x20;
TH1=0xFD;
TL1=0xFD;
SCON=0x50;
TR1=1;
TI=1;
}
void main()
{
unsigned char c[2];
init();
ES=1;
EA=1;
P0=0xFF;


while(1)
{
transmit('A');
transmit('T');
transmit('\r');

c[0]=recive();
c[1]=recive();

if((c[0]=='O' && c[1]=='K') || (c[0]=='o' && c[1]=='k'))
{
a=0; // Led is On
}
}
}
void transmit(unsigned char c)
{
while(!TI);
TI=0;
SBUF=c;
}
unsigned char recive()
{
while(!RI);
RI=0;
return SBUF;
}

---------- Post added at 23:17 ---------- Previous post was at 21:46 ----------

Sir i appreciate your help. I have also downloaded Br@y ++ terminal but i am help less.It is very difficult to use as compared to hyperterminal .Because use with rx and tx pin and no other gnd to get connected with Pc.This works fine with Hypertermianl with gsm modem but unable to get response in br@y ++ terminal.

You program has some bugs, As i said earlier that before and after sending "OK" SIM300 send 10 and 13,

You may use like this, i am adjusting few things rest you have to change.

Code:
unsigned char c[6];
init();
ES=1;
EA=1;
P0=0xFF;

transmit('A');
transmit('T');
transmit('\r');


c[0]=recive();
c[1]=recive();
c[2]=recive();
c[3]=recive();
c[4]=recive();
c[5]=recive();


if( ( (c[2]=='O') && (c[3]=='K') ) || ( (c[2]=='o') && (c[3]=='k') ))
{
a=0; // Led is On 
}

while(1)
{
}

void transmit(unsigned char c)
{
while(!TI);
TI=0;
SBUF=c;
}
unsigned char recive()
{
while(!RI);
RI=0;
return SBUF;
}

Do these step by step, When you send "AT" in capital letters, SIM300 will reponse as "OK", when you will Send "at" you will recieve "ok" in small letters.

first mistake you was doing was sending AT command in while loop forever, that was not correct.
Second you was trying to get response in you character set. Do step by step like this

if( ( c[0]=='O') )
{
a=0; // Led is On
}

if( ( c[1]=='O') )
{
a=0; // Led is On
}

if( ( c[2]=='O') )
{
a=0; // Led is On
}

if( ( c[3]=='O') )
{
a=0; // Led is On
}

if( ( c[4]=='O') )
{
a=0; // Led is On
}

if( ( c[5]=='O') )
{
a=0; // Led is On
}

Do above example for checking "O" in all character set this way, you will get your LED ON, than remove one character location one by one and test and carry on, till you get correct character at correct location.

Hope this may help you

---------- Post added at 16:05 ---------- Previous post was at 16:00 ----------

As far as Br@y++ Terminal concern,
you have to correct communications parameters of Br@y++ Terminal like as
COMx, 9600, 8 data Bit, 1 Stop bit, No parity, no Hand shaking

Than Press Connect button

About the datarate whic i mention 9600, you may choose any buadrate as compared to SIM300 baudrate, in between 9600 to 38400, it is better to use low baudrate first, as higher buadrate may cause communication errors
 

There is no problem with calling a delay. I did a project in the same manner. Calling a delay means to mask the ack bits comming from GSM.

All characters received in the receive buffer should be read whether you want them (required data) or not. Otherwise, receive interrupt flag won't clear and serial ports did not receive any more data further until receive buffer read or cleared. If you use delay, there is a chance to miss the required data and sometimes you receive and sometimes not.
 

I have got the solution.The problem was in my Code.The modem is replaying with <CR><LR>OK<CR><LR> .Thanks to
masterleous.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top