I am testing a routine with serial interrupt and I notice that the value is not transferred from SBUF. I notice this in uVison debug. What's happen? Please help me. follow my parcial intr routine
if(RI) { c = SBUF; //<-- here is my problems RI = 0; if (istart + ILEN != iend) { inbuf[iend++ & (ILEN-1)] = c; } }
Marcio, The language in your last post was very difficult for me to understand. I'll try to take it point-by-point: ...the debug do not more gave me access to see the interrupt reception routine (I think this is the normal)... I don't understand what this means. Changing the name of a variable shouldn't do anything with regard to the visibility of the ISR. When you say "the debug" do you mean the uVision simulator? When you say "when I get the appropriate line" what line are you talking about? Is this inside the interrupt service routine? Is this in your main code? What is the specific line before which you change the SBUF data? There's a very important point which several people here have tried to point out to you: SBUF is NOT a single register. It is TWO registers. One is accessed when you perform a write and a completely different one is accessed when you perform a read. So... WRITING something to SBUF has NO BEARING one what you will READ back from the SBUF. That is completely dependent on what's coming in the serial channel. So... here's what will happen with your scenario. You open the serial channel window and enter a value into the SBUF register. You then click RI to pretend that a character has been received. Your ISR runs and you execute a line like "c = SBUF" and you read zero. That's because NONE of what you've done has modified the contents of the READ version of the SBUF. I know there's a significant language barrier between us, but I hope I've made at least something clearer.
Let us try "the hortses mouth" an extract from "the bible" "The serial port receive and transmit registers are both accessed at Special Function Register SBUF. Writing to SBUF loads the transmit register, and reading SBUF accesses a physically separate receive register." Erik
And a quote from the actual Bible says: The leader of the people of Naphtali is Ahira son of Enan. His division numbers 53,400. but I could see how someone could read the entire text and somehow miss that one. Go figure.
"I could see how someone could read the entire text and somehow miss that one." The reference is Numbers chapter 2, verses 29b-30. I see what you're saying, but I just tried it: it took just over 5 minutes to find it - and that included fetching my Bible and leafing through the pages. I have read the whole text, and didn't know that verse by heart (no surprise there, then!) - but I had a good idea where it might be found (Numbers). That's the point: it's not expected that you know the 8051 "bible" by heart - but it is expected that you make it your first point if reference for any query. Plus, it's a lot shorter than the real Bible - and, being PDF, has a Search facility... And, for this particular case, it also has diagrams to illustrate the point!
Alright.. you found it. Here's the real point of my test: this time don't take out your Bible. Now tell me what the context of that passage is (i.e. what's going on, what's being talked about)? I understand that eventually people need to develop an instinct to just sit with the datasheet for their chip open and refer to it as needed, but I know that when I started there were plenty of things I didn't understand even after reading them, until I hacked and tried and finally got something to "work." I'm just trying to describe things for the OP in a bit more detail than might be included in the documentation. I know it's a simple concept, but there's also clearly a language barrier for Marcio with regard to English. Erik's follow-up for my long-winded post with the couple sentences from the datasheet doesn't seem to me to be designed to do anything other than humiliate the poster and that seems unfortunate.
Erik's follow-up for my long-winded post with the couple sentences from the datasheet doesn't seem to me to be designed to do anything other than humiliate the poster and that seems unfortunate. 1) no intention to "humiliate", I never have any desire to do so. I may be direct in my statements, but have never tried to humiliate anyone. I may not be very "sensitive" to questions that do not fully describe the background, but I will try as hard as I can to overcome a language barrier (as long as it is not SMS). 2) "the bible" explain SBUF from the opposite viewpoint (2 registers with one address, not one address with 2 registers), thus might be understood when approach 1 is not. 3) If there was any "intention" other than 2) it was to show that answers such as these can be foun in "the bible" Erik