??? 07/18/11 13:26 Read: times |
#182887 - Incorrect - look again! Responding to: ???'s previous message |
Ahmed Naser said:
so what i understood is that when ever i want to use any port as output we write a 0 to it to make it open drain No - read that FAQ again: http://www.8052.com/faqs/120176 The output is always open-drain! Writing a '0' to it just turns the open-drain device ON. if i need to use it as input i write 1 to it in order for the port to accept incoming data No. Again, the port always accepts incoming data - but, with the open-drain device ON, the only state that it can possbily be in is '0'. (unless you damage it). See also the link to Chapter 3 of the so-called "bible" for the 8051. And also this FAQ: http://www.8052.com/faqs/121619 - which explains the operation of the 8051's Quasi-Bidirectional IO pins. Note that this is a distinctive feature of the 8051 - it is not like other processors where you do have to specifically configure pins as either "input" or "output". This is why it is important not to think like that - because it isn't like that! This also explains why 8051 ports can sink but not source current. Also, note that some (many?) modern 8015 derivatives do have an option for ports to be unidirectional - so that they do need to be specifically configured as either "input" or "output". |
Topic | Author | Date |
a keyboard question AT89C51 | 01/01/70 00:00 | |
image of circuit | 01/01/70 00:00 | |
use P0 not P | 01/01/70 00:00 | |
Parity flag | 01/01/70 00:00 | |
How do you write a number to the parity flag? | 01/01/70 00:00 | |
PSW | 01/01/70 00:00 | |
Don't say, "make port 0 input" | 01/01/70 00:00 | |
port 2 not port 0 | 01/01/70 00:00 | |
Too simplified view on input/output | 01/01/70 00:00 | |
Incorrect - look again! | 01/01/70 00:00 |