From 022c0eb7dcc960b7965d51dc8deb17e9ca76b52f Mon Sep 17 00:00:00 2001 From: Laurent Meunier Date: Tue, 7 Jan 2020 17:58:53 +0100 Subject: [PATCH] Increase MSI clock frequency when exiting deep sleep This will optimize down the time it takes to restore the clock settings when getting out of deep sleep. If 48MHz is available let's use it, otherwise at least 4MHz should be available for any MCU with MSI. --- targets/TARGET_STM/sleep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/targets/TARGET_STM/sleep.c b/targets/TARGET_STM/sleep.c index f0656666e4..3eda86a1e6 100644 --- a/targets/TARGET_STM/sleep.c +++ b/targets/TARGET_STM/sleep.c @@ -98,7 +98,11 @@ static void ForceOscOutofDeepSleep(void) RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; RCC_OscInitStruct.MSIState = RCC_MSI_ON; RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; - RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_4; // Intermediate freq, 1MHz range +#if defined RCC_MSIRANGE_11 + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; // Highest freq, 48MHz range +#else + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; // 4MHz range +#endif RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; #else /* defined RCC_SYSCLKSOURCE_MSI */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;