Does an instruction like this: MOV P1.0, #1 makes the port P1 bit 0 High so i can drive an LED for example, or it just makes it FLOAT so i can use an external circuitry to light the LED. If so, does this mean that we can't output a "real" HIGH to the ports?

  • 2
    \$\begingroup\$ Surely this is answered in the datasheet! \$\endgroup\$ – Olin Lathrop Dec 20 '16 at 12:08
  • \$\begingroup\$ Please edit your question and add a link to the datasheet. \$\endgroup\$ – Bence Kaulics Dec 20 '16 at 13:04

The 8051 (original 'flavors') does not output a '1' with much drive capability. It is better to connect your LED + resistor from the output to Vdd and drive the pin low to turn the LED on. You could also add a pull-up to Vdd and shunt the LED, but that wastes power.

Edit: as per request, below is the i8051 I/O structure from the MCS-51 manual.

enter image description here

The strength of the pull-ups varies according to the type, but can be as high as 30mA nominal for the brief strong pull-up, and tens or hundreds of uA for the weak.

  • \$\begingroup\$ I know that microcontrollers "generally" can't drive LED's this way, i just want to know if the microcontroller pin acts as a FLOAT or HIGH if i used the instruction MOV P1.0, #1. \$\endgroup\$ – HumbleUser Dec 20 '16 at 12:15
  • \$\begingroup\$ It is weakly pulled to a high with a brief stronger pulse to high to drive external capacitance. So the answer is not so simple. \$\endgroup\$ – Spehro Pefhany Dec 20 '16 at 12:16
  • \$\begingroup\$ If it can't drive, then it can usually not sink current either. Just put a transistor/buffer in between the MCU and the LED(s). \$\endgroup\$ – Lundin Dec 20 '16 at 12:35
  • \$\begingroup\$ @Lundin In this case, the output is quite capable of sinking enough current to drive a modern LED. The p-channel drive is made deliberately weak. \$\endgroup\$ – Spehro Pefhany Mar 14 '17 at 12:50

It depends in the output pin driver.

  • If it is an Open-Drain type then the pin can either float or tied to ground.

  • If it is a Push-Pull then it is either tied to VCC or ground.

At many microcontrollers this can be configured so you should cehck the datasheet about the default setup.

  • \$\begingroup\$ Actually it is neither open drain nor push-pull. The 8051 uses pseudo-bidirectional outputs. \$\endgroup\$ – Spehro Pefhany Dec 20 '16 at 12:12
  • \$\begingroup\$ @SpehroPefhany That is an Open-Drain type with internal pull-ups? \$\endgroup\$ – Bence Kaulics Dec 20 '16 at 12:16
  • 1
    \$\begingroup\$ It's even a bit more convoluted- there is a weak pull-up MOSFET and a stronger MOSFET in parallel that is pulsed on during low-to-high transistions to quickly charge capacitive loads. \$\endgroup\$ – Spehro Pefhany Dec 20 '16 at 12:19
  • 1
    \$\begingroup\$ Someone else edited that into my answer and it is a simplified view. I've added a more complete schematic and a link to the original data to my answer here. \$\endgroup\$ – Spehro Pefhany Dec 20 '16 at 12:46
  • 1
    \$\begingroup\$ @SpehroPefhany Thank you I appreciate you efforts. \$\endgroup\$ – Bence Kaulics Dec 20 '16 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.