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

quickly perform flash write during power loss

I'm using nfr52 with softdevice s132. I want quickly perform flash write during power loss. When I realize write using fs_store() I obtain time more than 5 msec. How can I use sd_flash_write() without SoftDevice event? How can I disable SoftDevice during power loss int? It needs to perform flash write in less than 5 msec.

  • Hi Chris

    As in introduction , there is a description here that describes a littlebit the difference between the different flash storage modules.

    Im not sure what you mean by power loss. It is pretty hard to write to flash when you already lost supply power. We have however recommended for customers using pstorage module that when battery gets low on charge, you should finish any pending flash operations in time to prevent flash corruption. Pstorage does not handle handle sudden power loss. The FDS module should however be able to handle flash corruption with sudden power loss, see the FDS documentation.

    Flash write operation takes relatively long time, up to 338us according to the specification. Flash operation and BLE event can't normally process at the same time, because they both need the CPU. A softdevice event takes ~1 millisecond if you are transmitting or receiving one packet per connection event. So if you are only transmitting one packet per connection event, then a single flash write operation should be able to complete in <2ms. If you transmit/receive three packets per connection event, I assume BLE event should complete in 3ms which will make a flash write operation complete in <4ms. For peripheral BLE connections, the default setting is to transmit up to 6 packets per connection event, but this is configurable to maximum 3 packets per connection event with setting option BLE_CONN_BW_MID or maximum 1 packet per connection event with setting option BLE_CONN_BW_LOW, see the S13x 2.0.x migration document chapter about "Configurable bandwidth", and also described a little here. Note that when limiting the number of BLE packets per connection event, you will also limit throughput.

  • Sudden power loss is sometimes handled by a interrupt tied to a circuit that detects the loss of power. The power supply is designed with enough capacitance to run the system for as long as needed to shut things down, a few milliseconds usually. So you get the interrupt, and save. Dealing with the BLE stack is another story, but if youve lost power, you might not care if the last transmissions gets through

  • I use sequence code below, but it dosnt work. How I can reenable SoftDevice?

     uint32_t err_code = softdevice_handler_sd_disable();
      sd_flash_write(p_write_addr, value, len);
      softdevice_enable_get_default_config(CENTRAL_LINK_COUNT, PERIPHERAL_LINK_COUNT, &ble_enable_params);
      if (err_code == NRF_SUCCESS) err_code = softdevice_enable(&ble_enable_params);
    
  • Hi Chris

    sd_flash_write is a softdevice call, so if you disable the softdevice first, then it is not going to work. Try to call sd_flash_write before disabling the softdevice

Related