How to get internal RTC time in millisecond

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

How to get internal RTC time in millisecond

5,111 次查看
jyotiranjan_bal
Contributor I

Hi,

We are using MK60FN1M0VLQ12 controller and internal RTC with clock frequency 32.768KHz.

We found that internal RTC gives the time with 1sec resolution but we need time in milli seconds.

Can any one please tell us how to get time in milli seconds from internal RTC.

Thanks,

Jyotiranjan

标签 (1)
标记 (4)
0 项奖励
回复
2 回复数

4,184 次查看
mjbcswitzerland
Specialist V
0 项奖励
回复

4,184 次查看
BlackNight
NXP Employee
NXP Employee

You only get a 1 Hz resolution.

You could run your a timer (Software RTC) with a 1 kHz frequency and have it synchronized with the RTC. I do usually the following:

- at boot time, the software RTC is started and loaded with the value of the RTC

- the software RTC runs at 1 kHz so I get a 1 ms resolution

- from time to time (e.g. every day, the SW RTC gets synchronized with the HW RTC to compensate for any clock drift).

The advantage is that access to the SW RTC is faster/more efficient and I get the resolution I need.

You can find such an implemenation in McuOnEclipseLibrary/McuTimeDate.c at master · ErichStyger/McuOnEclipseLibrary · GitHub 

I hope this helps,

Erich

0 项奖励
回复