@@ -132,17 +132,15 @@ WEAK void initVariant(void)
132132 * Key features:
133133 * - SYSCLK = 80 MHz from MSI (4 MHz, Range 6) via PLL (4MHz x 40/2)
134134 * - USB FS (48 MHz) sourced from PLLSAI1 (4MHz x 24/2)
135- * - HSI disabled to reduce current consumption (~200-300 uA)
136135 * - LSE enabled with medium-low drive for RTC and MSI auto-calibration (MSIPLLEN)
137136 * - Voltage Scale 1 required for 80 MHz operation
138137 * - FLASH_LATENCY_4 required for HCLK > 64 MHz at VOS1 (RM0394 s.3.3.3)
139138 * - MSI PLL-mode (MSIPLLEN) enabled after SYSCLK moves to PLL to avoid MSIRDY stall
140139 * - Wake-up clock after STOP: MSI (PLL must be re-locked manually after wake)
141140 *
142141 * References:
143- * - RM0394 Rev 6 (STM32L43x/L44x) - s.6.2 "MSI clock"
144- * - RM0394 s.6.2.9 "MSI PLL-mode"
145- * - RM0394 s.3.3.3 "Performance versus VDD and clock frequency"
142+ * - RM0394 Rev 6 (STM32L43x/L44x) - s.6.2.3 "MSI clock" (includes MSI PLL-mode)
143+ * - RM0394 s.3.3.3 "Read access latency"
146144 * - AN2867 Rev 11 - "Oscillator design guide for STM8AF/AL/S, STM32 MCUs and MPUs"
147145 */
148146WEAK void SystemClock_Config (void )
@@ -153,15 +151,15 @@ WEAK void SystemClock_Config(void)
153151
154152 /* * Enable PWR peripheral clock
155153 *
156- * RM0394 s.5.1.2: PWR registers are on APB1. PWREN (RCC_APB1ENR1 bit 28)
157- * resets to 1, so this is defensive rather than strictly necessary, but
158- * required for correctness if PWREN has been cleared by prior code .
154+ * RM0394 s.6.4.18: PWREN (RCC_APB1ENR1 bit 28) resets to 0, so this call
155+ * is required before accessing any PWR register (e.g.,
156+ * HAL_PWREx_ControlVoltageScaling below) .
159157 * CubeMX generates this unconditionally for all STM32L4 projects.
160158 */
161159 __HAL_RCC_PWR_CLK_ENABLE ();
162160
163161 /* Voltage scaling - Scale 1 required for SYSCLK = 80 MHz
164- * RM0394 s.6.1 : VOS2 supports up to 26 MHz only
162+ * RM0394 s.5.1.7 : VOS2 supports up to 26 MHz only
165163 */
166164 if (HAL_PWREx_ControlVoltageScaling (PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) {
167165 Error_Handler ();
@@ -186,17 +184,15 @@ WEAK void SystemClock_Config(void)
186184 *
187185 * Oscillator configuration summary:
188186 * - MSI: MSIRANGE_6 (4 MHz) -- used as PLL input
189- * - HSI: OFF -- Unused, disabling it saves ~200-300 uA
190187 * - PLL: ON (MSI 4MHz x PLLN=40 / PLLR=2 = 80 MHz)
191188 * - SYSCLK: PLLCLK (80 MHz)
192189 * - USB clock: PLLSAI1 (48 MHz)
193190 * - MSIRDY transient can not stall SysTick because SYSCLK = PLL, not MSI.
194- * - FLASH_LATENCY: 4 (required for 80 MHz / VOS1 per RM0394 s.3.3)
191+ * - FLASH_LATENCY: 4 (required for 80 MHz / VOS1 per RM0394 s.3.3.3 )
195192 */
196193 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE
197194 | RCC_OSCILLATORTYPE_MSI;
198195 RCC_OscInitStruct.LSEState = RCC_LSE_ON;
199- RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
200196 RCC_OscInitStruct.MSIState = RCC_MSI_ON;
201197 RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
202198 RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
@@ -217,12 +213,12 @@ WEAK void SystemClock_Config(void)
217213 * the PLL output, completely decoupled from MSI. Any subsequent MSIRDY
218214 * transient (from HAL_RCCEx_EnableMSIPLLMode below) cannot stall SysTick.
219215 */
220- RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
221- | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
222- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
223- RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
216+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1
217+ | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_SYSCLK;
218+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
224219 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
225220 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
221+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
226222 /* FLASH_LATENCY_4: required for HCLK > 64 MHz at VOS1 (RM0394 s.3.3.3) */
227223 if (HAL_RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
228224 Error_Handler ();
@@ -259,7 +255,7 @@ WEAK void SystemClock_Config(void)
259255
260256 /* * Enable MSI Auto calibration (MSIPLLEN, RCC_CR[2])
261257 *
262- * RM0394 s.6.2 (MSI clock): setting MSIPLLEN causes the MSI hardware
258+ * RM0394 s.6.2.3 (MSI clock): setting MSIPLLEN causes the MSI hardware
263259 * to automatically trim itself against LSE as a phase reference,
264260 * reducing MSI frequency error to < +/-0.25%. LSE must already be
265261 * stable (LSERDY=1) before the bit is set -- guaranteed here because
@@ -277,7 +273,7 @@ WEAK void SystemClock_Config(void)
277273 *
278274 * (2) If SYSCLK were MSI, a deadlock would be possible: MSIRDY
279275 * drops -> SysTick stalls -> HAL_GetTick() freezes -> any
280- * subsequent timeout loop never exits. RM0394 s.6.2.9 confirms
276+ * subsequent timeout loop never exits. RM0394 s.6.2 confirms
281277 * SysTick is driven by HCLK (= SYSCLK / AHBdiv). Because
282278 * SYSCLK is now PLLCLK (80 MHz), SysTick is completely
283279 * decoupled from MSI and the transient is harmless.
0 commit comments