HI everyone!
I am workinf with Silabs 8051F020, and I need to use the uart1 shift register mode (mode 0). Everything seems to work fine, except that when I try to read the SBUF1 register and load it to a software buffer, i don't get anything. I am debugging on software, and loading myself the sbuf1 reg with a byte (0x51), and when i set the interrupt flag, it recognises a reception, but when it gets to the point
buffer = SBUF1;
i get 0x00 on buffer. i also checked that SBUF1 is loaded by posing the mouse over it's name Any ideas will be appreciated
Thanks
thx bible i already checked that but it doesn't say anything about errors like this
Read the bible again.
You somehow missed the following sentence - or possibly the implications from the sentence: "The Serial Buffer is actually two separate registers, a transmit buffer and a receive buffer."
i am probably missing the implicationes because i definetely read that. I also read that it only aplies for hardware, since the register you need to write or read is the same SBUF1 When you write SBUF like this
SBUF = 0x84;
You are writing the transmit buffer And when you read SBUF like this:
a = SBUF;
you are getting it from the receive buffer.
What am i missing?
You wrote:
I am debugging on software, and loading myself the sbuf1 reg with a byte (0x51), and when i set the interrupt flag, it recognises a reception, but when it gets to the point buffer = SBUF1; i get 0x00 on buffer.
There are one read-only and one write-only register sharing the same memory address. Writing to the write-only register does not mean that you can read this value from the read-only register.
So exactly how did you load 0x51 into SBUF1, and where would any data come from when you did read out 0x00 from SBUF1?
nonono that is not what i am trying to do. I need to communicate with a Real Time Clock, using the shift register mode, due to the need of the RTC to synchronise with the 8051. But right now, i am simulating the communication on the PC. I write to SBUF when I need to send any commands or data to the RTC, and the simulator works perfectly, automatically interrupting after 8 machine cycles. The transmission works. Now, when I try to read data from the serial port, I write with the debug tool, something on SBUF, anything, and i set the interrupt flag as if I had actually received something. The program moves to the ISR, and when it gets to the point that it actually reads the SBUF1, the variable that I am writing stays null, even though when I check the value contained on the register, it is the value I wrote with the debugger. Maybe I can not do that, write the register manually, but i remember the professor simulating serial com with PC and using this tool
Now, when I try to read data from the serial port, I write with the debug tool, something on SBUF, anything, and i set the interrupt flag as if I had actually received something.
That makes no sense. If the peripheral is simulated, you don't have to flag the interrupt yourself. So odds are you are writing to the wrong VTREG when you're trying to simulate incoming data.
what you say does make sense haha
I flag the interrupt because i want to check that what the ISR does is what i want it to do, and as i am not recieving anything i try that.
so what can i do to simulate incoming data? Which reg should I write so i can read it from the reciece buffer SBUF1?
Which reg should I write so i can read it from the reciece buffer SBUF1?
You should write to VTREG S1IN, I think. And you should have found that out by yourself when you read the documentation looking for this information.