| Details |
Message |
|
Read-Only
Author soundarya kumari
Posted 29-Nov-2011 12:31 GMT
Toolset C51
|
 Interrupt not working(tx in softuart)(reception is inbuilt uart in the interrupt mode)
soundarya kumari
#include<softuart.h>
#include<stdio.h>
#include<reg51.h>
void uart_init();
sbit sw=P1^7;
unsigned char rx();
code unsigned char rd[] = "AT+CMGR=1";
code unsigned char ne[] = "AT+CNMI=2,2,0,0,0";
unsigned int r=0,m=0,s1=0,n1=0,f1=0,m2=0;
unsigned char gs,mes_dat[]=0,mess[]=0;
extern void lcd_init();
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
//void wait();
void gsm_delay(unsigned int);
unsigned char txt[]="AT+CMGF=1";
unsigned char no[] ="AT+CMGS=\"9940151239\"";
unsigned char del[]="AT+CMGDA=\"DEL ALL\"";
unsigned char sen[]="SENSOR";
void send_no();
void new_mess();
void gsm_read();
void delete();
void gsm_read();
void mode();
unsigned char rx();
unsigned char w, re,rx_data;
void tx(unsigned char);
void serial(void) interrupt 4
{
if(TI==1) { TI=0; SBUF = '\0'; //ES=0; } else if(RI==1) { rx_data = SBUF;
if(rx_data=='+') { do { mess[m2] = rx_data;
m2++; RI=0; }while(rx_data=='T'); }
RI = 0; }
}
void main()
{ uart_init(); lcd_init(); mode(); new_mess();
// delete();
while(1) { IE = 0x90; m = 0; r = 0; s1 = 0; m2 = 0;
re = rx_data;
if(re=='+') { RI = 0;
if(SBUF=='C') { lcd_data('1'); RI = 0; if(re=='M') { RI=0; lcd_data('2'); if(re=='T') { RI=0; do { gs = re; RI = 0; }while(gs!=0x0a);
do { gs = re; RI = 0; }while(gs!=0x0a);
m=-1; do { m = m+1;
mes_dat[m] = re; RI = 0;
}while(mes_dat[m]!=0x0d); mes_dat[m] = '\0'; m=0; lcd_cmd(0x01); lcd_cmd(0x80); while(mes_dat[m]!='\0') { lcd_data(mes_dat[m]); m++; } } } } } while(sw==1); m2=0; while(mess[m2]!='T') { //lcd_data(mess[m2]); tx(mess[m2]); m2++; }
send_no();
while(sen[s1]!='\0') { putc(sen[s1]); s1++; } putc(0x1a);
lcd_data('L');
gsm_delay(1000); gsm_delay(1000); gsm_delay(1000);
}
}
void new_mess()
{ n1=0; while(ne[n1]!='\0') { putc(ne[n1]); n1++; } putc(0x0a); putc(0x0d); gsm_delay(1000);
}
void mode()
{ f1 = 0; while(txt[f1]!='\0') { putc(txt[f1]); f1++; }
putc(0x0a); putc(0x0d); gsm_delay(1000);
}
void uart_init()
{ TMOD = 0x20; TH1 = -3; SCON = 0x50; TR1 = 1; //IE = 0x90;
}
/*unsigned char rx()
{ unsigned char rec; while(RI==0); rec = SBUF; RI = 0; return rec;
}
void delete()
{ unsigned int d ; d=0; while(del[d]!='\0') { putc(del[d]); d++; } putc(0x0a); putc(0x0d); gsm_delay(1000);
} */
void send_no()
{ unsigned int s=0; while(no[s]!='\0') { putc(no[s]);
s++;
}
putc(0x0a); putc(0x0d);
}
/*void gsm_read()
{ m=0; r=0; lcd_data('R'); while(rd[r]!='\0') { putc(rd[r]); r++; }
putc(0x0a); putc(0x0d);
} */
void gsm_delay(unsigned int k)
{ unsigned int i,j; for(i=0;i<=k;i++) for(j=0;j<=1273;j++);
} void tx(unsigned char tx_data)
{ SBUF = tx_data; while(TI==0); TI=0;
}
|
|
|
Read-Only
Author Andrew Neil
Posted 29-Nov-2011 14:03 GMT
Toolset C51
|
 RE: Interrupt not working(tx in softuart)(reception is inbuilt uart in the interrupt mode)
Andrew Neil
This is a duplicate of http://www.keil.com/forum/19961/
- isn't it?
Do you really think that code is clear and easy to read?
Do you think anynody will bother to read it if you can't even be
bothered to describe exactly what you think it should be
doing, exactly what does happen when you run it, and what
attempts you have made to debug it?
At the very least, you need to comment your code.
Debugging tips: http://www.8052.com/faqs/120313
See also:
http://www.techonlineindia.com/article/09-09-23/Developing_a_good_bedside_manner.aspx
|
|
|
Read-Only
Author Neviothan Jones
Posted 29-Nov-2011 14:14 GMT
Toolset C51
|
 It's a view (but not one I go along with)
Neviothan Jones
Real programmers don't comment their code. If it was hard to
write, it should be hard to understand.
Taken from http://www.murphys-laws.com/murphy/murphy-computer.html
|
|
|
Read-Only
Author Andrew Neil
Posted 29-Nov-2011 17:46 GMT
Toolset None
|
 RE: If it was hard to write, it should be hard to understand
Andrew Neil
If it's hard to understand, then one should certainly not expect
anyone to look at it for free!
|
|
|
Read-Only
Author erik malund
Posted 29-Nov-2011 14:23 GMT
Toolset C51
|
 if you take a look, you will see ...
erik malund
... that aboive the message field it says:
NOTE: When posting messages, use the following HTML tags to make
your
message easier to read and understand. For more information, refer
to
Tips for Posting Messages.
I suggest you read it before posting
Erik
|
|
|
Read-Only
Author Andrew Neil
Posted 29-Nov-2011 22:40 GMT
Toolset None
|
 RE: HTML tags to make your message easier to read and understand
Andrew Neil
The tags are necessary, but not sufficient.
The OP did use the tags this time - but it takes more than just
tags to make a readable, understandable post.
http://www.catb.org/~esr/faqs/smart-questions.html
It requires the poster to think about clearly presenting
and describing the code and the observed problem(s) - which the OP
has clearly not done.
Any programming exercise requires careful thought,
analysis, and study to determine what, exactly, the requirement is -
and how it can be solved.
I suspect that the fact that the OP has still not managed - after
2 attempts - to frame a clear and understandable post is symptomatic
of underlying problems that need to be addressed before any success
can be expected...
|
|
|
Read-Only
Author erik malund
Posted 30-Nov-2011 14:30 GMT
Toolset None
|
 the tags only help if
erik malund
The tags are necessary, but not sufficient.
The OP did use the tags this time - but it takes more than just
tags to make a readable, understandable post.
the tags only help if as above AND evidently the poster has not heard
of indenting. The "code" as is is totally unreadable. I have no idea
if other issues may exist, but just seing the lack of indention
(which led me to miss the greying since the "code" looks as if it was
not "HTMLed"). I do not look at unindented code.
something else that should be mentioned is that when code is
illegible to others it is also illegible to the "coder" this is a
proven fact.
Erik
|
|
|
Read-Only
Author Per Westermark
Posted 30-Nov-2011 14:43 GMT
Toolset None
|
 RE: the tags only help if
Per Westermark
The code might have been indented. It's just that tab characters
are normally not working so well outside the editor. Sometimes not
even within the editor, depending on individual configuration
settings.
|
|
|
Read-Only
Author erik malund
Posted 30-Nov-2011 15:32 GMT
Toolset None
|
 maybe it has been changed
erik malund
maybe it has been changed, but (it used to be that) tabbing lead
to some quite wild appearnces
just as a check
this is tabbed
this is double tabbed
this is spaced
well the preview show that Keil and notepad use the same
tabbing
so, evidently the op has not heard of indenting
I am truly amazed seeing some of the scribbles posted here under
the guise of "code"
Erik
|
|
|
Read-Only
Author IB Shy
Posted 30-Nov-2011 15:39 GMT
Toolset None
|
 RE: maybe it has been changed
IB Shy
For what it's worth ...
It seems far more likely to me that the OP simply cut/pasted from
the original post and surrounded that with the
<pre> tags. Any hint of indentation had already
been lost by the first posting.
|
|
|
Read-Only
Author Per Westermark
Posted 30-Nov-2011 15:52 GMT
Toolset None
|
 RE: maybe it has been changed
Per Westermark
Yes, most people who get complaints about having forgotten the pre
tags do not go back to the editor, but reposts from the previous
post, including multiple source lines merged at random places.
|
|
|
Read-Only
Author Andrew Neil
Posted 30-Nov-2011 21:19 GMT
Toolset None
|
 RE: It seems far more likely to me that the OP simply cut/pasted from the original post
Andrew Neil
Indeed.
And, again, didn't bother to pay attention to the
preview!
Hardly surprising, then, that the code does not work.
|
|