But I'd be interested to know how they behave as the current is increased beyond 20mA; basically, is a single pin short-circuit proof (to ground or Vcc)?
The outputs are not short circuit proof. Currents above 20mA increase the temperature notably, in conjunction with adjacent outputs, with hard to control effects over time (positive feedback).
At 5V the output drivers' on-resistance is very roughly 40 ohms - the output drivers are just MOSFETs so they behave resistively when on, but as the graphs show this resistance depends strongly on temperature. (And the temperature of the output drivers will depend on the current flowing).
The phenomenon called thermal runaway (a chain reaction). If you operate the pin beyond the prescribed ratings, the junctions of the output transistor undergo thermal runaway and finally the pin gets damaged.
28.2 DC Characteristics (Continued) Although each I/O port can source more than the test conditions (20mA at V CC = 5V, 10mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed: ---> ---> Pins are not guaranteed to source current greater than the listed test condition.
Therefore, for >20mA:
Keep output steady state. I can attest to this, switching activity can latch-up the port.
Together with the external (dominant) load the current reduction is not so high.
For 20mA @ 5V a total resistance of 250 Ohm is required.
A drop of 0.45V @ 25° equals 9mW and an internal resistance of 22.5 Ohm, external resistance of 227.5 Ohm.
At 125° the drop is 0.65V equivalent to 32.5 Ohm and a total resistance of 260 Ohm. That means 19.2mA @ 5V and 12mW @ 0.62V (see diagram). The power increases by 30% even if the internal resistance increases by nearly 50%.
Thanks, that kind of answers my question. I wondered if the output would saturate, but from this example it seems as @MarkT says, they are working in the resistive region.
No, the current drops as the resistance rises given a fixed supply voltage in a short circuit situation, or overload condition. In a dead short the pin is well past its absolute maximum anyway so you know the output driver is cooking itself from the get-go.
Only if the load were constant-current sink would runaway be on the cards, but it would have to be voltage runaway.
When you overload the pin (i.e. short to power supply) it gets to the saturation region. The maximum current you get from a pin (with supply 5 V) is about 90 mA with direct short to GND. From my experiment it does not increase significantly when you get under 2V. There are traces taken for another thread (I don't remember which one and if I really showed it):
Yellow trace is pin voltage, blue trace is shunt voltage = current. Pink (purple?) trace is yellow/blue = driver resistance.
At start of the trace the pin is OUTPUT HIGH, cap is fully charged, no current flows. Pin is written LOW, discharging the cap, showing voltage/current dependence. You can see the current is about constant until the pin voltage drops to about 3 V.
EDIT: When rethinking this I noticed the traces don't match the schematic exactly: the blue trace should be inverted. In reality the scope ground was probably where the "Blue" label is on the schematic and blue probe was connected to the circuit ground.