Skip to content

Commit 8ff971e

Browse files
committed
Add DEBUG_UART build test for stm32wba. Fix stm32wba clock init
1 parent 660a4fa commit 8ff971e

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

.github/workflows/test-configs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,14 @@ jobs:
710710
arch: arm
711711
config-file: ./config/examples/stm32wba.config
712712

713+
# DEBUG_UART=1 variant: compiles the GPIO/UART drivers and board.h pin table.
714+
stm32wba_wolfhal_debug_uart_test:
715+
uses: ./.github/workflows/test-build.yml
716+
with:
717+
arch: arm
718+
config-file: ./config/examples/stm32wba.config
719+
make-args: DEBUG_UART=1
720+
713721
# TODO: ti-tms570lc435.config requires F021 Flash API (Windows installer only)
714722
# ti_tms570lc435_test:
715723
# uses: ./.github/workflows/test-build-ti-hercules.yml

hal/boards/stm32wba55cg_nucleo/board.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* BOARD_*_DEV handles for the rest. RCC is header-inlined and hardcodes
77
* its base — no dev pointer needed.
88
*
9-
* Clock target: HSE32 -> PLL1 (M=1, N=25, R=3) -> SYSCLK = 100 MHz, which
9+
* Clock target: HSE32 -> PLL1 (M=1, N=24, R=3) -> SYSCLK = 100 MHz, which
1010
* requires PWR voltage scaling Range 1 and 3 flash wait states (RM0493).
1111
*
1212
* Copyright (C) 2026 wolfSSL Inc.
@@ -66,7 +66,7 @@ static void set_vos_range1(void)
6666
;
6767
}
6868

69-
/* HSE32 -> PLL1 (M=1, N=25, R=3 -> 100 MHz) -> SYSCLK */
69+
/* HSE32 -> PLL1 (M=1, N=24, R=3 -> 100 MHz) -> SYSCLK */
7070
static void pll_clock_on(void)
7171
{
7272
/* Enable PWR clock so the PWR registers are accessible, then move to
@@ -85,10 +85,14 @@ static void pll_clock_on(void)
8585

8686
whal_Stm32wba_Rcc_EnableOsc(
8787
&(whal_Stm32wba_Rcc_OscCfg){WHAL_STM32WBA_RCC_HSE32_CFG});
88+
/* M/N/R are (value-1) encoded per RM0493 (divide/multiply = field + 1):
89+
* f_ref = HSE32 / (M+1) = 32 / 2 = 16 MHz (PLL1RGE 8-16)
90+
* f_vco = f_ref * (N+1) = 16 * 25 = 400 MHz (VCO 128-544)
91+
* SYSCLK = f_vco / (R+1) = 400 / 4 = 100 MHz (part max) */
8892
whal_Stm32wba_Rcc_EnablePll1(&(whal_Stm32wba_Rcc_Pll1Cfg){
8993
.clkSrc = WHAL_STM32WBA_RCC_PLL1SRC_HSE32,
9094
.rge = WHAL_STM32WBA_RCC_PLL1RGE_8_16,
91-
.m = 1, .n = 25, .r = 3, .q = 0, .p = 0,
95+
.m = 1, .n = 24, .r = 3, .q = 0, .p = 0,
9296
});
9397
whal_Stm32wba_Rcc_SetSysClock(WHAL_STM32WBA_RCC_SYSCLK_SRC_PLL1);
9498
}
@@ -104,11 +108,14 @@ static void pll_clock_off(void)
104108

105109
void hal_init(void)
106110
{
111+
#ifdef DEBUG_UART
112+
size_t i;
113+
#endif
107114
pll_clock_on();
108115
whal_Flash_Init(BOARD_FLASH_DEV);
109116

110117
#ifdef DEBUG_UART
111-
for (size_t i = 0; i < PERIPH_CLK_COUNT; i++) {
118+
for (i = 0; i < PERIPH_CLK_COUNT; i++) {
112119
whal_Stm32wba_Rcc_EnablePeriphClk(&g_periphClks[i]);
113120
}
114121

@@ -120,10 +127,12 @@ void hal_init(void)
120127
void hal_prepare_boot(void)
121128
{
122129
#ifdef DEBUG_UART
130+
size_t i;
131+
123132
whal_Uart_Deinit(BOARD_UART_DEV);
124133
whal_Gpio_Deinit(BOARD_GPIO_DEV);
125134

126-
for (size_t i = PERIPH_CLK_COUNT; i-- > 0; ) {
135+
for (i = PERIPH_CLK_COUNT; i-- > 0; ) {
127136
whal_Stm32wba_Rcc_DisablePeriphClk(&g_periphClks[i]);
128137
}
129138
#endif

0 commit comments

Comments
 (0)