Writing to flash within timer

I have developed my own flash management module that has been working fine for a long time.

Today, for the first time, I'm trying to write to flash from within a timer, and I'm not getting completion events.

Early on, I add a SOC event observer with priority 0. When the observer gets the NRF_EVT_FLASH_OPERATION_SUCCESS event, it notifies the flash module which was so far blocking execution. Execution then resumes, calling code knows for sure writing has been successfully performed.

Now, when using a timer from the APP_TIMER library, everything goes fine, call to sd_flash_write succeeds, but then the event is never received.

The APP_TIMER_CONFIG_IRQ_PRIORITY is set to 7 if that matters.

I suspect for some reason, while the handler of the interrupt is executing, the event observer doesn't get events anymore.

As a test, I've made my flash library not wait "too long", and if it has to wait "long", then just return success and output debug info. I also output debug info when the NRF_EVT_FLASH_OPERATION_SUCCESS event is received. I then get my first debug message indicating it aborted waiting, and soon after, I get the message indicating the operation successful event was received.

Is there anyway to get that event while executing in timer?

Related