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

Clearing Pending Flash Events via System Reset

I have a rare issue where my device won't advertising as it is waiting for a Pending Flash event to clear. However I want to add a supervisor time-out to this. It is safe to call sd_nvic_SystemReset() to clear pending Flash events?

Thanks

  • The CPU is blocked while flash operations are performed, so you cannot reset the chip (or do anything else) from software in that case. You could of course use the watchdog, but a better option is to figure out why your code is stuck waiting for the pending event to finish.

    How are you waiting for the event? Do you have a flag that you set yourself in your code that you wait for? How and where are you setting the flag, waiting for the flag and clearing the flag? Are you using pstorage or are you accessing the flash in another way?

  • Hi Einar,

    I know that the CPU is blocked during an operation. But I see cases where a Flash event is pending, pstorage_access_status_get(&count), count != 0

    I use Pstorage and I have a call back function which works 99% of the time. This only seems to occur when the device has intermittent connection to the central. Where its constantly connecting/disconnecting. Here is where is seems the chip starts to lag on Flash Event completion.

  • I see. I guess what is happening is that the softdevice never sees a timeslot long enough to give time for the flash operation in this case. It is probably possible to break the connecting/disconnecting loop somehow, but if not, I do think it would be safe to call sd_nvic_SystemReset(). However I think you can call pstorage_init() again instead, which will lead to flushing of the command queue.

Related