2025-11-04 6:48 AM - last edited on 2025-11-04 7:41 AM by Andrew Neil
Hi all,
I am having issues with Clock setup for Stm32h755. Especially regarding the M4 core. Currently, I only run the M4 core. The M7 core has no valid firmware. Is that even a supported mode?
I try to setup a rather basic clock setup but the setup keeps failing at the call: HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4), which will return an not ok return value.
I also tried using HSI and other different setups. But it seems the keep failing in the same way. Interestingly... When I simply ignore the error. Then most stuff seems to work just fine. I got ADC, SPI, Timers working. However, I am not sure where the issue is with the clock configuration.
The entire clock setup:
static void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
__HAL_RCC_SYSCFG_CLK_ENABLE();
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 5;
RCC_OscInitStruct.PLL.PLLN = 192;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
// print error
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 |
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
// print error
}
}
Best regards
Mark
Edited to apply proper source code formatting - please see How to insert source code for future reference.
2025-11-04 7:06 AM
The clock failing to start can suggest the HSE design is not correct. Perhaps incorrect load caps.
Guidelines for oscillator design on STM8AF/AL/S and STM32 MCUs/MPUs - Application note
M4 having no firmware is fine. You can set option bytes such that the M4 core doesn't boot, but it's not an issue here.
2025-11-04 7:43 AM
@Mark12 wrote:the call: HAL_RCC_ClockConfig( &RCC_ClkInitStruct, FLASH_LATENCY_4 ), which will return an not ok return value..
Have you tried stepping into that function to see where & why, exactly, it is failing?
2025-11-04 8:50 AM - edited 2025-11-04 8:53 AM
Hello,
Which board are you using? Nucleo board?
If it's the case, you need to set HSE in Bypass mode as the clock source is provided from the STLINK (STLINK_MCO) and there is no crystal on the board: