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

How to always Write to FLASH

There is my function for writing to flash.

It works when NRF52832 start from reset, if works when the NRF52832 gets data over BLE but it does not works after "power down and up".

It is strange, CPU works on Super Capacitor when the main power fall down, but when power wakes up flash erase works when start after some delay (about 100ms).

Problem is with waiting for flash ready, cpu stucks there. In another one implementation of writing flash processor doesn't stuck but writing has no effect. 

NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);  <<<<< HERE PROCESSOR STUCK

config_t* set_default_config(void)
{
  erase_config_flash();
  memset(&m_config.calendar,0x00, sizeof(m_config.calendar));
  m_config.mode=MODE_DEFAULT;
  m_config.button_mode=SHORT_MODE;
  m_config.calendar.RTCtime=1546300800; //  01-01-2019

  write_config_to_flash();
  return(&m_config);
}

Parents
  • Hi Bartosz

    Sorry about the late reply, but Ketil has been busy lately and I just now got to this case. 

    First off. What SDK version are you using? What example (if any) is your application based on, and do you use the SoftDevice or not?

    If you're using SDK version 14.0 or newer, you should check out the nrf_fstorage_erase function in nrf_fstorage.h within the SDK, to see how that function works.

    If you're using an older SDK version you should check out the fs_erase function in fstorage.h

    Best regards,

    Simon

Reply
  • Hi Bartosz

    Sorry about the late reply, but Ketil has been busy lately and I just now got to this case. 

    First off. What SDK version are you using? What example (if any) is your application based on, and do you use the SoftDevice or not?

    If you're using SDK version 14.0 or newer, you should check out the nrf_fstorage_erase function in nrf_fstorage.h within the SDK, to see how that function works.

    If you're using an older SDK version you should check out the fs_erase function in fstorage.h

    Best regards,

    Simon

Children
Related