This article explains the operation of a classic microcontroller power supply circuit, shown in the schematic below.
Initial State (Power Off)
Before the circuit is powered on, the "TEST" switch is open, and the MCU is not powered via VCC. At this point, the base of transistor T1 is connected to ground through R9 (100k), keeping it in a cutoff state. Since both the TEST switch and transistor T1 provide open paths, the base of T3 cannot be pulled low, so T3 also remains in cutoff. The +9V supply is isolated by T3 and does not reach the voltage regulator IC2, so the VCC output remains low.
Startup and Latching Operation
Pressing the "TEST" button starts the circuit. This action provides a path to ground for the base of T3 through R7 and the switch, causing T3 to conduct. The +9V supply then flows through T3 to the voltage regulator IC2, which outputs VCC to power the MCU. Once the MCU is running, it outputs a high level on its IO2 pin. This signal flows through R8, turning on T1. Now, even after the TEST button is released, the base of T3 has a path to ground through R7, LED1, and T1, creating a self-latching mechanism that keeps the circuit powered on.
Pressing TEST to start the circuit
MCU provides base voltage to T1 to keep T3 conducting
Software-Controlled Shutdown
To turn the circuit off, the MCU software can set the IO2 pin low. This turns off T1, which subsequently cuts off T3, removing power from the system. The MCU can also read the state of the TEST button via the IO1 port to determine if the user has pressed it. For instance, the software can be programmed to power down by setting IO2 low after detecting that the user has pressed and released the TEST button. This functionality also allows for features like an automatic power-off delay to conserve power.