Skip to content

Commit 8441aac

Browse files
committed
fix(Nucleo-G431KB): LPUART1 clock configuration
Old clock config prevented usage at 9600. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent ceb3beb commit 8441aac

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

variants/STM32G4xx/G431K(6-8-B)(T-U)_G441KB(T-U)/variant_NUCLEO_G431KB.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ WEAK void SystemClock_Config(void)
6666
/* HSE is available but SB9 and SB10 OFF so not usable per default */
6767
RCC_OscInitTypeDef RCC_OscInitStruct = {};
6868
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
69+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
6970

7071
/* Configure the main internal regulator output voltage */
7172
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
7273
/* Initializes the CPU, AHB and APB busses clocks */
73-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
74+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
7475
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
7576
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
77+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
7678
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
7779
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
7880
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
@@ -94,10 +96,17 @@ WEAK void SystemClock_Config(void)
9496
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8) != HAL_OK) {
9597
Error_Handler();
9698
}
99+
/* Initializes the peripherals clocks */
100+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
101+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
102+
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
103+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
104+
Error_Handler();
105+
}
97106
}
98107

99108
#ifdef __cplusplus
100109
} // extern "C"
101110
#endif
102111

103-
#endif /* ARDUINO_NUCLEO_G431KB */
112+
#endif /* ARDUINO_NUCLEO_G431KB */

variants/STM32G4xx/G431K(6-8-B)(T-U)_G441KB(T-U)/variant_NUCLEO_G431KB.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,17 @@
126126

127127
// UART Definitions
128128
#ifndef SERIAL_UART_INSTANCE
129-
#define SERIAL_UART_INSTANCE 2 //Connected to ST-Link
129+
#define SERIAL_UART_INSTANCE 101 //Connected to ST-Link
130130
#endif
131131

132132
// Default pin used for 'Serial' instance (ex: ST-Link)
133133
// Mandatory for Firmata
134-
#define PIN_SERIAL_RX PA3
135-
#define PIN_SERIAL_TX PA2
134+
#ifndef PIN_SERIAL_RX
135+
#define PIN_SERIAL_RX PA3
136+
#endif
137+
#ifndef PIN_SERIAL_TX
138+
#define PIN_SERIAL_TX PA2
139+
#endif
136140

137141
/* Extra HAL modules */
138142
#if !defined(HAL_DAC_MODULE_DISABLED)

0 commit comments

Comments
 (0)