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

store array using fstorage

I've been trying to store an array  (SDK16,S332)

uint8_t my_data[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,.........0x23}

using fstorage I wrote an update function :

I hardcoded the size. There are a few odd behaviors that I noted.

If I use the my_data as above,(incrementing values) it does write and I can read back the data consistently. The application runs consistently. 

If I use pseudo random values, the program works once then crashes. It will store the values, but if the applications is run again, it will not run.

void update_data(uint8_t *my_data)
{
ret_code_t rc;
rc = nrf_fstorage_erase(&fstorage, 0x7f000, 1, NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);

rc = nrf_fstorage_write(&fstorage, 0x7f000,my_data,24, NULL);
APP_ERROR_CHECK(rc);
if (rc != NRF_SUCCESS)
{
NRF_LOG_INFO("nrf_fstorage_write() returned: %s\r\n",
nrf_strerror_get(rc));
}
wait_for_flash_ready(&fstorage);
}

Is there a limit as to the number of bytes that can be sent at once?

Parents Reply Children
Related