The mechanism used to protect NVM from erroneous application code erasing/writing to protected pages in code flash will cause the CPU to hard fault if an erase or write to a protected page is attempted. This can be turned off when in debug mode by configuring the DISABLEINDEBUG register.
For more information on BPROT, see section BPROT — Block protection in the nRF52832 Product Specification.
Using the standard SWD Arm® CoreSight™ DAP protocol, write the value 0x00000001 to the DISABLEINDEBUG register (0x40000608) of the BPROT. This will disable the block protection mechanism in debug mode.