How to get internal RTC time in millisecond

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to get internal RTC time in millisecond

5,132件の閲覧回数
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,205件の閲覧回数
mjbcswitzerland
Specialist V
0 件の賞賛
返信

4,205件の閲覧回数
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 件の賞賛
返信