I'm trying if I can have some variables values unaffected during a reset (but always powered), using the noinit "directive". So far no luck. Board is a Nano 33 BLE and the code is below:
YMMV depending on which bootloader you are using (and how many global variables it uses and where it places them in RAM) and your device. Tested with Pro Mini 168 and whatever bootloader it came with.
What is actually resetting the device? Why reset the device at all? If you want to restart your program and count the number of resets, just create your own setup() and loop() aliases inside loop() and assign a GPIO to be your "reset button".
pjrebordao:
The nRF52 allows it but my tests fail, I suppose, because of the bootloader getting in the way.
That’s my assumption, and I provided an example that demonstrates that only later elements in the array are preserved (because lower elements are stored in lower memory locations, which are where globals for the boot loader are stored).
I did mention this in your previous thread that this could happen.
Also this test was on a “regular” 8-bit AVR device. The architecture of the nRF52840 may make things quite different again. Sorry, but I do not have one to test with.