IMX6 WEC2013 Clock Persistence

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IMX6 WEC2013 Clock Persistence

2,074 Views
nsmith
Contributor I

I have a custom imx6dl board (that generally follows the reference design) with a 3V coin cell attached to the pmic on the board. I'm trying to get the time in Windows Embedded Compact 2013 to work and persist, but the time keeps resetting to 12:00:00 on a power cycle or reset. Is there anything I should check to locate where the issue lies?

The RTC is hooked up according to the reference design on QZ500 and is outputting about 60Hz.

Labels (3)
0 Kudos
Reply
4 Replies

1,660 Views
--claus
Contributor III

Hi Nicolas,

the reference BSP we provided is designed for the NXP Sabre Lite community board, which doesn't have an external battery-backed RTC chip. For time-keeping at runtime the i.MX6 has a timer/counter unit in the IP block SNVS (Secure Non-Volatile Storage). It is documented in chapter 57 of the i.MX6DualLite_6Solo Reference Manual. There you can find a description of all registers used in the software. While it is possible to have the SNVS battery-backed, typical product designs work with an external RTC chip.

During runtime it is better for performance to use the SNVS for time-keeping, and when you power-off or suspend the device, the external RTC keeps it. So the missing part for your board is to add functionality to the SNVS based RTC driver to read the time from the external RTC and transfer it to the SNVS counter on startup or resume. And the second required modification is to store the time to the external RTC whenever the SetTime function gets called. With this modifications your board would always have the correct time as long as the RTC is battery powered.

Claus Rohde

Adeneo Embedded

0 Kudos
Reply

1,660 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Nicholas,

Maybe  Adeneo Engineering Team, can help you with this issue? 

Thanks.

0 Kudos
Reply

1,660 Views
nsmith
Contributor I

That seems like the best option at the moment. After doing some more digging, I was curious what the best practices for restoring system time on bootup were for WEC2013. I'm curious if my setup is flawed or the RTC driver was not designed to restore system time using the reference's RTC.

Any ideas, Deactivated user​?

0 Kudos
Reply

1,660 Views
nsmith
Contributor I

After looking over the RTC driver in the WEC2013 BSP, it looks like it's trying to read from some registers on the SNVS register that I cannot find documentation on:

        // LPSCMR is only valid when two consecutive reads

        // return the same result

        do

        {

            time.LowPart = INREG32(&g_pSNVS->LPSRTCLR);   //offset 0x054

            time.HighPart = INREG32(&g_pSNVS->LPSRTCMR);  //offset 0x050

        } while (time.LowPart != INREG32(&g_pSNVS->LPSRTCLR));

            // RTC is clocked with 32.768 kHz, so the SNVS LP counter

            // starts counting seconds in bit 16 and higher

            // for sub one second accuracy preserve the lower 15 bit

            // and convert them separately

            subSecond.QuadPart = time.QuadPart & 0x7FFF;

            subSecond.QuadPart = subSecond.QuadPart * 10000000;

            subSecond.QuadPart = subSecond.QuadPart >> 15;

        // Convert raw RTC ticks into seconds

        time.QuadPart = time.QuadPart / 32768;

       

        // Convert seconds into FILETIME ticks

        //  FILETIME tick = 100 nsec = 1e-7 sec

        time.QuadPart = time.QuadPart * 10000000;

            // Add contribution of lower 15 bits

            time.QuadPart += subSecond.QuadPart;

        // Add RTC offset to the time origin

        time.QuadPart += g_oalRtcOriginTime.QuadPart;

       

        // Reformat to FILETIME

        ft.dwLowDateTime = time.LowPart;

        ft.dwHighDateTime = time.HighPart;

        // Convert to SYSTEMTIME

        NKFileTimeToSystemTime(&ft, lpst);

            rc = TRUE;

Any ideas as to what these registers might be doing?

0 Kudos
Reply