Skip to content

RF52 serious behavioural regressions in RTC #7804

Closed
@NeilMacMullen

Description

@NeilMacMullen

GCC_ARM
nRF52 platform.
mbed-os-5.9.4

See #7763 for the likely breaking change.

The following code demonstrates that the seconds and minutes are NOT being correctly reset when calling set_time.

Further, other strange behaviour includes that described in #7763 where setting the clock (backwards?) can sometimes cause it to 'pause' for 35 minutes (1<<31 us).

I'm pretty sure I've also seen the clock drift significantly (several minutes over the course of an hour).

#include "mbed.h"

#include "segger_rtt.h"

int main()
{
    for (int hour = 23; hour >= 0; hour--)
    {
        for (int z = 0; z < 12; z++)
        {
            SEGGER_RTT_printf(0, "resetting time using hour %d...\n", hour);

            struct tm t
            {
            };
            t.tm_year = 2018 - 1900;
            t.tm_mon = 8 - 1;
            t.tm_mday = 16;
            t.tm_hour = hour;
            t.tm_min = 1;
            t.tm_sec = 1;
            set_time(mktime(&t));

            for (int c = 0; c < 10; c++)
            {
                time_t seconds = time(NULL);
                SEGGER_RTT_printf(0, "%s", ctime(&seconds));
                wait_ms(1000);
            }
        }
    }
    return 0;
}

Here's typical output. Note that the seconds/minutes are not being reset but hours are. I've confirmed the behaviour is correct on 5.8.5

0> resetting time using hour 23...
0> Thu Aug 16 23:02:41 2018
0> Thu Aug 16 23:02:41 2018
0> Thu Aug 16 23:02:42 2018
0> Thu Aug 16 23:02:43 2018
0> Thu Aug 16 23:02:44 2018
0> Thu Aug 16 23:02:45 2018
0> Thu Aug 16 23:02:46 2018
0> Thu Aug 16 23:02:47 2018
0> Thu Aug 16 23:02:48 2018
0> Thu Aug 16 23:02:49 2018
0> resetting time using hour 23...
0> Thu Aug 16 23:02:51 2018
0> Thu Aug 16 23:02:51 2018
0> Thu Aug 16 23:02:52 2018
0> Thu Aug 16 23:02:53 2018
0> Thu Aug 16 23:02:54 2018
0> Thu Aug 16 23:02:55 2018
0> Thu Aug 16 23:02:56 2018
0> Thu Aug 16 23:02:57 2018
0> Thu Aug 16 23:02:58 2018
0> Thu Aug 16 23:02:59 2018
0> resetting time using hour 22...
0> Thu Aug 16 22:03:01 2018
0> Thu Aug 16 22:03:01 2018
0> Thu Aug 16 22:03:02 2018
0> Thu Aug 16 22:03:03 2018
0> Thu Aug 16 22:03:04 2018
0> Thu Aug 16 22:03:05 2018
0> Thu Aug 16 22:03:06 2018
0> Thu Aug 16 22:03:07 2018
0> Thu Aug 16 22:03:08 2018
0> Thu Aug 16 22:03:09 2018
0> resetting time using hour 22...
0> Thu Aug 16 22:03:11 2018
0> Thu Aug 16 22:03:11 2018
0> Thu Aug 16 22:03:12 2018
0> Thu Aug 16 22:03:13 2018
0> Thu Aug 16 22:03:14 2018
0> Thu Aug 16 22:03:15 2018
0> Thu Aug 16 22:03:16 2018
0> Thu Aug 16 22:03:17 2018
0> Thu Aug 16 22:03:18 2018
0> Thu Aug 16 22:03:19 2018

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions