fsl_rtc... Why do not save time?

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

fsl_rtc... Why do not save time?

Jump to solution
1,183 Views
holyhope
Contributor III

Hi to all.

I'm developing on K20; I use KDS 2.0.0

I use the RTC_LDD component for Real-Time-Clock without using KSDK (for K20 KSDK is not ready yet...).

I set via the time via my Firmware and I turn off my device for two days.... and turn on... It give me the correct date and time!

Now I try to use KSDK 1.1.0 setting K60 uP instead K20; all seems work correctly but fsl_rtc component don't work well...

For the first thing I see that If i do not explicit do this instruction:

    uint32_t rtcBaseAddr = g_rtcBaseAddr[FSL_RTCTIMER1];

    RTC_HAL_EnableCounter(rtcBaseAddr, true);

the automatic init procedure do not enable it automatically.

The second (and very big problem....) is that if I turn off and turn on my device it will lost my time!

I suppose that this component do not work right... what I can do for preserve my time during turn off?

Many thanks,

Massimiliano

Labels (1)
1 Solution
856 Views
maheshmahadeva1
NXP Employee
NXP Employee

The issue of RTC not retaining its time is fixed in the upcoming KSDK 1.2 release, the problem was identified to a reset call issued in the HAL_Init function. Below is a patch that could be applied to the KSDK 1.1 RTC driver to fix this issue.

diff --git a/platform/hal/src/rtc/fsl_rtc_hal.c b/platform/hal/src/rtc/fsl_rtc_hal.c

index 905b59d..8fc188c 100644

--- a/platform/hal/src/rtc/fsl_rtc_hal.c

+++ b/platform/hal/src/rtc/fsl_rtc_hal.c

@@ -263,15 +263,15 @@ void RTC_HAL_Disable(uint32_t rtcBaseAddr)

void RTC_HAL_Init(uint32_t rtcBaseAddr)

{

-    uint32_t seconds = 0x1;

-

-    /* Resets the RTC registers except for the SWR bit */

-    RTC_HAL_SoftwareReset(rtcBaseAddr);

-    RTC_HAL_SoftwareResetFlagClear(rtcBaseAddr);

-

-    /* Set TSR register to 0x1 to avoid the TIF bit being set in the SR register */

-    RTC_HAL_SetSecsReg(rtcBaseAddr, seconds);

+    if(BR_RTC_SR_TIF(rtcBaseAddr))

+    {

+        /* Resets the RTC registers except for the SWR bit */

+        RTC_HAL_SoftwareReset(rtcBaseAddr);

+        RTC_HAL_SoftwareResetFlagClear(rtcBaseAddr);

+        /* Set TSR register to 0x1 to avoid the TIF bit being set in the SR register */

+        RTC_HAL_SetSecsReg(rtcBaseAddr, 1U);

+    }

     /* Clear the interrupt enable register */

     RTC_HAL_SetSecsIntCmd(rtcBaseAddr, false);

     RTC_HAL_SetAlarmIntCmd(rtcBaseAddr, false);

View solution in original post

2 Replies
857 Views
maheshmahadeva1
NXP Employee
NXP Employee

The issue of RTC not retaining its time is fixed in the upcoming KSDK 1.2 release, the problem was identified to a reset call issued in the HAL_Init function. Below is a patch that could be applied to the KSDK 1.1 RTC driver to fix this issue.

diff --git a/platform/hal/src/rtc/fsl_rtc_hal.c b/platform/hal/src/rtc/fsl_rtc_hal.c

index 905b59d..8fc188c 100644

--- a/platform/hal/src/rtc/fsl_rtc_hal.c

+++ b/platform/hal/src/rtc/fsl_rtc_hal.c

@@ -263,15 +263,15 @@ void RTC_HAL_Disable(uint32_t rtcBaseAddr)

void RTC_HAL_Init(uint32_t rtcBaseAddr)

{

-    uint32_t seconds = 0x1;

-

-    /* Resets the RTC registers except for the SWR bit */

-    RTC_HAL_SoftwareReset(rtcBaseAddr);

-    RTC_HAL_SoftwareResetFlagClear(rtcBaseAddr);

-

-    /* Set TSR register to 0x1 to avoid the TIF bit being set in the SR register */

-    RTC_HAL_SetSecsReg(rtcBaseAddr, seconds);

+    if(BR_RTC_SR_TIF(rtcBaseAddr))

+    {

+        /* Resets the RTC registers except for the SWR bit */

+        RTC_HAL_SoftwareReset(rtcBaseAddr);

+        RTC_HAL_SoftwareResetFlagClear(rtcBaseAddr);

+        /* Set TSR register to 0x1 to avoid the TIF bit being set in the SR register */

+        RTC_HAL_SetSecsReg(rtcBaseAddr, 1U);

+    }

     /* Clear the interrupt enable register */

     RTC_HAL_SetSecsIntCmd(rtcBaseAddr, false);

     RTC_HAL_SetAlarmIntCmd(rtcBaseAddr, false);

856 Views
holyhope
Contributor III

Ok many thanks!

Massimiliano

0 Kudos
Reply