Skip to content

Commit b93c8bb

Browse files
committed
[Nucleo F411RE] Update system clock config
Avoid using MCO output of ST-LINK MCU as HSE instead use HSI Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 5b94c79 commit b93c8bb

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

variants/NUCLEO_F411RE/variant.cpp

+24-34
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,17 @@ extern "C" {
103103
/**
104104
* @brief System Clock Configuration
105105
* The system Clock is configured as follow :
106-
* System Clock source = PLL (HSE)
107-
* SYSCLK(Hz) = 96000000
108-
* HCLK(Hz) = 96000000
106+
* System Clock source = PLL (HSI)
107+
* SYSCLK(Hz) = 10000000
108+
* HCLK(Hz) = 10000000
109109
* AHB Prescaler = 1
110110
* APB1 Prescaler = 2
111111
* APB2 Prescaler = 1
112-
* HSE Frequency(Hz) = 8000000
113112
* HSI Frequency(Hz) = 16000000
114113
* PLL_M = 8
115-
* PLL_N = 384
114+
* PLL_N = 100
116115
* PLL_P = 4
117-
* PLL_Q = 8
116+
* PLL_Q = 2
118117
* VDD(V) = 3.3
119118
* Main regulator output voltage = Scale1 mode
120119
* Flash Latency(WS) = 3
@@ -127,31 +126,28 @@ WEAK void SystemClock_Config(void)
127126
RCC_ClkInitTypeDef RCC_ClkInitStruct;
128127
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
129128

130-
/**Configure the main internal regulator output voltage
131-
*/
129+
/* Configure the main internal regulator output voltage */
132130
__HAL_RCC_PWR_CLK_ENABLE();
133131

134132
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
135133

136-
/**Initializes the CPU, AHB and APB busses clocks
137-
*/
138-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
139-
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
140-
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
134+
/* Initializes the CPU, AHB and APB busses clocks */
135+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE;
136+
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
137+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
138+
RCC_OscInitStruct.HSICalibrationValue = 16;
141139
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
142-
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
140+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
143141
RCC_OscInitStruct.PLL.PLLM = 8;
144-
RCC_OscInitStruct.PLL.PLLN = 384;
145-
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
146-
RCC_OscInitStruct.PLL.PLLQ = 8;
142+
RCC_OscInitStruct.PLL.PLLN = 100;
143+
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
144+
RCC_OscInitStruct.PLL.PLLQ = 4;
147145
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
148146
{
149-
/* Initialization Error */
150-
while(1);
147+
_Error_Handler(__FILE__, __LINE__);
151148
}
152149

153-
/**Initializes the CPU, AHB and APB busses clocks
154-
*/
150+
/* Initializes the CPU, AHB and APB busses clocks */
155151
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
156152
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
157153
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
@@ -161,31 +157,25 @@ WEAK void SystemClock_Config(void)
161157

162158
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
163159
{
164-
/* Initialization Error */
165-
while(1);
160+
_Error_Handler(__FILE__, __LINE__);
166161
}
167162

168-
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S|RCC_PERIPHCLK_RTC;
169-
PeriphClkInitStruct.PLLI2S.PLLI2SN = 192;
170-
PeriphClkInitStruct.PLLI2S.PLLI2SM = 8;
171-
PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;
172-
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
163+
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
164+
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
173165
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
174166
{
175-
/* Initialization Error */
176-
while(1);
167+
_Error_Handler(__FILE__, __LINE__);
177168
}
178169

179-
/**Configure the Systick interrupt time
180-
*/
170+
/* Configure the Systick interrupt time */
181171
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
182172

183-
/**Configure the Systick
184-
*/
173+
/* Configure the Systick */
185174
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
186175

187176
/* SysTick_IRQn interrupt configuration */
188177
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
178+
189179
}
190180
#ifdef __cplusplus
191181
}

0 commit comments

Comments
 (0)