Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help me with I/O Please

  1. Jun 7, 2006 #1
    I'm doing a project of sorting objects, and this is the first time i'm working with microcontrollers. I am using AT89C52 microcontrollers. i just couldn't understand these statements in the datasheets.

    "When 1s are written to Port 2 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups."

    how am i supposed to use the port as inputs? what should i do when i want the pins as inputs, and also, what should i do when i want the pins as outputs?

    the port is an I/O pin. since i would be using the T2 and T2EX timers, can i simultaneously using some of port 2 pins as input (timer/counter) and the others as output?

    The datasheets could be obtained from www.atmel.com

    Thx b4.
     
  2. jcsd
  3. Jun 7, 2006 #2
    You've pretty much explained this yourself. When a 1 is written to the port, it is pulled high by a pullup resistor. Just read the port if you want to use it as an input. If you want to use it as an output, don't hook anything on it that will drive it. Just write to it.
     
  4. Jun 7, 2006 #3
    thanks for the answer. It is obvious, but it is just my first time using microcontrollers. i will try this right away.
    thanks again.

    Oh.. and one more thing. like i said before. can i use a port as an input and an output simultaneously? my mistake to mention timer 2 on port2. it is timer0 and timer1 that is on port3. can i use P3.4 and P3.5 as timers/counters while i use the other pins as input?
     
    Last edited: Jun 7, 2006
  5. Jun 8, 2006 #4

    berkeman

    User Avatar

    Staff: Mentor

    That generally depends on the microcontroller, so just read the datasheet and Programmer's Guide to find out. On most uCs, you an define port I/O directions on a pin-by-pin basis.
     
  6. Jun 9, 2006 #5
    okay... thanks
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Help me with I/O Please
  1. Please help me! (Replies: 1)

Loading...