From 0f7374b694d40a4deaf60f61e4b6ae87f668522b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nedjar?= Date: Sun, 29 Nov 2026 21:53:31 +0100 Subject: [PATCH] variant(wb55): clock STeaMi from PLL at 64 MHz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SystemClock_Config() enabled the main PLL (HSI16 / 2 x 16 / 2 = 64 MHz) but selected HSE as SYSCLK, so the core ran at 32 MHz and the PLL output was unused. Feed the PLL from HSE / 2 = 16 MHz (N = 8, R = 2) and select it as SYSCLK: HCLK1, HCLK4, PCLK1 and PCLK2 run at 64 MHz, HCLK2 (CPU2) stays at 32 MHz (divider 2), with 3 flash wait states. The PLL input is shared with PLLSAI1, which clocks the PDM microphone on SAI1. It now comes from the HSE crystal instead of HSI16, and 16 MHz still divides 128 MHz, so PLLSAI1 can give 64 MHz to SAI1 with N = 8. Signed-off-by: Sébastien Nedjar --- .../WB55R(C-E-G)V/variant_STEAM32_WB55RG.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/variants/STM32WBxx/WB55R(C-E-G)V/variant_STEAM32_WB55RG.cpp b/variants/STM32WBxx/WB55R(C-E-G)V/variant_STEAM32_WB55RG.cpp index db594eb52a..ca8cb0efaa 100644 --- a/variants/STM32WBxx/WB55R(C-E-G)V/variant_STEAM32_WB55RG.cpp +++ b/variants/STM32WBxx/WB55R(C-E-G)V/variant_STEAM32_WB55RG.cpp @@ -105,10 +105,14 @@ WEAK void SystemClock_Config(void) RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + /* PLL input = HSE / 2 = 16 MHz (the input the HAL recommends to limit + * PLL jitter), VCO = 16 MHz x 8 = 128 MHz, PLLR = 64 MHz. + * The PLL input (source and M) is shared with PLLSAI1: 16 MHz divides + * 128 MHz exactly, so PLLSAI1 can still give 64 MHz to SAI1 (N = 8). */ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV2; - RCC_OscInitStruct.PLL.PLLN = 16; + RCC_OscInitStruct.PLL.PLLN = 8; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; @@ -119,13 +123,15 @@ WEAK void SystemClock_Config(void) /* Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK4 | RCC_CLOCKTYPE_HCLK2 | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE; + /* SYSCLK = HCLK1 = HCLK4 = PCLK1 = PCLK2 = 64 MHz, HCLK2 (CPU2) = 32 MHz + * (its maximum). 64 MHz on HCLK4 in range 1 needs 3 flash wait states. */ + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - RCC_ClkInitStruct.AHBCLK2Divider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLK2Divider = RCC_SYSCLK_DIV2; RCC_ClkInitStruct.AHBCLK4Divider = RCC_SYSCLK_DIV1; - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) { Error_Handler(); }