Hi,
I am saving data in flash memory but when I read after restarting the device it shows FF.
How can I read from flash after restarting the device? and how can I check that there is already data?
Thanks
Hi,
I am saving data in flash memory but when I read after restarting the device it shows FF.
How can I read from flash after restarting the device? and how can I check that there is already data?
Thanks
Edvin said:From where are you calling the flash read and write functions? I don't think you included that in your snippets.
Ok. So I asked where you called this from. I meant when it is not working, and the answer is: "From the BLE_GAP_EVT_CONNECTED" event.
You can't do that. That is, you can, but you can't use the wait_for_flash_ready() from this interrupt. The reason for this is that this will wait for an event in the fstorage module, but this interrupt priority is the same as the interrupt you are currently in. Therefore the interrupt it is waiting for will not be able to be processed before you release the ble_evt_handler() interrupt, and you are in what we call a deadlock. (both threads are waiting for the other to finish).
For easier debugging using the log, you can set #define NRF_LOG_DEFERRED 0 in sdk_config.h.
So you need to move the flash write function (or at least the wait_for_flash_ready()) to outside the interrupt.
Best regards,
Edvin
So you need to move the flash write function (or at least the wait_for_flash_ready()) to outside the interrupt.
I have removed the call after the device connected. Now when I write on characteristics 10 I call these functions but not getting reading results from memory. :( (I want that I write data on characteristics and save in flash memory)
probably the same issue.
Muqarrab said:Now when I write on characteristics 10 I call these functions but not getting reading results from memory.
What do you mean? Is it stuck in the wait_for_flash_ready()? (try to debug). If so, where are you calling this function from? Is it from an interrupt? If so, try to set some flag in the interrupt that you use to call this function from your main() loop to move it out of the interrupt.
Is it from an interrupt? If so, try to set some flag in the interrupt that you use to call this function from your main() loop to move it out of the interrupt.
Can you please tell me how can I check is there any interrupt running?
If you are in a function called directly from your main() function, then you are not in an interrupt. But if you are in some sort of event handler, you are in an interrupt. You can also check this using
uint8_t current_priority = current_int_priority_get();
If the current_priority that is returned is 15, then you are in the main context. If the number is smaller than 15, you are in an interrupt.