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 Reply Children
Related