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.

Unable to communicate with GSM module and P89V51RD2 MCU

Status
Not open for further replies.

kapuraje

Newbie level 3
Newbie level 3
Joined
Oct 12, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Pune
Activity points
1,309
i have checked both GSM module and MCU with PC through RS232 Cable both are working properly.

i am connecting two with Serial Port(GSM module and MCU),
GSM Module is of Quectel M95 !!!

i have connected 2---3
3---2
5---5 pins of two serial ports

and i wrote a program shown below to check the communication between the two
(i am showing only main function from 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
void main() 
{ 
  int i;
            TMOD=0x20;
            TH1=0xFD;
            SCON=0X50;
            TR1=1;
 
initialize();
 
    display_lcd(0x80, "   Serial Port  ");  
   
        display_lcd(0xC0, "    Ready!      ");  
 
 
transmit('A');
transmit('T');
transmit('\r');
 
    for(i=0;i<16;i++)
    {
    store=mygetchar();
    sprintf(buf,"%c",store);
    display_lcd(i,buf);
    }
    lcdcmd(0x01);
while(1) 
{
 
}
}




But i didn't get any data(response) from GSM after "Ready" on LCD .
 
Last edited by a moderator:

You may want to check connections first. After that, if you connect your PC to the microcontroller, you get the 'A', 'T' and '\r' ?
 
After downloading the above program in MCU and connecting it to Hyperterminal,
i dont get the 'A','T' and'\r' .

is there a problem in code....?

can u plz help me with the code....
 

Then there is a problem with either the connections (TX and RX inverted) or with the initialization of the UART in the microcontroller. I am not familiar with the microcontroller you are using, but you should get the 'A','T' and'\r' in the PC (hyperterminal).
 

Dear Sir after few modifications in code now i am able to get the 'A','T' and'\r' in the PC (hyperterminal).

Code:
#include<reg52.h>
#include<stdio.h>

sbit LCDrs=P0^0;  //The Register select Pin
sbit LCDrw=P0^1;  //The Read/Write Pin
sbit LCDen=P0^2;  //The Enable Pin

char sbuf[16],c,store; 
char buf[16]; 
void transmit(unsigned char );
void delay(unsigned int rtime)
	{
	unsigned int r,s;
	for(r=0;r<rtime;r++)
	for(s=0;s<1275;s++);
	}
void lcdcmd (unsigned char DATA)
	{

				LCDrs=0;
				LCDrw=0;
			    LCDen=1;
				P1=DATA;
				LCDrs=0;
				LCDen=0;
	}
void initialize (void) 
	{
				lcdcmd (0x30);	 //1 line and 5x7 matrix 
				delay(1);
				lcdcmd (0x38);	 //2 line and 5x7 matrix
				delay(1);
				lcdcmd (0x0C);	 //Display on, cursor off
				delay(1);
				lcdcmd (0x01);	 //Clear display Screen
				delay(1);
				lcdcmd (0x06);	 //shift cursor to right
				delay(1);
	}
void lcddat (unsigned int DATA)
	{      

				LCDrs=1;
				LCDrw=0;
				LCDen=1;
				P1=DATA;
				LCDrs=1;
				LCDen=0;
	}
void display_lcd (unsigned char location, unsigned char *d)
	{  
					lcdcmd(0x80 | location); 
					delay(1);
					while(*d)
					 	{
					 	  lcddat(*d++);  
					 	  
					 	}	 
	}
char mygetchar(void) 
{ 
char c; 
while(!RI); 
RI =0; 
c = SBUF; 
return SBUF; 
} 
void init()
{
TMOD=0x20;
TH1=0xFD;
TL1=0xFD;
SCON=0x50;
TR1=1;
TI=1;
}
void main()
{
int i;
init();
ES=1;
EA=1;
P0=0xFF;
initialize();

	display_lcd(0x80, "   Serial Port  ");	
    display_lcd(0xC0, "    Reception   ");
	delay(300);

display_lcd(0x80, "   Serial Port  ");


		
    display_lcd(0xC0, "    Ready!      "); 

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


for(i=0;i<16;i++)
	{
	store=mygetchar();
	sprintf(buf,"%c",store);
	display_lcd(i,buf);
	}
	lcdcmd(0x01);
while(1) 
{
 
}
}

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

But When i connect it with serial port of GSM Module

I am getting "AT" as output on LCD (that is from GSM).....expected output is "OK"

this output shows these connections may be correct,
i have to connect manually as i didn't find NULL Modem Connector in Pune based market.
 

This is really weird. The only idea that came to me is that transmit is not working properly when handling '\r', Have you tried sending commands to the module directly from the PC? If you can and recieve "OK", then you will probably try to implement transmit in a different way.
 

yup, The GSM Module is working properly with PC

AT
OK

it works with PC.

yes i might need to try another code to transmit commands!!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top