IMXRT1166 RTC does not keep its datetime after power cycle

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

IMXRT1166 RTC does not keep its datetime after power cycle

665 Views
burhanhagi
Contributor III

I have imxrt1166 eval board and trying to understand RTC. Although SNVS portion is powered by a seperate LDO regulator, It resets its counter whenever I press reset button. During reset, VDD_SNVS_IN input stays at 3.3V. It works as expected. I observed with oscilloscope.

The counter starts running from the date 2023.12.31 and time 23.58.00 after every reset/power cycle. These values are my initial config values.

I am studying "evkmimxrt1160_snvs_hp_rtc_cm7" example in SDK. How can I fix it and keeps retaining its date/time values in case unexpected crash happens?

P.S : I searched if anyone has encountered similar problem. I saw that one must say to save LPGPR register while GPR_Z_DIS bit enabled. I did it as the following;

status_t SNVS_HP_RTC_SetDatetime(SNVS_Type *base, const snvs_hp_rtc_datetime_t *datetime)
{

......

.......

base->LPCR |= SNVS_LPCR_GPR_Z_DIS_MASK;
base->LPGPR[0] = (uint32_t)(1U);

.......

}

Before the entry into the main loop, I added below lines;

rtcDate.year = 2023;
rtcDate.month = 12;
rtcDate.day = 31;
rtcDate.hour = 23;
rtcDate.minute = 58;
rtcDate.second = 0;

if ( SNVS->LPGPR[0] != 1U)
{
SNVS_HP_RTC_GetDefaultConfig(&snvsRtcConfig);
SNVS_HP_RTC_Init(SNVS, &snvsRtcConfig);
SNVS_HP_RTC_SetDatetime(SNVS, &rtcDate);
}

SNVS_HP_RTC_StartTimer(SNVS);


while (true)
{

......

}

I can now set the LPGPR register value. But this time when I reset the board, it counts starting from 1970-01-01 00:00:00

Do I have to save current date and time infos to LPGPR registers every time? If yes, when an unpected crash occurs, it will not show the exact time after reset. I need the RTC working similar to in STM32 series.

0 Kudos
Reply
3 Replies

599 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello, my name is Pavel, and I will be supporting your case, let me get into your case and when I have more information, I will contact you.

Best regards,
Pavel

0 Kudos
Reply

554 Views
burhanhagi
Contributor III

@Pavel_Hernandez, I have also one custom board with imxrt1170. The difference between my custom board with imxrt1170 and imxrt1160 eval board is that imxrt1160-EVK has no capacitors on Y5(RTC 32.768KHz crystal) capacitors on both legs. However in my imxrt1170 custom board, I have RTC 32.768KHz with both capacitors populated. When I reset the board, external RTC crytsal keeps running, but main crystal 24MHz takes reset as expected in my board.

I think the problem is that SDK example uses main external crystal 24MHz for SNVS peripheral. I quick searched but not find. How can I enable OSC32.768Khz RTC crystal and mux SNVS example in SDK to use this RTC clock instead of 24MHz one?

Actually fsl_snvs_hp.c NXP driver file does not include any definition with clock options!? See the below.Not found "SNVS_HP_Clocks" in index.

burhanh_0-1682326195710.png

 

 

0 Kudos
Reply

545 Views
burhanhagi
Contributor III

@Pavel_Hernandez 

https://community.nxp.com/t5/MCUXpresso-SDK/RT1050-keeping-RTC-across-power-cycles/m-p/914748 link solved my problem. LP one in SDK examples must be followed for internal RTC with battery backup aided. Both eval and my custom boards are keeping time well now.

0 Kudos
Reply