Understanding and Using AT89C52 Microcontroller Ports for Beginners

  • Thread starter Thread starter beluluk
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the use of AT89C52 microcontroller ports, specifically focusing on how to configure and utilize these ports for input and output operations in a project involving sorting objects. Participants seek clarification on the functionality described in the datasheets and the practical implementation of these features.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant expresses confusion regarding the operation of Port 2 pins as inputs and outputs, referencing specific statements from the datasheet about internal pullups and current sourcing.
  • Another participant suggests that to use a port as an input, one should write a 1 to the port, which activates the pullup resistors, and to use it as an output, one should simply write to the port without connecting anything that would drive it.
  • The original poster acknowledges the advice but seeks further clarification on whether it is possible to use some pins of a port as inputs while others are used as outputs, particularly in relation to timer functions.
  • A later reply indicates that the ability to use a port for both input and output simultaneously generally depends on the specific microcontroller, recommending that the datasheet and Programmer's Guide be consulted for detailed information.

Areas of Agreement / Disagreement

Participants generally agree on the basic functionality of the ports but have not reached a consensus on the simultaneous use of input and output on the same port, as it appears to depend on the specific microcontroller's capabilities.

Contextual Notes

Participants reference the datasheet for the AT89C52 microcontroller, indicating that understanding the specific configurations and capabilities of the microcontroller is essential for proper implementation.

beluluk
Messages
27
Reaction score
0
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.
 
Engineering news on Phys.org
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.
 
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:
beluluk said:
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?
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.
 
okay... thanks
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
2K
Replies
37
Views
7K