Skip to content

Commit d35320e

Browse files
committed
chore(variants): ensure LPUART clock source config
Since uart rework, LPUART source have to be properly set in SystemClock_Config() to ensure 9600 baudrate is supported. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 47f3704 commit d35320e

12 files changed

Lines changed: 85 additions & 25 deletions

File tree

‎variants/STM32L4xx/L412RB(I-T)xP/variant_NUCLEO_L412RB_P.cpp‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,21 @@ WEAK void SystemClock_Config(void)
117117
* in the RCC_OscInitTypeDef structure.
118118
*/
119119
/* MSI is enabled after System reset, activate PLL with MSI as source */
120-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
121-
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
120+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSI
121+
| RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
122122
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
123+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
124+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
125+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
123126
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
127+
RCC_OscInitStruct.MSICalibrationValue = 0;
124128
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
125-
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
126129
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
127130
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
128131
RCC_OscInitStruct.PLL.PLLM = 1;
129132
RCC_OscInitStruct.PLL.PLLN = 40;
130-
RCC_OscInitStruct.PLL.PLLR = RCC_PLLQ_DIV2;
131133
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
134+
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
132135
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
133136
Error_Handler();
134137
}
@@ -142,7 +145,8 @@ WEAK void SystemClock_Config(void)
142145
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
143146
Error_Handler();
144147
}
145-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
148+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
149+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
146150
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
147151
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
148152
Error_Handler();

‎variants/STM32L4xx/L433RCTxP/generic_clock.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ WEAK void SystemClock_Config(void)
2828
* Initializes the RCC Oscillators according to the specified parameters
2929
* in the RCC_OscInitTypeDef structure.
3030
*/
31-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_MSI;
31+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSI
32+
| RCC_OSCILLATORTYPE_MSI;
33+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
3234
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
35+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
3336
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
3437
RCC_OscInitStruct.MSICalibrationValue = 0;
3538
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
@@ -54,7 +57,8 @@ WEAK void SystemClock_Config(void)
5457
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
5558
Error_Handler();
5659
}
57-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
60+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
61+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
5862
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
5963
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
6064
Error_Handler();

‎variants/STM32L4xx/L433RCTxP/variant_NUCLEO_L433RC_P.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,11 @@ WEAK void SystemClock_Config(void)
116116
* Initializes the RCC Oscillators according to the specified parameters
117117
* in the RCC_OscInitTypeDef structure.
118118
*/
119-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
119+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE
120+
| RCC_OSCILLATORTYPE_MSI;
120121
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
122+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
123+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
121124
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
122125
RCC_OscInitStruct.MSICalibrationValue = 0;
123126
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
@@ -142,7 +145,8 @@ WEAK void SystemClock_Config(void)
142145
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
143146
Error_Handler();
144147
}
145-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
148+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
149+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
146150
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
147151
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
148152
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

‎variants/STM32L4xx/L452RC(I-T-Y)_L452RE(I-T-Y)x(P)_L462RE(I-T-Y)/variant_LEAFONY_AP03.cpp‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ WEAK void SystemClock_Config(void)
6767
{
6868
RCC_OscInitTypeDef RCC_OscInitStruct = {};
6969
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
70+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
7071

7172
/** Configure the main internal regulator output voltage
7273
*/
@@ -82,8 +83,11 @@ WEAK void SystemClock_Config(void)
8283
/** Initializes the RCC Oscillators according to the specified parameters
8384
* in the RCC_OscInitTypeDef structure.
8485
*/
85-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
86+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE
87+
| RCC_OSCILLATORTYPE_MSI;
8688
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
89+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
90+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
8791
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
8892
RCC_OscInitStruct.MSICalibrationValue = 0;
8993
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
@@ -111,6 +115,11 @@ WEAK void SystemClock_Config(void)
111115
Error_Handler();
112116
}
113117

118+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1;
119+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
120+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
121+
Error_Handler();
122+
}
114123
/** Enable MSI Auto calibration
115124
*/
116125
HAL_RCCEx_EnableMSIPLLMode();

