How to store stack info into flash for DA14585 when hard-fault or NMI happens?

Hello, is there a way to get contents in stack and store them into flash when Hard-fault or NMI happen? If it can't write flash in the situation, is there a mechanism to copy them into a block of SRAM which can be kept even when system has been re-started?