mxc_timer1, rtc and clock accuracy on 6sololite

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

mxc_timer1, rtc and clock accuracy on 6sololite

1,669 Views
jayakumar2
Contributor V

Hi,

I'm looking into how accurate the time source is on a 6sololite evk based board. The board uses the 6sl internal rtc. The kernel shows mxc_timer1 as its primary clock source.

root@imx6slevk:~# cat /sys/devices/system/clocksource/clocksource0/available_clocksource
mxc_timer1
root@imx6slevk:~# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
mxc_timer1

root@imx6slevk:~# dmesg|egrep -i rtc
snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc0
snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:00:00 UTC (0)

Here's a test I did:

ntpdate -b pool.ntp.org;

ntpdate -d pool.ntp.org 2>/dev/null| egrep offset | tail -1 ;
date;
hwclock -r ;
sleep 60 ;
hwclock -r ;
date ;
 ntpdate -d pool.ntp.org 2>/dev/null| egrep offset | tail -1 ;

The result shows:
27 Jan 09:41:24 ntpdate[645]: adjust time server 188.166.12.29 offset
0.003408 sec
Fri Jan 27 09:41:24 UTC 2017
Fri Jan 27 09:41:26 2017  0.000000 seconds
Fri Jan 27 09:42:41 2017  0.000000 seconds
Fri Jan 27 09:42:24 UTC 2017
27 Jan 09:42:33 ntpdate[653]: adjust time server 129.250.35.250 offset
0.003952 sec

That shows:
- system told to wait 60s, but actual time waited according to ntp
source (includes latency to reach ntp source so few seconds excess is
understandable) =  09:42:33 - 09:41:24 = 69 seconds
- amount of drift in 69 real seconds is 0.003952 - 0.003408 = 0.000544
= 544 microseconds.
That implies the system clock is fast by 544 microseconds / minute so
it would gain 0.68 s per day (0.000544 * 24 * 60 * 60/69).
- the RTC shows that it increased by 75s in that 60s.

That tells me that the 6sl internal RTC is drifting quite a lot, 15s/min which would lead to 6 hours / day if the system was off.

My questions are:

a) is that amount of RTC drift normal? Or is it indicating that there is some issue with the crystal used for the RTC?

b) what is the minimum current needed for the RTC? ie: if the system is fully off, and the licell is powering the RTC at 3.3V, what is the current consumption by the RTC? The closest thing I see to that is the "SNVS only" current which seems to be stated as 41uA. I think SNVS includes some security circuitry in addition to the RTC.

c) how to turn automatic correction of rtc time? I thought normally, the kernel will automatically correct RTC drift every 11 mins. But that doesn't seem to happen on my setup as I see the drift between system time and RTC time keep increasing:

root@imx6slevk:/mnt/mmc# while (/bin/true); do hwclock -r; date; sleep 60 ; done
Fri Jan 27 10:09:31 2017 0.000000 seconds
Fri Jan 27 10:04:52 UTC 2017
Fri Jan 27 10:10:46 2017 0.000000 seconds
Fri Jan 27 10:05:53 UTC 2017
Fri Jan 27 10:12:00 2017 0.000000 seconds
Fri Jan 27 10:06:53 UTC 2017
Fri Jan 27 10:13:15 2017 0.000000 seconds
Fri Jan 27 10:07:53 UTC 2017
Fri Jan 27 10:14:30 2017 0.000000 seconds
Fri Jan 27 10:08:53 UTC 2017
Fri Jan 27 10:15:45 2017 0.000000 seconds
Fri Jan 27 10:09:53 UTC 2017
Fri Jan 27 10:17:00 2017 0.000000 seconds
Fri Jan 27 10:10:53 UTC 2017
Fri Jan 27 10:18:15 2017 0.000000 seconds
Fri Jan 27 10:11:53 UTC 2017
Fri Jan 27 10:19:30 2017 0.000000 seconds
Fri Jan 27 10:12:53 UTC 2017
Fri Jan 27 10:20:45 2017 0.000000 seconds
Fri Jan 27 10:13:53 UTC 2017
Fri Jan 27 10:22:00 2017 0.000000 seconds
Fri Jan 27 10:14:53 UTC 2017
Fri Jan 27 10:23:14 2017 0.000000 seconds
Fri Jan 27 10:15:53 UTC 2017
Fri Jan 27 10:24:29 2017 0.000000 seconds
Fri Jan 27 10:16:53 UTC 2017

