I am working on a project that uses a PIC24F mcu. The power to my pic is backed by a very large capacitor (1F). When there is a main power loss, I can sense that immediately via a port pin but the PIC itself stays powered for several minutes via the capacitor as the charge in the cap slowly dissipates.
Once I detect that the main power is cut, I want to perform some actions (several micro seconds only) and then stop the PIC from doing anything else (sleep or hibernate i guess). But as the caps charge slowly dissipates the power to the pic will VERY slowly decrease below 3.3V down to zero. At any point, if the main power is re-applied, the pic should detect it at the Port Pin, and restart normal operation. I am wondering what would be the best way to handle this in software? I know that the PIC has Brownout detection and some kind of Low Voltage Tracking but I don't quite understand how to use them.