Hi guys, I am trying to use pstorage to store a temperature data inside the ROM. I have to use it as efficiently as possible so that 20.000 erase cycles should be enough for my application. I am wondering a couple of things. First, how does pstorage module give the numbers to its blocks? I mean logically pstorage should register the blocks starting from 0 to whatever the number of blocks in an increasing order, putting each block of data consecutively so is that what it is doing?
Let's say I have initialized my pstorage as the following:
static void m_pstorage_init()
{
uint32_t err_code;
pstorage_module_param_t p_example_param;
p_example_param.block_size = 0x4; // recommended to be >= 4 byte
p_example_param.block_count = 1024;
p_example_param.cb = m_pstorage_handler;
err_code = pstorage_init();
APP_ERROR_CHECK(err_code);
err_code = pstorage_register (&p_example_param, &m_pstorage);
APP_ERROR_CHECK(err_code);
}
Since my block_size = 4 bytes and number of blocks is 1024, I need 4 pages. Is it safe to assume that blocks 0-255 are in the same page and 256-511 are in the same page and so on. I am not concerned if the pages that are used are consecutively stored (are they though? :) ), I am just asking is it safe to assume that block 256 will not be affected when I call pstorage_clear() for the block 212?
Secondly, when I call pstorage_clear() for one block of data, it erases the whole page, but does it re-write other blocks that were on the same page back to their previous positions? If so, how can I avoid doing that.
Lastly, is there another module that you can offer to perform this action easily?
Sorry for my english, if there is any parts I was unable to explain please ask.
Thanks in advance,
Talha