How to get internal RTC time in millisecond

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

How to get internal RTC time in millisecond

3,623 Views
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

Labels (1)
0 Kudos
2 Replies

2,696 Views
mjbcswitzerland
Specialist V
0 Kudos

2,696 Views
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 Kudos