From cb4ccc74f42bcb0a8f469eb6e21e162dfc98e7b1 Mon Sep 17 00:00:00 2001 From: wdx04 <25487439@qq.com> Date: Mon, 25 Aug 2025 21:46:19 +0800 Subject: [PATCH 1/2] set MSI clock to RCC_MSIRANGE_0 (48MHz) for STM32U5 after wake-up from deep sleep --- targets/TARGET_STM/sleep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_STM/sleep.c b/targets/TARGET_STM/sleep.c index 0ae2e9dcbeb..6a787a1e759 100644 --- a/targets/TARGET_STM/sleep.c +++ b/targets/TARGET_STM/sleep.c @@ -98,8 +98,10 @@ __WEAK void ForceOscOutofDeepSleep(void) RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; RCC_OscInitStruct.MSIState = RCC_MSI_ON; RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; -#if defined RCC_MSIRANGE_11 - RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; // Highest freq, 48MHz range +#if defined (TARGET_STM32U5) + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_0; // Highest freq for U5, 48MHz range +#elif defined (RCC_MSIRANGE_11) + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; // Highest freq for L4/L5, 48MHz range #else RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; // 4MHz range #endif From 33c714395b26f35dc4823ee17302041367be0c40 Mon Sep 17 00:00:00 2001 From: wdx04 <25487439@qq.com> Date: Tue, 26 Aug 2025 08:30:13 +0800 Subject: [PATCH 2/2] modify the hardcoded HSICalibrationValue(16) to RCC_HSICALIBRATION_DEFAULT --- targets/TARGET_STM/sleep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/TARGET_STM/sleep.c b/targets/TARGET_STM/sleep.c index 6a787a1e759..452a3071aeb 100644 --- a/targets/TARGET_STM/sleep.c +++ b/targets/TARGET_STM/sleep.c @@ -109,7 +109,7 @@ __WEAK void ForceOscOutofDeepSleep(void) #else /* defined RCC_SYSCLKSOURCE_MSI */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; - RCC_OscInitStruct.HSICalibrationValue = 16; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; #endif /* defined RCC_SYSCLKSOURCE_MSI */