Hi,
I am using nRF52840 and SDK 17.0.2. I used to write data using nrf_fstorage_write() at some address of Flash and I want to read the same data using nrf_fstorage_read(). I am reading the data which I written to that location correctly for the first time. When I want to update the data at that same address I used to write but unable to read the data which is written by me. Sometimes getting the data as previous value and sometimes data is 0.
I used the function wait_for_flash_ready() after writing the data before reading.
I also used the function nrf_fstorage_erase() before data being written to that address for the updated data and wait_for_flash_ready() also before and after the fstorage write function. Can you suggest me how to read the updated data.
For your reference I am adding the code snippet
1.
ret_code_t rc;
uint32_t m_data = 0x12345678,r_data;
rc=nrf_fstorage_write(&fstorage, 0XF6000, &m_data, sizeof(m_data), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
rc=nrf_fstorage_read(&fstorage, 0XF6000, &r_data, sizeof(r_data), NULL);
I am able to read 0x12345678 this time
2.
ret_code_t rc;
uint32_t m_data = 0x11112222,r_data;
rc=nrf_fstorage_write(&fstorage, 0XF6000, &m_data, sizeof(m_data), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
rc=nrf_fstorage_read(&fstorage, 0XF6000, &r_data, sizeof(r_data), NULL);
This time I am able to write the data to that address when I want to read the data not getting the exact value.
I aslo used the function nrf_fstorage_erase(& fstorage, 0xF6000, sizeof(m_data), NULL); before write function
3. I want to write and read the data which is getting continuously from the sensor. How can I do that. Please suggest me
Thank you in advance