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.

plz help me in activating the serial interrupt of at89c2051

Status
Not open for further replies.
Re: plz help me in actavting the serial interrupt of at89c2051

Refer IE register

**broken link removed**

ES - enables or disables serial interrupt:

0 - UART system cannot generate an interrupt.
1 - UART system enables an interrupt.
 
Re: plz help me in actavting the serial interrupt of at89c2051

thanks for reply...
but when i used at89c51 it works...when i used at89c2051 it does'nt work...
when i send sms ..i receive nothing....plz help me....
 

It is better if you can post your program to check further
 

#include <reg2051.h>
#include <string.h>
#include <stdio.h>
#define CR 13
#define SUB 26
#define dot 46
sbit gps_en=P1^6;
void ms_delay(unsigned int t);
void cell_init();
void read_gps();
void read_str(unsigned char l1,unsigned char l2);
unsigned char recv_ser();
void send_cmd(unsigned char l1,unsigned char l2);
void send_msg();
void send_num();
void send_ser(unsigned char dat);
void del_msg();
void serial();
unsigned char cell_nubmer[13]="+923334705266";
unsigned char cmd[66]="AT+CMGF=1 AT+CNMI=2,1,0,0,0 AT+CMGR=1 AT+CMGD=1 AT+CMGS=,145 ALTO,";
unsigned char str[24]={0};

void ser_init()
{
SCON=0x50;
TMOD=0x20;
TH1=-6;
TR1=1;
}
void send_ser(unsigned char dat)
{
SBUF=dat;
while(TI==0);
TI=0;
}
unsigned char recv_ser()
{
unsigned char dat=0;
while(RI==0);
dat=SBUF;
while(RI==0);
RI=0;
return dat;
}
void read_str(unsigned char l1,unsigned char l2)
{
unsigned char loop=0;
for(loop=l1;loop<=l2;loop++)
str[loop]=recv_ser();
}
void read_gps()
{
start:
while('$'!=recv_ser());
read_str(0,5);
if((strncmp(str,"GPGGA",5))==0)
{
read_str(0,10); //avoid initial data of gps
read_str(0,23); //read earth co-ordinates
}
else
goto start;
}
void send_cmd(unsigned char l1,unsigned char l2)
{
unsigned char loop=0;
for(loop=l1;loop<=l2;loop++)
{ send_ser(cmd[loop]);
ms_delay(10);
}
}
void send_num()
{
unsigned char loop=0;
send_ser('"');
for(loop=0;loop<=12;loop++)
{
send_ser(cell_nubmer[loop]);
ms_delay(10);
}
send_ser('"');
}
void send_msg()
{
unsigned char loop;
send_cmd(0,8);
send_ser(CR);
ms_delay(1000);
send_cmd(48,55);
send_num();
send_cmd(56,59);
send_ser(CR);
ms_delay(500);
send_cmd(61,65);
for(loop=0;loop<=1;loop++)
{
send_ser(str[loop]);
ms_delay(10);
}
send_ser(dot);
for(loop=2;loop<=3;loop++)
{
send_ser(str[loop]);
ms_delay(10);
}
for(loop=5;loop<=9;loop++)
{
send_ser(str[loop]);
ms_delay(10);
}
for(loop=13;loop<=14;loop++)
{
send_ser(str[loop]);
ms_delay(10);
}
send_ser(dot);
for(loop=15;loop<=16;loop++)
{
send_ser(str[loop]);
ms_delay(10);
}
for(loop=18;loop<=21;loop++)
{
send_ser(str[loop]);
ms_delay(10);
}
send_ser(CR);
ms_delay(10);
send_ser(SUB);
send_ser(CR);
ms_delay(1000);
}
void serial(void)interrupt 4 .......... here is the problem.........
{
unsigned char loop=0,x='+';
if('+'==SBUF)

RI=0;
read_str(0,4);
ms_delay(1000);
if((strncmp(str,"+CMTI",5))==0)
{
ms_delay(500);
gps_en=1;
ms_delay(500);
gps_en=0;
ms_delay(500);
read_gps();
ms_delay(500);
gps_en=1;
send_msg();
//del_msg();
}
}
else
RI=0;
}
void del_msg()
{
unsigned char loop;
unsigned char loop1;
unsigned char i='1';
for(loop1=0;loop1<5;loop1++)
{
for(loop=38;loop<=45;loop++)
{
send_ser(cmd[loop]);
ms_delay(10);
}
send_ser(i);
ms_delay(10);
send_ser(13);
ms_delay(500);
i++;
}
ms_delay(1000);
}
void cell_init()
{
ms_delay(10000);
send_cmd(0,8);
ms_delay(10000);
send_cmd(0,8);
send_ser(CR);
ms_delay(1000);
send_cmd(10,26);
send_ser(CR);
ms_delay(1000);
del_msg();
}
void ms_delay(unsigned int t)
{
unsigned int j,k;
for(j=0;j<t;j++)
for(k=0;k<114;k++);
}

void main()
{

ser_init();
cell_init();

EA=1;
ES=1;
while(1)
{}




}

---------- Post added at 16:35 ---------- Previous post was at 16:26 ----------

my project name is gps gsm tracking system...when i send a sms to gsm module it should send me the coordinates...all the work is done only the interrupt problem...controller does not receive sms..plz help me...
 
Last edited:

Write EA=1; and ES=1; before cell_init(); routine

Also make sure that your circuit and check whether the correct pin connections when you use the same circuit for at89c51 and at89c2051
 

i did it...but its not working...all the connections are same...is there any problem in controller...???
 

It is also possible if you have extra controllers. However check whether the serial send and receive functions work properly.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top