8 years, 2 months ago.

Issue with KL46Z RTC running fast (almost double speed)?

Chasing another issue, I noticed that the RTC time seems to be running almost twice real time (approx. 0.6 real seconds per RTC second). This is trivially demonstrated by a simple tweak to the frdm_gpio example program using the online compiler. Two variants:

// Using wait() interface
#include "mbed.h"

DigitalOut gpo(D0);

int main()
{
    while (true) {
        wait(1.0);  
        gpo = !gpo; // toggle pin
    }
}

--------

// Using time() interface:
 #include "mbed.h"

DigitalOut gpo(D0);

int main()
{
    time_t lastSec = time(NULL);
    
    while (true) {
        if (time(NULL) != lastSec)
        {
            lastSec = time(NULL);
            gpo = !gpo; // toggle pin
        }
    }
}

--------

In both cases, D0 shows a square wave with 0.6 seconds between toggles ... I've verified that this board does have a sane 32.768 kHz clock signal on PTE1, which I believe is the source clock for the RTC configuration ...

Can anyone comment? This seems like a fairly basic clock configuration/scaling issue somewhere.

Thanks, Matt H.

So both examples run twice as fast as it should run? That is really weird.

posted by Erik - 12 Feb 2016

Not exactly twice unfortunately, probably easier to find a factor of 2 - but close to it ...

posted by Matthew Hughes 12 Feb 2016

1 Answer

8 years, 2 months ago.

Hi Matthew,

I have found other devices that the RTC runs exceptionally fast. Both the KL25Z and the K64F are my gripes. Though not as serious as your RTC speed problem, I have 2 K64Fs that run fast by 1-Sec/hour !! KL25Zs run fast by 0.25-Sec/hour.

At the other end of the spectrum, the nRF51-mkit and -DK are only fast by 1-sec/day.

...kevin

The KL25Z does not have an RTC crystal, and instead the internal oscillator of the interface chip is used as fake crystal. While better than nothing, it is a small miracle it only runs 0.25 sec / hour fast for you. The K64F I wouldn't know directly if it has its own crystal or uses the same setup.

But this is of course something different than running twice as fast as it should run.

posted by Erik - 12 Feb 2016