Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: System / VBAT register files

  1. #1
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,365

    System / VBAT register files

    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?

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,918
    I think Frank B did something with this - I can't find that post now … searching "VBAT register file" got me here so far ...

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,677
    Quote Originally Posted by WMXZ View Post
    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;
            }

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,918
    post that lead me here - where link to other post to that was made.

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,365
    Quote Originally Posted by defragster View Post
    post that lead me here - where link to other post to that was made.
    thanks for refreshing this 2+ year old question, so it got an answer

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,918
    … and added link to WiKi thread ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •