Storing data in flash at powerfail on nrf51/nrf52


For bluetooth mesh it would be good to save the replay protection list
to a dedicated flash page. This save would only be done in the case of
a powerfail or a reboot.

nrf51/nrf52 have a powerfail warning but it is unclear to me how to
use it. I know that if the powerfail warning appears writes to flash
are disabled. So to make it work I would:

a. set the powerfail at a rather high voltage level -> how to do that ?
b. if the powerfail is triggered, disable it, clear it, set it at a
lower voltage level, and then do the writing to flash.

Are there any examples on how to use the powerfail mechanism on nrf51/nrf52 ?

Kind regards,