This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Flash corruption caused by power down during writing

Hello,

I'm using nRF52840 chip with nRF5 SDK 15.2.0 ,Mesh SDK 3.1.0 and soft device S140 6.1.1

I'm trying to protect the flash if a shutdown occurs during a write.
Reading in the forum it seems that the POFWARN event does it for me.

I'm trying to configure this event but without success.
I use this code:

nrfx_power_config_t power_config = {.dcdcen = 1};
nrfx_power_init (& power_config);
nrfx_power_pofwarn_config_t pofwarn_config = {.thr = POWER_POFCON_THRESHOLD_V28,
                                                   .handler = power_failure_warn_handler};
nrfx_power_pof_init (& pofwarn_config);
nrfx_power_pof_enable (& pofwarn_config);

If I use this code snippet before enable the softdevice, the nrf_sdh_enable_request() return the NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION error code

If I use this code after enable the softdevice, the program stops when it try to write the POWER->DCDCEN register

What am I doing wrong?

Besides this, what is the best practice to avoid flash corruption it a power off occours during a write operation?

Parents Reply
  • Could POF warning help to block writing during power below threshold?


    // Initialize SoftDevice.
    err_code = sd_softdevice_enable(p_clock_lf_cfg, softdevice_fault_handler);
    if (err_code != NRF_SUCCESS){
     return err_code;
    }
    err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
    APP_ERROR_CHECK(err_code);
    err_code = sd_power_pof_enable(1);
    APP_ERROR_CHECK(err_code);
    err_code = sd_power_pof_threshold_set(NRF_POWER_THRESHOLD_V28);
    APP_ERROR_CHECK(err_code);

Children
Related