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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/22/05 10:20
Read: times


 
#97800 - 0 and 1
Responding to: ???'s previous message
You should start by stopping to think of 1 as on and 0 as off. This is only beginners instinct, and in the practice of digital electronics it is usually the other way around (not restricted to the 8052 universe). Switch to think of 1 as inactive, and 0 as active. The important thing is that the 8052's I/O pin circuitry is designed singularly for this philosohy, and the 1 on, 0 off notion will get you in deep problems. So an input switch to 0V connected to a port pin is GOOD, a switch from a port pin to Vcc is BAD. Setting a pin to 1 in software is like deactivating that port pin (THAT'S WHY PORTS ARE INITIALIZED TO FF AFTER RESET!, your setting them to 00 is like switching them all ON), clearing it is like activating it. External electronics should be built so that they take HIGH as off, and LOW as on. So in the case of a LED, connect it from the port pin to Vcc. If you stick to this philosophy, there is no contradiction anywhere.
Switching to simplistic explanation here: A (standard) 8052 port pin is constructed internally as a pullup resistor to Vcc and a transistor to ground . You can open or close the transistor by software (the output function). So if you don't activate the transistor (write a 1 to the output), the port pin is weakly pulled to Vcc through the resistor. You will measure +5V on the pin on the outside, but because it is through a resistor, you can not connect any load to it, if you do the voltage will collapse. If you activate the transistor, the pin is strongly short circuited to ground. On the outside you will measure 0V, and because it is through the low ohmic transistor, you can actually let a lot of current flow from Vcc through the port pin to ground. Also, internally you can read the pin to see the logic level on it (the input function). If you have deactivated the transistor, you will see a 1, unless some external circuit, for instance a button, is pulling it to 0V, in which case you will read a 0. If you activate the output transistor (write a 0 to it) however, you will always read a 0.
Now do what Erik suggested, and read the &^$%@# 8052 Bible! (see links on this site). If you do a site search you will see that variations of this story are told to beginners over and over and over again, because it is one of the first pits beginners fall into.
You can not work with microcontrollers unless you are at least part electronics engineer. If you are not and want to work with controllers anyway, become one fast. Being a software guy only does not get you there alone.


List of 31 messages in thread
TopicAuthorDate
Help with Assembly Code            01/01/70 00:00      
   Just one question            01/01/70 00:00      
   REPLY            01/01/70 00:00      
      74HC244            01/01/70 00:00      
   Some Possibilities:            01/01/70 00:00      
   Don't be surprised ...            01/01/70 00:00      
      Do not use TABs!            01/01/70 00:00      
         Right, but I meant            01/01/70 00:00      
            in case of Keil            01/01/70 00:00      
               Sharp eye !            01/01/70 00:00      
   re:mehdi & don't be surprised            01/01/70 00:00      
      RC Reset!!!            01/01/70 00:00      
   could you explain            01/01/70 00:00      
   Port 1 output/input conflict.            01/01/70 00:00      
      port 0 assigned as output            01/01/70 00:00      
         hiding the point            01/01/70 00:00      
   RE: Input/Output port            01/01/70 00:00      
      infinite loop            01/01/70 00:00      
      port            01/01/70 00:00      
         terminology            01/01/70 00:00      
         re: Erik Malund            01/01/70 00:00      
            killing your '51            01/01/70 00:00      
               re: killing your '51            01/01/70 00:00      
                  Negative logic            01/01/70 00:00      
                  0 and 1            01/01/70 00:00      
            I know it is not "in" to read before act            01/01/70 00:00      
   Pullups?            01/01/70 00:00      
      Well ... maybe not with TTL ...            01/01/70 00:00      
         strictly speaking,for 74LS...            01/01/70 00:00      
         oh yes?            01/01/70 00:00      
   re: re: got it            01/01/70 00:00      

Back to Subject List