Understanding and Using AT89C52 Microcontroller Ports for Beginners

  • Thread starter Thread starter beluluk
  • Start date Start date
AI Thread Summary
The discussion focuses on using the AT89C52 microcontroller ports for a sorting project. To use Port 2 as inputs, a '1' should be written to the pins, allowing internal pull-ups to pull them high, while externally pulled low pins will source current. For outputs, simply write to the port without connecting anything that drives it. It is possible to use some pins as inputs and others as outputs simultaneously, depending on the microcontroller's specifications, so consulting the datasheet is essential. The user acknowledges the guidance and plans to implement the advice in their project.
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
 
While I was rolling out a shielded cable, a though came to my mind - what happens to the current flow in the cable if there came a short between the wire and the shield in both ends of the cable? For simplicity, lets assume a 1-wire copper wire wrapped in an aluminum shield. The wire and the shield has the same cross section area. There are insulating material between them, and in both ends there is a short between them. My first thought, the total resistance of the cable would be reduced...
Hey guys. I have a question related to electricity and alternating current. Say an alien fictional society developed electricity, and settled on a standard like 73V AC current at 46 Hz. How would appliances be designed, and what impact would the lower frequency and voltage have on transformers, wiring, TVs, computers, LEDs, motors, and heating, assuming the laws of physics and technology are the same as on Earth?
I used to be an HVAC technician. One time I had a service call in which there was no power to the thermostat. The thermostat did not have power because the fuse in the air handler was blown. The fuse in the air handler was blown because there was a low voltage short. The rubber coating on one of the thermostat wires was chewed off by a rodent. The exposed metal in the thermostat wire was touching the metal cabinet of the air handler. This was a low voltage short. This low voltage...
Back
Top