1

According to the ATmega328P datasheet, the total current from all I/O pins must not exceed 200mA.

Let's say that an Output pin sources 30mA and an Input pin sinks 10mA. The total current should be 30+10=40mA or 30-10=20mA?

2

Neither. First, inputs don't draw current. Whether you're sourcing current or draining it, it will always be an output pin.

The 200 mA rule is probably determined by the bonding wires for the Vcc and ground pins on the die. That means that all outputs which are sourcing current shouldn't source more than 200 mA combined, as this current will have to enter the device through the Vcc pin.
Likewise all outputs sinking current shouldn't sink more than 200 mA combined, as this current will drain through the ground pin.

  • Could you possibly explain the "sourcing - sinking" difference? I thought than Output pins are sourcing current and Input pins are sinking. – user3060854 Apr 29 '15 at 19:31
  • @user3060854: in an input pin there doesn't flow any current. If an output pin is high it can provide current to a load connected to ground. It then sources current (which comes from the microcontroller's Vcc). When the output is low, it can draw current from a load connected to Vcc. It then sinks the current (and drains it to ground). – Joris Groosman Apr 30 '15 at 11:38
1

Usually you sum the magnitudes of the currents - so
|+30| + |-10| = 30 + 10 = 40 mA in your example.

Predictably but unfortunately. the principle of TANSTAAFL usually applies in such matters :-).

Such limitations are often (but not solely) dissipation based.
A low level output pin is dissipating ~= (Vo_low) x I low and
a high level pin dissipates (Vdd-Vo_high) x I_high.
For low currents versus I_pin_max, Voutlow is ~= 0 and Vouthigh is ~= Vdd.
As currents approach design capacities Voutlow starts to rise and Vouthigh starts to fall (due to the internal 'switch' not being able to handle the current) and dissipation rises.

IF you pulled a high pin fully low or a low pin fully high then
at 5V and 200 mA IC dissipation = 1 Watt.
Under that sort of abuse other bad things may happen.

There MAY be some specialist cases where you can treat SOME high and low currents as semi independent but this would need a good understanding of the IC and probably still lies outside specification.

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.