5 years, 3 months ago.

RTC time drift in mbed 5.10.4 using UBLOX C030_U201

I have encountered a rather large RTC time drift on the ublox C030_U201 evaluation board when using mbed 5.10.4. The RTC drifts 100 seconds in one hour. This time drift doesn't exist in mbed 5.9.7! There it's close to 0 seconds drift.

Note: We found the reason - in targets.json there is an override "overrides": {"lse_available": 0} which results in using internal crystal. Overriding again to '1' in mbed_app.json solves this and uses the external crystal. Is there any reason why this is set to 0?

I've tried this using a really simple program on both OS versions:

------

include "mbed.h"
#include "main.h"

/* Define the outpus for the RGB LED */
DigitalOut myGreenLed(LED2);

void blinkGreenLed(void) {
    myGreenLed = !myGreenLed;
}

/* Main... */
int main(int argc, char *argv[])
{
    // Unlit RGD LEDs, active LOW!
    myGreenLed = 1;

    printf("################### RTC Test ##################\n");
    printf("Using Mbed OS %d.%d.%d\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);

    for(int i =5; i>0; i--)
    {
        printf("%d seconds to start!\n", i);
        wait(1);
    }

    /* Init the RTC with 0 */
    set_time(0);

    time_t now;
    time_t last_report = 0;

    while (1)
    {
        time(&now);
        if(now > last_report )
        {
            time(&now);
            last_report = now;
            printf("Elapsed: %02d:%02d\n", (int) now/60, (int) now %60);
            blinkGreenLed();
        }
        wait(0.2);
    }
}
Be the first to answer this question.