fstorage write& Erase Interrupt not Triggered when BLE Init Called

I have written a word (32 bites) in 0xFF000 using nrf_fstorage_write(),  When BLEInit(), nrf_fstorage_evt() callback not trigged, 

BLE_Sleept()

nrf_storage_write()

BLE_wakeup()

  • Hello,

    Thank you for your reply, Can you check & reply

    InfaRadar.zip

  • I noticed a few problems with your write_to_flash() implementation, please see diff below for details. I did not review the other functions in your code.

    diff --git a/source/Infa.c b/source/Infa.c
    index 2168665..bca5633 100644
    --- a/source/Infa.c
    +++ b/source/Infa.c
    @@ -38,7 +38,7 @@ NRF_FSTORAGE_DEF(nrf_fstorage_t my_instance) = {
     bool write_to_flash(uint32_t SAddr,uint32_t dLen,uint8_t *wData)
     {
      ret_code_t rc=0;
    - NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;
    + //NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen; // Remove. NVMC cannot be accessed when Softdevice is enabled
      
          rc = nrf_fstorage_write(&my_instance, /* The instance to use. */
     	 SAddr, /* 
    @@ -49,10 +49,14 @@ bool write_to_flash(uint32_t SAddr,uint32_t dLen,uint8_t *wData)
     	 NULL   /* Optional parameter, backend-dependent. */
     	);
      
    -     app_sched_execute();
    +    // app_sched_execute(); // This function is meant to be called from the main loop
         //  nrf_delay_ms(1000);
         //iDebug("\r\nflash write.... \r\n");
    -    while(nrf_fstorage_is_busy(&my_instance));
    +    /* Remove while loop here. It will block forever if called from an interrupt context. 
    +     * Note that fstorage can queue up multiple write operations so a wait loop like this should normally
    +     * be reduntant
    +     * /
    +    //while(nrf_fstorage_is_busy(&my_instance)); 
         
         if (rc == NRF_SUCCESS) {
             //iDebug("\r\nflash write success");
    @@ -508,7 +512,10 @@ void StartRadarApp()
        iDebug(" fs pgnum %ul",pgnum);
        iDebug(" fs pgsize %ul ",pgsize);  
        read_from_flash(0xFF064,42);
    -  
    +    
    +    static uint32_t data = 0xAAAAAAAA;
    +    /* Test write */
    +    write_to_flash(0xFF064, sizeof(uint32_t), (uint8_t *) &data);
        
         nrf_delay_ms(100);
         for (;;)
    
    

Related