Skip to main content

get time in us using RTC

2 years ago

get time in us using RTC

Posted bygbmej0 points 1 reply
0 upvotes

Hello

I am trying to get a time in us using the RTC. I have used the function available in RTC application note "DA1468x_RTC_concept_tutorial_v1_00.pdf":uint64_t sw_rtc_convert_lp_to_time(uint64_t
lp_clocks)
。我在“LP_CLK_RCX”模式(/* Check whether the lp clock source is the internal RCX */) and this function uses the global variablercx_clock_period:


/*
* Use the variable named [rcx_clock_period] to get the
* current RCX period in usec. Please note that this value
* is multiplied by [1024 * 1024]
*/
time = (lp_clocks * (uint64_t)rcx_clock_period);
time = (time >> 20); // divide with (1024 * 1024)

Inidlemode, the time returned is always higher than the previous time got 50ms before.
Inextended sleepmode, the time is sometimes smaller than the previous time got 50ms before. So I return to the past.

This is due to the auto-re-calibration when exiting extended sleep mode ofrcx_clock_period
你有an idea about this use case?

Best regards,
Guillaume B.

2 years ago

PM_Dialog

Hi gbmej,

It is strongly recommended to use the XTAL32K as RTC instead of the RCX. The RCX is unstable and it need frequent calibration. Keep in mind that the RCX is software implemented and XTAL32K is hardware implemented. So, the most stable configuration is to use the XTAL32K, with an external 32KHz crystal oscillator.

Thanks, PM_Dialog