I revisited an older device that I made and discovered, that I had an 8 Ohm speaker connected directly to ground and an IO pin of an Atmega328P. According to my calculation that means that the pin would have to source 625 mA, which is way above the 40 mA that any single port should be able to source and even above the 200 mA that the Vcc and GND support. Yet it somehow worked and the chip seems to be working just fine. The application uses a duty cycle of 50%, so in the best case it would use maybe 312.5 mA, which is a little better but still way above the ratings.

So my question is, what happens if the output pin is asked to source more than it's rating?

I've seen chips that just release their magic smoke while others just can't keep up with supplying that kind of voltage, so only the voltage drops without any other problems. How does the Atmega328P handle this?

The Atmega clearly didn't burn through, but what other kind of damage should I expect?

  • It is not good, but the effective internal impedance means that when facing such a load the voltage of the pin will not be at the supply rail and so the current will be less than you calculated. – Chris Stratton May 24 '16 at 15:32
  • Your math is off. You would only draw 150mA. – Ignacio Vazquez-Abrams May 24 '16 at 15:33
  • @IgnacioVazquez-Abrams: How so? According to Ohm's Law 5V / 8Ohm = 625 mA. Where is my calculation off? – Dakkaron May 24 '16 at 15:44
  • @ChrisStratton: Sounds interesting. Do you have more details on that? – Dakkaron May 24 '16 at 15:44
  • 1
    You forgot to account for the 25ohm output impedance of the chip. – Ignacio Vazquez-Abrams May 24 '16 at 15:47

There's a few crude calculations you can do using some numbers from the datasheet.

This graph is in the datasheet: enter image description here

It shows the voltage dropped by the high-side MOSFET driver in the IO pin for different amounts of current draw. From that we can get its resistance R(DSON).

For instance at 10mA, at 25C, the output voltage would be 4.75V. That's a 0.25V drop from the 5V supply voltage. So we can calculate the resistance as:

  • R=V/I = 0.25V / 0.01A = 25Ω

Now we have that resistance we can use it to calculate the actual current from the IO pin with an 8Ω load. Simply add the two together:

  • 25Ω + 8Ω = 33Ω

Now we can calculate the current through that circuit:

  • I=V/R = 5V / 33Ω = 0.152A

That is, of course, way above what the IO pin can actually supply (or so the datasheet says).

So what happens? Well, two things, basically:

  1. The voltage on the IO pin will be below the 4.2V specification for the minimum of an output pin when HIGH, and
  2. It will get hot.

The actual voltage will be, of course, V=I×R = 0.152A × 25Ω = 3.8V droped, so 5 - 3.8 = 1.2V

What is more critical, though, is the heat. 152mA through a 25Ω resistance generates P=I²R = 0.152 × 0.152 × 25 = 0.5776W. That's quite a lot. Enough to melt the internal circuits in the chip and release the Magic Smoke™.

Running at 50% duty cycle, though, makes a difference. That's 50% of the power, which makes a big difference to the heat.

What would the actual allowable heat be? Well, at 40mA, with 25Ω, that is 0.04 × 0.04 × 25 = 0.04W.

So you're generating more than 14 times the amount of heat you are allowed to. Even at 50% duty cycle, that's over 7x the limit.

Will it kill the chip? Well, possibly, possibly not. It depends how rugged the chip is and how well it can withstand the heat. Short bursts may be OK since the heat doesn't build up enough to melt things. Extended use, though, will make it get too hot, and things will go pop.

  • Your duty cycle analysis is incorrect. At moderate PWM rates, when it is on it is still running at full power, however it is running at full power only half the time. Hence half the heat, not a quarter. – Chris Stratton May 24 '16 at 16:33
  • @ChrisStratton It's actually not as simple as either situation - you have to take thermal conductivity, dissipation, etc into account. Instantaneous power (which would be half) is not the same as dissipated heat power, since that is subject to time and the aforementioned parameters. Either way, though, it's still exceeding the limits by a considerable margin. – Majenko May 24 '16 at 18:02
  • Wow! Thanks for that amazing answer! That was much more than I expected! So basically, I am just really lucky that this is still working. I will add some resistance before using it the next time. – Dakkaron May 24 '16 at 18:30
  • 1
    @Dakkaron - while far outside the specs, the reality is that shorting a pin to ground does not usually damage a device such as this, at least in the short term. Of course when you go outside the specs, there are no guarantees, and even apparent functionality no longer implies complete reliability. – Chris Stratton May 24 '16 at 18:33
  • 1
    That is very true. I am getting my terminology mixed up somewhat. Feel free to edit the answer and improve it. – Majenko May 24 '16 at 18:54

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.