# How to relate Pwm on time to maximum current ratings?

I will try to make it more explicit with an example. Imagine we have a microcontroller Atmega328P and one of its pin is set as output pin. And when we investigate about it we find that max current a pin can source is 40mA.

Now we also know that the average current through a resistive load is (PW/T)*(V/R) where PW is pulse width T is period of the PWM and V is 5V and R is 62 Ohm.

Now if PW = T the current becomes 80mA. But if PW = 0.2*T the current becomes 16 mA. But in the second case if PWM is 10 seconds and T is 50 seconds, it is still not okay.

So my question is how can we know the max peak current for known duration? I hope it is clear what Im asking. If we take average we conclude 16 mA is fine but it seems if PW is not short enough the current will be 80mA. Is there a relationship between PW and max current ratings?

• If I feel I have to worry, I use a transistor instead of driving direct from the MCU pin. You don't have good specs on MCU pins to really know. The peak can still be tricky since what prevents you from having an infinite high peak for infinitesmal time is silicon imperfections which makes hot spots that are too fast for the heat can distribute and equalize. MCU pins aren't made to be pushed. I wouldn't even want to get to 80% of their continuous rating, let alone exceed it. Nov 2 '19 at 19:37

In this case it is more reliable to use current amplifier using for example npn transistor. 