System / VBAT register files

Status
Not open for further replies.

WMXZ

Well-known member
As during VLLS1 shutdown mode all SRAM data are lost and only the system and VBAT register files remain powered for critical user data (64 bytes total) , I was wondering if some has used this feature, or better, if all 64 bytes are freely available?
 
I think Frank B did something with this - I can't find that post now … searching "VBAT register file" got me here so far ...
 
if all 64 bytes are freely available?

4 bytes are used by the startup code, from 0x4003E01C to 0x4003E01F. These are used to remember if the RTC has been initialized after a cold boot using "stale" time info, and needs to be set again after a warm boot (presumably right after a code upload) when the time info is "fresh".

The rest should be available for any use.

If you really want those 4 bytes also, find and edit this code in mk20dx128.c.

Code:
        // RTC initialization
        if (RTC_SR & RTC_SR_TIF) {
                // this code will normally run on a power-up reset
                // when VBAT has detected a power-up.  Normally our
                // compiled-in time will be stale.  Write a special
                // flag into the VBAT register file indicating the
                // RTC is set with known-stale time and should be
                // updated when fresh time is known.
                #if ARDUINO >= 10600
                rtc_set((uint32_t)&__rtc_localtime);
                #else
                rtc_set(TIME_T);
                #endif
                *(uint32_t *)0x4003E01C = 0x5A94C3A5;
        }
        if ((RCM_SRS0 & RCM_SRS0_PIN) && (*(uint32_t *)0x4003E01C == 0x5A94C3A5)) {
                // this code should run immediately after an upload
                // where the Teensy Loader causes the Mini54 to reset.
                // Our compiled-in time will be very fresh, so set
                // the RTC with this, and clear the VBAT resister file
                // data so we don't mess with the time after it's been
                // set well.
                #if ARDUINO >= 10600
                rtc_set((uint32_t)&__rtc_localtime);
                #else
                rtc_set(TIME_T);
                #endif
                *(uint32_t *)0x4003E01C = 0;
        }
 
Status
Not open for further replies.
Back
Top