2
\$\begingroup\$

I'm playing around with an Atmel 89C microcontroller. The datasheet indicates a port can sink 20 mA in total. As an output with a load connected to the pin, when a 1 is written to it, the load is connected to the pull-up resistor.

I've seen the value of 10k as the effective resistance of the pull-up. But this would be 0.5 mA (@ 5V), which is very low.

Is the effective value of the pull-up much lower than this or am I misunderstanding something?

\$\endgroup\$
6
  • 1
    \$\begingroup\$ What does the datasheet say? \$\endgroup\$ Oct 9, 2016 at 14:33
  • \$\begingroup\$ .5 mA is not really high but it isn't really low either. .25 mW is quite a bit to be using in each digital line if you're trying to make a battery powered device, \$\endgroup\$
    – The Photon
    Oct 9, 2016 at 16:02
  • \$\begingroup\$ @BruceAbbott The datasheet is not particularly edifying in this case because it specifies the parameters of a model that is not obvious to the user unfamiliar with the old NMOS MCS-51 processors. \$\endgroup\$ Oct 9, 2016 at 18:31
  • \$\begingroup\$ @ThePhoton Battery drain was what had me thinking of this at first, I'd be using about 8 outputs and was curious to the current drain in an 'idle' state. \$\endgroup\$
    – carpboy
    Oct 11, 2016 at 2:31
  • \$\begingroup\$ I meant to say I was thinking of inputs in this sense - being held high and consuming energy. \$\endgroup\$
    – carpboy
    Oct 11, 2016 at 3:18

1 Answer 1

6
\$\begingroup\$

Your understanding is fairly close to reality. The 89C51 has 'pseudo-bidirectional' I/Os- quite familiar to ancients who have worked with the NMOS MCS-51 Intel series. There is no input mode vs. output mode - no DDR (TRIS) register. To use a pseudo-bidirectional pin as an input you just write a 1 to the output latch and read the pin state.

In fact, there is no pull-up resistor per-se rather there is a weak p-channel MOSFET that acts similarly to a pullup resistor. The transistor is made to have a very low Idss so it acts more-or-less like a constant current source when the latch output is high and the pin is lower than a couple volts due to external loading.

schematic

simulate this circuit – Schematic created using CircuitLab

The maximum current to ground is 50uA, so the Idss of M1 < 50uA. The minimum current at 0.75 Vcc is 25uA and at 0.9Vcc it is 10uA minimum. That brackets the current behavior of the output pretty well. With the output latch set to 1, we have (assuming a 5V supply) :

Vo = 0V 50uA maximum -> Requiv > 100K with 5V across it

Vo = 3.75 25uA minimum -> Requiv < 50K with 1.25V across it

Vo = 4.5V 10uA minimum -> Requiv < 50K with 0.5V across it

(I'm getting these numbers directly off the datasheet) So it's similar to a 50-100K resistor in behavior.

enter image description here

You are correct that's much to drive anything when high. In fact it's not even enough to rapidly drive the capacitive load of a trace and a few inputs. For that reason, when the output latch switches from low to high, the transistor M2, which is a 'strong' MOSFET is very briefly switched on to supply the charge current. Then it is switched off and M1 remains on. So a brief spike of current comes out of the pin when it is supposed to go high. That current (through M2 in my schematic) is a maximum of 650uA when the output is at 2V. So M2 behaves a bit like a resistor that is more than 4.6K for the brief time it is on.

TL;DR

You are correct that the outputs (Ports 1, 2, 3) have very little source drive capability. If you want to switch a lot of current (such as an LED + resistor) connect it between Vdd and the output. You can drive the base of a PNP transistor with base resistor or the gate of a P-channel MOSFET if you need to source a lot of current. Port 0 doesn't have M1 or M2 - it's an open drain I/O.

\$\endgroup\$
4
  • \$\begingroup\$ Thank you for the great explanation and time taken to make it. \$\endgroup\$
    – carpboy
    Oct 11, 2016 at 20:50
  • \$\begingroup\$ I am wondering about several things. First off, how can several mA be driven through M1 with its 50 uA limitation? I also am not sure as to the difference of the 'high voltage' and 'low voltage' current values. \$\endgroup\$
    – carpboy
    Oct 11, 2016 at 21:09
  • \$\begingroup\$ M1 can't supply mA. The pin can't supply mA. The pin can only supply hundreds of uA for a few microsconds, then tens of uA. It can sink many mA (M3). \$\endgroup\$ Oct 11, 2016 at 21:15
  • \$\begingroup\$ As to the voltage/current- a 50K resistor to +5 has a curve that is a straight line. 0uA at 5V and 100uA at 0V. The MOSFETs don't behave quite like a resistor - the curve is not a straight line. You can just think of it as a resistor if it makes it easier, it doesn't make much difference 99% of the time. \$\endgroup\$ Oct 11, 2016 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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