flash partial erase operation

hi support team,

am i operate partial erase correctly? i added delay_ms(10000) to see the memory, find out that only partialerase once, before i changes from 1 to 2, the flash is all changed to 0xFF.

so we still need to wait for over 85ms to make sure the flash operation is finished, correct?

void partial_page_erase(uint32_t address)
{
       NRF_NVMC->ERASEPAGEPARTIALCFG = 1;//1ms
       for(uint8_t i = 0; i<86; i++)
       {
             // Enable erase.
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een;
            __ISB();
            __DSB();
            nrf_gpio_pin_set(14);
            NRF_NVMC->ERASEPAGEPARTIAL = address;
            nrf_gpio_pin_clear(14);
            wait_for_flash_ready();
            NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
            nrf_delay_ms(10000);
            __ISB();
            __DSB();
      }
}

Regards,

William.

  • Hi,

     

    so we still need to wait for over 85ms to make sure the flash operation is finished, correct?

    Yes, this is correct.

    To ensure that the specific flash page is fully erased, it must be run a total time of tERASEPAGE (85 ms for nRF52840).

    If you use ERASEPAGEPARTIAL with a configuration of 1 ms, this needs to run 85 times to ensure that the specific page is fully erased (with all corners considered, like flash wear, temperature, etc).

     

    Kind regards,

    Håkon

Related