STM32L4: RTC Tickless Configuration


While attempting to update the Mbed OS version used by our application I started seeing crashes.

This led me to investigate the RTC tickless behaviour and question what the configuration should be.

I’ve discussed this configuration in the past a great deal with @jeromecoutant.

I have a very simple demonstration that will not run reliably on my NUCLEO-L433RC-P…

#include <Kernel.h>
#include <ThisThread.h>

#include <cstdio>

int main() {
    printf("tickless RTC V5.14.1\n");

    while (1) {
        printf("get_ms_count %llu\n", rtos::Kernel::get_ms_count());

Importantly the RTC is selected for the LPTICKER:

    "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": "115200",
            "target.lpticker_lptim": 0

If I build with Mbed V.5.14.1 this app will not run for long. Sometimes it freezes after a just a few iterations, sometimes it runs for a minute or 2.

If I build with Mbed V5.13.4 this app runs continually. Of course it is difficult to guarantee the absence of a problem but I’ve run the V5.13.4 version considerably longer without seeing it freeze.

Adding "target.lpticker_delay_ticks": 1 appears to make the V5.14.1 build stable but I’m reluctant to change an important setting like this without discussion! It seems a bit odd that updating Mbed OS requires a change to a setting like this.

To summarise my question, what’s the recommended RTC tickless configuration for STM32L4 and Mbed OS V5.14 or later?

I’m compiling this test using the online compiler which I guess is the ARM compiler. But, I believe I see the same issue building offline with ARM GCC.

I know there have been some significant changes relating to sleep, e.g. Sleep rework, RTOS API for bare metal, wait deprecations #10104, which partly why I wanted to update Mbed OS. But clearly, I can’t update if it breaks my app!


Tickless is supported only with LPTIM, not with RTC.
Keep the default settings.

Hi @jeromecoutant,

Tickless is supported only with LPTIM, not with RTC.

Oh, that’s a bit of a problem and I don’t believe it is what you said last time we discussed this! How to Achieve Long Periods of Deep Sleep on STM32 #7156

Is it just that ST don’t want to offer support for RTC or do you think there is a real problem?

Do you seem what I mean? Not supporting something is not always the same as saying it won’t work.