Hello,
I am working in NCS and I am trying to save some data in flash before the SoC turns off.
I am starting by using the code below.
//erase page NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} NRF_NVMC->ERASEPAGE = 0x0005A000; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} //write data in flash's page NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} *(uint32_t *)0x0005A000 =0x0000000AUL; NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
If I use this code in the main() I can see the data written in flash. Instead, if I write the same code either in a gpio interrupt or in a thread, the SoC goes in Hard Fault and nothing is written in flash.
Can you help me to understand the problem?
Best Regards,
Crescenzo