hello every body i have a problem when i use debugger i assign a value to sbuf but i can't get that?!?!? it seems that i can't simulate serial recieve?!?! plz help me :(
You can't write values directly to SBUF. Values written to SBUF are output to the serial port. There are basically, 2 ways to simulate received serial data. 1. Open the serial window and type the characters you want to receive. 2. Use the SIN VTReg to specify the serial input value. Refer to http://www.keil.com/support/docs/1944.htm for more information on this. Jon
"You can't write values directly to SBUF" Well, you can - but you will not see the same value when you read SBUF. SBUF is essentially two separate registers - one is read-only, the other is write-only. These two separate registers share the same SFR address - read accesses to that address read from the read-only register; write accesses to that address write to the write-only register. That's why you can't read-back the same value that you wrote! Writing to the write-only register causes data to be transmitted by the 8051 serial port hardware; Characters received by the 8051 serial port hardware can be read via the read-only register.
The document (commonly known as "the bible") that seemingly nobody wants to read has the following: Serial Data Buffer The Serial Buffer is actually two separate registers, a transmit buffer and a receive buffer. When data is moved to SBUF, it goes to the transmit buffer and is held for serial transmission. (Moving a byte to SBUF is what initiates the transmission.) When data is moved from SBUF, it comes from the receive buffer The amazing thing is that a quick look at "the bible" gives instant answers, posting in a forum, you have to wait a while. Erik here are the links to "the bible" Chapter 1 http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_ARCH_1.pdf chapter 2 http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_PROG_GUIDE_1.pdf chapter 3 http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf