fsl_rtc... Why do not save time?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

fsl_rtc... Why do not save time?

跳至解决方案
1,080 次查看
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

标签 (1)
1 解答
753 次查看
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);

在原帖中查看解决方案

2 回复数
754 次查看
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);

753 次查看
holyhope
Contributor III

Ok many thanks!

Massimiliano

0 项奖励
回复