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
My initial guess is that you are not waiting for the read finished callback before you print what you have read. Can you share some code showing how you read the data? What are you using to read? Fstorage? FDS? I suggest you check out the examples flash_fstorage or flash_fds, depending on which one you use.
Best regards,
Edvin
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.
Edvin
When I call the memory function in main I get 15 value but after connecting the device I get 6. what should I do? 
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.
Edvin
When I call the memory function in main I get 15 value but after connecting the device I get 6. what should I do? 
Don't call any flash write functions from an interrupt. It is what I have been trying to say the last 13 days.
When I say "don't call it from an interrupt" this also means that if you put your flash functions in another function, you can't call this function from an interrupt either.
In your case "characteristic10()" or whatever it was called contains a flash write. This means that characteristic10() can't be called from an interrupt. Your ble_evt_handler, where your BLE_GAP_EVT_CONNECTED event is generated is an interrupt. You can't call characteristic10() (which contains the flash write) from this interrupt. You must call it from main().
Workaround:
volatile write_to_flash = false;
write_to_flash_function()
{
write_to_flash();
wait_for_flash_ready();
}
characteristic10()
{
//do your characteristic things
//DON'T CALL YOUR FLASH WRITE FUNCTION!
}
ble_evt_handler()
{
...
case BLE_GAP_EVT_CONNECTED:
characteristic10();
}
main()
{
...
while(true)
{
if (write_to_flash == true)
{
write_to_flash = false;
write_to_flash_function();
}
sd_app_evt_wait(); //or whatever wait function you use in your main() loop.
}
}
This is pseudo code, but please study this snippet thoroughly, as I am trying to explain how to move the flash writes to main priority.