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

what exactly do I need softdevice_sys_evt_handler for?

Hi

I am using SDK12 with NRF51822,

So far I haven’t initialized the sys_evt_handler (softdevice_sys_evt_handler_set(sys_evt_dispatch)) And my program works fine,

Ive seen a thread mentioning that it is used for NVMC,

but I have used sd_flash_write successfully to write to flash, what will I gain from using this handler when writing to flash or in general?

I would like to get some more understanding about this issue, what exactly are the events this meant to handle, what is its importance? Preferably with some examples.

Thanks!

Parents
  • Hi,

    The Softdevice flash API is asynchronous meaning that the completion of the flash operation will be completed at some point after the program has returned from sd_flash_write(). So to know if a scheduled flash operation was successful or not, you need to monitor the system events through the registered sys event hander. A flash operation should either result in NRF_EVT_FLASH_OPERATION_SUCCESS or NRF_EVT_FLASH_OPERATION_ERROR if the Softdevice was somehow prevented from scheduling the task. 

    Our fds and fstorage modules builds on top of the sd flash API where the system events to notify the user whether a flash operation was completed successfully, or if it timed out.

    The main reason a scheduled flash operation can fail is if you have a lot of protocol activity, please refer to the Flash API section in the Softdevice specification here for more details: Flash memory API

  • Hey Vidar

    Are there more examples the might necessitate using the sys event handler? other than flash write?

    Thanks and have a great day

  • We don't have a minimal example that uses the sd_flash_* directly, but you may try to have a look at our BLE examples which use the peer manager module for storing bonding info to flash. The peer manager uses FDS->fstorage->sd flash API to manage NV memory access. In these examples, you can see that system events are forwarded to fstorage through fs_sys_event_handler(). 

Reply
  • We don't have a minimal example that uses the sd_flash_* directly, but you may try to have a look at our BLE examples which use the peer manager module for storing bonding info to flash. The peer manager uses FDS->fstorage->sd flash API to manage NV memory access. In these examples, you can see that system events are forwarded to fstorage through fs_sys_event_handler(). 

Children
Related