Fri Jan 27 10:25:44 2017 0.000000 seconds
Fri Jan 27 10:17:53 UTC 2017
Fri Jan 27 10:26:59 2017 0.000000 seconds
Fri Jan 27 10:18:53 UTC 2017

Thanks!

Labels (2)
0 Kudos
6 Replies

1,073 Views
igorpadykov
NXP Employee
NXP Employee

Hi Jaya

timer accuracy is defined by crystal accuracy. Current is given in

sect.4.5.2 OSC32K i.MX6SL Datasheet

http://cache.freescale.com/files/32bit/doc/data_sheet/IMX6SLCEC.pdf

As last question is generic linux question, it can be posted on generic linux forums.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,072 Views
jayakumar2
Contributor V

Hi Igor,

Thanks for your reply. In section 4.5.2, I see:

"

The OSC32k runs from VDD_SNVS_CAP, which comes from the VDD_HIGH_IN/VDD_SNVS_IN
power mux. The target battery is a ~3 V coin cell. Proper choice of coin cell type is necessary for chosen
VDD_HIGH_IN range. Appropriate series resistor (Rs) must be used when connecting the coin cell. Rs
depends on the charge current limit that depends on the chosen coin cell. For example, for Panasonic
ML621:


Average Discharge Voltage is 2.5 V
Maximum Charge Current is 0.6 mA
For a charge voltage of 3.2 V, Rs = (3.2-2.5)/0.6 m = 1.17 k

...

Current
consumption — 4 A — The typical value shown is only for the oscillator, driven by an external
crystal. If the internal ring oscillator is used instead of an external crystal,
then approximately 25 A should be added to this value.

"

I don't see where the RTC current is defined in above. Above only tells me the maximum current that would be drawn by a coin cell during charging, and then the current consumption 4uA of the crystal which would be separate from the RTC. As I mentioned, I'm trying to determine what current the RTC consumes so that I can add that to the current consumed by the crystal in order to determine total dissipated power during system off (ie: only RTC+crystal are powered).

> As last question is generic linux question, it can be posted on generic linux forums.

I see.

Thanks!

0 Kudos

1,073 Views
igorpadykov
NXP Employee
NXP Employee

Hi Jaya

sorry, other RTC data is not specified by documentation.

Best regards
igor

0 Kudos

1,073 Views
jayakumar2
Contributor V

Hi Igor,

Thanks for your reply. Based on that, it would mean that the VSVNS(RTC+security)=41uA + osc/crystal=4uA = 45uA. Therefore, a typical 1.2mAh coin cell would only run 1.2E-3/45E-6=26.6 hours. Even if I doubled to bigger 3.4mAh, that's only 2.x days. Is that expected? If there was some real world numbers for how long the RTC can keep time on the 6sl EVK with a coin cell battery, then that would be very useful.

Let me ask it a different way in the hope of clarifying why I'm asking. It seems like the 6sl's internal RTC consumes a lot more current/power than an external RTC. Therefore, if I rely on the discussion we have had, I would end up having to recommend an external RTC since most of those are under the 0.8uA consumption range which is 2 orders of magnitude lower that the 6sl's internal RTC.

Thanks!

0 Kudos

1,073 Views
igorpadykov
NXP Employee
NXP Employee

Hi Jaya

 

your understanding is right, in general may be recommended to use external RTC.

 

Best regards
igor

0 Kudos

1,073 Views
igorpadykov
NXP Employee
NXP Employee

Hi Jaya

4uA is oscillator current. It is sufficient description data.

Then could you clarify exactly what do you mean by

"I don't see where the RTC current is defined in above." ?

There is "SNVS only" current which is 41uA. As you correctly noted SNVS includes

some security circuitry in addition to the RTC. As other circuitry can not be separated from

RTC, since it is integrated as one whole module, only RTC curent can not be measured.

Best regards
igor

0 Kudos