I'm currently using the pstorage functions to be able to store permenant data when turning off the power, it works good with me while writing or reading but when I turn off the power, the data is erased from the memory, I think it may be it's a volatile memory, but on its documentation it's said that it write data to flash memory and the flash memory is a non-volatile memory.
thanks in advance
static void example_pstorage_init()
{
uint32_t err_code;
pstorage_module_param_t p_example_param;
// Setup pstorage with 5blocks of 16byte in each.
p_example_param.block_size = 0x10; // recommended to be >= 4 byte
p_example_param.block_count = 10;
p_example_param.cb = example_cb_handler;
err_code = pstorage_init();
//APP_ERROR_CHECK(err_code);
err_code = pstorage_register (&p_example_param, &m_p_example_id);
if (err_code == NRF_SUCCESS)
{
pattern_ID_4();
flash_init();
}
}
int main(void)
{
pg_size = NRF_FICR->CODEPAGESIZE;
pg_num = NRF_FICR->CODESIZE - 1;
address = (uint32_t *)(pg_size * pg_num);
Dt_store = * address;
// Initialize
leds_init();
timers_init();
gpiote_init();
ble_stack_init();
scheduler_init();
gap_params_init();
services_init();
advertising_init();
conn_params_init();
sensor_simulator_init();
sec_params_init();
// if(Dt_store != 0x0001)
example_pstorage_init();
// Start execution
advertising_start();
LPCOMP_init();
// Enter main loop
for (;;)
{
app_sched_execute();
power_manage();
}
}
void edit_speed_ID(uint8_t speed)
{
static uint8_t value __attribute__((aligned(8)));
uint32_t err_code;
value = speed;
err_code = pstorage_block_identifier_get(&m_p_example_id, dummy_block, &p_block_id);
if (err_code == NRF_SUCCESS)
pattern_ID_4();
nrf_delay_ms(1000);
err_code = pstorage_store(&p_block_id, &value, dummy_size, dummy_offset);
if (err_code == NRF_SUCCESS)
pattern_ID_4();
nrf_delay_ms(1000);
//APP_ERROR_CHECK(err_code);
}