Skip to content

Commit 60cbab3

Browse files
authored
Merge pull request #13640 from isaev-d/fix-pll-stm32h743
STM32: Fix system clock setup for XTAL and/or internal source on STM32H743
2 parents d896ea3 + 8597f6a commit 60cbab3

File tree

1 file changed

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

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ void SetSysClock(void)
8585
}
8686
}
8787

88+
8889
#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) )
8990
/******************************************************************************/
9091
/* PLL (clocked by HSE) used as System clock source */
@@ -109,11 +110,18 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
109110
} else {
110111
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
111112
}
113+
#if HSE_VALUE==8000000
114+
RCC_OscInitStruct.PLL.PLLM = 4; // 2 MHz
115+
RCC_OscInitStruct.PLL.PLLN = 480; // 960 MHz
116+
#elif HSE_VALUE==25000000
117+
RCC_OscInitStruct.PLL.PLLM = 5; // 5 MHz
118+
RCC_OscInitStruct.PLL.PLLN = 192; // 960 MHz
119+
#else
120+
#error Unsupported externall clock value, check hse_value define
121+
#endif
112122
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
113123
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
114124
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
115-
RCC_OscInitStruct.PLL.PLLM = 4; // 2 MHz
116-
RCC_OscInitStruct.PLL.PLLN = 480; // 960 MHz
117125
RCC_OscInitStruct.PLL.PLLP = 2; // PLLCLK = SYSCLK = 480 MHz
118126
RCC_OscInitStruct.PLL.PLLQ = 96; // PLL1Q used for FDCAN = 10 MHz
119127
RCC_OscInitStruct.PLL.PLLR = 2;
@@ -178,7 +186,7 @@ uint8_t SetSysClock_PLL_HSI(void)
178186
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
179187
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
180188
RCC_OscInitStruct.PLL.PLLM = 8;
181-
RCC_OscInitStruct.PLL.PLLN = 100;
189+
RCC_OscInitStruct.PLL.PLLN = 120;
182190
RCC_OscInitStruct.PLL.PLLP = 2;
183191
RCC_OscInitStruct.PLL.PLLQ = 2;
184192
RCC_OscInitStruct.PLL.PLLR = 2;

0 commit comments

Comments
 (0)