Q. Is there a way to run code when the external power supply is removed?
A. No, it is not possible. Removing the main power means removing the power from
the CPU core, so, no code can be executed. The VDD_SNVS_IN voltage only supplies
the 32kHz oscillator and SNVS module. When the main power is back, the processor
starts booting in normal cold boot.
Best Regards,
Artur