Skip to content

Commit 3f83163

Browse files
committed
Fixed system clock setup for XTAL and/or internal source on stm32f743 chips.
1 parent 33a538a commit 3f83163

File tree

1 file changed

+11
-4
lines changed
  • targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H743xI/TARGET_NUCLEO_H743ZI2

1 file changed

+11
-4
lines changed

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H743xI/TARGET_NUCLEO_H743ZI2/system_clock.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void SetSysClock(void)
7272
#if ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL)
7373
/* 2- If fail try to start with HSE and external xtal */
7474
if (SetSysClock_PLL_HSE(0) == 0)
75-
#endif
75+
#endif
7676
{
7777
#if ((CLOCK_SOURCE) & USE_PLL_HSI)
7878
/* 3- If fail start with HSI clock */
@@ -109,11 +109,18 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
109109
} else {
110110
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
111111
}
112+
#if HSE_VALUE==8000000
113+
RCC_OscInitStruct.PLL.PLLM = 4; // 2 MHz
114+
RCC_OscInitStruct.PLL.PLLN = 480; // 960 MHz
115+
#elif HSE_VALUE==25000000
116+
RCC_OscInitStruct.PLL.PLLM = 5; // 5 MHz
117+
RCC_OscInitStruct.PLL.PLLN = 192; // 960 MHz
118+
#else
119+
error("Unsupported externall clock value, check hse_value define\n")
120+
#endif
112121
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
113122
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
114123
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
115-
RCC_OscInitStruct.PLL.PLLM = 4; // 2 MHz
116-
RCC_OscInitStruct.PLL.PLLN = 480; // 960 MHz
117124
RCC_OscInitStruct.PLL.PLLP = 2; // PLLCLK = SYSCLK = 480 MHz
118125
RCC_OscInitStruct.PLL.PLLQ = 96; // PLL1Q used for FDCAN = 10 MHz
119126
RCC_OscInitStruct.PLL.PLLR = 2;
@@ -178,7 +185,7 @@ uint8_t SetSysClock_PLL_HSI(void)
178185
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
179186
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
180187
RCC_OscInitStruct.PLL.PLLM = 8;
181-
RCC_OscInitStruct.PLL.PLLN = 100;
188+
RCC_OscInitStruct.PLL.PLLN = 120;
182189
RCC_OscInitStruct.PLL.PLLP = 2;
183190
RCC_OscInitStruct.PLL.PLLQ = 2;
184191
RCC_OscInitStruct.PLL.PLLR = 2;

0 commit comments

Comments
 (0)