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

Save in flash a NO_INIT variable

Hi everyone!

After defining a variable as no_init , my intention is to update its value along the program to debug what was its last state before a random reset.

I am able to write this variable in flash but it never remains its last value after reset.

I am using softdevice so I think that although it is defined as no_init, it is reset by softdevice during ble_stack_init.

I have tested doing Hardware Pin Reset as well as NVIC_System_reset().

is there  any way to save its value before it is reset again?

Parents
  • Hi,

    Thank you for your answer.

    As you say, flash writes are time consuming  operations. For that reason, I don't try to do it during the program. My idea was to use a uint32_t variable to update state during the program and after reset, write it in flash before starting the main loop.

    I tryed to define that variable as no_init with the hope that after the reset it remained its value which I would write in the flash.

    However, that value always resets to 0. 

    I am using FDS functions and It works fine if I initialize the variable to a specific value, otherwise it writes 0. 

    After reading with fds_read function I store the value in an other variable which I check using BLE.

Reply
  • Hi,

    Thank you for your answer.

    As you say, flash writes are time consuming  operations. For that reason, I don't try to do it during the program. My idea was to use a uint32_t variable to update state during the program and after reset, write it in flash before starting the main loop.

    I tryed to define that variable as no_init with the hope that after the reset it remained its value which I would write in the flash.

    However, that value always resets to 0. 

    I am using FDS functions and It works fine if I initialize the variable to a specific value, otherwise it writes 0. 

    After reading with fds_read function I store the value in an other variable which I check using BLE.

Children
Related