This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reading SBUF

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??????????

Parents
  • 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.

Reply
  • 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.

Children