Hi, in a serial communication program, do I have to "SETB P3.0" in order to receive from the serial port ??
Presumably, you're talking about a chip where RxD shares a pin with P3.0 as an "Alternate Function" ?
Look on page 3 of chapter 3 (Hardware Description) of the so-called "bible" for the 8051:
"The alternate functions can only be activated if the corresponding bit latch in the port SFR contains a 1. Otherwise the port pin remains at 0"
www.8052.com/.../120112
Also, look at this post, and follow the links, about how the 8051 Quasi-Bidirectional port pins work: www.8052.com/.../182887
It is important that you take time to understand this - as it is quite different from most other architectures!
It has nothing specifically to do with Keil.
But variant of 8051 does matter. Some 8051 may behave similarly like a traditional 8051, but automatically switch to real push-pull outputs as soon as an alternative function (like UART) is activated to make use of the port pins.
It really does not hurt to give full information when asking a question - and the exact processor model should alwaysw be given.
Yes - the information I gave does relate to the "Classic" 8051.
As always, you need to check the specific datasheet for the particular chip that you are actually using to verify whether it follows (or can follow) the "Classic" 8051 way...
Doing it the "classic" way shouldn't hurt even if the chip has logic to automatically switch to conventional push-pull outputs.
THanks for replies guys, - I am using AT89C51 device which uses P3.0 as serial RxD bit. - My program tries to receive a byte from Hyperterminal (PC), but it does not. - But it successfully sends bytes - I just coulnt understand that much the link you gave, because I'm not that familiar with circuits, transistors. - So, my question is a software one: We are making a port bit HIGH whenever I want to get an input, Do I need to do this when using RxD pin. Because I dont remember so(I programmed these devices more than 3 years ago), and couldnt find a quick solution in internet.
I appreciate any help
Well, this bit seems pretty clear and explicit:
Have you also enabled the receiver?
Serial comms is a very common requirement on any microcontroller, and there's loads of examples readily available - including for the 8051.
You are working at the level where that kind of understanding is imoprtant!
You need to either gain some understanding, or ensure that your team includes someone with that understanding.
- All right, When I go back to LAB, I'll try it out (setting P3.0) By the way, yes, I have enabled the receiver using SCON register.
should, of course, be: "important".
Here's some basic electronics links:
http://www.kpsec.freeuk.com/ www.electronics-tutorials.ws/ www.google.com/search
But variant of 8051 does matter with this verbiage it does "do I have to "SETB P3.0"" some chips (e.g. f12x) have the UART on other pins.
Erik
and some chips have more than 1 UART - so "the UART" is meaningless!
and more modern chips often have more things that need to be configured; eg, www.8052.com/.../182918
So, again, it really is important to state exactly what chip you are using!
"how the 8051 Quasi-Bidirectional port pins work"
for signaling purposes (low current), you can easily write all your code, pretending that there is a direction register on the 8051. for example, all the code I have written sets a _DDR register, even for 8051.
this allows me to write code that works for a variety of chips, including the 8051.
Yes - so long as you're clear that you're just pretending!
Some modern 8051 derivatives also have (the option of) ports with a real direction register...
"for example, all the code I have written sets a _DDR register, even for 8051"
How does that work when you "set" the pretend DDR for output?
"How does that work when you "set" the pretend DDR for output?"
nothing. absolutely nothing.