I have a ATMega128 and 5V VCC.
I would like the AVR to "detect" power out.
I do have one example, where there is voltage divider before the VCC regulator (regulator input is 12V) and a fairly large cap to give the MCU time to shutdown.
The problem is, when I'm using battery power, the regulator is not used and hence I can not use the voltage divider neither.
I also guess the Vref changes too if the VCC goes low?
So how can I detect (reliably) that the voltage has dropped below acceptable level?
Any code examples? ISR AD or what?