‎variants/STM32L4xx/L452RC(I-T-Y)_L452RE(I-T-Y)x(P)_L462RE(I-T-Y)/variant_NUCLEO_L452RE.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ WEAK void SystemClock_Config(void)
111111
HAL_PWR_EnableBkUpAccess();
112112
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
113113
/* Initializes the CPU, AHB and APB busses clocks */
114-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
114+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE
115+
| RCC_OSCILLATORTYPE_MSI;
115116
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
117+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
118+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
116119
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
117120
RCC_OscInitStruct.MSICalibrationValue = 0;
118121
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
@@ -137,7 +140,8 @@ WEAK void SystemClock_Config(void)
137140
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
138141
Error_Handler();
139142
}
140-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
143+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
144+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
141145
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
142146
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
143147
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

‎variants/STM32L4xx/L452RETxP/variant_NUCLEO_L452RE_P.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ WEAK void SystemClock_Config(void)
110110
HAL_PWR_EnableBkUpAccess();
111111
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
112112
/* Initializes the CPU, AHB and APB busses clocks */
113-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
113+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
114+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
115+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
114116
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
115117
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
116118
RCC_OscInitStruct.MSICalibrationValue = 0;
@@ -136,7 +138,8 @@ WEAK void SystemClock_Config(void)
136138
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
137139
Error_Handler();
138140
}
139-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
141+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
142+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
140143
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
141144
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
142145
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

‎variants/STM32L4xx/L496Z(E-G)T_L4A6ZGT/variant_NUCLEO_L496ZG.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,11 @@ WEAK void SystemClock_Config(void)
194194
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
195195

196196
/* Initializes the CPU, AHB and APB busses clocks */
197-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
197+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE
198+
| RCC_OSCILLATORTYPE_MSI;
198199
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
200+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
201+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
199202
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
200203
RCC_OscInitStruct.MSICalibrationValue = 0;
201204
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
@@ -222,7 +225,8 @@ WEAK void SystemClock_Config(void)
222225
Error_Handler();
223226
}
224227

225-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
228+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
229+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
226230
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
227231
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
228232
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

‎variants/STM32L4xx/L496ZGTxP_L4A6ZGTxP/variant_NUCLEO_L496ZG_P.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,11 @@ WEAK void SystemClock_Config(void)
193193
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
194194

195195
/* Initializes the CPU, AHB and APB busses clocks */
196-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
196+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE
197+
| RCC_OSCILLATORTYPE_MSI;
197198
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
199+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
200+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
198201
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
199202
RCC_OscInitStruct.MSICalibrationValue = 0;
200203
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
@@ -221,7 +224,8 @@ WEAK void SystemClock_Config(void)
221224
Error_Handler();
222225
}
223226

224-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
227+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
228+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
225229
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
226230
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
227231
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

‎variants/STM32L4xx/L4R5Z(G-I)T_L4R7ZIT_L4S5ZIT_L4S7ZIT/variant_NUCLEO_L4R5ZI.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ WEAK void SystemClock_Config(void)
191191
* Initializes the RCC Oscillators according to the specified parameters
192192
* in the RCC_OscInitTypeDef structure.
193193
*/
194-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
194+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE
195+
| RCC_OSCILLATORTYPE_MSI;
196+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
197+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
195198
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
196199
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
197200
RCC_OscInitStruct.MSICalibrationValue = 0;
@@ -217,7 +220,8 @@ WEAK void SystemClock_Config(void)
217220
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) {
218221
Error_Handler();
219222
}
220-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
223+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
224+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
221225
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
222226
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
223227
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

‎variants/STM32L4xx/L4R5ZITxP/variant_NUCLEO_L4R5ZI_P.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ WEAK void SystemClock_Config(void)
190190
* Initializes the RCC Oscillators according to the specified parameters
191191
* in the RCC_OscInitTypeDef structure.
192192
*/
193-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI;
193+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE
194+
| RCC_OSCILLATORTYPE_MSI;
195+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
196+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
194197
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
195198
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
196199
RCC_OscInitStruct.MSICalibrationValue = 0;
@@ -216,7 +219,8 @@ WEAK void SystemClock_Config(void)
216219
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) {
217220
Error_Handler();
218221
}
219-
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
222+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB;
223+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI;
220224
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
221225
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_MSI;
222226
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;

0 commit comments

Comments
 (0)