The code is like this: #include <reg51.h> void main() { unsigned char ch; SBUF = 0xcc; ch = SBUF ; } I found that the value in ch is always zero,however, when I substituated SBUF with other SFRs, the result in ch is 0xcc, which is correct. What is the problem here and how can I read the value in SBUF? Thanks!
Alex; The reason you cannot read the SBUF in your code is that there are two entirely different SBUF registers. Both registers have the same SFR address but cannot be accessed in the same manner. The only way to get data into the Receive SBUF is through the Serial Port. The only way to read data out of the transmitt SBUF is out the Serial Port. I suggest that you read Eric and Andrews bible of 8051 operations as posted on this website. Just search Bible in the discussion forum and you will find the links to the Philips websites. Bradford
Just read my own post and noticed I mis-spelled Erik's name. Sorry about that Erik. Bradford
Thanks,I have already found it, and I really appreciate your help.
Is this on a test? Usually when several ask the same question we are answering a test question is that the cse? Erik
NO, our group is finishing a project involving programming 8051 for serial communication. And I have no idea about previous questions.
"our group is finishing a project involving programming 8051 for serial communication" Finishing?! - yet you're still stuck on fundamentals like this?!