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

NRF_EVT_FLASH_OPERATION_SUCCESS fired only if Radio notifications enabled.

Hello, Before writing here I made some forum search and didn't find the answer. Previously I used radio notifications to sync ADC measurements with radio events. Now I need to disable radio notifications in the project and noticed that firmware become working unstable. The BLE connection breaks ocasionally and the flash write operations stuck. Softdevice used S110. I do not use pstorage but use own functions. Flash operation states are read from SD_EVT_IRQHandler (SWI2) ( NRF_EVT_FLASH_OPERATION_SUCCESS and NRF_EVT_FLASH_OPERATION_ERROR ). Noticed that no interrupt fired after flash operation (sd_flash_write()) . What could cause such behaviour? Why enabling Radio notifications make flashoperation working?

P.S. I read the errata for softdevice but do not see the link with my issue.

  • Ok, one more question in S110v8.0.0 release notes limitation, the "...notified to the application as Radio Events" shall we say NRF_EVT_RADIO... events?like used in timeslot api?

  • Yes, when you use sd_flash_xxx when radio notifications are enabled, then you get both NRF_EVT_FLASH_OPERATION_xxx and also a radio notification because flash is written using an internal module within the softdevice that cannot differentiate it with radio activity. So when the flash operation is completed you get both NRF_EVT_FLASH and also a radio notification for it.

  • In my code the timeout 1000ms was set for NRF_EVT_FLASH_OPERATION_xxx event after sd_flash_xxx function ran. And it expires. I put some debug to softdevice handler and non events fired till timeout expired.neither soc nor ble. And its strange, because ble operation seem to be ok, and ble events fired in the interrupt handler. Similar situation was previously when I configured powerfail functionality, and no flash events came if power failure occured.

  • The scheme of my NV functionality is next:

    void SD_EVT_IRQHandler(void){
     uint32_t evt_id;
     while (sd_evt_get(&evt_id)!= NRF_ERROR_NOT_FOUND){
    switch (evt_id){
    case NRF_EVT_FLASH_OPERATION_SUCCESS:
    if(need_to_write) sd_flash_write();
    else set(EVENT);
    break;				
     case NRF_EVT_FLASH_OPERATION_ERROR:            
    set(EVENT);
    break;
    }
    }
    	
    void flash_write(){  //erase page and wait until write operation started on erase operation finished. Than after write operation finished issue EVENT to break while loop.   
    sd_flash_erase();
    while( !EVENT || !TIMEOUT);
    }
    

    This works if radio notifications enabled, otherwise no interrupt triggered.

Related