I have a 3.3V regulator which is driven by 5V from a DC power supply, and the DC PSU regularly outputs 50mA to operate the regulator, which supplies voltage to MCU and other devices.
The MCU has a GPIO pin which can push 20mA, and this pin drives a 20mA LED.
When LED is turned OFF, PSU outputs 50mA, but when I toggle the LED, so now the MCU drives the LED, the PSU suddenly outputs 110mA instead of the expected 70mA (50mA regularly + 20mA LED).
Do you know why is that?
I assumed that if MCU outputs addintional 20mA current, then the 3.3V regulator would output addintional 20mA current, and therefore the PSU would output addintional 20mA current.
Where is my mistake?
Are you measuring the current draw of the entire chip? What else is loading your other I/O lines. It has to be coming from somewhere. Perhaps you've inadvertantly grounded other I/O lines?
A PIC output can sink or source up to 25mA when its supply is 5V. But then the output voltage will have a loss of about 0.5V.
It might be able to sink or source 20mA when its supply is only 3.3V but its voltage loss might be 1V.