turning off/on mcu by software?

Our system has an on/off button. This button , should work like this- when you switch(/push) to on, it will immediately turn on the mcu . But when you want to turn off, i will have to check some conditions in the software ,and then decide- allowing the turning off, or , wait for a few seconds and then turn off.

I am looking for a simple way (circuit) to do that .(something with a MOSFet and capacitor ? )

Thanks a lot .

You can do this sort of thing with a component called a latching relay. You want the sort with two coils, one to turn the realy on and the other to turn it off.

Hi, Google mcu power self power down

http://letsmakerobots.com/content/self-shutting-down-arduino-or-any-other-microcontroller-matter

http://electronics.stackexchange.com/questions/34866/how-to-switch-power-of-microcontroller-by-button

Tom.... :)

thanks a lot .