Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/18/11 11:48
Read: times


 
#182886 - Too simplified view on input/output
Responding to: ???'s previous message
Ahmed Naser said:
andy: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 that way it won‘t accept any incoming data


Not at all. The port pins are always both inputs and outputs. You write a 0 to it because you want to drive it strongly low. Meaning the port pin would fight with another output in this state.

You write a 1 to it because you either want it as a high output (with a weak pull-up that might need external help in some situations) or because you want to use it as an input, in which case the external electronic will be able to win over the weak pull up and draw the port pin high or low as required.

So writing a 1 means it is both a input (accepting low or high from the outside) or an output trying to keep the signal high.
And writing a 0 means it is an output driven low, but with strong enough drive that you get into troubles if you try to force it high.


List of 10 messages in thread
TopicAuthorDate
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      

Back to Subject List