Skip to content

Commit 06e36fe

Browse files
committed
STM32H7: set ADC PLL clock for various source configurations
Replaces c65d254
1 parent 9f249ac commit 06e36fe

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

targets/TARGET_STM/TARGET_STM32H7/analogin_device.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,25 @@ void analogin_pll_configuration(void)
3636

3737
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
3838
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADC;
39-
PeriphClkInitStruct.PLL2.PLL2M = 4;
40-
PeriphClkInitStruct.PLL2.PLL2N = 240;
41-
PeriphClkInitStruct.PLL2.PLL2P = 2;
42-
PeriphClkInitStruct.PLL2.PLL2Q = 2;
39+
if(__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSI) {
40+
PeriphClkInitStruct.PLL2.PLL2M = 16;
41+
PeriphClkInitStruct.PLL2.PLL2N = 120;
42+
} else {
43+
#if HSE_VALUE==8000000
44+
PeriphClkInitStruct.PLL2.PLL2M = 2;
45+
PeriphClkInitStruct.PLL2.PLL2N = 120;
46+
#elif HSE_VALUE==16000000
47+
PeriphClkInitStruct.PLL2.PLL2M = 2;
48+
PeriphClkInitStruct.PLL2.PLL2N = 60;
49+
#elif HSE_VALUE==25000000
50+
PeriphClkInitStruct.PLL2.PLL2M = 5;
51+
PeriphClkInitStruct.PLL2.PLL2N = 96;
52+
#else
53+
error("HSE not configured properly");
54+
#endif
55+
}
56+
PeriphClkInitStruct.PLL2.PLL2P = 3;
57+
PeriphClkInitStruct.PLL2.PLL2Q = 4;
4358
PeriphClkInitStruct.PLL2.PLL2R = 2;
4459
PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_1;
4560
PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;

0 commit comments

Comments
 (0)