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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/18/06 04:56
Read: times


 
Msg Score: +2
 +2 Good Answer/Helpful
#118486 - input/output
Responding to: ???'s previous message
Hi Munaza,

I am guessing that you are thinking of the port of the µ-controller as if it were the port of a digital i/o card. Stop thinking of it like that. Instead, think of the port as a register associated with a data bus. Each bit in the register is tied to one line of the bus.

Now, if anything tied to the bus pulls one of the lines low, that line will cause anything that "reads" the bus to read that bit as a 0. And if the µ-controller reads the port register tied to that bus, it too will read that bit as a 0. Of course, if you put a 0 in any of the bits in that register, then you will still read that bit as a 0.

This is why you want to load 0xFF into port 0 anytime you aren't actively writing something to the data bus. This is not the same as pulling all of the lines high. Instead you are allowing them to go high, as long as nothing else on the data bus is pulling any of them low. If you're familiar with tri-state devices, think of writing a 1 to one of the port bits as putting that bit in the Hi-Z state.

So, it really isn't like working with a digital i/o card. You don't have to program the µ-controller ports as input or output. If you MOV A, P0, then you read the data bus and used P0 as input. If you MOV P0, A, then you wrote something to the data bus and used P0 as an output.

Some might tell you to think of loading 0xFF to P0 as "putting P0 in the input mode." Don't think of it this way. If you do, it will only be a matter of time before you're trying to figure out why something else on the bus isn't working when the only problem is that you never put the port back into "INPUT" mode since you had no plans to read anything. Instead, think of putting the bus back into HI-Z mode after your finished writing to it. And just stop thinking about putting it in either INPUT or OUTPUT modes at all.

Good luck,

Joe

List of 30 messages in thread
TopicAuthorDate
can P0 of c51input/output at same time            01/01/70 00:00      
   Why the 8255 ?            01/01/70 00:00      
      how to interface 8155            01/01/70 00:00      
         what does that have to do with this thread ?            01/01/70 00:00      
         Clearly, you should read the datasheet(s)            01/01/70 00:00      
   input/output            01/01/70 00:00      
      That's a very good put it!            01/01/70 00:00      
   Hints...            01/01/70 00:00      
      is 8255 really a bad idea???            01/01/70 00:00      
         Maybe            01/01/70 00:00      
            possibilities            01/01/70 00:00      
         Depends on your actual needs            01/01/70 00:00      
         Have you really considered the economics?            01/01/70 00:00      
            not all of us            01/01/70 00:00      
               the REAL question is ...            01/01/70 00:00      
                  answers            01/01/70 00:00      
                  8255 main drawback            01/01/70 00:00      
      Sorry, wrong link!            01/01/70 00:00      
      74HC595            01/01/70 00:00      
         As long as we must guess...            01/01/70 00:00      
            a little correction kai            01/01/70 00:00      
   Serial I/O Expanders            01/01/70 00:00      
      laser diodes/ldr sensors            01/01/70 00:00      
         Inductive loops            01/01/70 00:00      
            need little more info on inductive loop            01/01/70 00:00      
               Inductive loop            01/01/70 00:00      
                  basically an inductive loop is the same            01/01/70 00:00      
   I2C I/O expander            01/01/70 00:00      
      echo            01/01/70 00:00      
   60LEDs: MAX7219            01/01/70 00:00      

Back to Subject List