I am attempting to use the retained memory feature on a boron and argon (Tested firmware 0.8.0-rc.26 and rc.27) but the results are not as expected. It appears that the values are initializing incorrectly, but are being stored correctly following an increment. I tested a variety of data types and they all exhibit the same pattern. However, if I flash the same code to a photon, then everything works as expected (Values start at 0 with a fresh power up and are incremented on each reset).
NOTE: I used the web IDE for the testing to rule out firmware issues on my end.
The code:
STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY));
retained uint8_t retTest1 = 0;
retained int8_t retTest2 = 0;
retained uint16_t retTest3 = 0;
retained int16_t retTest4 = 0;
retained uint32_t retTest5 = 0;
retained int32_t retTest6 = 0;
retained float retTest7 = 0;
void setup() {
Serial.begin();
// Wait so we can catch the output
delay(10000);
// Output test retained variables
Serial.println(retTest1++);
Serial.println(retTest2++);
Serial.println(retTest3++);
Serial.println(retTest4++);
Serial.println(retTest5++);
Serial.println(retTest6++);
Serial.println(retTest7); retTest7 += 1.5f;
Serial.println("Done 3"); // Change this with each flash so I know it took
}
void loop() {
Serial.println("Looping");
delay(1000);
}
Here are the results. I first unplugged USB (No battery used), waiting a few seconds, plugged it back in, then clicked the “reset” button twice to get the following outputs.
// Power up
152
5
30116
-1189
209993728
-2047084961
ovf
Done 3
Looping
Looping
...
// Reset 1
153
6
30117
-1188
209993729
-2047084960
ovf
Done 3
Looping
Looping
...
// Reset 2
154
7
30118
-1187
209993730
-2047084959
ovf
Done 3
Looping
Looping
...
Any ideas?