Skip to content

Commit 022c0eb

Browse files
committed
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.
1 parent b1b0673 commit 022c0eb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

targets/TARGET_STM/sleep.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ static void ForceOscOutofDeepSleep(void)
9898
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
9999
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
100100
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
101-
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_4; // Intermediate freq, 1MHz range
101+
#if defined RCC_MSIRANGE_11
102+
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; // Highest freq, 48MHz range
103+
#else
104+
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; // 4MHz range
105+
#endif
102106
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
103107
#else /* defined RCC_SYSCLKSOURCE_MSI */
104108
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

0 commit comments

Comments
 (0)