We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I write a C application for the Cygnal C8051F126( and I'm having some problems with writeng data to SBUF0 A simple example in C code is here: SFRPAGE = UART0_PAGE; SBUF0 = 0x12; On disassembler window I see something like this: MOV SFRPAGE(ox84),#0x01 MOV SBUF1(0x99),#?C_PBP(0x12) and ... SBUF0 not modified. If I change in to UART0 to UART1 and SBUF0 SBUF1 , - SBUF1 doesn't modified also. This is not a bug...? What is it? Thanks in advance, MVM
"I see something like..." Use cut-and-paste to post the exact text, then we could see exactly what you get - instead of something like what you get. There's no point us trying to debug your typos!
and ... SBUF0 not modified Of course it is not. read up on this in "the bible" chapter 3. 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
There are two physical buffers hiding behind the SBUF0 address. If you read SBUF0, you get the value of the receive buffer. If you write SBUF0, you set the value of the transmit buffer. So, you can never read the value that you just wrote into SBUF0; the read comes from a different set of bits than the write. This trick of sharing one address is (or at least was) moderately common, especially for simple devices like UARTs and devices of the vintage of the 8051.
"There are two physical buffers hiding behind the SBUF0 address: If you read SBUF0, you get the value of the receive buffer; If you write SBUF0, you set the value of the transmit buffer." This is clearly illustrated in Figs 13-16 of the 80C51 Family Hardware Description (Chapter 3 of "the bible"): http://www.semiconductors.philips.com/acrobat/various/80C51_FAM_HARDWARE_1.pdf Pages 9-15 of this document (which includesg those figures) describe the 8051 serial interface in detail.