Skip to content

STM32WL System Clock differs at boot/reset and after deepsleep #15470

Open
@hallard

Description

@hallard

Description of defect

When the board is booting up of after a reset button push, sysclock is set to 4Mhz and immediately atfer first deepsleep Sysclock is back to 48MHz, I don't know if it is intentional, issue or just normal behavior.

Anyway it could be cause of my previous issue a boot #15463

Target(s) affected by this defect ?

STM32WL, may be others

Toolchain(s) (name and version) displaying this defect ?

image

What version of Mbed-os are you using (tag or sha) ?

mbed-os-99.99.99

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

MBED Studio V1.4.5

How is this defect reproduced ?

build an run following code

#include "mbed.h"
using namespace std::chrono;

EventQueue ev_queue(16 * EVENTS_EVENT_SIZE);

void show_sysclocks_freq()
{
  printf("SysClk=%dMHz  PCLK1=%dMHz  PCLK2=%dMHz\r\n", 
    (uint32_t) HAL_RCC_GetSysClockFreq() / 1000000, 
    (uint32_t) HAL_RCC_GetPCLK1Freq() / 1000000 , 
    (uint32_t) HAL_RCC_GetPCLK2Freq() / 1000000 );
}

int main()
{
  printf("\r\nStarting\r\n");
  show_sysclocks_freq();

  for (int i=0; i< 4 ; i++) {
    printf("Sleeping\r\n");
    ThisThread::sleep_for(1s);
    show_sysclocks_freq();
  }
  ev_queue.dispatch_forever();
}

result is as follow

Starting
SysClk=4MHz  PCLK1=4MHz  PCLK2=4MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz

Starting with a small deepsleep fix the issue

int main()
{
  ThisThread::sleep_for(10ms);
  printf("\r\nStarting\r\n");
  show_sysclocks_freq();

  for (int i=0; i< 4 ; i++) {
    printf("Sleeping\r\n");
    ThisThread::sleep_for(1s);
    show_sysclocks_freq();
  }
  ev_queue.dispatch_forever();
}

result is as follow

Starting
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz
Sleeping
SysClk=48MHz  PCLK1=48MHz  PCLK2=48MHz

Please not that sleeping less than 8ms when starting does not resolve the issue, looks like some time is needed for clock going to 48MHz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Needs Triage

    Status

    Untriaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions