Skip to content

Commit 84bb026

Browse files
committed
Portenta: Fix clocks for Beta boards
1 parent df82674 commit 84bb026

File tree

1 file changed

+31
-4
lines changed
  • targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7

1 file changed

+31
-4
lines changed

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_PORTENTA_H7/system_clock.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ bool isBootloader() {
9090
return ((uint32_t)&_keep < 0x8040000);
9191
}
9292

93+
bool isBetaBoard() {
94+
uint8_t* bootloader_data = (uint8_t*)(0x801F000);
95+
if (bootloader_data[0] != 0xA0 || bootloader_data[1] < 14) {
96+
return true;
97+
} else {
98+
return (bootloader_data[10] == 27);
99+
}
100+
}
101+
93102
#if ( ((CLOCK_SOURCE) & USE_PLL_HSE_XTAL) || ((CLOCK_SOURCE) & USE_PLL_HSE_EXTC) )
94103
/******************************************************************************/
95104
/* PLL (clocked by HSE) used as System clock source */
@@ -112,7 +121,11 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
112121
HAL_GPIO_WritePin(GPIOH, GPIO_PIN_1, 1);
113122

114123
/* Supply configuration update enable */
115-
HAL_PWREx_ConfigSupply(PWR_SMPS_1V8_SUPPLIES_LDO);
124+
if (isBetaBoard()) {
125+
HAL_PWREx_ConfigSupply(PWR_SMPS_1V8_SUPPLIES_EXT);
126+
} else {
127+
HAL_PWREx_ConfigSupply(PWR_SMPS_1V8_SUPPLIES_LDO);
128+
}
116129
/* Configure the main internal regulator output voltage */
117130

118131
if (isBootloader()) {
@@ -139,6 +152,15 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
139152
} else {
140153
RCC_OscInitStruct.PLL.PLLN = 160;
141154
}
155+
if (isBetaBoard()) {
156+
RCC_OscInitStruct.PLL.PLLM = 9;
157+
if (isBootloader()) {
158+
RCC_OscInitStruct.PLL.PLLN = 80;
159+
} else {
160+
RCC_OscInitStruct.PLL.PLLN = 300;
161+
}
162+
}
163+
142164
RCC_OscInitStruct.PLL.PLLFRACN = 0;
143165
RCC_OscInitStruct.PLL.PLLP = 2;
144166
RCC_OscInitStruct.PLL.PLLR = 2;
@@ -195,8 +217,13 @@ uint8_t SetSysClock_PLL_HSI(void)
195217
RCC_ClkInitTypeDef RCC_ClkInitStruct;
196218
RCC_OscInitTypeDef RCC_OscInitStruct;
197219

198-
/*!< Supply configuration update enable */
199-
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
220+
/* Supply configuration update enable */
221+
if (isBetaBoard()) {
222+
HAL_PWREx_ConfigSupply(PWR_SMPS_1V8_SUPPLIES_EXT);
223+
} else {
224+
HAL_PWREx_ConfigSupply(PWR_SMPS_1V8_SUPPLIES_LDO);
225+
}
226+
200227
/* The voltage scaling allows optimizing the power consumption when the device is
201228
clocked below the maximum system frequency, to update the voltage scaling value
202229
regarding system frequency refer to product datasheet. */
@@ -211,7 +238,7 @@ uint8_t SetSysClock_PLL_HSI(void)
211238
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
212239
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
213240
RCC_OscInitStruct.PLL.PLLM = 8;
214-
RCC_OscInitStruct.PLL.PLLN = 113;
241+
RCC_OscInitStruct.PLL.PLLN = 100;
215242
RCC_OscInitStruct.PLL.PLLP = 2;
216243
RCC_OscInitStruct.PLL.PLLQ = 10;
217244
RCC_OscInitStruct.PLL.PLLR = 2;

0 commit comments

Comments
 (0)