defragster
Senior Member+
Code below shows usage of the 1062 NVRAM bytes. For use it shows the "SDK" documented bit change required for function.
This code is RAM'ish - but on the RTC unit it appears a bit sluggish - versus a real RAM write - perhaps as it is in a different exec unit running on a 32 MHz clock.
This code has SerMon input options: " 'r':RESTART 'z':ZERO '?':INC 10 to each "
> 'r' will restart to demo the values are held
> 'z' to ZERO the values
> any other ( including the '\n' ) input char will add 10 by inc++ to each of the four DWORDS.
DOES IT WORK:
> restart on a powered T_4.x :: YES
> restart on a powered T_4.x with RTC cell :: YES
> Power PIN OFF/ON on a powered T_4.x :: YES
> Power PIN OFF/ON on a powered T_4.x with RTC cell :: YES
> Power PIN OFF/ON on a then UNplugged T_4.x with RTC cell :: YES
> Power interrupted T_4.x with RTC cell :: YES
This code demonstrates usage:
<edit>: updated code to better show 10 Increment to each ( not 100 )
This code is RAM'ish - but on the RTC unit it appears a bit sluggish - versus a real RAM write - perhaps as it is in a different exec unit running on a 32 MHz clock.
This code has SerMon input options: " 'r':RESTART 'z':ZERO '?':INC 10 to each "
> 'r' will restart to demo the values are held
> 'z' to ZERO the values
> any other ( including the '\n' ) input char will add 10 by inc++ to each of the four DWORDS.
DOES IT WORK:
> restart on a powered T_4.x :: YES
> restart on a powered T_4.x with RTC cell :: YES
> Power PIN OFF/ON on a powered T_4.x :: YES
> Power PIN OFF/ON on a powered T_4.x with RTC cell :: YES
> Power PIN OFF/ON on a then UNplugged T_4.x with RTC cell :: YES
> Power interrupted T_4.x with RTC cell :: YES
This code demonstrates usage:
Code:
// TWO ways to access as 4 32 bit DWORDS of NVRAM backed data
// #define NVRAM_UINT32 ((uint32_t *)0x400D4100)
uint32_t *NVRAM_UINT32 ((uint32_t *)0x400D4100);
elapsedMillis tSome;
void setup() {
SNVS_LPCR |= (1 << 24); //Enable NVRAM - documented in SDK
Serial.begin(115200);
while (!Serial && millis() < 4000 );
Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
tSome = 0;
Serial.print(" 'r':RESTART 'z':ZERO '?':INC 10 to each\n");
}
void loop() {
if ( tSome >= 1000 ) {
tSome -= 1000;
for ( int ii = 0; ii < 4; ii++ ) {
Serial.print( '\t' );
Serial.print( NVRAM_UINT32[ii] );
}
Serial.println();
for ( int ii = 0; ii < 4; ii++ ) {
NVRAM_UINT32[ii]++;
}
}
while ( Serial.available() ) {
char cc = Serial.read();
if ( 'r' == cc ) {
SCB_AIRCR = 0x5FA0004;
while (true);
}
else if ( 'z' == cc ) {
Serial.print( "_ZERO_ NVRAM\n" );
for ( int ii = 0; ii < 4; ii++ ) {
NVRAM_UINT32[ii] = ii * 1000;
}
}
else {
Serial.print( "_10_INC_ NVRAM\n" );
tSome += 10000;
}
}
}
<edit>: updated code to better show 10 Increment to each ( not 100 )
Last edited: