Delay functions aren't working on custom NUCLEO-L452RE-P configuration

Hi all,

I managed to create custom target configuration for NUCLEO-L452RE-P board (mostly by copying config from L432KC which looks very similar) and compiling, flashing and turning GPIO pins on and off works but wait/sleep functions aren’t waiting. I guess it’s something related to clocks and/or timer but I don’t know where to look any more.

So, if I just toggle the digital out and check the pin with the scope (basic blinky with ThisThread::sleep_for() removed) I get toggling at 220kHz. If I put sleep_for then the toggling happens at 13kHz (whatever number I put into sleep_for).

Can anyone give me any clue about this?

This is the custom configuration:

    "NUCLEO_L452RE_P": {
    "inherits": ["FAMILY_STM32"],
    "core": "Cortex-M4F",
    "extra_labels_add": [
    "config": {
        "clock_source": {
            "help": "Mask value : USE_PLL_HSE_EXTC (need HW patch) | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI | USE_PLL_MSI",
            "value": "USE_PLL_MSI",
            "macro_name": "CLOCK_SOURCE"
        "lpticker_lptim": {
            "help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
            "value": 1
    "macros_add": [
    "overrides": { "lpticker_delay_ticks": 0 },
    "detect_code": ["0770"],
    "device_has_add": [
    "release_versions": ["2", "5"],
    "device_name": "STM32L452RE",
    "bootloader_supported": true

EDIT: It’s definitely something clock related. If I start another thread with busy loop then sleep_for() in the main works as it should. But whenever The CPU goes to sleep it doesn’t wake up. For testing I added a serial print before the sleep_for() in the while loop and I get the text only once. This is a bit unfortunate as I need to build low power node :slight_smile:

I do not believe that it has hit the online compiler, but the mbed github 6.0.0-alpha-2 version (released this February) has this specific board released. Have you tried your code with that release (or later version)?

It may not solve the issue directly, but it did pass the tests for all 3 compilers. If there is an issue, it would be good to look at the problems in the released code.

1 Like

@peapod you’re my hero! It never crossed my mind to check that. I’ve copied the configuration from 6.0 into custom target and it works now. Thanks!