Power Failure Detection Circuit via Flip-Flop
You can detect that the power has failed because the microcontroller is starting up.

If the power just came on, then it must have been off before. Therefore, there was a power failure.

Perhaps I haven't understood the question correctly.