unsigned char GetSerial =0;
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */ TMOD = 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xfd; /* TH1: reload value for 9600 baud */ TR1 = 1; /* TR1: timer 1 run */
GetSerial = SBUF;
the problem is when i add some data in serial window, and while running this command GetSerial = SBUF; , there is no data will copy from SBUF to GetSerial,
i see the watch-window.
so what is the problem??????????
But what code do you use to wait until there is a character available, before reading from SBUF?
If you reach with your hand into an empty postal office box to try to get any mails, you will fail to pick up the mails if no mails have arrived...
@ Per Westermark
thnx my problem is solved
I am suffering from same problem. I didn't understand what you exactly want to say? Could you plz elaborate.
this is my code
char chr; // variable to hold the new character while (RI != 1) {;} chr = SBUF; <-- My problem is here.... RI = 0;
Hey, Please tell me how you solved this problem??????
1) How do you know you are suffering from the same problem?
2) Why do you think spamming helps? Or the use of many question marks?
3) What have _you_ done to try to figure out what is wrong?
1) Well..My Problem is while debugging in keil compiler I use serial window to make RI flag 1. And SBUF is set to some value suppose 0x3A; While debugging Rec_char is unable to copy the value of SBUF.
I tried to Simulate it even it is not simulating perfectly. the problem occurs when you pass SBUF value to another variable.
if (RI) /* it was a receive interrupt */ { Rec_char = SBUF; RI = 0; } Compiled this code without error..
I wan't to know what's wrong in it? I am beginner. Plz help me.
2) No. I don't think spamming helps. It is just my style of writing.
3) I tried much..but couldn't figured out the exact problem... I hv searched about it and came to know that SBUF is Transmitting And Receiving Register at same address.The SBUF you write to is not the same as the one you read. I might not be simulating it properly..Plz show me the way.
Well..My Problem is while debugging in keil compiler I use serial window to make RI flag 1. And SBUF is set to some value suppose 0x3A; While debugging Rec_char is unable to copy the value of SBUF. elementary questions like this comes up almost daily. to avoid you asking something equally basic tomorrow I suggest you read "the '51 bible" where you will find the answer to this and your next questions.
here is the link to "the bible" www.8052.com/.../120112
Erik
The link is very helpful. Thank you & Regards.