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
 
I have recently moved into a new (rather ancient) house and had a few trips of my Residual Current breaker. I dug out my old Socket tester which tell me the three pins are correct. But then the Red warning light tells me my socket(s) fail the loop test. I never had this before but my last house had an overhead supply with no Earth from the company. The tester said "get this checked" and the man said the (high but not ridiculous) earth resistance was acceptable. I stuck a new copper earth...
Thread 'Electromagnet magnetic field issue'
Hi Guys We are a bunch a mechanical engineers trying to build a simple electromagnet. Our design is based on a very similar magnet. However, our version is about 10 times less magnetic and we are wondering why. Our coil has exactly same length, same number of layers and turns. What is possibly wrong? PIN and bracket are made of iron and are in electrical contact, exactly like the reference design. Any help will be appreciated. Thanks. edit: even same wire diameter and coil was wounded by a...
Thread 'Beauty of old electrical and measuring things, etc.'
Even as a kid, I saw beauty in old devices. That made me want to understand how they worked. I had lots of old things that I keep and now reviving. Old things need to work to see the beauty. Here's what I've done so far. Two views of the gadgets shelves and my small work space: Here's a close up look at the meters, gauges and other measuring things: This is what I think of as surface-mount electrical components and wiring. The components are very old and shows how...
Back
Top