I'm making an alarm clock with an ATMega32 (it's a "special" alarm clock). I'd like to add a battery backup circuit, like all the commercially available clocks have. Presumably, I'd use a 9 volt battery as the power source.
I'd like to detect that my +5v line driven supply has failed, switch to battery power, and shut off my power hungry peripherals with my software. I'm mainly interested in keeping the 32khz timer running and keeping track of time. Of course, when line voltage came back, I'd go back to normal operation.
I have a plain old fashioned transformer/rectifier/filter cap linear power supply and 7805 regulator supplying my 5 volts.
Anybody have any good ideas for a cheap, easy way to do this?