My wife wanted a single button control for the flashing bike flag light circuit I built for her using the MSP430 and some 3 watt leds. I came up with this simple circuit which allows a single momentary switch to both turn on and turn off the power to the system and also function as a digital input to the MSP430 as well (to control the pwm (brightness) of the leds for example). Breadboarded, the circuit works as expected, and seems to consume nanoamps if anything when powered off (leakage current of the pmos). I suspect I do not really need R1, as the opto transistor would just have the dc current through R2 plus the pulse current from discharging the gate capacitance of the pmos, and anyway, the base current is limited by the light from the led in the opto which should limit the collector current as well. But in any case, 100 ohms works as is.
The circuit is very basic...when the momentary switch is pressed, the pmos gate is pulled low causing the channel to conduct, supplying power to the 3.3V regulator which in turn causes the msp430 to power up. The first line of code in the MSP430 outputs a high signal on the latch line which activates the opto which keeps the pmos gate pulled low even after the momentary switch is released. During normal power on operation of the MSP430, pressing the momentary button pulls the microcontroller line low (msp430 internal 47K pullup turned on). This is where D1 and D2 come into play. D2 keeps the opto from pulling the microcontroller input line low and D1 prevents the msp430 from seeing the battery voltage through the 10K resistor R2 (not sure exactly what this would do...possibly without D1 the MSP430 would power up slightly through the 10K resistor and it's pullup logic even with the pmos off).
Anyway, as always, appreciate any comments on improvements although it seems to work perfectly as is. To turn off the power to the system requires the momentary switch to be held down for greater than 1 second, which the msp430 monitors using one of the timers. Another added benefit is by using the watchdog timer with a slow input divided clock, the bike lights will auto shut off after about 2 hours.
Just seemed like a useful beginner circuit to share.